geoips.pydantic package#

Submodules#

geoips.pydantic.bases module#

Pydantic base models for GeoIPS.

Intended for use by other base models.

PluginModel should be used as the parent class of all other plugin models.

Other models defined here validate field types within child plugin models.

class geoips.pydantic.bases.DynamicModel[source]#

Bases: PrettyBaseModel

Pydantic model with a customized ConfigDict configurations for GeoIPS.

This model extends PrettyBaseModel and uses Pydantic’s ConfigDict to provide customized configurations. It is intended for use in cases where additional fields are not allowed, but the object data can be modified after initialization.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.bases.FrozenModel[source]#

Bases: PrettyBaseModel

Pydantic model with a customized ConfigDict configurations for GeoIPS.

This model extends PrettyBaseModel and uses Pydantic’s ConfigDict to provide customized configurations. It is intended for use in cases where additional fields are not allowed, and the object data cannot be modified after initialization.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.bases.PermissiveDynamicModel(**extra_data: Any)[source]#

Bases: PrettyBaseModel

Pydantic model with a customized ConfigDict configurations for GeoIPS.

This model extends PrettyBaseModel and uses Pydantic’s ConfigDict to provide customized configurations. It is intended for use in cases where additional fields are allowed, and the object data can be modified after initialization.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.bases.PermissiveFrozenModel(**extra_data: Any)[source]#

Bases: PrettyBaseModel

Pydantic model with a customized ConfigDict configurations for GeoIPS.

This model extends PrettyBaseModel and uses Pydantic’s ConfigDict to provide customized configurations. It is intended for use in cases where additional fields are allowed, but the object data cannot be modified after initialization.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.bases.PluginModel(*, interface: str, family: str, name: str, docstring: str, description: str = None, package: str = (FieldInfo(annotation=NoneType, required=True, description='Package that contains this plugin.'),), relpath: str = None, abspath: str = None)[source]#

Bases: FrozenModel

Base Plugin model for all GeoIPS plugins.

This should be used as the base class for all top-level PluginModels. It adds standard plugin attributes for inheritance. It validates YAML plugins for the order based procflow.

See the YAML plugin documentation here for more information about how this is used.

abspath: str#
description: str#
docstring: str#
family: str#
interface: str#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

name: str#
package: str#
relpath: str#
class geoips.pydantic.bases.PrettyBaseModel[source]#

Bases: BaseModel

Make Pydantic models pretty-print by default.

This model overrides the default string representation of Pyantic models to generate a user-friendly, JSON-formatted output with two-space indentation.

model_config: ClassVar[ConfigDict] = {}#

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

geoips.pydantic.bases.get_interfaces() set[str][source]#

Return a set of distinct interfaces.

This function returns all available plugin interfaces. The results are cached for runtime memory optimizaiton.

Returns:

set of interfaces

Return type:

set of str

geoips.pydantic.bases.python_identifier(val: str) str[source]#

Validate if a string is a valid Python identifier.

Validate if a string is a valid Python identifier and not a reserved Python keyword. See for more information on Python identifiers and reserved keywords.

Validation is performed by calling str.isidentifier and keyword.iskeyword.

Parameters:

val (str) – The input string to validate.

Returns:

The input string if it is a valid Python identifier.

Return type:

str

Raises:

ValueError – If the input string is invalid as a Python identifier or a reserved keyword.

geoips.pydantic.feature_annotators module#

Pydantic models used to validate GeoIPS feature annotator plugins.

