Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CrocoDash/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ def configure_initial_and_boundary_conditions(
config["forcing"]["information"] = ProductRegistry.get_product(
self.forcing_product_name.lower()
).write_metadata(include_marbl_tracers=self.bgc_in_compset)
config["forcing"]["function_default_args"] = (
ProductRegistry.get_function_default_args(
self.forcing_product_name.lower(), function_name
)
)

# General
config["general"]["boundary_number_conversion"] = {
Expand Down
3 changes: 3 additions & 0 deletions CrocoDash/extract_forcings/case_setup/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ def run_workflow(
output_data_dir=cfg["basic"]["paths"]["output_path"],
bathymetry_path=cfg["basic"]["paths"]["bathymetry_path"],
preview=preview,
function_default_args=cfg["basic"]["forcing"].get(
"function_default_args", {}
),
)

if bgcic:
Expand Down
7 changes: 2 additions & 5 deletions CrocoDash/extract_forcings/initial_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def process_initial_condition(
output_data_dir: str | Path,
bathymetry_path: str | Path,
preview: bool = False,
function_default_args: dict = None,
):
"""
Process the initial condition (t=0) through the data retrieval pipeline.
Expand Down Expand Up @@ -75,11 +76,7 @@ def process_initial_condition(
for k, v in product_information["tracer_var_names"].items()
if k not in ("temp", "salt")
]
extra_args = {
key: product_information[key]
for key in ["dataset_path", "date_format", "regex", "delimiter"]
if key in product_information
}
extra_args = function_default_args or {}
if not preview:
_download_initial_condition(
data_access_function=data_access_function,
Expand Down
6 changes: 1 addition & 5 deletions CrocoDash/extract_forcings/obc.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,7 @@ def process_obc_conditions(
if k not in ("temp", "salt")
]
variables = phys_vars + extra_tracers
extra_args = {
k: product_info[k]
for k in ("dataset_path", "date_format", "regex", "delimiter")
if k in product_info
}
extra_args = config["basic"]["forcing"].get("function_default_args", {})

fill_method = rm6.regridding.fill_missing_data
if product_info.get("boundary_fill_method", "regional_mom6") != "regional_mom6":
Expand Down
15 changes: 15 additions & 0 deletions CrocoDash/raw_data_access/registry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import inspect

from CrocoDash.raw_data_access.datasets import load_all_datasets


Expand Down Expand Up @@ -53,6 +55,19 @@ def call(cls, product_name, method_name, **kwargs):
method = product._access_methods[method_name]
return method(**kwargs)

@classmethod
def get_function_default_args(cls, product_name, function_name):
"""Return a dict of {param: default} for all non-required parameters of an access method."""
product = cls.get_product(product_name)
func = product._access_methods[function_name].__func__
sig = inspect.signature(func)
required = set(product.required_args)
return {
name: param.default
for name, param in sig.parameters.items()
if name not in required and param.default is not inspect.Parameter.empty
}

@classmethod
def load(cls):
loaded = True
Expand Down
Loading