mosaic.Descriptor#
- class mosaic.Descriptor(mesh_ds, projection=None, transform=None, use_latlon=False)#
Data structure describing unstructured MPAS meshes.
Enables visualization of fields defined at cell centers, vertices, and edges within
matplotlibthrough the creation ofPolyCollectionobjects. Separate patch arrays, which are subsequently passed to thePolyCollectionclass by thepolypcolormethod, are lazily loaded for each variable location (i.e. cells, edges, and vertices) when attribute is first looked up. We use lazily loaded arrays because we are rarely plotting variables located at all three locations and patch array creation is the most expensive process in our visualization procedure.The resulting patch arrays properly handle culled mesh boundaries (i.e. culled land boundaries for spherical meshes and/or mesh boundary for planar non-periodic meshes). Additionally, x and/or y periodicity is properly handled for planar periodic mesh and we can correct for patch wrapping over the antimeridian for projected spherical meshes.
- Parameters:
mesh_ds (
DataSet) – A valid MPAS mesh dataset that contains the basic mesh variables (i.e. coordinate and connectivity arrays) needed for creating patch arrays.projection (
cartopy.crs.CRS, optional) – The target projection for plotting.transform (
cartopy.crs.CRS, optional) – The coordinate system in which the parent mesh coordinates are defined.use_latlon (
bool, optional) – Whether to use the lat/lon coordinate arrays to construct the patches.
Notes
If both the
projectionandtransformparameters are passed, then the coordinate arrays in theDescriptor.dswill be transformed prior to patch construction. We do this as matter of efficiency, since transforming the one-dimensional coordinate arrays is much faster than transforming the multi-dimensional patch arrays. This means theDescriptor.transformwill not be the values passed to the constructor, but instead will be equal toDescriptor.projectionExamples
>>> import cartopy.crs as ccrs >>> import mosaic >>> >>> ds = mosaic.datasets.open_dataset("QU.240km") >>> >>> transform = ccrs.PlateCarree() >>> projection = ccrs.NorthPolarStereo() >>> >>> # set `use_latlon` to True b/c our transform expects lat/lon coords >>> descriptor = mosaic.Descriptor( >>> ds, projection, transform, use_latlon=True >>> )
- __init__(mesh_ds, projection=None, transform=None, use_latlon=False)#
Methods
__init__(mesh_ds[, projection, transform, ...])Attributes
ndarrayof patch coordinates for cell centered valuesndarrayof patch coordinates for edge centered valueslatlonBoolean whether the lat/lon coordinate arrays should be used for patch construction.
originCoordinates of bottom left corner of plot
projectionThe target projection for plotting.
ndarrayof patch coordinates for vertex centered valuesx_periodPeriod along x-dimension, is
Nonefor non-periodic meshesy_periodPeriod along y-dimension, is
Nonefor non-periodic meshesThe coordinate system in which patch coordinates are defined.
is_sphericalBoolean whether parent mesh is spherical
is_periodicBoolean whether parent mesh is (planar) periodic in at least one dim
dsDatasetthat contains the minimal subset of coordinate and connectivity arrays from the parent mesh needed to create patches arrays.