libera_utils.io.netcdf.LiberaDimension#

class libera_utils.io.netcdf.LiberaDimension(*, name: str, size: int, long_name: str, is_set: bool = True)#

Bases: BaseModel

Pydantic model for any dimension used for Libera data

name#

The name of the dimension, which should match the names defined in the available dimensions.

Type:

str

size#

The size of the dimension. If it is dynamic, it should be set to “dynamic”. If it is a fixed size, it should be an integer representing the size. If it is not set, it can be None.

Type:

str | int | None

long_name#

A long name for the dimension, providing a human-readable description of what the dimension represents.

Type:

str

Notes

This class defines the needed aspects of a Libera Dimension and also contains the list of known and defined dimensions that are available to be used.

Attributes:
is_dynamic_size
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.

get_available_dimensions_dict([file_path])

Loads the available dimensions for variables on the Libera project.

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, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

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.

validate_dynamic_size_and_is_set()

Ensure that the dynamic size and set status are properly set after initialization.

construct

dict

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

get_available_dimensions_dict([file_path])

Loads the available dimensions for variables on the Libera project.

validate_dynamic_size_and_is_set()

Ensure that the dynamic size and set status are properly set after initialization.

Attributes

is_dynamic_size

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.

name

size

long_name

is_set

static get_available_dimensions_dict(file_path: AnyPath | None = None)#

Loads the available dimensions for variables on the Libera project.

Parameters:

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

Notes

These are the only available dimensions to be used with official Libera variables.

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.

validate_dynamic_size_and_is_set()#

Ensure that the dynamic size and set status are properly set after initialization.

Returns:

The instance of LiberaDimension with the dynamic size and set status updated.

Return type:

LiberaDimension

Notes

This method is called after the model is validated. It sets the _is_dynamic and is_set attributes correctly based on the size of the dimension. If the size is -1, called DYNAMIC_SIZE, it indicates a dynamic size, and is_set is set to False.