Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now let user specify X11 backend with "export MPLBACKEND="tkagg" (or "MacOSX") #275

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
14 changes: 12 additions & 2 deletions gcpy/examples/plotting/plot_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions gcpy/examples/plotting/plot_single_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading