melodies_monet.plots.xarray_plots

Functions

calculate_boxplot(dset[, varname, label, ...])

Combines data into acceptable format for box-plot

make_boxplot(comb_bx, label_bx[, ylabel, ...])

Creates box-plot.

make_diurnal_cycle(dset, varname[, ax])

Calculates diurnal cycle for region and does the timeseries

make_multi_boxplot(comb_bx, label_bx, region_bx)

Creates box-plot.

make_spatial_bias_gridded(dset[, varname_o, ...])

Creates difference plot for satellite and model data.

make_spatial_dist(dset[, varname, label, ...])

Creates a plot for satellite or model data.

make_taylor(dset[, varname_o, label_o, ...])

Creates taylor plot.

make_timeseries(dset[, varname, label, ax, ...])

Creates timeseries plot.

sel_region([domain_type, domain_name, ...])

Selects box for region.

time_average(dset[, varname, period, ...])

Calculates 24-hour averages

melodies_monet.plots.xarray_plots.calculate_boxplot(dset, varname=None, label=None, plot_dict=None, comb_bx=None, label_bx=None)

Combines data into acceptable format for box-plot

Parameters:
  • dset (xr.Dataset) – model/obs pair data to plot

  • varname (str) – Dataset label of variable to plot

  • label (str) – Name of variable to use in plot legend

  • comb_bx (dataframe) – dataframe containing information to create box-plot from previous occurrence so can overlay multiple model results on plot

  • label_bx (list) – list of string labels to use in box-plot from previous occurrence so can overlay multiple model results on plot

Returns:

dataframe, list – dataframe containing information to create box-plot list of string labels to use in box-plot

melodies_monet.plots.xarray_plots.make_boxplot(comb_bx, label_bx, ylabel=None, vmin=None, vmax=None, outname='plot', domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, debug=False)

Creates box-plot.

Parameters:
  • comb_bx (dataframe) – dataset containing information to create box-plot from calculate_boxplot

  • label_bx (list) – list of string labels to use in box-plot from calculate_boxplot

  • ylabel (str) – Title of y-axis

  • vmin (real number) – Min value to use on y-axis

  • vmax (real number) – Max value to use on y-axis

  • outname (str) – file location and name of plot (do not include .png)

  • domain_type (str) – Domain type specified in input yaml file

  • domain_name (str) – Domain name specified in input yaml file

  • plot_dict (dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)

  • fig_dict (dictionary) – Dictionary containing information about figure

  • text_dict (dictionary) – Dictionary containing information about text

  • debug (boolean) – Whether to plot interactively (True) or not (False). Flag for submitting jobs to supercomputer turn off interactive mode.

Returns:

plot – box plot

melodies_monet.plots.xarray_plots.make_diurnal_cycle(dset, varname, ax=None, **kwargs)

Calculates diurnal cycle for region and does the timeseries

Parameters:
  • dset (xr.Dataset) – Dataset with paired data

  • time_offset (int | float) – Offset (in hours) to apply to the diurnal cycle

  • ax (ax) – matplotlib ax from previous occurrence so can overlay obs and model results on the same plot

  • **kwargs – Other plotting arguments. Optional arguments are:

    • time_offsetint | float, optional

      Time offset in hours. E. g., if you are at UTC-7, and wish to have the plot at local time, do time_offset=-7. Default = 0.

    • ylabelstr, optional

      Title of y-axis Default = varname

    • vminreal number, optional

      Min value to use on y-axis

    • vmaxreal number, optional

      Max value to use on y-axis

    • domain_typestr, optional

      Domain type specified in input yaml file

    • domain_namestr, optional

      Domain name specified in input yaml file

    • plot_dictdict, optional

      Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)

    • fig_dictdict, optional

      Dictionary containing information about figure

    • text_dictdict, optional

      Dictionary containing information about text

    • range_shadingstr, optional

      Whether to shade the range obtained for each hour. options: “no”, “total”, “std”, “pct:number”. If “no”, no range shading if performed. if “total”, the total range obtained is shaded. If “std”, the standard deviation is shaded. if “pct:number”, then the percentile chosen is shaded (e. g., “pct:98”)

    • debugbool, optional

      Whether to plot interactively (True) or not (False). Flag for submitting jobs to supercomputer turn off interactive mode.

Returns:

ax – matplotlib ax such that driver.py can iterate to overlay multiple models on the same plot

melodies_monet.plots.xarray_plots.make_multi_boxplot(comb_bx, label_bx, region_bx, region_list=None, model_name_list=None, ylabel=None, vmin=None, vmax=None, outname='plot', domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, debug=False)

Creates box-plot.

Parameters:
  • comb_bx (dataframe) – dataframe containing information to create box-plot from calculate_boxplot

  • label_bx (list) – list of string labels to use in box-plot from calculate_boxplot

  • region_bx (dataframe) – dataframe containing information of boxes to help create multi-box-plot from calculate_boxplot

  • model_name_list (list of str) – list of models and observation sources used for x-labels in plot

  • ylabel (str) – Title of y-axis

  • vmin (real number) – Min value to use on y-axis

  • vmax (real number) – Max value to use on y-axis

  • outname (str) – file location and name of plot (do not include .png)

  • domain_type (str) – Domain type specified in input yaml file

  • domain_name (str) – Domain name specified in input yaml file

  • plot_dict (dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)

  • fig_dict (dictionary) – Dictionary containing information about figure

  • text_dict (dictionary) – Dictionary containing information about text

  • debug (boolean) – Whether to plot interactively (True) or not (False). Flag for submitting jobs to supercomputer turn off interactive mode.

Returns:

plot – multi-box plot