class geoips.pydantic.feature_annotators.CartopyFeature(*, enabled: bool, edgecolor: Tuple[float, float, float] | Tuple[float, float, float, float] | str = None, linewidth: float = None, **extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Generic model for cartopy features.

edgecolor: Tuple[float, float, float] | Tuple[float, float, float, float] | str#
enabled: bool#
linewidth: float#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.feature_annotators.FeatureAnnotatorPluginModel(*, interface: str, family: str, name: str, docstring: str, description: str = None, package: str = (FieldInfo(annotation=NoneType, required=True, description='Package that contains this plugin.'),), relpath: str = None, abspath: str = None, spec: FeatureAnnotatorSpec)[source]#

Bases: PluginModel

Feature Annotator plugin format.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

spec: FeatureAnnotatorSpec#
class geoips.pydantic.feature_annotators.FeatureAnnotatorSpec(*, coastline: CartopyFeature, borders: CartopyFeature, rivers: CartopyFeature, states: CartopyFeature, background: Tuple[float, float, float] | Tuple[float, float, float, float] | str = None)[source]#

Bases: FrozenModel

Feature Annotator spec (specification) format.

background: Tuple[float, float, float] | Tuple[float, float, float, float] | str#
borders: CartopyFeature#
coastline: CartopyFeature#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

rivers: CartopyFeature#
states: CartopyFeature#

geoips.pydantic.sectors module#

Pydantic models used to validate GeoIPS sector plugins.

class geoips.pydantic.sectors.AreaDefinitionSpec(*, area_id: str = None, description: str = None, projection: SectorProjection, shape: Tuple[int, int] | SectorShape = None, area_extent: Tuple[float, float, float, float] | SectorAreaExtent = None, resolution: float | Tuple[float, float] | SectorResolution = None, units: Literal['m', 'km', 'meters', 'kilometers', 'deg', 'degrees'] = 'm', center: Tuple[float, float] | XYCoordinate = (0, 0))[source]#

Bases: FrozenModel

Defines an AreaDefinition for use with pyresample.

The resulting dictionary should be able to just be passed to pyresample.create_area_def().

area_extent: Tuple[float, float, float, float] | SectorAreaExtent#
area_id: str#
center: Tuple[float, float] | XYCoordinate#
description: str#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

projection: SectorProjection#
resolution: float | Tuple[float, float] | SectorResolution#
shape: Tuple[int, int] | SectorShape#
units: Literal['m', 'km', 'meters', 'kilometers', 'deg', 'degrees']#
class geoips.pydantic.sectors.BoxMetadata(*, min_lat: float, min_lon: float, max_lat: float, max_lon: float, box_resolution_km: float)[source]#

Bases: FrozenModel

Metadata format for pyroCb sectors.

box_resolution_km: float#
max_lat: float#
max_lon: float#
min_lat: float#
min_lon: float#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.sectors.EarthConstants(value)[source]#

Bases: float, Enum

A simple class containing constant values relative to the geometry of Earth.

SEMI_MAJOR_AXIS = 6371228.0#
class geoips.pydantic.sectors.RegionMetadata(*, continent: str, country: str, area: str, subarea: str, state: str, city: str)[source]#

Bases: FrozenModel

Metadata format for standard static sectors.

area: str#
city: str#
continent: str#
country: str#
model_config: ClassVar[ConfigDict] = {'coerce_numbers_to_str': False, 'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

state: str#
subarea: str#
class geoips.pydantic.sectors.SectorAreaExtent(*, lower_left_xy: Tuple[int, int], upper_right_xy: Tuple[int, int])[source]#

Bases: FrozenModel

The extent of the sector in projection units.

For more information on how this is used, see the pyresample documentation.

lower_left_xy: Tuple[int, int]#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

upper_right_xy: Tuple[int, int]#
class geoips.pydantic.sectors.SectorPluginModel(*, interface: str, family: str, name: str, docstring: str, description: str = None, package: str = (FieldInfo(annotation=NoneType, required=True, description='Package that contains this plugin.'),), relpath: str = None, abspath: str = None, spec: AreaDefinitionSpec, metadata: BoxMetadata | StaticMetadata | StitchedMetadata | TCMetadata | VolcanoMetadata, **extra_data: Any)[source]#

Bases: PluginModel

Sector plugin format.

classmethod add_parent(value, info)[source]#

Collect default area_id and description from parent.

This is a field validator that runs before the root validator. It accesses the properties of the parent object to fill in area_id and description if they are not provided. These values come from the parent’s name and docstring.

classmethod coerce_metadata(value)[source]#

Coerce metadata to StaticMetadata if possible.

Doing this as pydantic by default will return the last class that validates correctly, and this applies to other metadata classes.

metadata: BoxMetadata | StaticMetadata | StitchedMetadata | TCMetadata | VolcanoMetadata#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

spec: AreaDefinitionSpec#
class geoips.pydantic.sectors.SectorProjection(*, proj: str, a: EarthConstants = EarthConstants.SEMI_MAJOR_AXIS, R: float = None, ellps: str = 'GRS80', h: float = None, k_0: float = 1.0, lat_0: float = None, lat_1: float = 0.0, lat_2: float = 0.0, lat_ts: float = 0.0, lon_0: float = None, t_epoch: float = None, t_final: float = None, x_0: float = 0.0, y_0: float = 0.0, units: Literal['m', 'km', 'degrees'] = 'm', **extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Projection information for a sector.

This is a dictionary that provides Proj projection information for the sector. For more information on what parameters can be supplied, see the Proj documentation.

Validation has only been implemented for some of the most common options. If you need validation for a parameter that is not currently implemented, please open an issue and, if possible, a pull request on GitHub.

R: float#
a: EarthConstants#
ellps: str#
h: float#
k_0: float#
lat_0: float#
lat_1: float#
lat_2: float#
lat_ts: float#
lon_0: float#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

proj: str#
t_epoch: float#
t_final: float#
units: Literal['m', 'km', 'degrees']#
x_0: float#
y_0: float#
class geoips.pydantic.sectors.SectorResolution(*, dx: float, dy: float)[source]#

Bases: FrozenModel

The resolution of the sector in projection units.

The height and width of pixels in the units specified by the sector’s projection units.

dx: float#
dy: float#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.sectors.SectorShape(*, height: int, width: int)[source]#

Bases: FrozenModel

The shape of the sector in pixels.

height: int#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

width: int#
class geoips.pydantic.sectors.StaticMetadata(*, region: RegionMetadata)[source]#

Bases: FrozenModel

Metadata format for standard static sectors.

This is the same as StaticMetadata, just with an additional ‘region’ level. This is a convenience model for specifying static sector plugins in a legacy format.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

region: RegionMetadata#
class geoips.pydantic.sectors.StitchedMetadata(*, region: RegionMetadata, primary_area_definition: str)[source]#

Bases: StaticMetadata

Metadata for stitched imagery sectors.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

primary_area_definition: str#
class geoips.pydantic.sectors.TCMetadata(*, pressure: float, vmax: float, clat: float, clon: float, synoptic_time: datetime, aid_type: str, storm_num: int, storm_name: str, storm_basin: str, storm_year: int, deck_line: str, source_file: str, final_storm_name: str)[source]#

Bases: FrozenModel

Metdata format for Tropical Cyclone sectors.

aid_type: str#
clat: float#
clon: float#
deck_line: str#
final_storm_name: str#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

pressure: float#
source_file: str#
storm_basin: str#
storm_name: str#
storm_num: int#
storm_year: int#
synoptic_time: datetime#
vmax: float#
class geoips.pydantic.sectors.VolcanoMetadata(*, summit_elevation: float, plume_height: float, wind_speed: float, wind_dir: float, clat: float, clon: float)[source]#

Bases: FrozenModel

Metadata format for Volcano sectors.

clat: float#
clon: float#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

plume_height: float#
summit_elevation: float#
wind_dir: float#
wind_speed: float#
class geoips.pydantic.sectors.XYCoordinate(*, x: float = None, y: float = None)[source]#

Bases: FrozenModel

A coordinate in projection units.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

x: float#
y: float#
geoips.pydantic.sectors.lat_lon_coordinate(arg: tuple[float, float]) tuple[float, float][source]#

Validate a latitude and longitude coordinate.

geoips.pydantic.workflows module#

Workflow plugin models.

Defines pydantic models related to Workflow plugins, including top-level callable interfaces (eg. Readers, OutputFormatters, etc.).

class geoips.pydantic.workflows.AlgorithmArgumentsModel(**extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Validate Algorithm arguments.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.workflows.CoverageCheckerArgumentsModel(**extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Validate Coverage Checker arguments.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.workflows.FilenameFormatterArgumentsModel(**extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Validate FilenameFormatter arguments.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.workflows.InterpolatorArgumentsModel(**extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Validate Interpolator arguments.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.workflows.OutputFormatterArgumentsModel(**extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Validate Output Formatter arguments.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.workflows.ReaderArgumentsModel(*, area_def: str = None, chans: List[str] = None, metadata_only: bool = False, self_register: List[str] = None, fnames: List[str] = None, **extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Reader step argument definition.

Pydantic model defining and validating Reader step arguments.

area_def: str#
fnames: List[str]#
metadata_only: bool#
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

self_register: List[str]#
variables: List[str]#
class geoips.pydantic.workflows.WorkflowArgumentsModel(**extra_data: Any)[source]#

Bases: PermissiveFrozenModel

Validate workflow arguments.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

class geoips.pydantic.workflows.WorkflowPluginModel(*, interface: str, family: str, name: str, docstring: str, description: str = None, package: str = (FieldInfo(annotation=NoneType, required=True, description='Package that contains this plugin.'),), relpath: str = None, abspath: str = None, spec: WorkflowSpecModel, **extra_data: Any)[source]#

Bases: PluginModel

A plugin that produces a workflow.

model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

spec: WorkflowSpecModel#
class geoips.pydantic.workflows.WorkflowSpecModel(*, steps: List[WorkflowStepModel])[source]#

Bases: FrozenModel

The specification for a workflow.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

steps: List[WorkflowStepModel]#
class geoips.pydantic.workflows.WorkflowStepDefinitionModel(*, type: str, name: str, arguments: ~typing.Dict[str, ~typing.Any] = <factory>)[source]#

Bases: FrozenModel

Validate step definition : name, arguments.

arguments: Dict[str, Any]#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

name: str#
type: str#
class geoips.pydantic.workflows.WorkflowStepModel(*, definition: WorkflowStepDefinitionModel)[source]#

Bases: FrozenModel

Validate and process a sequence of steps with their data.

definition: WorkflowStepDefinitionModel#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

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

geoips.pydantic.workflows.get_plugin_names(plugin_type: str) List[str][source]#

Return valid plugin names for passed plugin type.

Parameters:

plugin_type (str) – valid plugin interface name

Returns:

A list of plugin names for a valid plugin type

Return type:

list

Raises:

AttributeError – If the plugin type is invalid

geoips.pydantic.workflows.get_plugin_types() set[str][source]#

Return plugin types from available interfaces.

Returns:

singular names of distinct plugin types

Return type:

set of str

Module contents#

GeoIPS order-based procflow pydantic models init file.

geoips.pydantic.collect_classes(modules)[source]#

Extract all classes from the given modules.

Parameters:

modules (dict) –

  • A dictionary of mod_name: module objects found within geoips.pydantic

geoips.pydantic.collect_modules()[source]#

Dynamically find and import all submodules within a package.