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 CESM xml value. mom6 (FMS) is the string the netcdf files must have on time:calendar attribute, since it is not necessarily the same as cf OR cesm.

cesm: str#
cf: str#
classmethod from_config(section: dict) Calendar#

Rebuild a Calendar from the calendar object in a config.json section.

Reads the copy the chl / river-nutrients configurators store in their own inputs block, so the extraction driver can hand those writers the whole Calendar rather than one name and a guess about which of its roles that name was meant for. The product metadata block is a separate copy, written by BaseProduct.write_metadata and read directly by the OBC step; it does not come through here.

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

Specific enforcement needs for Forcing Products

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', 'u_x_coord', 'u_y_coord', 'v_x_coord', 'v_y_coord', 'tracer_x_coord', 'tracer_y_coord', 'depth_coord', 'u_var_name', 'v_var_name', 'eta_var_name', 'tracer_var_names', 'boundary_fill_method', 'time_units', 'calendar']#
classmethod validate_method(method_name, **kwargs)#

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

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.

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#