melodies_monet.plots.surfplots
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
List of default colors, lines, and markers to use if user does not specify them in the input yaml file. |
|
Combines data into acceptable format for box-plot |
|
Combines data into acceptable format for box-plot |
|
get UTC offset in hour based on a point (lat/lon) |
|
Calculates 24-hour averages |
|
Calculates 8-hour rolling average daily |
|
Creates box-plot. |
|
Creates timeseries plot. |
|
Creates box-plot. |
|
Creates windroses and pollution roses. |
|
Creates a scatter density plot for the specified column (variable) in the paired DataFrame (df). |
|
Creates surface spatial bias plot. |
|
Creates surface spatial bias plot. |
|
Creates spatial overlay plot. |
|
Creates taylor plot. |
|
Creates timeseries plot. |
|
Define map projection. |
Creates new color map for difference plots |
|
|
Combines data into acceptable format for box-plot |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 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 plotdf_reg (
pandas.DataFrame) – model/obs paired regulatory data to plotcolumn (
str) – Column label of variable to plotlabel (
str) – Name of variable to use in plot legendcomb_bx (
dataframe) – dataframe containing information to create box-plot from previous occurrence so can overlay multiple model results on plotlabel_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 plotdf_reg (
pandas.DataFrame) – model/obs paired regulatory data to plotregion_name (
listofstr) – user input regions of interest to plotinterval_list (
listofnumbers) – 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 forinterval_labels (
listofstr) – 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-axiscolumn (
str) – Column label of variable to plotlabel (
str) – Name of variable to use in plot legendcomb_bx (
dataframe) – dataframe containing information to create box-plot from previous occurrence so can overlay multiple model results on plotlabel_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 datacol (
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 datacol (
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_boxplotlabel_bx (
list) – list of string labels to use in box-plot from calculate_boxplotylabel (
str) – Title of y-axisvmin (
real number) – Min value to use on y-axisvmax (
real number) – Max value to use on y-axisoutname (
str) – file location and name of plot (do not include .png)domain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml fileplot_dict (
dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)fig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textdebug (
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 plotcolumn (
str) – Column label of variable to plotlabel (
str) – Name of variable to use in plot legendax (
ax) – matplotlib ax from previous occurrence so can overlay obs and model results on the same plotavg_window (
rule) – Pandas resampling rule (e.g., ‘h’, ‘D’)ylabel (
str) – Title of y-axisvmin (
real number) – Min value to use on y-axisvmax (
real number) – Max value to use on y-axisdomain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml fileplot_dict (
dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)fig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textdebug (
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_boxplotlabel_bx (
list) – list of string labels to use in box-plot from calculate_boxplotregion_bx (
dataframe) – dataframe containing information of stations to help create multi-box-plot from calculate_boxplotregion_list (
listofstr) – list of regions to plotinterval_labels (
listofstr) – list of interval labels to plotmodel_name_list (
listofstr) – list of models and observation sources used for x-labels in plotylabel (
str) – Title of y-axisxlabel (
str) – Title of x-axisvmin (
real number) – Min value to use on y-axisvmax (
real number) – Max value to use on y-axisoutname (
str) – file location and name of plot (do not include .png)domain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml fileplot_dict (
dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)fig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textgridlines (
boolean) – Draws background gridlinesdebug (
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 plotobsvar (
str) – observed variable to compare with observed wind directionmodvar (
str) – modeled variable to compare with modeled wind directionobs_wdir (
str) – observed variable name for wind directionmodel_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 plotylabel (
str) – Title of y-axisoutname (
str) – file location and name of plot (do not include .png)domain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml fileplot_dict (
dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)fig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textdebug (
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 plotobs_var (
str) – obs variable name in mapped pairsmod_var (
str) – model variable name in mapped pairsax (
Matplotlib axis from a previous occurrencetooverlay obsandmodel 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 plotoutname (
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 plotdf_reg (
pandas.DataFrame) – model/obs paired regulatory data to plotcolumn_o (
str) – Column label of observation variable to plotlabel_o (
str) – Name of observation variable to use in plot titlecolumn_m (
str) – Column label of model variable to plotlabel_m (
str) – Name of model variable to use in plot titleylabel (
str) – Title of colorbar axisptile (
integer) – Percentile calculationvdiff (
float) – Min and max value to use on colorbar axisoutname (
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 barbsv_comp (
str) – Name of v_component in the model to use for wind barbswind_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 plotwind_barb_kwargs (
dictionary) – Dictionary containing information about wind barbsdomain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml filefig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textdebug (
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 calcsdf_wind (
pandas.DataFrame) – model/obs paired data to plot with wind datacolumn_o (
str) – Column label of observation variable to plotlabel_o (
str) – Name of observation variable to use in plot titlecolumn_m (
str) – Column label of model variable to plotlabel_m (
str) – Name of model variable to use in plot titleylabel (
str) – Title of colorbar axisvdiff (
float) – Min and max value to use on colorbar axisoutname (
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 barbsv_comp (
str) – Name of v_component in the model to use for wind barbswind_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 plotwind_barb_kwargs (
dictionary) – Dictionary containing information about wind barbsdomain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml filefig_dict (
dict) – Dictionary containing information about figuretext_dict (
dict) – Dictionary containing information about textdebug (
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 plotvmodel (
dataarray) – slice of model data to plotcolumn_o (
str) – Column label of observation variable to plotlabel_o (
str) – Name of observation variable to use in plot titlecolumn_m (
str) – Column label of model variable to plotlabel_m (
str) – Name of model variable to use in plot titleylabel (
str) – Title of colorbar axisvmin (
real number) – Min value to use on colorbar axisvmax (
real number) – Max value to use on colorbar axisnlevels (
integer) – Number of levels used in colorbar axisproj (
cartopy projection) – cartopy projection to use in plotoutname (
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 barbsv_comp (
str) – Name of v_component in the model to use for wind barbswind_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 plotwind_barb_kwargs (
dictionary) – Dictionary containing information about wind barbsdomain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml filefig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textdebug (
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 plotdf_reg (
pandas.DataFrame) – model/obs paired regulatory data to plotcolumn_o (
str) – Column label of observational variable to plotlabel_o (
str) – Name of observational variable to use in plot legendcolumn_m (
str) – Column label of model variable to plotlabel_m (
str) – Name of model variable to use in plot legenddia (
dia) – matplotlib ax from previous occurrence so can overlay obs and model results on the same plotylabel (
str) – Title of x-axisty_scale (
real) – Scale to apply to taylor plot to control the plotting rangedomain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml fileplot_dict (
dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)fig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textdebug (
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 plotdf_reg (
pandas.DataFrame) – model/obs paired regulatory data to plotcolumn (
str) – Column label of variable to plotlabel (
str) – Name of variable to use in plot legendax (
ax) – matplotlib ax from previous occurrence so can overlay obs and model results on the same plotavg_window (
rule) – Pandas resampling rule (e.g., ‘h’, ‘D’)ylabel (
str) – Title of y-axisvmin (
real number) – Min value to use on y-axisvmax (
real number) – Max value to use on y-axisdomain_type (
str) – Domain type specified in input yaml filedomain_name (
str) – Domain name specified in input yaml fileplot_dict (
dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle)fig_dict (
dictionary) – Dictionary containing information about figuretext_dict (
dictionary) – Dictionary containing information about textdebug (
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 existingm.projprojection 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 plotdf_reg (
pandas.DataFrame) – model/obs paired regulatory data to plotcolumn (
str) – Column label of variable to plotlabel (
str) – Name of variable to use in plot legendcomb_bx (
dataframe) – dataframe containing information to create box-plot from previous occurrence so can overlay multiple model results on plotlabel_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