smoke_dust.core.regrid package

Submodules

smoke_dust.core.regrid.common module

Common regridding functionality used by the regrid processor.

class AbstractWrapper(*args: Any, **kwargs: Any)

Bases: ABC, BaseModel

Superclass for all wrapper objects. Wrapper objects map metadata to an associated esmpy object.

dims: DimensionCollection
class Dimension(*args: Any, **kwargs: Any)

Bases: BaseModel

A dimension object containing metadata and rank bounds information.

coordinate_type: Literal['y', 'x', 'time']
lower: int
name: Tuple[str, ...]
size: int
staggerloc: int
upper: int
class DimensionCollection(*args: Any, **kwargs: Any)

Bases: BaseModel

A collection of dimension objects.

get(name: str | Tuple[str, ...]) Dimension

Get a dimension object from the collection.

value: Tuple[Dimension, ...]
class FieldWrapper(*args: Any, **kwargs: Any)

Bases: AbstractWrapper

Wraps an esmpy field with dimension metadata.

fill_nc_variable(path: Path)

Fill the netCDF variable associated with the esmpy field.

gwrap: GridWrapper
value: esmpy.Field
class GridSpec(*args: Any, **kwargs: Any)

Bases: BaseModel

Defines a grid specification that can be read from a netCDF file.

create_grid_dims(nc_ds: netCDF4.Dataset, grid: esmpy.Grid, staggerloc: esmpy.StaggerLoc) DimensionCollection

Create a dimension collection from a netCDF dataset and esmpy grid.

get_x_corner() str

Get the name of the x corner.

get_x_data(grid: esmpy.Grid, staggerloc: esmpy.StaggerLoc) numpy.ndarray

Get x-coordinate data from a grid.

get_y_corner() str

Get the name of the y corner.

get_y_data(grid: esmpy.Grid, staggerloc: esmpy.StaggerLoc) numpy.ndarray

Get y-coordinate data from a grid.

property has_corners: bool

Returns true if the grid has corners.

x_center: str
x_corner: str | None = None
x_corner_dim: Tuple[str, ...] | None = None
x_dim: Tuple[str, ...]
x_index: int = 1
y_center: str
y_corner: str | None = None
y_corner_dim: Tuple[str, ...] | None = None
y_dim: Tuple[str, ...]
y_index: int = 0
class GridWrapper(*args: Any, **kwargs: Any)

Bases: AbstractWrapper

Wraps an esmpy grid with dimension metadata.

corner_dims: DimensionCollection | None = None
fill_nc_variables(path: Path)

Fill netCDF variables using coordinate data from an esmpy grid.

spec: GridSpec
value: esmpy.Grid
class NcToField(*args: Any, **kwargs: Any)

Bases: BaseModel

Converts a netCDF file to an esmpy field.

create_field_wrapper() FieldWrapper

Create a field wrapper.

dim_time: Tuple[str, ...] | None = None
gwrap: GridWrapper
name: str
path: Path
class NcToGrid(*args: Any, **kwargs: Any)

Bases: BaseModel

Converts a netCDF file to an esmpy grid.

create_grid_wrapper() GridWrapper

Create a grid wrapper.

path: Path
spec: GridSpec
load_variable_data(var: netCDF4.Variable, target_dims: DimensionCollection) numpy.ndarray

Load variable data using bounds defined in the dimension collection.

Parameters:
  • var – netCDF variable to load data from.

  • target_dims – Dimensions for the variable containing esmpy bounds.

Returns:

The loaded data array.

mask_edges(data: numpy.ma.MaskedArray, mask_width: int = 1) None

Mask edges of domain for interpolation.

Parameters:
  • data – The masked array to alter

  • mask_width – The width of the mask at each edge

Returns:

A numpy array of the masked edges

smoke_dust.core.regrid.processor module

Implements the smoke/dust regrid processor.

class SmokeDustRegridProcessor(context: SmokeDustContext)

Bases: object

Regrids smoke/dust data to the forecast grid.

log(*args: Any, **kwargs: Any) None

See SmokeDustContext.log.

run(cycle_metadata: pandas.DataFrame) None

Run the regrid processor. This may be run in parallel using MPI.