From 452d09208fbb817b87bf8a8e1aaff53dbecc613d Mon Sep 17 00:00:00 2001 From: Kristen Thyng Date: Wed, 21 Feb 2024 13:49:00 -0800 Subject: [PATCH 1/2] small change and fix to setup.cfg config filename --- particle_tracking_manager/the_manager.py | 50 +++++++++++++++--------- setup.cfg | 2 +- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/particle_tracking_manager/the_manager.py b/particle_tracking_manager/the_manager.py index d3d687d..3d90ec3 100644 --- a/particle_tracking_manager/the_manager.py +++ b/particle_tracking_manager/the_manager.py @@ -328,36 +328,47 @@ def __setattr__(self, name: str, value) -> None: # this is not a user-defined option if -180 < self.lon < 0: self.__dict__["lon"] += 360 + self.config_ptm["lon"]["value"] = False if name == "surface_only" and value: self.logger.info( - "overriding values for `do3D`, `z`, and `vertical_mixing` because `surface_only` True" + "Overriding values for do3D, z, and vertical_mixing because surface_only is True (to False, 0, False)." ) self.do3D = False self.z = 0 self.vertical_mixing = False # in case any of these are reset by user after surface_only is already set - if name in ["do3D", "z", "vertical_mixing"]: - if self.surface_only: - self.logger.info( - "overriding values for `do3D`, `z`, and `vertical_mixing` because `surface_only` True" - ) - if name == "do3D": - value = False - if name == "z": - value = 0 - if name == "vertical_mixing": - value = False - self.__dict__[name] = value - self.config_ptm[name]["value"] = value - - # if not 3D turn off vertical_mixing + # if surface_only is True, do3D must be False + if name == "do3D" and value and self.surface_only: + self.logger.info( + "do3D must be False because surface_only is True. Setting do3D to False." + ) + self.__dict__["do3D"] = False + self.config_ptm["do3D"]["value"] = False + + # if surface_only is True, z must be 0 + if name == "z" and value != 0 and self.surface_only: + self.logger.info( + "z must be 0 because surface_only is True. Setting z to 0." + ) + self.__dict__["z"] = 0 + self.config_ptm["z"]["value"] = 0 + + # if surface_only is True, vertical_mixing must be False + if name == "vertical_mixing" and value and self.surface_only: + self.logger.info( + "vertical_mixing must be False because surface_only is True. Setting vertical_mixing to False." + ) + self.__dict__["vertical_mixing"] = False + self.config_ptm["vertical_mixing"]["value"] = False + + # if not 3D turn off vertical_mixing + if name in ["do3D", "vertical_mixing"]: if not self.do3D and self.vertical_mixing: - self.logger.info("turning off vertical_mixing since do3D is False") + self.logger.info("Turning off vertical_mixing since do3D is False") self.__dict__["vertical_mixing"] = False self.config_ptm["vertical_mixing"]["value"] = False - # self.vertical_mixing = False # this is recursive # set z to None if seed_seafloor is True if name == "seed_seafloor" and value: @@ -414,9 +425,12 @@ def __setattr__(self, name: str, value) -> None: ): # the behavior in calc_end_time changes depending on which variable has been updated self.__dict__["end_time"] = self.calc_end_time(name) + self.config_ptm["end_time"]["value"] = self.calc_end_time(name) # duration and steps are always updated now that start_time and end_time are set self.__dict__["duration"] = self.calc_duration() + self.config_ptm["duration"]["value"] = self.calc_duration() self.__dict__["steps"] = self.calc_steps() + self.config_ptm["steps"]["value"] = self.calc_steps() if name == "ocean_model" and value not in _KNOWN_MODELS: self.logger.info(f"ocean_model is not one of {_KNOWN_MODELS}.") diff --git a/setup.cfg b/setup.cfg index 4d745e2..9bb5b3c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -64,7 +64,7 @@ python_requires = >=3.9 [options.package_data] particle_tracking_manager = the_manager_config.json -particle_tracking_manager.models.opendrift = opendrift_config.json +particle_tracking_manager.models.opendrift = config.json ################ Up until here From 100bf569b8d9ae60c3eba46e85bf544e282a9eec Mon Sep 17 00:00:00 2001 From: Kristen Thyng Date: Wed, 21 Feb 2024 13:50:08 -0800 Subject: [PATCH 2/2] update to whats new and version --- docs/whats_new.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/whats_new.md b/docs/whats_new.md index 53b792f..d0b271c 100644 --- a/docs/whats_new.md +++ b/docs/whats_new.md @@ -1,5 +1,11 @@ # What's New +## v0.7.1 (February 21, 2024) + +* Small fix to some attributes to be less verbose +* Fix setup.cfg to have correct config path since name changed + + ## v0.7.0 (February 21, 2024) * Now initialize all class attributes with None and removed usage of `hasattr` which simplifies and clarifies some code.