emodpy_malaria.weather.weather_metadata module#

Weather metadata module, implementing functionality for working with weather metadata files (.bin.json).

class emodpy_malaria.weather.weather_metadata.WeatherAttributes(attributes_dict: Dict[str, str | int | float] | None = None, reference: str | None = None, resolution: str | None = None, provenance: str | None = None, update_freq: str | None = None, start_year: int | None = None, end_year: int | None = None, start_doy: int | None = None, lat_min: float | None = None, lat_max: float | None = None, lon_min: float | None = None, lon_max: float | None = None, tool: str | None = None, author: str | None = None, schema_version: str | None = None)[source]#

Bases: object

Weather attributes containing metadata used to construct the “metadata” element and stored in .bin.json file. Used to initiate weather metadata object. If no metadata is specified, defaults are used. If metadata dict is specified, that dictionary is used as is, without setting any defaults.

property attributes_dict: Dict[str, str | int | float]#
property tool: str#

Tool name used to prepare weather files.

property date_created: str#

Date weather files are created.

property author: str#

Author of weather files.

property id_reference: str#

Id reference value used to semantically bind weather files.

property update_resolution: str#

Data update frequency (e.g. monthly, yearly).

property data_years: str#

Data years range describing the temporal coverage.

property provenance: str#

Data provenance, describing the data source and how the data was obtained.

property spatial_resolution: str#

Weather data Spatial resolution (e.g., 30arcsec or 1km)

classmethod format_create_date(created: datetime) str[source]#
classmethod metadata_defaults_dict() Dict[str, str | int | float][source]#

Metadata defaults dictionary.

classmethod required_metadata_defaults_dict(exclude_keys: List[str] | None = None) Dict[str, str | int | float][source]#

Dictionary of required metadata defaults.

update(value: Dict[str, int | str])[source]#

Update metadata dictionary.

validate() NoReturn[source]#

Validate metadata contains requires argument.

class emodpy_malaria.weather.weather_metadata.WeatherMetadata(node_ids: List[int] | Dict[int, int], series_len: int | None = None, attributes: WeatherMetadata | WeatherAttributes | Dict[str, str | int | float] | None = None)[source]#

Bases: WeatherAttributes

Weather metadata containing weather data attributes, counts and node offsets. Used to initiate WeatherData, expose metadata programmatically and create weather metadata files (.bin.json).

validate()[source]#

Validate metadata object node-related counts. Relies on inherited validation of metadata attributes.

property attributes: WeatherAttributes#

Cast back into WeatherAttributes.

property datavalue_count: int#

Number of data values in each weather time series (must be > 0).

property series_len: int#

Number of data values in each timeseries, should be > 0.

property series_count: int#

The number of weather time series (expected based on metadata), corresponding to the number of offsets.

property series_unique_count#

The number of unique weather time series (expected based on metadata), based on offsets.

property total_value_count: int#

The total count of all values, in all weather time series (expected based on metadata).

property nodes: List[int]#

The list of nodes (node ids) in the node-offset dictionary.

property node_count: int#

The number of node in the node-offset dictionary.

property node_offset_str: str#

The node offset string, as it will appear in the weather metadata file (.bin.json).

property node_offsets: Dict[int, int]#

Node-offset dictionary, mapping node ids (keys) to node offsets (values).

property offset_nodes: Dict[int, List[int]]#

The offset-nodes dictionary, grouping nodes (values) by offset (key). Used to find unique series.

to_file(file_path: str | Path) NoReturn[source]#

Save weather metadata object as weather metadata file (.bin.json).

Parameters:

file_path – The path of the output weather metadata file.

Returns:

None

classmethod from_file(file_path: str | Path) WeatherMetadata[source]#

Read weather metadata file into a weather metadata object.