eviz.lib.autoviz package

Submodules

eviz.lib.autoviz.config module

class eviz.lib.autoviz.config.Config(source_names: list[str], config_files: list[str], app_data: ~typing.Dict[str, ~typing.Any] = <factory>, spec_data: ~typing.Dict[str, ~typing.Any] = <factory>, history_data: ~typing.Dict[str, ~typing.Any] = <factory>, meta_attrs: dict = <factory>, meta_coords: dict = <factory>, species_db: dict = <factory>, readers: dict = <factory>, compare_fields: ~typing.List[str] | None = None, ds_index: int = 0, _to_plot: dict = <factory>, _file_list: dict = <factory>, _trop_height_file_list: dict = <factory>, _sphum_conv_file_list: dict = <factory>, _exp_name: str | None = None, _description: str | None = None, _compare_exp_ids: list = <factory>, _extra_diff_plot: bool = False, _compare: bool = False, _comp_panels: tuple = <factory>, _cmap: str = 'rainbow', _profile: bool = False, _use_trop_height: bool = False, _use_sphum_conv: bool = False, _specs_yaml_exists: bool = True, _use_cartopy: bool = True, _add_logo: bool = False, _print_to_file: bool = False, _print_format: str = 'png', _make_pdf: bool = False, _print_basic_stats: bool = False, _mpl_style: str = 'classic', _output_dir: str | None = None, _use_history: bool = False, _history_expid: str | None = None, _history_expdsc: str | None = None, _history_dir: str | None = None, _history_collection: str | None = None, _history_year: str | None = None, _history_month: str | None = None, _history_season: str | None = None, _history_to_plot: dict = <factory>, _use_mp_pool: bool = False, _archive_web_results: bool = False, _collection: str | None = None, ax_opts: dict = <factory>, _map_params: dict = <factory>, _subplot_specs: tuple = <factory>)

Bases: object

This class defines attributes and methods for managing user-defined configurations necessary to create plots.

The configurations are defined in YAML files. There are some default configurations that work quite well as starting points. These are found under config/ and include templates for GEOS, WRF and LIS models (among others). Once YAML files are parsed, their contents are stored in dict structures which are all part of the Config object.

Parameters:
  • source_names (list) – The names of the supported sources.

  • config_files (list) – A list of YAML files associated with the sources.

Notable Attributes:

app_data (dict) : a dictionary that holds the contents of the APP YAML file spec_data (dict) : a dictionary that holds the contents of the SPEC YAML file

Note

Every other Config attribute is a subset of app_data ad spec_data.

app_data: Dict[str, Any]
property archive_web_results
ax_opts: dict
property cmap
property collection
property compare
property compare_exp_ids
compare_fields: List[str] = None
config_files: list[str]
ds_index: int = 0
property extra_diff_plot
property file_list
get_comp_file_index(filename, source_name)

Is filename in map_params with the given source_name? if so get index

get_data(name)
static get_dim_names(pid)
get_file_description(file)

Get user-defined file description (default: None)

get_file_exp_id(i)

Get user-defined experiment ID associated with the input file (default None) If an expid is set, then it will be used to compare with another expid, as set in compare field

get_file_exp_name(i)

Get user-defined experiment name associated with the input file (default None)

get_file_index(filename)

Get the file index associated with the filename

get_levels(to_plot, plot_type)

Get model levels to plot from YAML specs file

get_levels_old(toplot, plot_type)

Get model levels to plot from YAML specs file

get_meta_coord(key)

Return a meta coords value associated with a model’s key

get_model_attr_name(attr_name)

Get model-specific attribute name associated with the source as defined in meta_attributes.yaml

get_model_dim_name(dim_name)

Get model-specific dimension name associated with the source as defined in meta_coordinates.yaml.

get_plot_specs(for_name)
static get_source_from_name(name)
property gif_fps
property have_specs_yaml_file
hist_list_files()

Read GEOS HISTORY.rc file and construct the list of data files to be used.

property history_collection
history_data: Dict[str, Any]
property history_dir
property history_expdsc
property history_expid
property history_month
property history_to_plot
property history_year
property logger: Logger
property make_gif
property make_pdf
property map_params
meta_attrs: dict
meta_coords: dict
property mpl_style
property output_dir
property print_basic_stats
property print_format
property print_to_file
readers: dict
real_time = ''
source_names: list[str]
spec_data: Dict[str, Any]
species_db: dict
property sphum_conv_file_list
property subplot_specs
property to_plot
property trop_height_file_list
property units
property use_cartopy
property use_history
property use_mp_pool
property use_sphum_conv
property use_trop_height

eviz.lib.autoviz.figure module

