scripts.plotting.regional_map_multicase
Module: regional_map_multicase
Provides a plot with regional maps of specified variables for all cases (up to 10) in a row.
Since this is a specialty plot, it looks for several custom options to be provided in the YAML configuration file. For example, one might include this block in the YAML:
- region_multicase:
region_spec: [slat, nlat, wlon, elon] region_time_option: <calendar | zeroanchor> If calendar, will look for specified years. If zeroanchor will use a nyears starting from year_offset from the beginning of timeseries region_start_year: region_end_year: region_nyear: region_year_offset: region_month: <NULL means look for season> region_season: <NULL means use annual mean> region_variables: <list of variables to try to use; allows for a subset of the total diag variables>
Functions
|
|
|
regional_map_multicase |
|
Custom function that retrieves a variable. |
Utility to get the number (1-12) from a string form. |
|
|
Determines a string to use for the output file. |
|
Make a figure with up to 10 cases in a row of maps for specified region. |
|
Determine plot location based on ADF object. |
|
Construct a complete Path object for the output plot. |
|
Utility function that tries to shrink the title to fit on top of the Axes. |
|
Reduce case names by removing a common prefix. |
Module Contents
- scripts.plotting.regional_map_multicase.regional_map_multicase(adfobj)[source]
regional_map_multicase input -> ADF object
Sketch of workflow: - check for regional options (see module docstring), - get case names/locations (time series are used), - determine plot location and type - detect per-variable plot options - Loop through variables: make one multi-panel plot per variable
- scripts.plotting.regional_map_multicase._retrieve(ropt, variable, casename, location, return_dataset=False)[source]
- Custom function that retrieves a variable.
Returns the variable as a DataArray, unless keyword return_dataset=True.
Applies the regional and time interval selections based in values in ropt.
ropt -> dict, regional options specified via YAML
variable -> str, the variable to get from files
casename -> str, case name for constructing file search
location -> Path, path to case
kwarg: return_dataset -> bool, if true, return the dataset object, otherwise return the DataArray
with variable
- scripts.plotting.regional_map_multicase._get_month_number(m)[source]
Utility to get the number (1-12) from a string form.
Input, m, can be string or integer. If it is a string, can be 3-letter abbreviation or full month name. If integer, needs to be 1-12. Emits a useful string if it looks like a season abbreviation.
- scripts.plotting.regional_map_multicase._get_sampling_string(ropt)[source]
Determines a string to use for the output file. The month that is specified as region_month, the season specified as region_season, or ANN otherwise, in that order of precedence.
Note: if month is specified as an integer, that is what will be returned.
- scripts.plotting.regional_map_multicase.regional_map_multicase_plot(adf, datadict, opt=None)[source]
Make a figure with up to 10 cases in a row of maps for specified region.
- scripts.plotting.regional_map_multicase._get_plot_location(adfobj)[source]
Determine plot location based on ADF object. Create location if it is not a directory. Return a Path object to the directory.
- scripts.plotting.regional_map_multicase._construct_outfile_name(ploc, ptype, *args)[source]
Construct a complete Path object for the output plot. ploc -> plot location directory (expects Path object) ptype -> file extension for output (e.g., pdf, png) args -> arbitrary arguments to be joined by underscores
Example: _construct_outfile_name(“/scratch/plots”, “png”, “cam6.120”, “PRECT”, “March”, “LabSea”) [returns] /scratch/plots/cam6.120_PRECT_March_LabSea_MultiCaseRegion_Mean.png