Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add substack_windows config parameter #297

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/noisepy/seis/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ class ConfigParameters(BaseModel):
substack: bool = Field(
default=False, description="True: smaller stacks within the time chunk. False: it will stack over inc_hours"
)
substack_len: int = Field(
default=1800, description="how long to stack over (for monitoring purpose): need to be multiples of cc_len"
)
substack_windows: int = Field(default=1, description="How many windows of size cc_len to stack over.")

maxlag: int = Field(default=200, description="lags of cross-correlation to save (sec)")
inc_hours: int = Field(default=24, description="Time increment size in hours")
# criteria for data selection
Expand Down Expand Up @@ -237,6 +236,10 @@ def get_storage_options(self, path: str) -> Dict[str, Any]:
url = urlparse(path)
return self.storage_options.get(url.scheme, {})

@property
def substack_len(self) -> int:
return self.cc_len * self.substack_windows

@property
def dt(self) -> float:
return 1.0 / self.samp_freq
Expand Down Expand Up @@ -274,8 +277,6 @@ def validate_date(d: datetime, name: str):

validate_date(m.start_date, "start_date")
validate_date(m.end_date, "end_date")
if m.substack_len % m.cc_len != 0:
raise ValueError(f"substack_len ({m.substack_len}) must be a multiple of cc_len ({m.cc_len})")

if m.stations_file:
fs = get_filesystem(m.stations_file, storage_options=m.storage_options)
Expand All @@ -291,6 +292,8 @@ def __getitem__(self, key):
# Hack since pydantic model properties are nor part of the object's __dict__
if key == "dt":
return self.dt
if key == "substack_len":
return self.substack_len
return self.__dict__[key]

def save_yaml(self, filename: str):
Expand Down
Loading