Skip to content

Commit

Permalink
Merge pull request #42 from axiom-data-science/updates
Browse files Browse the repository at this point in the history
changed location of hard-wired model dates
  • Loading branch information
kthyng authored Jan 31, 2025
2 parents a954873 + d687225 commit afc38d0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
4 changes: 4 additions & 0 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# What's New

## unreleased

* Move known model hard-wired model times into the class so they are refreshed each time the library is read.

## v0.10.1 (January 30, 2025)

* Added built-in way to create plots for simulation using OpenDrift. Details available in {ref}`plots`.
Expand Down
42 changes: 30 additions & 12 deletions particle_tracking_manager/the_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@
config_ptm[key]["default"] = None


ciofs_operational_start_time = datetime.datetime(2021, 8, 31, 19, 0, 0)
ciofs_operational_end_time = (pd.Timestamp.now() + pd.Timedelta("48H")).to_pydatetime()
ciofs_end_time = datetime.datetime(2023, 1, 1, 0, 0, 0)
nwgoa_end_time = datetime.datetime(2009, 1, 1, 0, 0, 0)
overall_start_time = datetime.datetime(1999, 1, 1, 0, 0, 0)
overall_end_time = ciofs_operational_end_time


class ParticleTrackingManager:
"""Manager class that controls particle tracking model.
Expand Down Expand Up @@ -156,6 +148,13 @@ class ParticleTrackingManager:

logger: logging.Logger
ocean_model: str
overall_start_time: str
overall_end_time: str
ciofs_operational_start_time: str
ciofs_operational_end_time: str
ciofs_end_time: str
nwgoa_end_time: str

lon: Union[int, float]
lat: Union[int, float]
surface_only: Optional[bool]
Expand Down Expand Up @@ -210,6 +209,17 @@ def __init__(
) -> None:
"""Inputs necessary for any particle tracking."""

self.__dict__["ciofs_operational_start_time"] = datetime.datetime(
2021, 8, 31, 19, 0, 0
)
self.__dict__["ciofs_operational_end_time"] = (
pd.Timestamp.now() + pd.Timedelta("48H")
).to_pydatetime()
self.__dict__["ciofs_end_time"] = datetime.datetime(2023, 1, 1, 0, 0, 0)
self.__dict__["nwgoa_end_time"] = datetime.datetime(2009, 1, 1, 0, 0, 0)
self.__dict__["overall_start_time"] = datetime.datetime(1999, 1, 1, 0, 0, 0)
self.__dict__["overall_end_time"] = self.__dict__["ciofs_operational_end_time"]

# get all named parameters input to ParticleTrackingManager class
from inspect import signature

Expand Down Expand Up @@ -409,14 +419,22 @@ def __setattr__(self, name: str, value) -> None:
if self.start_time is not None and self.ocean_model is not None:
assert isinstance(self.start_time, pd.Timestamp)
if self.ocean_model == "NWGOA":
assert overall_start_time <= self.start_time <= nwgoa_end_time
assert (
self.overall_start_time
<= self.start_time
<= self.nwgoa_end_time
)
elif self.ocean_model == "CIOFS":
assert overall_start_time <= self.start_time <= ciofs_end_time
assert (
self.overall_start_time
<= self.start_time
<= self.ciofs_end_time
)
elif self.ocean_model == "CIOFSOP":
assert (
ciofs_operational_start_time
self.ciofs_operational_start_time
<= self.start_time
<= ciofs_operational_end_time
<= self.ciofs_operational_end_time
)

# deal with if input longitudes need to be shifted due to model
Expand Down

0 comments on commit afc38d0

Please sign in to comment.