nsrdb.utilities.plots.Spatial

class Spatial[source]

Bases: object

Framework to perform NSRDB spatial QA via map plots.

Methods

dsets(h5, dsets, out_dir[, timesteps, ...])

Make map style plots at several timesteps for a given dataset.

goes_cloud(fpath, dsets, out_dir[, ...])

Plot datasets from a GOES cloud file.

multi_year(year_range, out_dir, dsets[, ...])

Make map plots at timesteps for datasets in multiple NSRDB files.

plot_geo_df(df, fname, out_dir[, labels, ...])

Plot a dataframe to verify the blending operation.

Attributes

EXTENTS

static multi_year(year_range, out_dir, dsets, nsrdb_dir='/projects/PXS/nsrdb/v3.0.1/', fname_base='nsrdb_{year}.h5', timesteps=range(0, 17520, 8600), **kwargs)[source]

Make map plots at timesteps for datasets in multiple NSRDB files.

Parameters:
  • year_range (iterable) – List of integer or string values to plot data for.

  • out_dir (str) – Path to dump output plot files.

  • dsets (str | list) – Name of target dataset(s) to plot

  • nsrdb_dir (str) – Target resource file directory.

  • fname_base (str) – Base nsrdb filename found in the nsrdb_dir. Should have a {year} keyword.

  • timesteps (iterable) – Timesteps (time indices) to make plots for.

Returns:

  • fig (matplotlib.pyplot.figure) – Plotting figure object.

  • ax (matplotlib.axes._subplots.AxesSubplot) – Plotting axes object.

static dsets(h5, dsets, out_dir, timesteps=(0,), fname=None, file_ext='.png', sites=None, interval=None, max_workers=1, timedelta=datetime.timedelta(0), **kwargs)[source]

Make map style plots at several timesteps for a given dataset.

Parameters:
  • h5 (str) – Target resource file with path.

  • dsets (str | list) – Name of target dataset(s) to plot

  • out_dir (str) – Path to dump output plot files.

  • timesteps (iterable | slice) – Timesteps (time indices) to make plots for. Slice will have faster data extraction and will be later converted to an iterable.

  • fname (str) – Filename without extension.

  • file_ext (str) – File extension

  • sites (None | List | Slice) – sites to plot.

  • interval (None | int) – Interval to plots sites at, i.e. if 100, only 1 every 100 sites will be plotted.

  • max_workers (int | None) – Maximum number of workers to use (>1 is parallel).

  • timedelta (datetime.timedelta) – Time delta object to shift the time index printed inthe title if {} is present in the title. This has no effect on the input timesteps.

Returns:

  • fig (matplotlib.pyplot.figure) – Plotting figure object (Only returned if not parallel).

  • ax (matplotlib.axes._subplots.AxesSubplot) – Plotting axes object (Only returned if not parallel).

static goes_cloud(fpath, dsets, out_dir, nan_fill=-15, sparse_step=10, **kwargs)[source]

Plot datasets from a GOES cloud file.

Parameters:
  • fpath (str) – Target cloud file with path (either .nc or .h5).

  • dsets (str | list) – Name of target dataset(s) to plot

  • out_dir (str) – Path to dump output plot files.

  • nan_fill (int | float) – Value to fill missing cloud data.

  • sparse_step (int) – Step size to plot sites at a given interval (speeds things up). sparse_step=1 will plot all datapoints.

Returns:

  • fig (matplotlib.pyplot.figure) – Plotting figure object.

  • ax (matplotlib.axes._subplots.AxesSubplot) – Plotting axes object.

static plot_geo_df(df, fname, out_dir, labels=('latitude', 'longitude'), xlabel='Longitude', ylabel='Latitude', title=None, title_loc='center', cbar_label='dset', marker_size=0.1, marker='s', xlim=(-127, -65), ylim=(24, 50), figsize=(10, 5), cmap='OrRd_11', cbar_range=None, dpi=150, extent=None, axis=None, alpha=1.0, shape=None, shape_aspect=None, shape_edge_color=(0.2, 0.2, 0.2), shape_line_width=2, bbox_inches='tight', dark=True)[source]

Plot a dataframe to verify the blending operation.

Parameters:
  • df (pd.DataFrame) – DataFrame with latitude/longitude in 1st/2nd columns, data in the 3rd column.

  • fname (str) – Filename to save to including file extension (usually png).

  • out_dir (str) – Output directory to save fname output.

  • labels (list | tuple) – latitude/longitude column labels in the df.

  • xlabel (str) – Label to put on the xaxis in the plot. Disabled if axis=’off’

  • ylabel (str) – Label to put on the yaxis in the plot. Disabled if axis=’off’

  • title (str) – Figure and file title.

  • title_loc (str) – Location of title (center, left, right).

  • cbar_label (str) – Label for the colorbar. Should usually include units of the plot.

  • marker_size (float) – Marker size. 0.1 is good for CONUS at 4km.

  • marker (string) – marker shape ‘s’ is square marker.

  • xlim (list | tuple) – Plot x limits (left limit, right limit) (longitude bounds).

  • ylim (list | tuple) – Plot y limits (lower limit, upper limit) (latitude bounds).

  • figsize (tuple) – Figure size inches (width, height).

  • cmap (str) – Matplotlib colormap (Blues, OrRd, viridis)

  • cbar_range = None | tuple – Optional fixed range for the colormap.

  • dpi (int) – Dots per inch.

  • extent (str) – Optional extent kwarg to fix the axis bounds and figure size from class.EXTENTS

  • axis (None | str) – Option to turn axis “off”

  • alpha (float) – Transparency value between 0 (transparent) and 1 (opaque)

  • shape (str) – Filepath to a shape file to plot on top of df data (only the boundaries are plotted).

  • shape_aspect (None | float) – Optional aspect ratio to use on shape.

  • shape_edge_color (str | tuple) – Color of the plotted shape edges

  • shape_line_width (float) – Line width of the shape edges

  • bbox_inches (str) – kwarg for saving figure.

  • dark (bool) – Flag to turn on dark mode plots.

Returns:

  • fig (matplotlib.pyplot.figure) – Plotting figure object.

  • ax (matplotlib.axes._subplots.AxesSubplot) – Plotting axes object.