Skip to content

Commit

Permalink
Allow multiple netcdf files
Browse files Browse the repository at this point in the history
  • Loading branch information
mcuntz committed Jan 14, 2024
1 parent edeeb30 commit f801491
Show file tree
Hide file tree
Showing 36 changed files with 804 additions and 540 deletions.
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
}
],
"access_right": "open",
"description": "<p><strong>ncvue</strong> is a minimal GUI for a quick view of netCDF files. It is aiming to be a drop-in replacement for <a href=\"http://meteora.ucsd.edu/~pierce/ncview_home_page.html\">ncview</a>, being slightly more general than <a href=\"http://meteora.ucsd.edu/~pierce/ncview_home_page.html\">ncview</a>, which targets maps. If <strong>ncvue</strong> is used with maps, it supports mostly structured grids, more precisely the grids supported by <a href=\"https://scitools.org.uk/cartopy/docs/latest/\">cartopy</a>.</p>\n\n<p><strong>ncvue</strong> is a Python script that can be called from within Python or as a command line tool. It is not supposed to produce publication-ready plots but rather provide a quick overview of the netCDF file.</p>\n\n<p>The complete documentation for <strong>ncvue</strong> is available from: <a href=\"https://mcuntz.github.io/ncvue/\">https://mcuntz.github.io/ncvue/</a></p>\n\n<p>The current version features three panels, that means three different plotting styles: Scatter/Line plots, Contour Plots, and Maps, with extensive tooltips on buttons, sliders, entry boxes, spinboxes, and menus. It includes the possibility to open and change netCDF files within <strong>ncvue</strong>. The netCDF file will be changed in all panels of the primary window and any secondary window once focus changes on the panel or window. Graphical documentation exists on <a href=\"https://mcuntz.github.io/ncvue/\">Github Pages</a>.</p>\n\n<p>The current version also provides two standalone applications on macOS and on Windows that come with all necessary libraries to run <strong>ncvue</strong>, including Python. Links to the installers are given on <a href=\"https://github.com/mcuntz/ncvue/\">Github</a> and in the <a href=\"https://mcuntz.github.io/ncvue/\">documentation</a>.</p>\n\n<p>Version 3.6 added different designs on macOS, Windows and Linux.</p>\n\n<p>Version 4.0 moved to a new project structure, using pyproject.toml, automatic versioning, src layout, and Github actions for continuous integration.</p>\n\n<p>Version 4.1 ported <strong>ncvue</strong> to conda-forge.</p>\n\n<p>Version 4.2 allowed groups in netcdf files.</p>"
"description": "<p><strong>ncvue</strong> is a minimal GUI for a quick view of netCDF files. It is aiming to be a drop-in replacement for <a href=\"http://meteora.ucsd.edu/~pierce/ncview_home_page.html\">ncview</a>, being slightly more general than <a href=\"http://meteora.ucsd.edu/~pierce/ncview_home_page.html\">ncview</a>, which targets maps. If <strong>ncvue</strong> is used with maps, it supports mostly structured grids, more precisely the grids supported by <a href=\"https://scitools.org.uk/cartopy/docs/latest/\">cartopy</a>.</p>\n\n<p><strong>ncvue</strong> is a Python script that can be called from within Python or as a command line tool. It is not supposed to produce publication-ready plots but rather provide a quick overview of the netCDF file.</p>\n\n<p>The complete documentation for <strong>ncvue</strong> is available from: <a href=\"https://mcuntz.github.io/ncvue/\">https://mcuntz.github.io/ncvue/</a></p>\n\n<p>The current version features three panels, that means three different plotting styles: Scatter/Line plots, Contour Plots, and Maps, with extensive tooltips on buttons, sliders, entry boxes, spinboxes, and menus. It includes the possibility to open and change netCDF files within <strong>ncvue</strong>. The netCDF file will be changed in all panels of the primary window and any secondary window once focus changes on the panel or window. Graphical documentation exists on <a href=\"https://mcuntz.github.io/ncvue/\">Github Pages</a>.</p>\n\n<p>The current version also provides two standalone applications on macOS and on Windows that come with all necessary libraries to run <strong>ncvue</strong>, including Python. Links to the installers are given on <a href=\"https://github.com/mcuntz/ncvue/\">Github</a> and in the <a href=\"https://mcuntz.github.io/ncvue/\">documentation</a>.</p>\n\n<p>Version 3.6 added different designs on macOS, Windows and Linux.</p>\n\n<p>Version 4.0 moved to a new project structure, using pyproject.toml, automatic versioning, src layout, and Github actions for continuous integration.</p>\n\n<p>Version 4.1 ported <strong>ncvue</strong> to conda-forge.</p>\n\n<p>Version 4.2 allowed groups in netcdf files.</p>\n\n<p>Version 4.3 allowed multiple netcdf files.</p>"
}
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Changelog
---------

