libera_utils.io.netcdf.DataProductConfig#

class libera_utils.io.netcdf.DataProductConfig(*, data_product_id: ~libera_utils.aws.constants.DataProductIdentifier, static_project_metadata: ~libera_utils.io.netcdf.StaticProjectMetadata = <factory>, version: str, variable_configuration_path: ~pathlib.Path | None = None, variables: dict[str, ~libera_utils.io.netcdf.LiberaVariable] | None = None, product_metadata: ~libera_utils.io.netcdf.ProductMetadata | None = None)#

Bases: BaseModel

Pydantic model for a Libera data product configuration.

Notes

This is the primary object used to configure and write properly formatted NetCDF4 files that can be archived with the Libera SDC.

Attributes:
model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

Methods

add_data_to_variable(variable_name, ...)

Adds the actual data to an existing LiberaVariable

add_variables_with_metadata(...)

A wrapper around the load_data_product_variables_with_metadata method.

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

enforce_version_format(version_string)

Enforces the proper formatting of the version string as M.m.p.

ensure_data_product_id(raw_data_product_id)

Converts raw data product id string to DataProductIdentifier class if necessary.

generate_data_product_filename(...[, revision])

Generate a valid data product filename using the Filenaming methods

get_static_project_metadata([file_path])

Loads the static project metadata field of the object from a file

load_data_product_variables_with_metadata(...)

Method to create a properly made LiberaVariables from a config file.

load_variables_from_config()

If a model is instantiated with a configuration path listed then populate the variables from that file

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, include, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

use_variable_configuration(...)

Optional validator method that allows the user to specify a path to the variable configuration file.

construct

dict

format_version

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

__init__(**data: Any) None#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Methods

add_data_to_variable(variable_name, ...)

Adds the actual data to an existing LiberaVariable

add_variables_with_metadata(...)

A wrapper around the load_data_product_variables_with_metadata method.

enforce_version_format(version_string)

Enforces the proper formatting of the version string as M.m.p.

ensure_data_product_id(raw_data_product_id)

Converts raw data product id string to DataProductIdentifier class if necessary.

format_version()

generate_data_product_filename(...[, revision])

Generate a valid data product filename using the Filenaming methods

get_static_project_metadata([file_path])

Loads the static project metadata field of the object from a file

load_data_product_variables_with_metadata(...)

Method to create a properly made LiberaVariables from a config file.

load_variables_from_config()

If a model is instantiated with a configuration path listed then populate the variables from that file

use_variable_configuration(...)

Optional validator method that allows the user to specify a path to the variable configuration file.

Attributes

model_computed_fields

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_extra

Get extra fields set during validation.

model_fields

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

data_product_id

static_project_metadata

version

variable_configuration_path

variables

product_metadata

add_data_to_variable(variable_name, variable_data)#

Adds the actual data to an existing LiberaVariable

add_variables_with_metadata(variable_config_file_path)#

A wrapper around the load_data_product_variables_with_metadata method.

Notes

This allows the model to be validated after the variables have been added.

classmethod enforce_version_format(version_string: str)#

Enforces the proper formatting of the version string as M.m.p.

classmethod ensure_data_product_id(raw_data_product_id: str | DataProductIdentifier) DataProductIdentifier#

Converts raw data product id string to DataProductIdentifier class if necessary.

generate_data_product_filename(utc_start_time: datetime, utc_end_time: datetime, revision: datetime | None = None) LiberaDataProductFilename#

Generate a valid data product filename using the Filenaming methods

classmethod get_static_project_metadata(file_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/lasp-libera-sdc-libera-utils/checkouts/3.2.1/libera_utils/data/static_project_metadata.yml'))#

Loads the static project metadata field of the object from a file

Parameters:

file_path (Path) – The path to the corresponding yml file.

classmethod load_data_product_variables_with_metadata(file_path: str | Path)#

Method to create a properly made LiberaVariables from a config file.

Notes

This method is used as part of validator if a filepath is passed in to construct the Data ProductConfig object.

load_variables_from_config()#

If a model is instantiated with a configuration path listed then populate the variables from that file

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod use_variable_configuration(variable_configuration_path: str | Path)#

Optional validator method that allows the user to specify a path to the variable configuration file.