melodies_monet.plots.surfplots

Functions

CalcIOA(v2, v1)

Calc_Score(score_name_input, ...)

GetDateList(start_time_input, end_time_input)

Plot_CSI(column, score_name_input, ...[, ...])

calc_24hr_ave_v1(df[, col])

calc_8hr_rolling_max_v1(df[, col, window])

calc_default_colors(p_index)

List of default colors, lines, and markers to use if user does not specify them in the input yaml file.

calculate_boxplot(df[, df_reg, column, ...])

Combines data into acceptable format for box-plot

calculate_multi_boxplot(df[, df_reg, ...])

Combines data into acceptable format for box-plot

get_utcoffset(lat, lon)

get UTC offset in hour based on a point (lat/lon)

make_24hr_regulatory(df[, col])

Calculates 24-hour averages

make_8hr_regulatory(df[, col])

Calculates 8-hour rolling average daily

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

Creates box-plot.

make_diurnal_cycle(df[, column, label, ax, ...])

Creates timeseries plot.

make_multi_boxplot(comb_bx, label_bx, region_bx)

Creates box-plot.

make_rose_plot(rose_df, obsvar, modvar, ...)

Creates windroses and pollution roses.

make_scatter_density_plot(df[, mod_var, ...])

Creates a scatter density plot for the specified column (variable) in the paired DataFrame (df).

make_spatial_bias(df[, df_reg, column_o, ...])

Creates surface spatial bias plot.

make_spatial_bias_exceedance(df[, df_wind, ...])

Creates surface spatial bias plot.

make_spatial_overlay(df, vmodel[, column_o, ...])

Creates spatial overlay plot.

make_taylor(df[, df_reg, column_o, label_o, ...])

Creates taylor plot.

make_timeseries(df[, df_reg, column, label, ...])

Creates timeseries plot.

map_projection(m, *[, model_name])

Define map projection.

new_color_map()

Creates new color map for difference plots

scorecard_step1_combine_df(df[, df_reg, ...])

Combines data into acceptable format for box-plot

scorecard_step2_prepare_individual_df(...[, ...])

scorecard_step3_getLUC(region_name_input, ...)

scorecard_step4_GetRegionLUCDate([ds_name, ...])

scorecard_step5_KickNan([obs_input, ...])

scorecard_step6_BetterOrWorse([obs_input, ...])

scorecard_step7_SigLevel([model1_input, ...])

scorecard_step8_OutputMatrix([...])

scorecard_step9_makeplot([output_matrix, ...])

melodies_monet.plots.surfplots.calc_default_colors(p_index)

List of default colors, lines, and markers to use if user does not specify them in the input yaml file.

Parameters:

p_index (integer) – Number of pairs in analysis class

Returns:

list – List of dictionaries containing default colors, lines, and markers to use for plotting for the number of pairs in analysis class

melodies_monet.plots.surfplots.calculate_boxplot(df, df_reg=None, column=None, label=None, plot_dict=None, comb_bx=None, label_bx=None)

Combines data into acceptable format for box-plot

Parameters:
  • df (pandas.DataFrame) – model/obs paired data to plot

  • df_reg (pandas.DataFrame) – model/obs paired regulatory data to plot

  • column (str) – Column 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.surfplots.calculate_multi_boxplot(df, df_reg=None, region_name=None, interval_list=None, interval_var=None, interval_labels=None, column=None, label=None, plot_dict=None, comb_bx=None, label_bx=None)

Combines data into acceptable format for box-plot

Parameters:
  • df (pandas.DataFrame) – model/obs paired data to plot

  • df_reg (pandas.DataFrame) – model/obs paired regulatory data to plot

  • region_name (list of str) – user input regions of interest to plot

  • interval_list (list of numbers) – list of points that will create a single groupped boxplot. E.g. [0, 3, 5, 8, 11, 14] will create groupped boxplots for [0-3), [3-5), and so forth.

  • interval_var (str) – the variable a grouped boxplot will be created for

  • interval_labels (list of str) – Labels that refer to the interval list. e.g. [“[0, 3)”, “[3, 5)”, “[5, 8)”, “[8, 11)”, “[11, 14)”] are labels that will appear on the x-axis

  • column (str) – Column 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 – dataframe containing information to create box-plot list of string labels to use in box-plot dataframe containing information for regions to help create multi-box-plot

melodies_monet.plots.surfplots.get_utcoffset(lat, lon)

get UTC offset in hour based on a point (lat/lon)

Parameters:
  • lat – Latitude (deg; -90. to 90.)

  • lon – Longitude (deg; -180. to 180.)

Returns:

UTC offset in hour

