Plotting Ocean Transects


The function mpas_tools.ocean.viz.plot_ocean_transects() and the associated plot_ocean_transects command-line tool can be used to plot transects of various MPAS-Ocean variables. The arguments to the command-line tool are:

$ plot_ocean_transects --help
usage: plot_ocean_transects [-h] -g GEOJSON_FILENAME [-m MESH_FILENAME] -f
                            FILENAME [-v VARIABLE_LIST [VARIABLE_LIST ...]]
                            [-c COLORMAP] [--flip]

  -h, --help            show this help message and exit
                        A geojson file with transects to plot
                        An MPAS-Ocean mesh file.  If not specified, the MPAS-Ocean data file must contain the mesh.
                        An MPAS-Ocean data file
                        List of variables to plot.  All variables on cells in the data file is the default.
  -c COLORMAP, --colormap COLORMAP
                        A colormap to use for the plots, default depends on the field name.
  --flip                Flip the x axis for all transects

See transects from geometric_features for a examples of what a geojson transect might look like:

    "type": "FeatureCollection",
    "features": [
            "type": "Feature",
            "properties": {
                "name": "Drake Passage",
                "object": "transect",
                "component": "ocean",
                "author": "Mark Petersen, Xylar Asay-Davis, Milena Veneziani",
            "geometry": {
                "type": "LineString",
                "coordinates": [

Add more features to the features list to plot multiple transects at the same time.

The MPAS-Ocean mesh file must including not just the horizontal mesh variables but also the vertical mesh variables (minLevelCell, maxLevelCell, layerThickness, etc.)

If you don’t specify the list of variables to plot, all variables with dimensions nCells and nVertLevels will be plotted.

One way of customizing these visualizaitons is to make your own copy of and change _plot_transect() to suite your needs, (changing figure size, dpi, colorbar, etc.)