Types¶
Shared type aliases used in grid-doctor's signatures. Use them to
annotate your own code, e.g. an encoding you build up before passing it
to save_pyramid:
from grid_doctor.types import PyramidEncoding
encoding: PyramidEncoding = {
level: {"ta": {"dtype": "int16", "scale_factor": 0.01}}
for level in pyramid
}
Special type definitions.
Shared aliases, so that signatures say what a value is instead of
Any. The only Any left in grid-doctor's own annotations is the
precision parameter of NumPy's generic float type (FloatingArray)
and keyword arguments passed through unchanged to third-party
functions.
FloatingArray = npt.NDArray[np.floating[Any]]
module-attribute
¶
NumPy array of any float precision (float16 ... float128).
GenericArray = np.ndarray[tuple[int, ...], np.dtype[np.generic]]
module-attribute
¶
NumPy array of any dtype and shape (without Any in its type).
BoolArray = np.ndarray[tuple[int, ...], np.dtype[np.bool_]]
module-attribute
¶
Boolean NumPy array of any shape.
NumberArray = npt.NDArray[np.number[Any]]
module-attribute
¶
NumPy array of any numeric dtype.
IndexSlice = 'slice[int | None, int | None, int | None]'
module-attribute
¶
An index slice as used by isel and zarr regions.
RegridFunc = Callable[[FloatingArray], FloatingArray]
module-attribute
¶
A function regridding one block of values.
S3Options = Mapping[str, object]
module-attribute
¶
Keyword arguments for :class:s3fs.S3FileSystem, e.g. key,
secret and endpoint_url. Never stored in a manifest.
Region = 'dict[str, slice[int | None, int | None, int | None]]'
module-attribute
¶
Zarr write region: one slice of the cell (and other) dimensions.
ZarrStore = str | MutableMapping[str, bytes]
module-attribute
¶
Where a zarr store lives: a local path or an fsspec mapping (S3).
ZarrArray = zarr.Array[ArrayV2Metadata] | zarr.Array[ArrayV3Metadata]
module-attribute
¶
A zarr array of format 2 or 3.
VarEncoding = Mapping[str, object]
module-attribute
¶
Encoding of one variable as accepted by to_zarr, e.g.
{"dtype": "int16", "scale_factor": 0.01, "chunks": (24, 4096)}.
Kept open (not a TypedDict) because zarr and xarray accept many
codec-specific keys (compressors, filters, serializer,
shards, ...).
LevelEncoding = Mapping[str, VarEncoding]
module-attribute
¶
Encodings of one dataset (pyramid level), keyed by variable name.
PyramidEncoding = Mapping[int, LevelEncoding]
module-attribute
¶
Encodings of a whole pyramid, keyed by HEALPix level.
EncodingDict = dict[str, dict[str, object]]
module-attribute
¶
A mutable per-variable encoding mapping, as built internally.
JSONValue = 'None | bool | int | float | str | list[JSONValue] | dict[str, JSONValue]'
module-attribute
¶
Any value json.loads can return.
RemapMethod = Literal['nearest', 'conservative']
module-attribute
¶
Supported weight-generation methods.
SourceUnits = Literal['auto', 'deg', 'rad']
module-attribute
¶
Angular unit convention for source coordinates.
SourceKind = Literal['auto', 'regular', 'curvilinear', 'unstructured', 'spectral']
module-attribute
¶
Explicit source grid classification.
Ellipsoid = Literal['sphere', 'WGS84']
module-attribute
¶
Reference ellipsoid of the HEALPix geometry, as a healpix_geo name.
CoarsenMode = Literal['mean', 'mode', 'auto']
module-attribute
¶
Coarsening strategy for HEALPix pyramid construction.
ValidFraction = bool | Literal['static'] | Collection[str] | Mapping[str, bool | Literal['static']]
module-attribute
¶
Which variables get a <name>_valid_fraction companion, and its shape.
True/"static" apply to every variable with a cell dimension;
a collection of names selects variables (full shape); a mapping sets the
shape per variable. "static" stores the fraction of the first slice
along all non-cell dimensions only, for masks that never change.
BinAgg = Literal['mean', 'mode', 'min', 'max', 'count']
module-attribute
¶
Per-cell aggregation methods for point binning.
FloatArray = npt.NDArray[np.float64]
module-attribute
¶
Shorthand for a float64 NumPy array.
IntArray = npt.NDArray[np.int32]
module-attribute
¶
Shorthand for a int32 NumPy array.
Int64Array = npt.NDArray[np.int64]
module-attribute
¶
Shorthand for a int64 NumPy array.
MissingPolicy = Literal['renormalize', 'propagate']
module-attribute
¶
Missing-value handling strategy for weight application.
ApplyBackend = Literal['auto', 'scipy', 'numba', 'cupy']
module-attribute
¶
Which application backend to use.
WeightOptions
¶
Bases: TypedDict
Options for generating weight files.
Shared by
compute_healpix_weights and
regrid_to_healpix. Functions that pass them through unchanged (e.g.
cached_weights) accept them as
keyword arguments; see compute_healpix_weights for what each one
does.
RegridOptions
¶
Bases: WeightOptions
Keyword options of regrid_to_healpix.
Functions that build pyramids pass them through unchanged; see
regrid_to_healpix for what each one does.
ZarrOptions
¶
Bases: TypedDict
Definitions of possible to_zarr arguments.