Skip to content

Commit

Permalink
Merge pull request #20 from axiom-data-science/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
kthyng authored Feb 21, 2024
2 parents 3ae1faf + 100bf56 commit 4e57e0b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
6 changes: 6 additions & 0 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
50 changes: 32 additions & 18 deletions particle_tracking_manager/the_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}.")
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4e57e0b

Please sign in to comment.