melodies_monet.plots.xarray_plots.make_spatial_bias_gridded(dset, varname_o=None, label_o=None, varname_m=None, label_m=None, ylabel=None, vdiff=None, nlevels=None, proj=None, outname='plot', domain_type=None, domain_name=None, fig_dict=None, text_dict=None, debug=False, **kwargs)

Creates difference plot for satellite and model data. For data in swath format, overplots all differences For data on regular grid, mean difference.

Parameters:
  • dset (xr.Dataset) – model/obs paired data to plot

  • varname_o (str) – Name of observation variable to plot

  • label_o (str) – Name of observation variable to use in plot title

  • varname_m (str) – Name of model variable to plot

  • label_m (str) – Name of model variable to use in plot title

  • cblabel (str) – Title of colorbar axis

  • vdiff (float) – Min and max value to use on colorbar axis

  • nlevels (float) – number of levels to break colorbar map into

  • proj (cartopy projection) – cartopy projection to use in plot

Returns:

plot – satellite spatial bias plot

melodies_monet.plots.xarray_plots.make_spatial_dist(dset, varname=None, label=None, ylabel=None, vmin=None, vmax=None, nlevels=None, proj=None, outname='plot', domain_type=None, domain_name=None, fig_dict=None, text_dict=None, debug=False)

Creates a plot for satellite or model data.

Parameters:

dset (xr.Dataset) – Dataset containing the paired data

melodies_monet.plots.xarray_plots.make_taylor(dset, varname_o=None, label_o='Obs', varname_m=None, label_m='Model', mean_criteria=None, dia=None, ylabel=None, ty_scale=1.5, domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, debug=False, normalize=False, scale_factor=1)

Creates taylor plot. Note sometimes model values are off the scale on this plot. This will be fixed soon.

Parameters:
  • dset (xr.Dataset) – model/obs pair data to plot

  • column_o (str) – Column label of observational variable to plot

  • label_o (str) – Name of observational variable to use in plot legend

  • column_m (str) – Column label of model variable to plot

  • label_m (str) – Name of model variable to use in plot legend

  • mean_criteria (str) – ‘None’, ‘space’, ‘time’. If None, values and correlations are compared over all dimensions (x, y and time). If ‘space’, the spatial mean over the comain is calculated before doing the comparison. If ‘time’, the temporal mean is calculated before doing the comparison.

  • dia (dia) – matplotlib ax from previous occurrence so can overlay obs and model results on the same plot

  • ylabel (str) – Title of x-axis

  • ty_scale (real) – Scale to apply to taylor plot to control the plotting range

  • domain_type (str) – Domain type specified in input yaml file

  • domain_name (str) – Domain name specified in input yaml file

  • plot_dict (dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)

  • fig_dict (dictionary) – Dictionary containing information about figure

  • text_dict (dictionary) – Dictionary containing information about text

  • debug (boolean) – Whether to plot interactively (True) or not (False). Flag for submitting jobs to supercomputer turn off interactive mode.

Returns:

class – Taylor diagram class defined in MONET

melodies_monet.plots.xarray_plots.make_timeseries(dset, varname=None, label=None, ax=None, avg_window='h', ylabel=None, vmin=None, vmax=None, domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, debug=False)

Creates timeseries plot.

Parameters:
  • dset (xr.Dataset) – model/obs pair data to plot

  • varname (str) – Variable label of variable to plot

  • label (str) – Name of variable to use in plot legend

  • ax (ax) – matplotlib ax from previous occurrence so can overlay obs and model results on the same plot

  • avg_window (rule) – Pandas resampling rule (e.g., ‘h’, ‘D’)

  • ylabel (str) – Title of y-axis

  • vmin (real number) – Min value to use on y-axis

  • vmax (real number) – Max value to use on y-axis

  • domain_type (str) – Domain type specified in input yaml file

  • domain_name (str) – Domain name specified in input yaml file

  • plot_dict (dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)

  • fig_dict (dictionary) – Dictionary containing information about figure

  • text_dict (dictionary) – Dictionary containing information about text

  • debug (boolean) – Whether to plot interactively (True) or not (False). Flag for submitting jobs to supercomputer turn off interactive mode.

Returns:

ax – matplotlib ax such that driver.py can iterate to overlay multiple models on the same plot

melodies_monet.plots.xarray_plots.sel_region(domain_type=None, domain_name=None, domain_box=None)

Selects box for region. If the region has a domain name, it is selected using get_epa_bounds or get_giorgi_bounds. Otherwise, if there is a domain_box, it is selected as a whole. The current implementation cannot deal with domain boxes containing the antimeridian.

Parameters:
  • domain_type (str) – ‘all’, ‘epa_region’, ‘giorgi_region’, ‘auto-region:giorgi’, ‘auto-region:CNA’, ‘custom’

  • domain_name (str) – EPA or Giorgi region acronym

  • domain_box (list[int|float, int|float, int|float, int|float]) – domain box containing the region to be plotted. Only read if region is ‘custom’. Expected order: latmin, lonmin, latmax, lonmax

Returns:

Boundaries for the plotting

melodies_monet.plots.xarray_plots.time_average(dset, varname=None, period='1D', time_offset=None)

Calculates 24-hour averages

Parameters:
  • dset (dataframe) – Model/obs pair of hourly data

  • varname (None | str) – Column label of observation variable to apply the calculation

  • period (str) – The period over which to average. Should be noted in Pandas style (e.g., ‘1D’, ‘1h’, ‘ME’, etc.)

  • time_offset (None | timedelta) – Whether a time_offset should be applied. Can be useful if accounting for time offsets is desirable.

Returns:

dataframe – dataframe with applied calculation