4.1. thuner.utils

General utilities for the thuner package.

pydantic model thuner.utils.BaseDatasetOptions[source]

Bases: BaseOptions

Base class for dataset options.

Fields:
Validators:
  • _check_fields » all fields

  • _check_name » all fields

  • _check_parents » all fields

field attempt_download: bool = False

Whether to attempt to download the data.

field converted_options: ConvertedOptions = ConvertedOptions(type='ConvertedOptions', save=False, load=False, parent_converted='/home/docs/THUNER_output/input_data/converted')

Options for saving and loading converted data.

field deque_length: int = 2

Number of current/previous grids from this dataset to keep in memory. Most tracking algorithms require a ‘next’ grid, ‘current’ grid, and at least two previous grids.

field end: str | datetime64 [Required]

Tracking end time.

field end_buffer: int = 0

Minutes after interval end time to include. Useful for tagging when one wants to record post-storm ambient profiles.

field fields: list[str] | None = None

List of dataset fields, i.e. variables, to use. Fields should be given using their thuner, i.e. CF-Conventions, names, e.g. ‘reflectivity’.

field filepaths: list[str] | dict = None

List of filepaths for the dataset.

field name: str = None

Name of the dataset.

field parent_local: str | Path | None = '/home/docs/THUNER_output/input_data/raw'

Parent directory of the dataset on local storage.

field parent_remote: str | None = None

Parent directory of the dataset on remote storage.

field reuse_regridder: bool = False

Whether to save and reuse an xesmf regridder for this dataset.

field start: str | datetime64 [Required]

Tracking start time.

field start_buffer: int = -120

Minutes before interval start time to include. Useful for tagging when one wants to record pre-storm ambient profiles.

field type: Literal['BaseDatasetOptions'] = 'BaseDatasetOptions'
field use: Literal['track', 'tag', 'both'] = 'track'

Whether this dataset will be used for tagging, tracking or both.

field weights_filepath: str | None = None

This should generally be left as None and inferred during tracking.

convert_dataset(time, filepath, track_options, grid_options)[source]

Convert the dataset. Note if the base class is used directly, the data is assumed to be already converted, and hence this function just opens the dataset. Function returns the converted dataset, and the boundary coordinates. Note the simple boundary coordinates are only used for visualization.

get_filepaths()[source]

Return the subset of the input filepaths that is within the start and end time range.

grid_from_dataset(dataset, variable, time)[source]

Get the grid from a generic/pre-converted dataset.

update_boundary_data(dataset, input_record, boundary_coords)[source]

Update the boundary data in the input record.

update_input_record(time, input_record, track_options, grid_options)[source]

Update the input record.

pydantic model thuner.utils.BaseOptions[source]

Bases: BaseModel

The base class for all options classes. This class is built on the pydantic BaseModel, which is similar to python dataclasses but with type checking.

Fields:
Validators:
field type: Literal['BaseOptions'] = 'BaseOptions'
validator convert_floats  »  all fields[source]

Convert all floats to np.float32.

model_summary() str[source]

Return a summary of the model fields and their descriptions.

revalidate()[source]

Revalidate the model to ensure all fields are valid.

to_dict() Dict[str, Any][source]

Convert the options to a dictionary.

to_yaml(filepath: str)[source]

Save the options to a yaml file.

pydantic model thuner.utils.ConvertedOptions[source]

Bases: BaseOptions

Converted options.

Fields:
Validators:

field load: bool = False

Whether to load the converted data.

field parent_converted: str | None = '/home/docs/THUNER_output/input_data/converted'

Parent directory for converted data.

field save: bool = False

Whether to save the converted data.

field type: Literal['ConvertedOptions'] = 'ConvertedOptions'