class eviz.lib.autoviz.figure.Figure(config: ~eviz.lib.autoviz.config.Config, plot_type: str, mfig: matplotlib.figure.Figure | None = None, axes: ~typing.Any | None = None, _gs: matplotlib.gridspec.GridSpec | None = None, _rindex: int = 0, _ax_opts: dict = <factory>, _frame_params: dict = <factory>, _subplots: tuple = (1, 1), _use_cartopy: bool = False)

Bases: object

This class acts like Matplotlib’s Figure but customized for the eViz framework.

Parameters:

config (Config) :

Representation of the model configuration used to specify data sources and user choices for the map generation. The config instance is created at the application level.

Note

Frame defines an internal state with figure and axes option.

static add_grid(ax, lines=True, locations=None)

Add a grid to the current plot.

Parameters:
  • ax (Axis) – axis object in which to draw the grid.

  • lines (bool, optional) – add lines to the grid. Defaults to True.

  • locations (tuple, optional) – (xminor, xmajor, yminor, ymajor). Defaults to None.

axes: Any = None
static colorbar(mappable)

Create a colorbar.

config: Config
create_subplot_grid()
create_subplots(gs)
create_subplots_crs(gs)
property frame_params
get_fig_ax()
get_gs_geometry()
get_projection(projection=None)

Get projection parameter

have_multiple_axes()
have_nontrivial_grid()
init_ax_opts(field_name)

Initialize map options for a given field, using specs data or some sensible defaults.

Parameters:

field_name (str) – File name whose axes options need to be initialized

Returns:

Updated axes internal state

property logger: Logger
mfig: matplotlib.figure.Figure = None
plot_text(field_name, ax, pid, level=None, data=None)

Add text to a map .

Parameters:
  • field_name (str) – Name of the field

  • ax (Axes) – Axes object

  • pid (str) – Plot type identifier

  • level (int) – Vertical level (optional, default=None)

Returns:

Updated axes internal state

plot_type: str
set_ax_opts_diff_field(ax)

Modify axes internal state based on user-defined options

Note

Only relevant for comparison plots.

set_cartopy_features(axes)

These are ‘typical’ map features used in Cartopy-dependent maps

Parameters:

axes (Axes) – Figure axes.

Returns:

Update axes.

static set_cartopy_latlon_opts(ax, extent)

These appear to be pretty good settings for latlon maps

Parameters:
  • ax (Axes) – Figure axes.

  • extent (list) – Domain extent for cartopy coordinates.

Returns:

Update axes.

static show()
static squeeze_fig_aspect(fig, preserve='h')
property subplots
update_ax_opts(field_name, ax, pid, level=None)

Set (or reset) some map options

Parameters:
  • field_name (str) – Name of field that needs axes options updated

  • ax (Axes) – Axes object

  • pid (str) – Plot type identifier

  • level (int) – Vertical level (optional, default=None)

Returns:

Updated axes internal state

eviz.lib.autoviz.operations module

eviz.lib.autoviz.operations.obs_to_grid()
eviz.lib.autoviz.operations.regrid(config, field_names, ax, ax_opts, level, pid)

Wrapper for regrid method

This function takes in two fields and, if necessary, regrids them to a common resolution.

Parameters:
  • field_names (tuple) – Names of fields

  • ax (Axes) – Axes object

  • ax_opts (dict) – Axes object

  • level (int) – index of vertical level to interpolate (level=0 for 2D fields)

  • pid (str) – a plot identifier

Returns:

Regridded fields

eviz.lib.autoviz.operations.regrid_check(config, field_names, ax, ax_opts, level, pid)

Main regrid method

eviz.lib.autoviz.plot_utils module

class eviz.lib.autoviz.plot_utils.FlexibleOOMFormatter(*args: Any, **kwargs: Any)

Bases: ScalarFormatter

class eviz.lib.autoviz.plot_utils.OOMFormatter(*args: Any, **kwargs: Any)

Bases: ScalarFormatter

adds image logo to axes

eviz.lib.autoviz.plot_utils.add_logo_anchor(ax, logo, label=None, logo_loc='upper left', alpha=0.5)

adds image logo and optionally, text

eviz.lib.autoviz.plot_utils.add_logo_fig(fig, logo)

adds image logo to a figure

eviz.lib.autoviz.plot_utils.add_logo_xy(logo, ax, x0, y0, scale=50)

adds image logo and positions it on the figure at position x0, y0

eviz.lib.autoviz.plot_utils.archive(config, output_dir, event_stamp)

Archive data for web results

Parameters:
  • output_dir (str) – Output directory to store images

  • event_stamp (str) – Time stamp for archived web results

eviz.lib.autoviz.plot_utils.axes_label_font_size(panels=None)
eviz.lib.autoviz.plot_utils.axis_tick_font_size(panels=None)
eviz.lib.autoviz.plot_utils.bar_font_size(panels=None)
eviz.lib.autoviz.plot_utils.cbar_fraction(panels=None)

fraction of original axes to use for colorbar