melodies_monet.plots.surfplots.make_24hr_regulatory(df, col=None)

Calculates 24-hour averages

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

  • col (str) – Column label of observation variable to apply the calculation

Returns:

dataframe – dataframe with applied calculation

melodies_monet.plots.surfplots.make_8hr_regulatory(df, col=None)

Calculates 8-hour rolling average daily

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

  • col (str) – Column label of observation variable to apply the calculation

Returns:

dataframe – dataframe with applied calculation

melodies_monet.plots.surfplots.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, set_stat_sig=False, gridlines=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

  • 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.

  • set_stat_sig (boolean) – Whether to provide statistical significance marker or not.

  • gridlines (boolean) – Draws background gridlines

Returns:

plot – box plot

melodies_monet.plots.surfplots.make_diurnal_cycle(df, column=None, label=None, ax=None, avg_window=None, ylabel=None, vmin=None, vmax=None, domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, debug=False, **kwargs)

Creates timeseries plot.

Parameters:
  • df (pandas.DataFrame) – model/obs paired data to plot

  • column (str) – Column 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.surfplots.make_multi_boxplot(comb_bx, label_bx, region_bx, region_list=None, interval_labels=None, model_name_list=None, ylabel=None, xlabel=None, vmin=None, vmax=None, outname='plot', domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, gridlines=False, 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 stations to help create multi-box-plot from calculate_boxplot

  • region_list (list of str) – list of regions to plot

  • interval_labels (list of str) – list of interval labels to plot

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

  • ylabel (str) – Title of y-axis

  • xlabel (str) – Title of x-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

  • gridlines (boolean) – Draws background gridlines

  • 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.surfplots.make_rose_plot(rose_df, obsvar, modvar, obs_wdir, model_wdir, obs_wspd, model_wspd, wr_calm_limit=0.5, color_map='viridis', ylabel=None, outname='plot', domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, debug=False)

Creates windroses and pollution roses. Roses can be generated for any meteorological and chemical variable.

Parameters:
  • rose_df (dataframe) – model/obs pair data to plot

  • obsvar (str) – observed variable to compare with observed wind direction

  • modvar (str) – modeled variable to compare with modeled wind direction

  • obs_wdir (str) – observed variable name for wind direction

  • model_wdir (str) – modeled variable name for wind direction.

  • obs_wspd (str) – observed variable name for wind speed. Needed for pollution roses.

  • model_wspd (str) – modeled variable name for wind speed. Needed for polution roses.

  • wr_calm_limit (real number) – Limit to use for calm_winds. Default is 0.5 m/s.

  • color_map (str) – Color_map to use in plot

  • ylabel (str) – Title of 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 – rose plot

melodies_monet.plots.surfplots.make_scatter_density_plot(df, mod_var=None, obs_var=None, ax=None, color_map='viridis', xlabel=None, ylabel=None, title=None, fill=False, vmin_x=None, vmax_x=None, vmin_y=None, vmax_y=None, gridlines=False, outname='plot', **kwargs)

Creates a scatter density plot for the specified column (variable) in the paired DataFrame (df).

Parameters:
  • df (dataframe) – Paired DataFrame containing the model and observation data to plot

  • obs_var (str) – obs variable name in mapped pairs

  • mod_var (str) – model variable name in mapped pairs

  • ax (Matplotlib axis from a previous occurrence to overlay obs and model results on the same plot)

  • color_map (str) – Colormap for the density (optional)

  • xlabel (str) – Label for the x-axis (optional)

  • ylabel (str) – Label for the y-axis (optional)

  • title (str) – Title for the plot (optional)

  • fill (bool) – Fill set to True for seaborn kde plot

  • outname (str) – File location and name of plot.

  • gridlines (boolean) – Draws background gridlines

  • **kwargs (dict) – Additional keyword arguments for customization

Returns:

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

melodies_monet.plots.surfplots.make_spatial_bias(df, df_reg=None, column_o=None, label_o=None, column_m=None, label_m=None, ylabel=None, ptile=None, vdiff=None, outname='plot', u_comp=None, v_comp=None, wind_barb=False, wind_barb_step=1, wind_barb_kwargs=None, domain_type=None, domain_name=None, fig_dict=None, text_dict=None, debug=False)

Creates surface spatial bias plot.

Parameters:
  • df (pandas.DataFrame) – model/obs paired data to plot

  • df_reg (pandas.DataFrame) – model/obs paired regulatory data to plot

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

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

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

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

  • ylabel (str) – Title of colorbar axis

  • ptile (integer) – Percentile calculation

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

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

  • u_comp (str) – Name of u_component in the model to use for wind barbs

  • v_comp (str) – Name of v_component in the model to use for wind barbs

  • wind_barb (boolean) – Whether to plot wind barbs (True) or not (False)

  • wind_barb_step (integer) – Step or stride frequency to plot every nth wind_barb to declutter plot

  • wind_barb_kwargs (dictionary) – Dictionary containing information about wind barbs

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

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

  • 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 – surface bias plot

melodies_monet.plots.surfplots.make_spatial_bias_exceedance(df, df_wind=None, column_o=None, label_o=None, column_m=None, label_m=None, ylabel=None, vdiff=None, outname='plot', u_comp=None, v_comp=None, wind_barb=False, wind_barb_step=1, wind_barb_kwargs=None, domain_type=None, domain_name=None, fig_dict=None, text_dict=None, debug=False)

Creates surface spatial bias plot.

Parameters:
  • df (pandas.DataFrame) – model/obs paired data to plot with regulatory calcs

  • df_wind (pandas.DataFrame) – model/obs paired data to plot with wind data

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

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

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

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

  • ylabel (str) – Title of colorbar axis

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

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

  • u_comp (str) – Name of u_component in the model to use for wind barbs

  • v_comp (str) – Name of v_component in the model to use for wind barbs

  • wind_barb (boolean) – Whether to plot wind barbs (True) or not (False)

  • wind_barb_step (integer) – Step or stride frequency to plot every nth wind_barb to declutter plot

  • wind_barb_kwargs (dictionary) – Dictionary containing information about wind barbs

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

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

  • fig_dict (dict) – Dictionary containing information about figure

  • text_dict (dict) – Dictionary containing information about text

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

Returns:

plot – surface bias plot

melodies_monet.plots.surfplots.make_spatial_overlay(df, vmodel, column_o=None, label_o=None, column_m=None, label_m=None, ylabel=None, vmin=None, vmax=None, nlevels=None, proj=None, outname='plot', u_comp=None, v_comp=None, wind_barb=False, wind_barb_step=1, wind_barb_kwargs=None, domain_type=None, domain_name=None, fig_dict=None, text_dict=None, debug=False)

Creates spatial overlay plot.

Parameters:
  • df (dataframe) – model/obs pair data to plot

  • vmodel (dataarray) – slice of model data to plot

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

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

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

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

  • ylabel (str) – Title of colorbar axis

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

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

  • nlevels (integer) – Number of levels used in colorbar axis

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

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

  • u_comp (str) – Name of u_component in the model to use for wind barbs

  • v_comp (str) – Name of v_component in the model to use for wind barbs

  • wind_barb (boolean) – Whether to plot wind barbs (True) or not (False)

  • wind_barb_step (integer) – Step or stride frequency to plot every nth wind_barb to declutter plot

  • wind_barb_kwargs (dictionary) – Dictionary containing information about wind barbs

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

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

  • 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 – spatial overlay plot

melodies_monet.plots.surfplots.make_taylor(df, df_reg=None, column_o=None, label_o='Obs', column_m=None, label_m='Model', 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)

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

Parameters:
  • df (pandas.DataFrame) – model/obs paired data to plot

  • df_reg (pandas.DataFrame) – model/obs paired regulatory 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

  • 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.surfplots.make_timeseries(df, df_reg=None, column=None, label=None, ax=None, avg_window=None, 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:
  • df (pandas.DataFrame) – model/obs paired data to plot

  • df_reg (pandas.DataFrame) – model/obs paired regulatory data to plot

  • column (str) – Column 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.surfplots.map_projection(m, *, model_name=None)

Define map projection.

Parameters:
  • m (melodies_monet.driver.model) – Model class instance.

  • model_name (str, optional) – For example, 'ufs'. m.model.lower() used if not provided. If provided, will be used to create a new projection (i.e., an existing m.proj projection won’t be returned).

Returns:

cartopy.crs.Projection – Projection to be used by cartopy in plotting.

melodies_monet.plots.surfplots.new_color_map()

Creates new color map for difference plots

Returns:

colormap – Orange and blue color map

melodies_monet.plots.surfplots.scorecard_step1_combine_df(df, df_reg=None, region_name=None, urban_rural_name=None, column=None, label=None, plot_dict=None, comb_bx=None, label_bx=None)

Combines data into acceptable format for box-plot

Parameters:
  • df (pandas.DataFrame) – model/obs paired data to plot

  • df_reg (pandas.DataFrame) – model/obs paired regulatory data to plot

  • column (str) – Column 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 – dataframe containing information to create box-plot list of string labels to use in box-plot dataframe containing information for regions to help create multi-box-plot