Skip to content

Instantly share code, notes, and snippets.

@phil-blain
Last active June 7, 2020 19:34
Show Gist options
  • Save phil-blain/2b08f52ff4a0c7967d58916c31a4eabb to your computer and use it in GitHub Desktop.
Save phil-blain/2b08f52ff4a0c7967d58916c31a4eabb to your computer and use it in GitHub Desktop.
How to install version 4.11.3 of the Panoply NetCDF viewer on macOS 10.11 El Capitan

Panoply is a viewer for NetCDF files. It's much more inviting to use then Ncview.

As of this writing, the Panoply 4.11.3 macOS download does not work correctly on my macOS 10.11 (El Capitan) system. The app launches but hangs when opening a file. I don't know much about debugging GUI macOS applications, but I know that Panoply is written in Java and Java works cross-platform, as long as you have a Java Runtime Environment installed. If you don't, the easiest way to install the JRE is from java.com.

So instead of using the macOS download, just use the Linux download, which simply contains a shell script to launch Panoply and the necessary Java jar files.

However, we need to tweak the shell script a little:

$ cat PanoplyJ/panoply.sh
#!/bin/sh
#

SCRIPT=`readlink -f $0`
SCRIPTDIR=`dirname $SCRIPT`

java -Xms512m -Xmx1600m -jar $SCRIPTDIR/jars/Panoply.jar "$@"
  1. readlink -f is not POSIX so it does not work on macOS. If you have Hombrew installed, you can actually brew install coreutils and simply replace readlink with greadlink:

    -SCRIPT=`readlink -f $0`
    +SCRIPT=`greadlink -f $0`

    You could also simply remove this line completely and replace the second line to use dirname $0 directly:

    -SCRIPT=`readlink -f $0`
    -SCRIPTDIR=`dirname $SCRIPT`
    +SCRIPTDIR=`dirname $0`
  2. Java applications launched from the command line with the java launcher do not use the installed Java 8 JRE, they use the Java 6 SDK that used to be installed by Apple and is now a separate download for legacy applications. Since Panoply requires Java 8 or later, we need to point it to to the right java executable:

    -java -Xms512m -Xmx1600m -jar $SCRIPTDIR/jars/Panoply.jar "$@"
    +/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -Xms512m -Xmx1600m -jar $SCRIPTDIR/jars/Panoply.jar "$@"

And that's it ! You can now put the shell script and the jars folder somewhere in your PATH, and open NetCDF files from the command line!

cp -r PanoplyJ/* ~/bin
chmod u+x ~/bin/panoply.sh
mv ~/bin/panoply.sh ~/bin/panoply
panoply /path/to/iceh_inst.1998-01-01-03600.nc
#!/bin/sh
#
SCRIPTDIR=`dirname $0`
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -Xms512m -Xmx1600m -jar $SCRIPTDIR/jars/Panoply.jar "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment