PseudoNetCDF.wrffiles package

Module contents

class PseudoNetCDF.wrffiles.wrf(*args, **kwds)[source]

Bases: wrf_base, netcdf

createDimension(*args, **kwds)[source]

Create a dimension

Parameters:
  • name (string) – name for dimension

  • length (integer) – maximum length of dimension

Returns:

dim – new dimension

Return type:

PseudoNetCDFDimensions

createVariable(*args, **kwds)[source]

Create a variable

Parameters:
  • name (string) – name for new variable

  • type (string or numpy dtype) – code (e.g., ‘f’, ‘i’, ‘d’)

  • dimensions (tuple of strigns) – dimension keys that can be found in objects’ dimensions dictionary

Returns:

var

Return type:

new variable

classmethod from_ncf(infile)[source]
Parameters:

infile (PseudoNetCDF-like file)

Returns:

outf

Return type:

PseudoNetcdf-like file

classmethod isMine(*args, **kwds)[source]

True if this file or object can be identified for use by this class. Useful to override for classes that can be initialized from disk.

class PseudoNetCDF.wrffiles.wrf_base(*args, **kwds)[source]

Bases: PseudoNetCDFFile

getCoordFile()[source]
getMap(maptype='basemap_auto', **kwds)[source]

Description

Parameters:
  • maptype (string) –

    choices ‘basemap’, ‘basemap_auto’, ‘cartopy’ (not yet) basemap : attempts to open a basemap with only supplied kwds basemap_auto : automatically adds llcrnrlon,llcrnrlat,u

    rcrnrlon,urcrnrlat based on longitude_bounds

  • **kwds (keywords) – for basemap or cartopy

Returns:

map

Return type:

basemap or cartopy axis

getTimes()[source]

Get an array of datetime objects

Parameters:
  • datetype (string or numpy.dtype) – ‘datetime’ or datetime64 dtype

  • bounds (boolean) – get time boundaries

Returns:

out – datetime objects or array of numpy’s datetype type

Return type:

array

Notes

self must have a time or TFLAG variable

ij2ll(*args, **kwds)[source]

Converts i, j to lon, lat (no false easting/northing) using cell centers assuming 0-based i/j

Parameters:
  • i (scalar/iterable) – indicies (0-based) for the west-east dimension

  • j (scalar/iterable) – indicies (0-based) for the south-north dimension

Returns:

lon, lat – longitudes and latitudes in decimal degrees

Return type:

scalars or iterables

classmethod isMine(path, *args, **kwds)[source]

True if this file or object can be identified for use by this class. Useful to override for classes that can be initialized from disk.

ll2ij(*args, **kwds)[source]

Converts lon/lat to 0-based indicies (0,M), (0,N)

Parameters:
  • lon (scalar or iterable) – longitudes in decimal degrees

  • lat (scalar or iterable) – latitudes in decimal degrees

  • bounds (string) – ignore, error, warn if i,j are out of domain

  • clean (string) – none - return values regardless of bounds; mask - mask values out of bounds; clip - return min(max(0, v), nx - 1)

Returns:

i, j

Return type:

indices (0-based) for variables

ll2xy(*args, **kwds)[source]

Converts lon/lat to x distances (no false easting/northing)

Parameters:
  • lon (scalar or iterable) – longitudes in decimal degrees

  • lat (scalar or iterable) – latitudes in decimal degrees

Returns:

x, y – coordinates in map projection (meters or radians)

Return type:

tuple of arrays

plot(varkey, **kwds)[source]
Parameters:
  • varkey (string) – the variable to plot

  • plottype (string) – any dimension name pair delimited by a hyphen (e.g., longitude-latitude, latitude-pressure, longitude-pressure, vertical-profile, time-longitude, time-latitude, time-pressure) defaults to the last two dimensions.

  • ax_kw (dictionary) – keywords for the axes to be created

  • plot_kw (dictionary) – keywords for the plot (plot, scatter, or pcolormesh) to be created

  • cbar_kw (dictionary or bool or None) – keywords for the colorbar; if True or None, use defaults. If False, do not create a colorbar

  • map_kw (dictionary or bool or None) – keywords for the getMap routine, which is only used with map capable dimensions (ie, plottype=’longitude-latitude’) If True or None, use default configuration dict(countries=True, coastlines=True, states=False, counties=False). If False, do not draw a map.

  • dimreduction (string or function) – dimensions not being used in the plot are removed using applyAlongDimensions(dimkey=dimreduction) where each dimenions

Returns:

ax – Axes that was drawn on

Return type:

matplotlib.axes.Axes

val2idx(*args, **kwds)[source]

Convert coordinate values to indices

Parameters:
  • dim (str) – name of dimensions, which must have a coordinate variable

  • val (array-like) – value in coordinate space

  • method (str) –

    nearest, bounds, exact - each calculates the index differently
    • nearest : uses interp with coord values and rounds

    • bounds : uses interp between bounding values and truncates

    • exactreturns indices for exact coord values with other

      indices masked (clean keyword has no effect)

  • bounds (str) – ignore, error, warn if i,j are out of domain

  • left (scalar) – see np.interp

  • right (scalar) – see np.interp

  • clean ({'none', 'mask'}) –

    none - return values regardless of bounds; mask - mask invalid values (use with left/right=np.nan);

    has no affect with method exact

Returns:

i – indices (0-based) for variables

Return type:

array-like

xy2ll(*args, **kwds)[source]

Converts x, y to lon, lat (no false easting/northing)

Parameters:
  • x (scalar or iterable) – projected west-east coordinates

  • y (scalar or iterable) – projected south-north coordinates

Returns:

lon, lat – longitudes and latitudes in decimal degrees

Return type:

scalars or iterables