eviz.lib.autoviz.plot_utils.cbar_pad(panels=None)

0.05 if vertical, 0.15 if horizontal; fraction of original axes between colorbar and new image axes

eviz.lib.autoviz.plot_utils.cbar_shrink(panels=None)
eviz.lib.autoviz.plot_utils.colorbar(mappable)

Create a colorbar https://joseph-long.com/writing/colorbars/

eviz.lib.autoviz.plot_utils.contour_format_from_levels(levels, scale=None)
eviz.lib.autoviz.plot_utils.contour_label_size(panels=None)
eviz.lib.autoviz.plot_utils.contour_levels_plot(clevs)
eviz.lib.autoviz.plot_utils.contour_tick_font_size(panels)
eviz.lib.autoviz.plot_utils.create_gif(config)
eviz.lib.autoviz.plot_utils.create_pdf(config)
eviz.lib.autoviz.plot_utils.dump_json_file(fname, config, plot_type, findex, map_filename, fig, output_dir)
eviz.lib.autoviz.plot_utils.fmt(x, pos)

Format color bar labels to show scientific label

eviz.lib.autoviz.plot_utils.fmt_once(x, pos)

Format color bar labels to show scientific label but not the x10^x

eviz.lib.autoviz.plot_utils.fmt_two_digits(x, pos)
eviz.lib.autoviz.plot_utils.formatted_contours(clevs)
eviz.lib.autoviz.plot_utils.get_subplot_geometry(axes)
eviz.lib.autoviz.plot_utils.image_font_size(panels=None)
eviz.lib.autoviz.plot_utils.image_scaling(image, num_rows, num_cols)

Scale the image to desired length(num_rows) and width (num_cols)

eviz.lib.autoviz.plot_utils.load_log()

Retrieve Eviz.LOG used by streamlit

eviz.lib.autoviz.plot_utils.natural_key(filename)
eviz.lib.autoviz.plot_utils.output_basic(config, name)
eviz.lib.autoviz.plot_utils.plot_process(filename)
eviz.lib.autoviz.plot_utils.print_map(config, plot_type, findex, fig, level=None)
eviz.lib.autoviz.plot_utils.revise_tick_labels(cbar)
eviz.lib.autoviz.plot_utils.run_plot_commands(filenames)
eviz.lib.autoviz.plot_utils.subplot_title_font_size(panels=None)
eviz.lib.autoviz.plot_utils.subproc(cmd)
eviz.lib.autoviz.plot_utils.title_font_size(panels=None)
eviz.lib.autoviz.plot_utils.update(i, im, image_array)

eviz.lib.autoviz.plottable module

class eviz.lib.autoviz.plottable.Plottable(config: eviz.lib.autoviz.config.Config, plottable: dict = <factory>)

Bases: object

config: Config
property logger: Logger
plottable: dict

eviz.lib.autoviz.plotter module

class eviz.lib.autoviz.plotter.ComparisonPlotter(to_compare: list)

Bases: object

comparison_plots(config: Config, field_to_plot: tuple, level: int | None = None)
property logger: Logger
static plot(config, field_to_plot, level)

Create a single plot using specs data :param config: Config :param field_to_plot: tuple (data2d, dim1, dim2, field_name, plot_type, findex, map_params) :param level: int (optional)

to_compare: list
class eviz.lib.autoviz.plotter.Plotter

Bases: object

property logger: Logger
static simple_plot(config, data_to_plot)

Create a basic plot, i.e. one without specifications.

class eviz.lib.autoviz.plotter.SimplePlotter

Bases: object

property logger: Logger
static plot(config, field_to_plot)

Create a basic plot (ala ncview) :param config: Config :param field_to_plot: tuple (data2d, dim1, dim2, field_name, plot_type, findex, map_params)

simple_plot(config, field_to_plot)
class eviz.lib.autoviz.plotter.SinglePlotter

Bases: Plotter

property logger: Logger
static plot(config, field_to_plot, level)

Create a single plot using specs data :param config: Config :param field_to_plot: tuple (data2d, dim1, dim2, field_name, plot_type, findex, map_params) :param level: int (optional)

single_plots(config: Config, field_to_plot: tuple, level: int | None = None)
eviz.lib.autoviz.plotter.z_masked_overlap(axe, X, Y, Z, source_projection=None)

for data in projection axe.projection find and mask the overlaps (more 1/2 the axe.projection range)

X, Y either the coordinates in axe.projection or longitudes latitudes Z the data operation one of ‘pcorlor’, ‘pcolormesh’, ‘countour’, ‘countourf’

if source_projection is a geodetic CRS data is in geodetic coordinates and should first be projected in axe.projection

X, Y are 2D same dimension as Z for contour and contourf same dimension as Z or with an extra row and column for pcolor and pcolormesh

return ptx, pty, Z

Module contents