v4.3 (Jan 2024)
* Added conda and continuous integration badges.
* Allow multiple netcdf files.
* Squeeze output in `get_slice_miss` only if more than 1 dimension.

v4.2 (Jan 2024)
* Updated versions of github actions.
* Changed to sphinx_book_theme for documentation.
* Use local copy of `tooltip.py` from idle.
* Allow groups in netcdf files.
Expand Down
81 changes: 39 additions & 42 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ replacement for ncview_ and panoply_.
:target: https://badge.fury.io/py/ncvue
:alt: PyPI version

.. image:: https://img.shields.io/conda/vn/conda-forge/ncvue.svg
:target: https://anaconda.org/conda-forge/ncvue
:alt: Conda version

.. image:: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
:target: https://github.com/mcuntz/ncvue/blob/master/LICENSE
:alt: License

.. image:: https://github.com/mcuntz/ncvue/workflows/Continuous%20Integration/badge.svg?branch=main
:target: https://github.com/mcuntz/ncvue/actions
.. image:: https://github.com/mcuntz/ncvue/actions/workflows/main.yml/badge.svg?branch=main
:target: https://github.com/mcuntz/ncvue/actions/workflows/main.yml
:alt: Build status

About ncvue
Expand Down Expand Up @@ -56,54 +60,45 @@ Quick usage guide
.. code-block:: bash
ncvue netcdf_file.nc
ncvue netcdf_file1.nc netcdf_file2.nc
or from within Python:

.. code-block:: python
from ncvue import ncvue
ncvue('netcdf_file.nc')
ncvue(['netcdf_file.nc'])
where the netCDF file is optional. The latter can also be left out and
a netCDF file can be opened with the "Open File" button from within
``ncvue``.
``ncvue``. The netCDF has to be given in a list because several netcdf
files can be given as in the second example from the command line.

Note, ``ncvue`` uses the `TkAgg` backend of `matplotlib`. It must be
called before any other call to `matplotlib`. This also means that you
cannot launch it from within `iPython` if it was launched with
`--pylab`. It can be called from within a standard `iPython`, though,
or using `ipython --gui tk`.

When using ``ncvue`` with `jupyter` notebooks, one has to set
`%matplotlib inline` before the import and call of ``ncvue``. You have
set `%matplotlib inline` again if you want to continue having inline
plots in `jupyter` afterwards.

.. code-block:: python
%matplotlib inline
from ncvue import ncvue
ncvue('netcdf_file.nc')
%matplotlib inline
One can also install standalone macOS or Windows applications that
come with everything needed to run ``ncvue`` including Python:
..
One can also install standalone macOS or Windows applications that
come with everything needed to run ``ncvue`` including Python:
- `macOS app`_ (macOS > 10.13 [High Sierra] on Intel)
- `Windows executable`_ (Windows 10)
- `macOS app`_ (macOS > 10.13 [High Sierra] on Intel)
- `Windows executable`_ (Windows 10)

The macOS app should work from macOS 10.13 (High Sierra) onward on
Intel processors. There is no standalone application for macOS on
Apple Silicon (M1) chips because I do not have a paid Apple
Developer ID. Other installation options work, though.
The macOS app should work from macOS 10.13 (High Sierra) onward on
Intel processors. There is no standalone application for macOS on
Apple Silicon (M1) chips because I do not have a paid Apple
Developer ID. Other installation options work, though.

A dialog box might pop up on macOS saying that the ``ncvue.app`` is
from an unidentified developer. This is because ``ncvue`` is an
open-source software. Depending on the macOS version, it offers to
open it anyway. In later versions of macOS, this option is only given
if you right-click (or control-click) on the ``ncvue.app`` and choose
`Open`. You only have to do this once. It will open like any other
application the next times.
A dialog box might pop up on macOS saying that the ``ncvue.app`` is
from an unidentified developer. This is because ``ncvue`` is an
open-source software. Depending on the macOS version, it offers to
open it anyway. In later versions of macOS, this option is only given
if you right-click (or control-click) on the ``ncvue.app`` and choose
`Open`. You only have to do this once. It will open like any other
application the next times.

General layout
^^^^^^^^^^^^^^
Expand Down Expand Up @@ -220,9 +215,9 @@ Installation
------------

``ncvue`` is an application written in Python. If you have Python
installed, then the best is to install ``ncvue`` within the Python
universe. The easiest way to install ``ncvue`` is thence via `pip` if
you have cartopy_ installed already:
installed, then the best is to install ``ncvue`` within the Python
universe. The easiest way to install ``ncvue`` is thence via `pip` if
you have cartopy_ installed already:

.. code-block:: bash
Expand All @@ -236,14 +231,15 @@ installing, for example, Miniconda_:
conda install -c conda-forge ncvue
We also provide a standalone `macOS app`_ and a `Windows executable`_
that come with everything needed to run ``ncvue`` including
Python. The macOS app should work from macOS 10.13 (High Sierra)
onward. It is, however, only tested on macOS 10.15 (Catalina). Drop me
a message if it does not work on newer operating systems.
..
We also provide a standalone `macOS app`_ and a `Windows executable`_
that come with everything needed to run ``ncvue`` including
Python. The macOS app should work from macOS 10.13 (High Sierra)
onward. It is, however, only tested on macOS 10.15 (Catalina). Drop me
a message if it does not work on newer operating systems.
See the installation instructions_ in the documentation_ for more
information.
information on installing `Cartopy` and ``ncvue with pip``.

License
-------
Expand All @@ -255,8 +251,9 @@ Copyright (c) 2020-2024 Matthias Cuntz

``ncvue`` uses the Azure_ 2.0 theme by rdbende_ on Linux and Windows.

Standalone applications are produced with `cx_Freeze`_, currently
maintained by `Marcelo Duarte`_.
..
Standalone applications are produced with `cx_Freeze`_, currently
maintained by `Marcelo Duarte`_.
The project structure of ``ncvue`` was very originally based on a
template_ provided by `Sebastian Müller`_ but has evolved
Expand Down
89 changes: 49 additions & 40 deletions cx_freeze_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
Make stand-alone version of ncvue with cx_Freeze.
On macOS, use minimal virtual environment
pyenv virtualenv 3.12.1 install-ncvue
pyenv rehash
pyenv local install-ncvue
pip install --upgrade cython numpy pyshp six
isshapely=$(pip freeze | grep shapely)
if [[ -z ${isshapely} ]] ; then pip uninstall -y shapely ; fi
pip install shapely --no-binary shapely
pip install scipy
pip install matplotlib
pip install pykdtree
pip install netcdf4
pip install cartopy
pip install flake8 # for Emacs
pip install cx_Freeze
# libtiff.5.dylib version of PIL too old for pyproj -> use current from homebrew
mv ~/.pyenv/versions/3.12.1/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib \
~/.pyenv/versions/3.12.1/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib.save
\cp /usr/local/lib/libtiff.5.dylib \
~/.pyenv/versions/3.12.1/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib
# essential subset
if [[ "$(uname -m)" == "arm64" ]] ; then
export OPENBLAS="$(brew --prefix openblas)"
export HDF5_DIR="$(brew --prefix hdf5)"
export GEOS_DIR="$(brew --prefix geos)"
export GEOS_CONFIG="$(brew --prefix geos)/bin/geos-config"
fi
pyenv virtualenv 3.11.7 install-ncvue
pyenv rehash
pyenv local install-ncvue
pyenv rehash
# test if install works
python -m pip install --upgrade cython numpy pyshp six
[[ -z $(python -m pip freeze | grep shapely) ]] && \
python -m pip uninstall -y shapely
python -m pip install shapely --no-binary shapely
python -m pip install scipy matplotlib pykdtree
python -m pip install netcdf4 cartopy flake8
python -m pip install GDAL==$(gdal-config --version) \
--global-option=build_ext --global-option="-I${HOMEBREW_PREFIX}/include"
python -m pip install cartopy
python -m pip install cx_Freeze
# libtiff.5.dylib version of PIL too old for pyproj -> use current from homebrew
mv ~/.pyenv/versions/3.11.7/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib \
~/.pyenv/versions/3.11.7/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib.save
\cp /usr/local/lib/libtiff.5.dylib \
~/.pyenv/versions/3.11.7/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib
On Windows, use conda-forge for everything because more up-to-date
# Do not use mkl for smaller executable with PyInstaller/cx_Freeze
Expand All @@ -41,6 +49,7 @@
python cx_freeze_setup.py bdist_dmg
Windows installer
python.exe cx_freeze_setup.py bdist_msi
'''
import os
import codecs
Expand All @@ -51,7 +60,7 @@
import shutil

from cx_Freeze import setup, Executable
from cx_Freeze.dist import build as _build
# from cx_Freeze.dist import build as _build


# find __version__
Expand Down Expand Up @@ -99,24 +108,24 @@ def _post_build_m1(exedir):
shutil.copy2(aa, exedir)


# post build hook
# https://stackoverflow.com/questions/17806485/execute-a-python-script-post-install-using-distutils-setuptools
class build(_build):
def run(self):
_build.run(self)
if sys.platform == 'win32':
self.execute(_post_build_win, (self.build_exe,),
msg='Post-build on Windows')
elif sys.platform == 'darwin':
if platform.machine() == 'arm64':
# self.execute(_post_build_m1, (self.build_exe,),
# msg='Post-build on macOS Apple Silicon (M1)')
pass
else:
self.execute(_post_build_mac, (self.build_exe,),
msg='Post-build on macOS')
else:
pass
# # post build hook
# # https://stackoverflow.com/questions/17806485/execute-a-python-script-post-install-using-distutils-setuptools
# class build(_build):
# def run(self):
# _build.run(self)
# if sys.platform == 'win32':
# self.execute(_post_build_win, (self.build_exe,),
# msg='Post-build on Windows')
# elif sys.platform == 'darwin':
# if platform.machine() == 'arm64':
# # self.execute(_post_build_m1, (self.build_exe,),
# # msg='Post-build on macOS Apple Silicon (M1)')
# pass
# else:
# self.execute(_post_build_mac, (self.build_exe,),
# msg='Post-build on macOS')
# else:
# pass


package = 'ncvue'
Expand All @@ -128,7 +137,7 @@ def run(self):

version = _find_version('src/' + package, '_version.py')

script = 'bin/ncvue'
script = 'bin.save/ncvue' # 'src/ncvue/__main__.py'
packages = ['scipy', 'netCDF4'] # others detected automatically
excludes = ['pyflakes', 'mccabe', 'pycodestyle', 'flake8', # flake8
'gtk', 'PyQt4', 'PyQt5', 'wx'] # matplotlib
Expand Down Expand Up @@ -213,7 +222,7 @@ def run(self):
setup(name=package,
version=version,
description=doclines,
cmdclass={'build': build},
# cmdclass={'build': build},
options={'build_exe': build_exe_options,
'bdist_mac': bdist_mac_options,
'bdist_dmg': bdist_dmg_options,
Expand Down
Loading

0 comments on commit f801491

Please sign in to comment.