CrocoDash.forcing package#
Submodules#
CrocoDash.forcing.base module#
- class CrocoDash.forcing.base.BaseConfigurator(**kwargs)#
Bases:
ABCBase class for all CrocoDash configurators.
- allowed_compsets: List[str] = []#
- classmethod check_input_params_synced()#
Make sure the init args exactly match the input param names. This check is only run in testing
- classmethod check_output_params_exist()#
- abstractmethod configure()#
Bind input values to parameters and files.
- depends_on_outputs: Dict[str, List[str]] = {}#
- classmethod deserialize(data: Dict[str, Any])#
- property do_exec: bool#
Whether case-side effects should actually be executed.
False when the case was configured but never created (an un-ported machine, i.e. MACHINE == CESM_NOT_PORTED), where there is no case directory to xmlchange or append user_nl into. Sourced from the live Case via the registry, the same way is_non_local is, so no configurator has to declare a ctor arg just to carry it down to apply().
Defaults to True – the opposite of is_non_local – so that a configurator with no live Case (direct construction in tests, or deserialize()) keeps behaving exactly as it did before this existed.
- forbidden_compsets: List[str] = []#
- get_input_param(name: str) OutputParam#
- get_input_param_object(name: str) OutputParam#
- get_output_filepaths(ocn_ice_directory)#
Get output files from the output parameters
- get_output_param(name: str) OutputParam#
- get_output_param_object(name: str) OutputParam#
- property has_cesm: bool#
Whether there is a CESM checkout behind this case.
With none, visualCaseGen is never initialized, so cvars is empty – and both xmlchange and append_user_nl read cvars[“CASEROOT”] before they consult do_exec, so they raise KeyError rather than no-op. Output params therefore have to be skipped outright rather than applied with do_exec=False.
This is deliberately narrower than do_exec: on an un-ported machine that does have a checkout, apply() is still called so that it prints the commands a user would run to create the case by hand, which is the point of that path.
Defaults to True, like do_exec, so a configurator with no live Case (direct construction in tests, or deserialize()) behaves as it always has.
- classmethod inspect(caseroot)#
Return an instance of the configurator with placeholder values for input and correct output params from case
- property is_non_local: bool#
Whether this configurator’s case is non-local (CIME’s –non-local).
Sourced from the live Case via the registry rather than a declared input param, so an XMLConfigParam output doesn’t require its configurator to accept/thread a case_is_non_local ctor arg just to reach apply() – it’s always False when there’s no live Case (e.g. direct construction in tests, or deserialize()).
- classmethod is_required(compset: str) bool#
- make_serializable(obj)#
- name: str = ''#
- output_params: List[OutputParam]#
- process_components: Dict[str, str] = {}#
- registry: ForcingConfigRegistry | None = None#
- required_for_compsets: List[str] = []#
- serialize() Dict[str, Any]#
- set_input_param(name: str, value)#
- set_output_param(name: str, value)#
- validate_args(**kwargs)#
Validate provided inputs against declared input_params.
- classmethod validate_compset_compatibility(compset: str) bool#
- validate_output_filepaths(ocn_ice_directory)#
- class CrocoDash.forcing.base.ConfigOutputParam(name: str, comment: str | None = None, is_file: bool = False)#
Bases:
OutputParamDerived value with no case-side effect (not written to user_nl or xmlchange’d).
Exists purely so set_output_param() + the generic serialize() pick it up under a configurator’s outputs, for values consumed only via config.json (e.g. by a sibling configurator’s process_* method).
- apply()#
Apply the configuration change.
- inspect(caseroot)#
Inspect the current value of this parameter in the case located at caseroot.
- class CrocoDash.forcing.base.ForcingConfigRegistry(compset, inputs: dict, case=None)#
Bases:
object- classmethod all_process_flags()#
Every process-component flag name any registered configurator can answer to, regardless of whether it’s active for a given case – used to build cli.py’s argparse flags generically.
- classmethod available_process_flags(config: dict)#
Every process-component flag name available given which forcing types are present in a config.json dict – looked up from each entry’s declared class only (no full deserialize), so this works even when an entry’s inputs/outputs aren’t fully valid yet. Used by resolve_components/cli.py to answer “does this flag exist” without needing working configurator instances the way actual dispatch does.
- find_active_configurators(compset, inputs: dict)#
- classmethod find_required_configurators(compset)#
Returns the required configurations based on the compset in a list
- classmethod find_valid_configurators(compset)#
Returns the valid configurations based on the compset in a list
- get_active_configurators()#
- classmethod get_configurator(obj_dict)#
- classmethod get_configurator_from_name(name)#
- classmethod get_configurator_output(config: dict, configurator_name: str, output_name: str)#
Look up another configurator’s serialized output value from config.json – for a process_*() method that depends on a sibling’s output but (unlike configure()) can’t rely on a live registry/Case, since process() may run in a different process. Raises a clear, named error instead of a bare KeyError several dict levels deep if the dependency isn’t there (e.g. the sibling hasn’t run yet, or never configured this case).
- classmethod get_ctor_signature(configurator_cls)#
- classmethod get_user_args(configurator_cls)#
- classmethod instantiate_configurator(configurator_cls, inputs)#
- is_active(name: str) bool#
Return True if a configurator with this name is active.
- classmethod register(configurator_cls: type)#
- registered_types: List[type] = [<class 'CrocoDash.forcing.bgc.BGCConfigurator'>, <class 'CrocoDash.forcing.bgc.CICEConfigurator'>, <class 'CrocoDash.forcing.bgc.BGCICConfigurator'>, <class 'CrocoDash.forcing.bgc.BGCIronForcingConfigurator'>, <class 'CrocoDash.forcing.bgc.BGCRiverNutrientsConfigurator'>, <class 'CrocoDash.forcing.chl.ChlConfigurator'>, <class 'CrocoDash.forcing.mom6.ConditionsConfigurator'>, <class 'CrocoDash.forcing.runoff.RunoffConfigurator'>, <class 'CrocoDash.forcing.tides.TidesConfigurator'>]#
- classmethod resolve_process_targets(config: dict)#
Deserialize every configurator present in a config.json dict and return {flag_name: (configurator_instance, method_name)} covering every process component any of them declare. Used by driver.py to dispatch generically instead of a hand-maintained if-ladder.
- classmethod return_missing_inputs(configurator_cls, inputs)#
- run_configurators(config_path)#
- class CrocoDash.forcing.base.InputFileParam(name: str, comment: str | None = None)#
Bases:
InputParamBase class for a single file parameter in our forcing configurations.
- set_item(filepath: str)#
Bind a runtime value to this parameter.
- class CrocoDash.forcing.base.InputValueParam(name: str, comment: str | None = None)#
Bases:
InputParamBase class for a single value parameter in our forcing configurations.
- set_item(item)#
Bind a runtime value to this parameter.
- class CrocoDash.forcing.base.OutputParam(name: str, comment: str | None = None, is_file: bool = False)#
Bases:
ParamBase class for a single configuration parameter applied to a CESM/MOM6 case.
- abstractmethod apply()#
Apply the configuration change.
- abstractmethod inspect(caseroot)#
Inspect the current value of this parameter in the case located at caseroot.
- set_item(value: Any)#
Bind a runtime value to this parameter.
- class CrocoDash.forcing.base.Param(name: str, comment: str | None = None)#
Bases:
ABCBase class for a single parameter in our forcing configurations.
- abstractmethod set_item(item: Any)#
Bind a runtime value to this parameter.
- exception CrocoDash.forcing.base.UndeclaredParamError#
Bases:
KeyErrorCode referenced an input/output param name that isn’t declared on the class (a schema bug, e.g. a stale name after a rename). Kept as a KeyError subclass so existing except KeyError call sites are unaffected, but a distinct type so a param-consistency check can catch exactly this failure and not any other incidental KeyError raised by a configurator’s own business logic.
- class CrocoDash.forcing.base.UserNLConfigParam(name: str, user_nl_name: str = 'mom', comment: str | None = None, is_file: bool = False, do_exec: bool = True)#
Bases:
OutputParamParameter written to a user_nl_<component> file (default: user_nl_mom).
- apply()#
Apply the configuration change.
- inspect(caseroot)#
Inspect the current value of this parameter in the case located at caseroot.
- class CrocoDash.forcing.base.WorkflowContext(inputdir: Path, supergrid_path: Path, vgrid_path: Path, topo_path: Path, raw_data_dir: Path, regridded_data_dir: Path, output_path: Path, config: dict, preview: bool = False)#
Bases:
objectWorkflow-level paths shared by every configurator’s process step.
Built once by driver.run_workflow() from config.json + case_state, and passed into every
process_*(ctx)call. These are paths no single configurator owns (they’re not part of any configurator’s own inputs/ outputs) but that most process steps need – grid/topo/vgrid files and the raw/regridded/output directories for this case.- property grid#
- property ocn_topo#
- class CrocoDash.forcing.base.XMLConfigParam(name: str, is_non_local: bool = False, comment: str | None = None, is_file: bool = False, do_exec: bool = True)#
Bases:
OutputParamParameter applied via xmlchange.
XML changes are permanent and do not save previous state.
- apply()#
Apply the configuration change.
- inspect(caseroot)#
Inspect the current value of this parameter in the case located at caseroot.
- CrocoDash.forcing.base.is_serializable(v)#
- CrocoDash.forcing.base.register(cls)#
Decorator: register a BaseConfigurator subclass with ForcingConfigRegistry.
Every module under CrocoDash.forcing that defines a configurator class applies this at class-definition time; CrocoDash.forcing/__init__.py’s auto-discovery ensures those modules (and hence this decorator) run for every file in the package, so adding a new forcing type is just adding a new file here – nothing else needs to import it by name.
CrocoDash.forcing.bgc module#
- class CrocoDash.forcing.bgc.BGCConfigurator#
Bases:
BaseConfiguratorToggles the MARBL-tracer namelist default – no forcing data of its own to extract. BGCIC/BGCIronForcing/BGCRiverNutrients below are the configurators that actually produce BGC forcing files.
- allowed_compsets: List[str] = ['MARBL']#
- configure()#
Bind input values to parameters and files.
- name: str = 'BGC'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='MAX_FIELDS')]#
- required_for_compsets: List[str] = ['MARBL']#
- class CrocoDash.forcing.bgc.BGCICConfigurator(marbl_ic_filepath)#
Bases:
BaseConfigurator- allowed_compsets: List[str] = ['MARBL']#
- configure()#
Bind input values to parameters and files.
- name: str = 'BGCIC'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='MARBL_TRACERS_IC_FILE')]#
- process(ctx)#
Copy the MARBL initial condition file into place.
- process_components: Dict[str, str] = {'bgcic': 'process'}#
- required_for_compsets: List[str] = ['MARBL']#
- class CrocoDash.forcing.bgc.BGCIronForcingConfigurator(case_session_id, case_grid_name)#
Bases:
BaseConfigurator- allowed_compsets: List[str] = ['MARBL']#
- configure()#
Bind input values to parameters and files.
- input_params: List[Param] = [InputValueParam(name='case_session_id'), InputValueParam(name='case_grid_name')]#
- name: str = 'BGCIronForcing'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='MARBL_FESEDFLUX_FILE'), UserNLConfigParam(name='MARBL_FEVENTFLUX_FILE'), UserNLConfigParam(name='MARBL_FESEDFLUXRED_FILE')]#
- process(ctx)#
Create dummy iron forcing files for MARBL.
- process_components: Dict[str, str] = {'bgcironforcing': 'process'}#
- required_for_compsets: List[str] = ['MARBL']#
- class CrocoDash.forcing.bgc.BGCRiverNutrientsConfigurator(global_river_nutrients_filepath, case_session_id, case_grid_name, case_forcing_product=None, cf_calendar=None)#
Bases:
BaseConfigurator- allowed_compsets: List[str] = ['MARBL', 'DROF']#
- configure()#
Bind input values to parameters and files.
- depends_on_outputs: Dict[str, List[str]] = {'runoff': ['ROF2OCN_LIQ_RMAPNAME']}#
- input_params: List[Param] = [InputFileParam(name='global_river_nutrients_filepath'), InputValueParam(name='case_session_id'), InputValueParam(name='case_grid_name'), InputValueParam(name='cf_calendar')]#
- name: str = 'BGCRiverNutrients'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='READ_RIV_FLUXES'), UserNLConfigParam(name='RIV_FLUX_FILE')]#
- process(ctx)#
Regrid global river nutrients onto the ocean grid via the runoff mapping file – requires RunoffConfigurator’s process step to have already produced that mapping file. See depends_on_outputs above: driver.py derives the required run-before ordering from it automatically.
- process_components: Dict[str, str] = {'bgcrivernutrients': 'process'}#
- validate_args(**kwargs)#
Validate provided inputs against declared input_params.
- class CrocoDash.forcing.bgc.CICEConfigurator#
Bases:
BaseConfigurator- allowed_compsets: List[str] = ['CICE']#
- configure()#
Bind input values to parameters and files.
- name: str = 'CICE'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='ice_ic'), UserNLConfigParam(name='ns_boundary_type'), UserNLConfigParam(name='ew_boundary_type'), UserNLConfigParam(name='close_boundaries')]#
- required_for_compsets: List[str] = ['CICE']#
CrocoDash.forcing.chl module#
- class CrocoDash.forcing.chl.ChlConfigurator(chl_processed_filepath, case_grid_name, case_session_id, case_forcing_product=None, cf_calendar=None)#
Bases:
BaseConfigurator- configure()#
Bind input values to parameters and files.
- forbidden_compsets: List[str] = ['MARBL']#
- input_params: List[Param] = [InputFileParam(name='chl_processed_filepath'), InputValueParam(name='case_grid_name'), InputValueParam(name='case_session_id'), InputValueParam(name='cf_calendar')]#
- name: str = 'Chl'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='CHL_FILE'), UserNLConfigParam(name='CHL_FROM_FILE'), UserNLConfigParam(name='VAR_PEN_SW'), UserNLConfigParam(name='PEN_SW_NBANDS')]#
- process(ctx)#
- process_components: Dict[str, str] = {'chl': 'process'}#
- validate_args(**kwargs)#
Validate provided inputs against declared input_params.
CrocoDash.forcing.driver module#
CrocoDash Forcing Driver
Orchestrates both stages of the forcing workflow for a CrocoDash case:
configuration (Case.configure_forcings(), which writes config.json)
and extraction (Case.process_forcings(), which reads it back).
Extraction dispatches generically: for every forcing type present in
config.json, the matching BaseConfigurator subclass is deserialized
and asked which process flags it answers to (its process_components
manifest) – there’s no hand-maintained per-type if branch to update
when a new forcing type is added. The CLI entry point is crocodash
process (see CrocoDash.cli).
Typical Python usage:
from CrocoDash.forcing.driver import run_workflow
run_workflow(config_path="~/croc_input/mycase/extract_forcings/config.json", bc=True, ic=True)
- CrocoDash.forcing.driver.resolve_components(args, config)#
Resolve which components to run based on CLI args and config availability.
- CrocoDash.forcing.driver.run_workflow(config_path, preview=False, **flags)#
Execute the forcing extraction workflow.
- Parameters:
config_path (str or Path) – Path to the
config.jsonwritten byCase.configure_forcings.preview (bool) – Preview task graph without executing.
**flags (bool) – Which process components to run, e.g.
ic=True, bc=True, tides=True. Valid names are whateverprocess_componentskeys the forcing types present inconfig.jsondeclare – seeForcingConfigRegistry.resolve_process_targets.
CrocoDash.forcing.ic module#
IC (Initial Condition) forcing extraction engine for CrocoDash.
Model-agnostic: this module gets the raw t=0 snapshot, but knows nothing
about how to regrid it. Callers (mom6.py, cice.py, ww3.py)
supply a regrid_fn that turns the raw snapshot into that target’s own
initial-condition file(s) – the GET step is shared.
- CrocoDash.forcing.ic.process_initial_condition(product_name: str, function_name: str, variables: list, extra_args: dict, dataset_varnames: dict, start_date: str | datetime, hgrid_path: str | Path, raw_data_dir: str | Path, output_data_dir: str | Path, regrid_fn, preview: bool = False)#
Process the initial condition (t=0) through the GET → REGRID pipeline.
- Parameters:
product_name – The name of the data product to retrieve.
function_name – The function to call for retrieving data.
variables – Variable names to request from the download function (already resolved by the caller from its own product metadata).
extra_args – Extra kwargs for the download function (already resolved by the caller).
dataset_varnames – Opaque metadata dict forwarded to
regrid_fn– this module never reads its keys itself.start_date – The start date (any pandas-parseable string or datetime).
hgrid_path – Path to the hgrid supergrid file.
raw_data_dir – Directory for raw downloaded data.
output_data_dir – Directory for final output files.
regrid_fn – Target-specific regrid step, called as
regrid_fn(raw_file, hgrid, start_date, output_dir, dataset_varnames)once the raw snapshot has been downloaded. Owns its own idempotency (this engine has no per-chunk state to check – IC is a single snapshot, not a date-chunked series).preview – Return metadata dict without executing, default False.
CrocoDash.forcing.mom6 module#
MOM6 initial + open boundary condition configuration and processing.
ConditionsConfigurator is always active for regional MOM6 cases – it
builds the user_nl_mom initial condition and OBC_SEGMENT_* parameters at
configure time, and (one-to-many: this one configurator answers for both
the “ic” and “bc” process flags) drives IC/OBC extraction at process time via
forcing.ic/forcing.obc’s model-agnostic engines, supplying MOM6’s own
regrid step – built on regional_mom6’s segment/experiment
classes and mom6_forge’s fill utilities – and the MOM6-specific piece of
the GET step (turning a forcing product’s own u/v/eta/tracer var-name
metadata into a download request).
- class CrocoDash.forcing.mom6.ConditionsConfigurator(boundaries, product_name, function_name, compset, date_range=None, start_date=None, end_date=None, function_args=None)#
Bases:
BaseConfiguratorInitial condition + open boundary condition (OBC) setup for MOM6.
Always active for regional MOM6 cases. Builds the user_nl_mom initial condition and OBC_SEGMENT_* parameters, and the derived values consumed by process_ic/process_bc (dates, forcing product metadata, boundary numbering).
- configure()#
Bind input values to parameters and files.
- classmethod deserialize(data)#
Reconstruct dynamic per-boundary output params alongside the static ones.
- input_params: List[Param] = [InputValueParam(name='start_date'), InputValueParam(name='end_date'), InputValueParam(name='boundaries'), InputValueParam(name='product_name'), InputValueParam(name='function_name'), InputValueParam(name='compset'), InputValueParam(name='function_args')]#
- name: str = 'conditions'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='INIT_LAYERS_FROM_Z_FILE'), UserNLConfigParam(name='Z_INIT_ALE_REMAPPING'), UserNLConfigParam(name='TEMP_SALT_INIT_VERTICAL_REMAP_ONLY'), UserNLConfigParam(name='DEPRESS_INITIAL_SURFACE'), UserNLConfigParam(name='VELOCITY_CONFIG'), UserNLConfigParam(name='TEMP_SALT_Z_INIT_FILE'), UserNLConfigParam(name='SURFACE_HEIGHT_IC_FILE'), UserNLConfigParam(name='VELOCITY_FILE'), UserNLConfigParam(name='Z_INIT_FILE_PTEMP_VAR'), UserNLConfigParam(name='Z_INIT_FILE_SALT_VAR'), UserNLConfigParam(name='SURFACE_HEIGHT_IC_VAR'), UserNLConfigParam(name='U_IC_VAR'), UserNLConfigParam(name='V_IC_VAR'), UserNLConfigParam(name='OBC_NUMBER_OF_SEGMENTS'), UserNLConfigParam(name='OBC_FREESLIP_VORTICITY'), UserNLConfigParam(name='OBC_FREESLIP_STRAIN'), UserNLConfigParam(name='OBC_COMPUTED_VORTICITY'), UserNLConfigParam(name='OBC_COMPUTED_STRAIN'), UserNLConfigParam(name='OBC_ZERO_BIHARMONIC'), UserNLConfigParam(name='OBC_TRACER_RESERVOIR_LENGTH_SCALE_OUT'), UserNLConfigParam(name='OBC_TRACER_RESERVOIR_LENGTH_SCALE_IN'), UserNLConfigParam(name='BRUSHCUTTER_MODE'), ConfigOutputParam(name='date_format'), ConfigOutputParam(name='information'), ConfigOutputParam(name='get_step_days'), ConfigOutputParam(name='regrid_step_days'), ConfigOutputParam(name='boundary_number_conversion'), ConfigOutputParam(name='preview'), ConfigOutputParam(name='function_args')]#
- process_bc(ctx)#
Process MOM6 boundary conditions through forcing.obc’s GET → REGRID → MERGE engine, using regional_mom6’s Segment as the regrid step.
- process_components: Dict[str, str] = {'bc': 'process_bc', 'ic': 'process_ic'}#
- process_ic(ctx)#
Process the MOM6 initial condition (t=0) through forcing.ic’s GET → REGRID engine, using regional_mom6’s experiment + mom6_forge’s fill utilities as the regrid step.
- required_for_compsets: List[str] = ['MOM6']#
- validate_args(**kwargs)#
Validate provided inputs against declared input_params.
- CrocoDash.forcing.mom6.build_forcing_request(product_info: dict, function_args: dict = None) tuple[list, dict]#
Build the (variables, extra_args) an access function needs from a MOM6 forcing product_info dict (u/v/eta/tracer var names).
function_args: user overrides (or access-function defaults) for the access function’s non-required arguments, as written to config.json’s forcing.function_args by configure_forcings()’s function_overrides. Merged into extra_args last so they take precedence over product_info-derived keys.
- CrocoDash.forcing.mom6.final_cleanliness_fill(var, x_dim, y_dim, z_dim=None)#
CrocoDash.forcing.obc module#
OBC (Open Boundary Condition) forcing extraction engine for CrocoDash.
Model-agnostic: this module gets raw data and chunks/merges it, but knows
nothing about how to regrid it. Callers (mom6.py, cice.py, ww3.py)
supply a regrid_chunk_fn that turns one raw chunk into that target’s own
per-segment output file – everything else (GET, date-chunking, idempotency,
MERGE) is shared.
Three-phase pipeline per boundary:
- GET — download raw data, chunked by
get_step(default: full range in one request). Chunk size is driven by data-provider constraints (API limits, download size). Each chunk is written as
{boundary}_unprocessed.{start}_{end}.nc.
- GET — download raw data, chunked by
- REGRID — validate raw coverage from filenames, then open all raw files
lazily and regrid (via the caller-supplied
regrid_chunk_fn) inregrid_step-sized slices. Chunk size is driven by memory and xESMF performance. GET and REGRID chunks are fully independent.
MERGE — concatenate regridded chunks into
forcing_obc_segment_NNN.nc.
Each phase is idempotent: existing output files are detected and skipped, so a failed run can be safely re-started.
- CrocoDash.forcing.obc.process_obc_conditions(start_date, end_date, boundary_number_conversion: dict, product_name: str, function_name: str, variables: list, extra_args: dict, dataset_varnames: dict, hgrid_path, raw_dataset_path, regridded_dataset_path, output_path, regrid_chunk_fn, get_step_days=None, regrid_step_days: int = 30, preview: bool = False)#
Process boundary conditions through the GET → REGRID → MERGE pipeline.
Each phase is idempotent. Re-running after a partial failure resumes from the last completed file.
GET and REGRID chunk sizes are independent. GET defaults to the full date range in one request; REGRID defaults to 30-day slices for memory efficiency.
- Parameters:
start_date – Forcing start date (datetime or any pandas-parseable string).
end_date – Forcing end date (datetime or any pandas-parseable string).
boundary_number_conversion – Boundary name -> target-model segment number.
product_name – Forcing data product name.
function_name – Download function name for the product.
variables – Variable names to request from the download function (already resolved by the caller from its own product metadata).
extra_args – Extra kwargs for the download function (already resolved by the caller).
dataset_varnames – Opaque metadata dict forwarded to
regrid_chunk_fn– this module never reads its keys itself.hgrid_path – Path to the hgrid supergrid file.
raw_dataset_path – Directory for raw downloaded data.
regridded_dataset_path – Directory for per-chunk regridded data.
output_path – Directory for final, merged output files.
regrid_chunk_fn – Target-specific regrid step – see
_regrid_boundary.get_step_days – GET chunk size in days; None = full range in one request.
regrid_step_days – REGRID chunk size in days.
preview – If True, return a dict of expected date pairs without executing any downloads or regridding.
CrocoDash.forcing.runoff module#
- class CrocoDash.forcing.runoff.RunoffConfigurator(case_grid_name, case_session_id, case_compset_lname, case_inputdir, case_esmf_mesh_path, case_cime=None, rmax=None, fold=None, rof_grid_name=None, rof_esmf_mesh_filepath=None)#
Bases:
BaseConfigurator- allowed_compsets: List[str] = {'DROF'}#
- configure()#
Bind input values to parameters and files.
- get_output_filepaths(ocn_ice_directory)#
Get output files from the output parameters
- input_params: List[Param] = [InputValueParam(name='case_grid_name'), InputValueParam(name='case_session_id'), InputValueParam(name='case_compset_lname'), InputValueParam(name='case_inputdir'), InputValueParam(name='rmax'), InputValueParam(name='rof_grid_name'), InputValueParam(name='fold'), InputFileParam(name='rof_esmf_mesh_filepath'), InputFileParam(name='case_esmf_mesh_path')]#
- name: str = 'Runoff'#
- output_params: List[OutputParam] = [XMLConfigParam(name='ROF2OCN_LIQ_RMAPNAME'), XMLConfigParam(name='ROF2OCN_ICE_RMAPNAME')]#
- process(ctx)#
Generate runoff-to-ocean mapping files if runoff is active in the compset.
- process_components: Dict[str, str] = {'runoff': 'process'}#
- required_for_compsets: List[str] = {'DROF'}#
- validate_args(**kwargs)#
Validate provided inputs against declared input_params.
CrocoDash.forcing.tides module#
- class CrocoDash.forcing.tides.TidesConfigurator(tpxo_elevation_filepath, tpxo_velocity_filepath, tidal_constituents, boundaries, date_range=None, start_date=None)#
Bases:
BaseConfigurator- configure()#
Bind input values to parameters and files.
- get_output_filepaths(ocn_ice_directory)#
Get output files from the output parameters
- input_params: List[Param] = [InputFileParam(name='tpxo_elevation_filepath'), InputFileParam(name='tpxo_velocity_filepath'), InputValueParam(name='tidal_constituents'), InputValueParam(name='start_date'), InputValueParam(name='boundaries')]#
- name: str = 'tides'#
- output_params: List[OutputParam] = [UserNLConfigParam(name='TIDES'), UserNLConfigParam(name='TIDE_M2'), UserNLConfigParam(name='CD_TIDES'), UserNLConfigParam(name='TIDE_USE_EQ_PHASE'), UserNLConfigParam(name='TIDE_REF_DATE'), UserNLConfigParam(name='OBC_TIDE_ADD_EQ_PHASE'), UserNLConfigParam(name='OBC_TIDE_N_CONSTITUENTS'), UserNLConfigParam(name='OBC_TIDE_CONSTITUENTS'), UserNLConfigParam(name='OBC_TIDE_REF_DATE')]#
- process(ctx)#
- process_components: Dict[str, str] = {'tides': 'process'}#
CrocoDash.forcing.utils module#
- CrocoDash.forcing.utils.check_date_continuity(boundary_file_list: dict)#
Check for overlaps or missing dates between consecutive files.
- CrocoDash.forcing.utils.fetch_raw_chunk(data_access_fn, dates: list, latlon: dict, output_folder: str | Path, output_filename: str, variables: list, extra_args: dict, name=None) Path#
Download one raw data chunk, skipping if a valid output file already exists.
Shared by obc.py and ic.py — both fetch a chunk of raw data for a given date range and bounding box, and both need to be idempotent across re-runs.
- CrocoDash.forcing.utils.get_data_access_function(product_name: str, function_name: str)#
Load the product registry and return the raw access function for (product_name, function_name).
- CrocoDash.forcing.utils.is_valid_netcdf(path: Path) bool#
Check a file’s magic bytes match a known NetCDF format (HDF5, classic, or 64-bit offset).
- CrocoDash.forcing.utils.parse_dataset_folder(folder: str | Path, input_dataset_regex: str, date_format: str)#
Parse a folder to find and extract dataset file information based on a regex pattern.
- Parameters:
folder (str or Path) – Path to the folder containing the dataset files.
input_dataset_regex (str) – Regular expression pattern to match dataset filenames. Example: “(north|east|south|west)_unprocessed.(d{8})_(d{8}).nc”
date_format (str) – Date format string used to parse dates in filenames (e.g., “%Y%m%d”).
- Returns:
Dictionary mapping boundaries to a list of tuples with: - Start date (datetime) - End date (datetime) - Full file path (Path)
Example: {
”north”: [(datetime(2000, 1, 1), datetime(2000, 1, 2), Path(“/path/to/north_20000101_20000102.nc”))], “east”: [(datetime(2000, 1, 3), datetime(2000, 1, 4), Path(“/path/to/east_20000103_20000104.nc”))]
}
- Return type:
dict
Module contents#
- CrocoDash.forcing.load_all_configurators()#
Dynamically import every module in this package so each configurator class’s @register decorator runs and populates ForcingConfigRegistry. Adding a new forcing type is just adding a new file here – nothing needs to import it by name.