Replies: 1 comment
-
I don't have a particularly strong opinion on this topic, but in general I would say that if a plotting script is going to make the exact same plot type for many different variables then it can have its main plotting routine in Also, although not a high priority, it would probably be good to split "plotting" functions, which actually create some sort of image, with "computational" or "utility" functions, which perform other tasks (like averaging, interpolation, unit conversions, etc.). Anyways, that's my two cents. |
Beta Was this translation helpful? Give feedback.
-
As raised in Issue #176, there are some ambiguities about how we deal with plotting scripts. @justin-richling identified a number of consistency issues, but I would like to frame it as a slightly broader discussion.
We have
plotting_functions.py
in thelib
directory to provide some common/convenience/utility functions to plotting scripts. These functions currently are:use_this_norm
: deprecated because we don't expect old matplotlib versions anymoreget_difference_colors
: attempt to automate colors for difference plotsget_central_longitude
: tries to find a central longitude specification for mapsglobal_average
: pure numpy global average that allows for missing datawgt_rmse
: area-weighted RMSEplot_map_vect_and_save
: make a vector plot of 2 fields and the supplied differenceplot_map_and_save
: make contour map of 2 scalar fields and the supplied differencepres_from_hybrid
: calculates the pressure field for hybrid-sigma coordinatesvert_remap
: simple 1-d interpolation, assumes pressure, assumes data as (nlevel, spacetime)lev_to_plev
: interpolation from hybrid to pressure levels, uses GeoCATpmid_to_plev
: interpolation from hybrid to pressure levels, usesvert_remap
zonal_mean_xr
: generalized zonal average, but only allows for "lat" and "lev" dimension names (otherwise averages)lat_lon_validate_dims
: checks if input field has dims "lat" and "lon"zm_validate_dims
: checks if a zonal plot can be made from input field, based on dimension names_zonal_plot_line
: line plot with latitude as x-axis, Axes object as input argument_zonal_plot_preslat
: contour plot for zonal mean, lev by lat, Axes object as input argumentzonal_plot
: given lat and data, decides whether to call_zonal_plot_line
or_zonal_plot_preslat
plot_zonal_mean_and_save
: zonal mean plots, handles many plotting options and callszonal_plot
, andsavefig
square_contour_difference
: a contour plot with square axes (intended for annual cycle plot)This is kind of a mish-mash. Some functions might be useful for plotting scripts, but others are pretty much the final product (
plot_zonal_mean_and_save
,plot_map_and_save
,plot_map_vect_and_save
), and others are computations that are different degrees of specialized.Should we be more prescriptive about how we support plotting scripts? What do we expect them to do on their own, and what do we want to provide?
I definitely do not know what we should do. I suppose that where I would start to think about it, however, is by considering the generic workflow for plotting within ADF (either "supported" or user-defined). My sketch of what plotting scripts need:
xr.open_dataset
)Right now people writing plotting scripts are left to their own devices once they get the ADFDiag object as input. We don't have a lot of examples of how people (who are not me) deal with that; I think the QBO plots are the primary example.
Thoughts about whether we should change anything? We could leave things as they are if it works. I kind of think we should refactor
plotting_functions.py
to be a more coherent module; maybe splitting out computation methods into their own module?Beta Was this translation helpful? Give feedback.
All reactions