CrocoDash.raw_data_access package#

Subpackages#

Submodules#

CrocoDash.raw_data_access.base module#

Raw Data Access Module Requirements: 1. Must enforce a certain amount of metadata for each product (things like z coordinate name, u velocity name, etc) (from the parent class) 2. Must enforce specific keyword args in each access function (from the parent class) 3. There must be some sort of registry that can list/query all products & access methods 4. As minimal overhead as possible (for me, that meant no initialization!) 5. Should be easy to validate the function (easy to test if they work and the metadata) 6. Should be easy to validate the metadata 7. Need to be able to print out the available products, functions, and their respective descriptions.

How it was solved: 1. There is a set of “abstract” classes that specify an array of “required_metadata”. There is no type enforcement currently. This is checked in the _init_subclass hook. 2. There is a set of “abstract” classes that specify an array of “required_args”. There is no type enforcement. This is checked in the _init_subclass hook. 3. There is a class called ProductRegistry in the registry.py file that does this 4. The classes are all static. 5. There is a validate method in the BaseProduct class that takes in additional default args from child classes, and the _init_subclass hook validates the args. 6. The metadata is validated in the _init_subclass hook 7. The ProductRegistry holds all of that.

class CrocoDash.raw_data_access.base.BaseProduct#

Bases: object

Base class for all raw data products. It enforces the metadata on the product as well as the function args.

required_args = ['output_folder', 'output_filename']#
required_metadata = ['product_name', 'description', 'link']#
classmethod validate_call(method_name, **kwargs)#

Validate that a call to an access method has correct arguments.

classmethod validate_method(method_name, **kwargs)#

Default validation just makes a toy call with a temporary directory.

classmethod write_metadata(file_path: str = None) dict#

Return a dict of the class metadata fields and their values, writes a file if a filepath is specified.

class CrocoDash.raw_data_access.base.Calendar(cf: str, cesm: str, mom6: str)#

Bases: object

Pairs the calendar name each downstream consumer expects, so a product can’t declare one without the others.

cf is for xarray’s own time decode/encode while reading raw data (its CF convention name, e.g. “standard” for the real-world calendar). cesm is the CIME CALENDAR xml value. mom6 is the literal string the regridding step must stamp on output forcing files’ time:calendar attribute, since MOM6’s get_cal_time() accepts neither cf’s “standard” nor cesm’s upper-cased “GREGORIAN”/”NO_LEAP” – only e.g. “gregorian”/”noleap”.

cesm: str#
cf: str#
mom6: str#
class CrocoDash.raw_data_access.base.DatedBaseProduct#

Bases: BaseProduct

Specific enforcement needs for Dated Products

required_args = ['output_folder', 'output_filename', 'dates']#
classmethod validate_method(method_name, **kwargs)#

Default validation just makes a toy call with a temporary directory.

class CrocoDash.raw_data_access.base.ForcingProduct#

Bases: DatedBaseProduct

Generic enforcement for any gridded, bounding-box-downloadable forcing product. Holds the metadata every such product needs regardless of target model: a lat/lon/variables/dates download contract, sane toy-call defaults for that contract’s lat/lon args, and its own time-axis naming (time_var_name/time_units/cf_calendar/cesm_calendar/mom6_calendar) – every dated forcing product has some time coordinate to name, even one (like a static restart snapshot) that leaves these unused. Velocity/ tracer grid-point metadata is NOT here – see VelocityTracerForcingProduct/MOM6ForcingProduct.

required_args = ['output_folder', 'output_filename', 'dates', 'variables', 'lon_max', 'lat_max', 'lon_min', 'lat_min', 'name']#
required_metadata = ['product_name', 'description', 'link', 'time_var_name', 'time_units', 'cf_calendar', 'cesm_calendar', 'mom6_calendar']#
classmethod validate_method(method_name, **kwargs)#

Default validation just makes a toy call with a temporary directory.

class CrocoDash.raw_data_access.base.MOM6ForcingProduct#

Bases: VelocityTracerForcingProduct

MOM6/regional_mom6-specific regridding metadata on top of VelocityTracerForcingProduct – SSH and the OBC fill method, neither of which generalize to other models. Products that feed CrocoDash’s MOM6 OBC/IC pipeline (GLORYS, MOM6_OUTPUT) extend this.

required_metadata = ['product_name', 'description', 'link', 'time_var_name', 'time_units', 'cf_calendar', 'cesm_calendar', 'mom6_calendar', 'u_x_coord', 'u_y_coord', 'v_x_coord', 'v_y_coord', 'tracer_x_coord', 'tracer_y_coord', 'u_var_name', 'v_var_name', 'tracer_var_names', 'depth_coord', 'eta_var_name', 'boundary_fill_method']#
classmethod write_metadata(file_path: str | None = None, include_marbl_tracers=False) dict#

Return a dict of the class metadata fields and their values, writes a file if a filepath is specified.

class CrocoDash.raw_data_access.base.VelocityTracerForcingProduct#

Bases: ForcingProduct

Coordinate/variable-name metadata for a product’s u/v velocity and tracer grid points – the var-map contract consumed by regional_mom6’s Segment.regrid_velocity_tracers, not by the generic GET layer. Shared by MOM6ForcingProduct and any future model whose velocity/tracer state lives on a plain (nj, ni) index space.

required_metadata = ['product_name', 'description', 'link', 'time_var_name', 'time_units', 'cf_calendar', 'cesm_calendar', 'mom6_calendar', 'u_x_coord', 'u_y_coord', 'v_x_coord', 'v_y_coord', 'tracer_x_coord', 'tracer_y_coord', 'u_var_name', 'v_var_name', 'tracer_var_names', 'depth_coord']#
CrocoDash.raw_data_access.base.accessmethod(func=None, *, description=None, type=None, how_to_use=None)#

CrocoDash.raw_data_access.registry module#

class CrocoDash.raw_data_access.registry.ProductRegistry#

Bases: object

Static registry that tracks all products and provides driver-like introspection.

classmethod call(product_name, method_name, **kwargs)#
classmethod get_access_function(product_name, method_name)#

Return the raw function (unbound), even if staticmethod.

classmethod get_function_default_args(product_name, function_name)#

Return a dict of {param: default} for all non-required parameters of an access method.

classmethod get_product(name)#
classmethod list_access_methods(name)#
classmethod list_products()#
classmethod load()#
loaded = False#
classmethod product_exists(name)#
classmethod product_is_of_type(name, the_class)#
products = {}#
classmethod register(product_cls)#

Register a product class.

classmethod validate_function(product_name, method_name)#

Module contents#