melodies_monet.plots.aircraftplots

aircraftplots.py this code is designed for plotting aircraft specific plot types

Functions

add_yax2_altitude(ax, pairdf, altitude_yax2, ...)

Creates secondary y-axis (altitude) for timeseries plot.

calculate_violin(df[, column, label, ...])

Combines data into an acceptable format for violin plots, similar to calculate_boxplot for box plots.

custom_yaxis_formatter(x, pos)

make_curtain_plot(time, altitude, ...[, ...])

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.

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

Creates surface spatial bias plot.

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

Creates altitude profile plot.

make_violin_plot(comb_violin, label_violin)

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 (float or None) – Minimum value for color normalization, if applicable.

  • cmax (float or None) – 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_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 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)

  • 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.aircraftplots.make_vertprofile(df, column=None, label=None, ax=None, bins=None, ylabel_vert=None, gridlines=False, 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 (int or array-like) – Bins for binning the altitude variable.

  • ylabel (str) – Title of y-axis.

  • gridlines (boolean) – Draws background gridlines

  • altitude_variable (str) – The Altitude variable in the paired df e.g., ‘MSL_GPS_Altitude_YANG’

  • 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 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 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, set_stat_sig=False, gridlines=False)

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.

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

  • gridlines (boolean) – Draws background gridlines

Returns:

None