melodies_monet.plots.xarray_plots
Functions
|
Combines data into acceptable format for box-plot |
|
Creates box-plot. |
|
Calculates diurnal cycle for region and does the timeseries |
|
Creates box-plot. |
|
Creates difference plot for satellite and model data. |
|
Creates a plot for satellite or model data. |
|
Creates taylor plot. |
|
Creates timeseries plot. |
|
Selects box for region. |
|
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 plotvarname (
str) – Dataset 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.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_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.
- 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 datatime_offset (
int | float) – Offset (in hours) to apply to the diurnal cycleax (
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_boxplotlabel_bx (
list) – list of string labels to use in box-plot from calculate_boxplotregion_bx (
dataframe) – dataframe containing information of boxes to help create multi-box-plot from calculate_boxplotmodel_name_list (
listofstr) – list of models and observation sources used for x-labels in plotylabel (
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.
- 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 plotvarname_o (
str) – Name of observation variable to plotlabel_o (
str) – Name of observation variable to use in plot titlevarname_m (
str) – Name of model variable to plotlabel_m (
str) – Name of model variable to use in plot titlecblabel (
str) – Title of colorbar axisvdiff (
float) – Min and max value to use on colorbar axisnlevels (
float) – number of levels to break colorbar map intoproj (
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 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 legendmean_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 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.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 plotvarname (
str) – Variable 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.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 acronymdomain_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 datavarname (
None | str) – Column label of observation variable to apply the calculationperiod (
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