diff --git a/CHANGELOG.md b/CHANGELOG.md index b9d3d15a..06df1bf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Updated and cleaned up code in `gcpy/regrid.py` - Example scripts`plot_single_level` and `plot_comparisons` can now accept command-line arguments - Example scripts `plot_single_level.py`, `plot_comparisons.py`, `compare_diags.py` now handle GCHP restart files properly +- Now specify the X11 backend with by setting the `MPLBACKEND` environment variable ### Fixed - Generalized test for GCHP or GCClassic restart file in `regrid_restart_file.py` diff --git a/gcpy/examples/plotting/plot_comparisons.py b/gcpy/examples/plotting/plot_comparisons.py index 1bd7bb16..9ddd0561 100755 --- a/gcpy/examples/plotting/plot_comparisons.py +++ b/gcpy/examples/plotting/plot_comparisons.py @@ -11,11 +11,21 @@ The example data described here is in lat/lon format, but the same code works equally well for cubed-sphere (GCHP) data. + +NOTE: If you are using GCPy from a Mac, set the environment variable: + + export MPLBACKEND="MacOSX" + +Otherwise set: + + export MPLBACKEND="tkagg" + +This will set the proper X11 backend (which is needed to open a plot +window on the screen. There is some incompatibility with the Tck/Tk +backend "tkagg" in MacOS X operating systems. """ import argparse import xarray as xr -from matplotlib import use as mpl_use -mpl_use("tkagg") # X11 backend for plt.show() import matplotlib.pyplot as plt from gcpy.constants import skip_these_vars from gcpy.plot.compare_single_level import compare_single_level diff --git a/gcpy/examples/plotting/plot_single_panel.py b/gcpy/examples/plotting/plot_single_panel.py index e9c3a8ba..b10f9d1b 100755 --- a/gcpy/examples/plotting/plot_single_panel.py +++ b/gcpy/examples/plotting/plot_single_panel.py @@ -12,11 +12,21 @@ For full documentation on the plotting capabilities of GCPy (including full argument lists), please see the GCPy documentation at https://gcpy.readthedocs.io. + +NOTE: If you are using GCPy from a Mac, set the environment variable: + + export MPLBACKEND="MacOSX" + +Otherwise set: + + export MPLBACKEND="tkagg" + +This will set the proper X11 backend (which is needed to open a plot +window on the screen. There is some incompatibility with the Tck/Tk +backend "tkagg" in MacOS X operating systems. """ import argparse import xarray as xr -from matplotlib import use as mpl_use -mpl_use("tkagg") # X11 backend for plt.show() import matplotlib.pyplot as plt from gcpy.plot.single_panel import single_panel from gcpy.util import rename_and_flip_gchp_rst_vars @@ -40,8 +50,7 @@ def plot_single_panel(infile, varname, level): # If the data is from a GCHP restart file, rename variables and # flip levels to match the GEOS-Chem Classic naming and level # conventions. Otherwise no changes will be made. - ref_ds = rename_and_flip_gchp_rst_vars(ref_ds) - dev_ds = rename_and_flip_gchp_rst_vars(dev_ds) + dset = rename_and_flip_gchp_rst_vars(dset) # You can easily view the variables available for plotting # using xarray. Each of these variables has its own xarray