libera_utils.io.netcdf#

Classes

DataProductConfig(*, data_product_id, ...)

Pydantic model for a Libera data product configuration.

DynamicProductMetadata(*, GranuleID, input_files)

Pydantic model for file specific metadata.

DynamicSpatioTemporalMetadata(*, ...)

Pydantic model for file specific spatial and temporal metadata

GPolygon(*, latitude, longitude)

Pydantic model for file specifics geolocation metadata.

LiberaVariable(*, metadata[, ...])

Pydantic model for a Libera variable.

ProductMetadata(*, dynamic_metadata, ...)

Pydantic model for file-level metadata.

StaticProjectMetadata(*, Format, ...)

Pydantic model for unchanging NetCDF-4 file metadata.

VariableMetadata(*, long_name, dimensions, ...)

Pydantic model for variable-level metadata for NetCDF-4 files.

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)#

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

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].

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.

class libera_utils.io.netcdf.DynamicProductMetadata(*, GranuleID: str, input_files: list[str])#

Pydantic model for file specific metadata.

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

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

Returns a copy of the model.

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.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

model_config: ClassVar[ConfigDict] = {}#

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

class libera_utils.io.netcdf.DynamicSpatioTemporalMetadata(*, ProductionDateTime: datetime, RangeBeginningDate: datetime, RangeBeginningTime: datetime, RangeEndingDate: datetime, RangeEndingTime: datetime, GPolygon: list[GPolygon])#

Pydantic model for file specific spatial and temporal metadata

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

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

Returns a copy of the model.

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.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

model_config: ClassVar[ConfigDict] = {}#

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

class libera_utils.io.netcdf.GPolygon(*, latitude: Annotated[float, Ge(ge=-90), Le(le=90)], longitude: Annotated[float, Ge(ge=-180), Le(le=180)])#

Pydantic model for file specifics geolocation metadata.

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

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

Returns a copy of the model.

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.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

model_config: ClassVar[ConfigDict] = {}#

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

class libera_utils.io.netcdf.LiberaVariable(*, metadata: VariableMetadata, variable_encoding: dict | None = {'_FillValue': None, 'complevel': 4, 'zlib': True}, data: DataArray | ndarray | DataFrame | None = None)#

Pydantic model for a Libera variable.

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

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

Returns a copy of the model.

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.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#

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

class libera_utils.io.netcdf.ProductMetadata(*, dynamic_metadata: DynamicProductMetadata | None, dynamic_spatio_temporal_metadata: DynamicSpatioTemporalMetadata | None)#

Pydantic model for file-level metadata.

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

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

Returns a copy of the model.

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.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

Notes

This data will change between files and is obtained from the science Dataset. The create_file_metadata method makes this object.

model_config: ClassVar[ConfigDict] = {}#

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

class libera_utils.io.netcdf.StaticProjectMetadata(*, Format: str, Conventions: str, ProjectLongName: str, ProjectShortName: str, PlatformLongName: str, PlatformShortName: str)#

Pydantic model for unchanging NetCDF-4 file metadata.

Notes

See more details at https://wiki.earthdata.nasa.gov/display/CMR/UMM-C+Schema+Representation

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

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

Returns a copy of the model.

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.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

model_config: ClassVar[ConfigDict] = {}#

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

class libera_utils.io.netcdf.VariableMetadata(*, long_name: str, dimensions: list, valid_range: list, missing_value: int | float, units: str | None = None, dtype: str | None = None)#

Pydantic model for variable-level metadata for NetCDF-4 files.

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

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

Returns a copy of the model.

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.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

model_config: ClassVar[ConfigDict] = {}#

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