melodies_monet.plots.aircraftplots
aircraftplots.py this code is designed for plotting aircraft specific plot types
Functions
|
Creates secondary y-axis (altitude) for timeseries plot. |
|
Combines data into an acceptable format for violin plots, similar to calculate_boxplot for box plots. |
|
|
|
Generates a curtain plot comparing model data with obs across altitude (Pressure, right now) over time, with the ability to customize the appearance through a configuration dictionary. |
|
Creates a scatter density plot for the specified column (variable) in the paired DataFrame (df). |
|
Creates surface spatial bias plot. |
|
Creates altitude profile plot. |
|
Creates a violin plot using combined data from multiple model/observation datasets. |
- melodies_monet.plots.aircraftplots.add_yax2_altitude(ax, pairdf, altitude_yax2, text_kwargs, vmin_y2, vmax_y2)
Creates secondary y-axis (altitude) for timeseries plot.
- Parameters
ax (
ax) – Matplotlib ax from previous occurrences so it can overlay obs and model results on the same plot.pairdf (
pandas.DataFrame) – Model/obs paired data to plot.text_kwargs (
dictionary) – Dictionary containing information about text.altitude_yax2 (
dictionary) – Secondary y-axis (altitude) control options, including altitude_variable, altitude_ticks, etc.vmin_y2, vmax_y2 (
the value[0],value[1] respectively defined in filter_dict in altitude_yax2 in YAML control option)
- Returns
ax (
ax) – Matplotlib ax such that driver.py can iterate to overlay multiple models on the same plot.
- melodies_monet.plots.aircraftplots.calculate_violin(df, column=None, label=None, plot_dict=None, comb_violin=None, label_violin=None)
Combines data into an acceptable format for violin plots, similar to calculate_boxplot for box plots.
- Parameters
df (
pandas.DataFrame) – DataFrame containing the model/obs paired data to plot.column (
str) – Column label of the variable to plot.label (
str) – Name of the variable to use in the plot legend.plot_dict (
dict) – Dictionary containing color information for the plot.comb_violin (
pandas.DataFrame) – DataFrame containing information to create violin plots from previous occurrences, to overlay multiple model results on one plot.label_violin (
list) – List of dictionaries with string labels and colors to use in the violin plot from previous occurrences, to overlay multiple model results on one plot.
- Returns
comb_violin (
pandas.DataFrame) – DataFrame containing information to create violin plots.label_violin (
list) – List of dictionaries with string labels and colors to use in the violin plot.
- melodies_monet.plots.aircraftplots.make_curtain_plot(time, altitude, model_data_2d, obs_pressure, pairdf, mod_var, obs_var, grp_dict, vmin=None, vmax=None, cmin=None, cmax=None, plot_dict=None, outname='plot', domain_type=None, domain_name=None, obs_label_config=None, text_dict=None, debug=False)
Generates a curtain plot comparing model data with obs across altitude (Pressure, right now) over time, with the ability to customize the appearance through a configuration dictionary. ##Two Subplots: 1) model data contourf plot with model scatter overlay, 2) another for observation data using scatter plot. This layout ensures that both datasets can be analyzed without visual interference from each other. Shared X-Axis: The time axis is shared between the two plots for better comparison. Titles and Labels: Each subplot has a title specific to the data it displays.
- Parameters
time (
numpy.ndarray) – Array of time points, expected to be numerical values suitable for plotting.altitude (
numpy.ndarray) – Array of altitude points.model_data_2d (
numpy.ndarray) – 2D array of cleaned and interpolated model data.obs_pressure (
numpy.ndarray) – Array of pressure points corresponding to observations.pairdf (
pandas.DataFrame) – Paired DataFrame containing model and observation data for scatter plots.mod_var (
str) – Model variable name for labeling.obs_var (
str) – Observation variable name for labeling.grp_dict (
dict) – Plot configuration options including aesthetics and normalization parameters.vmin (
float) – Min value to use on y-axis.vmax (
float) – Max value to use on y-axis.cmin (
floatorNone) – Minimum value for color normalization, if applicable.cmax (
floatorNone) – Maximum value for color normalization, if applicable.plot_dict (
dictionary) – Dictionary containing information about plotting for each pair (e.g., color, linestyle, markerstyle).outname (
str) – File location and name of plot.domain_type (
str) – Type of domain being plotted (e.g., ‘region’, ‘global’).domain_name (
str) – Name of the domain being plotted.obs_label_config (
dict) – Configuration dictionary for observation labels.text_dict (
dict) – Dictionary containing text properties (fontsize, fontweight, etc.).debug (
bool) – Whether to plot interactively (True) or not (False). Flag for submitting jobs to supercomputer turn off interactive mode.
- Returns
None– Saves the generated plot to a file.
- melodies_monet.plots.aircraftplots.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, 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.**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.aircraftplots.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', 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)domain_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.aircraftplots.make_vertprofile(df, column=None, label=None, ax=None, bins=None, altitude_variable=None, ylabel=None, vmin=None, vmax=None, domain_type=None, domain_name=None, plot_dict=None, fig_dict=None, text_dict=None, debug=False, interquartile_style=None)
Creates altitude profile 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 it can overlay obs and model results on the same plot.bins (
intorarray-like) – Bins for binning the altitude variable.altitude_variable (
str) – The Altitude variable in the paired df e.g., ‘MSL_GPS_Altitude_YANG’ylabel (
str) – Title of y-axis.vmin (
float) – Min value to use on y-axis.vmax (
float) – Max value to use on y-axis.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 the figure.text_dict (
dictionary) – 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.interquartile_style= str – Whether the vertical profile uses shading or box style for interquartile range
- Returns
ax (
ax) – Matplotlib ax such that driver.py can iterate to overlay multiple models on the same plot.
- melodies_monet.plots.aircraftplots.make_violin_plot(comb_violin, label_violin, outname='plot', domain_type=None, domain_name=None, fig_dict=None, text_dict=None, debug=False, ylabel=None, vmin=None, vmax=None)
Creates a violin plot using combined data from multiple model/observation datasets.
- Parameters
comb_violin (
pandas.DataFrame) – DataFrame containing combined data for all datasets to be plotted.label_violin (
list) – List of dictionaries with string labels and colors to use in the violin plot.outname (
str) – File location and name of plot (do not include .png).domain_type (
str) – Domain type specified in the input yaml file.domain_name (
str) – Domain name specified in the input yaml file.fig_dict (
dict) – Dictionary containing information about figure properties.text_dict (
dict) – Dictionary containing information about text properties.debug (
bool) – If True, the plot will be shown interactively. Useful for debugging.ylabel (
str, optional) – The label for the y-axis.vmin (
float, optional) – The minimum value for the y-axis.vmax (
float, optional) – The maximum value for the y-axis.
- Returns
None