Skip to content

Hovmoeller Plots

Hank Fisher edited this page Apr 19, 2021 · 17 revisions

Hovmoeller Plots

A Hovmoeller plot is a 2D contour plot with time along one axis and a spatial dimension along the other axis. Typically the spatial dimension not shown has been averaged over some domain. The current METplotpy Hovmoeller class supports only time along the vertical axis and longitude along the horizontal axis. This can be generalized in future releases to allow, for instance, time on the horizontal and latitude on the vertical. The examples are based on tropical diagnostics applications, so a meridional average of precipitation from 5 S to 5 N has been setup in the default configuration.

As all METplotpy plot types, the Hovmoeller class is a sub-class of MetPlot.

class Hovmoeller(BasePlot)
    def __init__(self, parameters, time, lon, data)
    def create_figure(self)
    def lat_avg(self, data, lat_min, lat_max)

The BasePlot super-class defines various utility methods for setting up the plot layout from default or user-defined configuration parameters. These parameters, as well as data variables and ranges, are set in the YAML configuration file. This is done in part to enable compatibility with METviewer, as user selected layout options within the viewer are handled at the MetPlot level. The Hovmoeller plot type has not yet been integrated or tested within METviewer. A separate task may be defined for this in a future METviewer release.

All sub-classes of BasePlot define, in addition to an __init__ method, a create_figure method. The create_figure method implemented in the Hovmoeller sub-class invokes the plotly.graph_objects.Contour method followed by plotly.graph_objects.Figure.update_layout. The data averaging is done by the helper method Hovmoeller.lat_avg, called upon object instantiation. There are several other minor helper methods involved in plot formatting.

Config File

The default config file is plots/config/hovmoeller_defaults.yaml.

plot_filename: erai_precip.png
height: 800
width: 1200
title: ERAI Precipitation

font_size: 20

xaxis_title: Longitude
yaxis_title: Time

date_start: 2016-01-01
date_end: 2016-03-31

lat_max: 5
lat_min: -5

var_name: precip
var_units: mm / day
unit_conversion: 250

contour_min: 0.2
contour_max: 1.6
contour_del: 0.2
colorscale: 'BuPu'

METplotpy does not support automatic unit conversion, so the user must supply var_units, the units in which to plot the variable, and a conversion factor unit_conversion used to convert from data file units to plotting units.

The Hovmoeller class comes with a __main__ block for direct scripting use. This section follows the emerging METcalcpy conventions for setting up logging with the --logfile and --debug command line options.

usage: hovmoeller.py [-h] [--config CONFIG] [--datadir DATADIR] --input INPUT
                     [--logfile LOGFILE] [--debug]

optional arguments:
  -h, --help         show this help message and exit
  --config CONFIG    configuration file
  --datadir DATADIR  top-level data directory (default $DATA_DIR)
  --input INPUT      input file name
  --logfile LOGFILE  log file (default stdout)
  --debug            set logging level to debug

The --input option specifies the name of the input NetCDF data file relative to the directory set with the --datadir option. A user-defined YAML configuration can be specified with --config. Any parameters defined there will clobber those in the default config file. The --debug flag will set the python logging level to DEBUG.

Sample Dataset

The sample Hovmoeller plot can be generated from the default YAML config file and using the input file precip.erai.sfc.1p0.2x.2014-2016.nc found in METplotpy/METplotpy_Data/TropicalDiagnostics.

Clone this wiki locally