Skip to content

Commit f801491

Browse files
committed
Allow multiple netcdf files
1 parent edeeb30 commit f801491

36 files changed

+804
-540
lines changed

.zenodo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@
3838
}
3939
],
4040
"access_right": "open",
41-
"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>"
41+
"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>"
4242
}

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
Changelog
22
---------
33

4+
v4.3 (Jan 2024)
5+
* Added conda and continuous integration badges.
6+
* Allow multiple netcdf files.
7+
* Squeeze output in `get_slice_miss` only if more than 1 dimension.
8+
49
v4.2 (Jan 2024)
10+
* Updated versions of github actions.
511
* Changed to sphinx_book_theme for documentation.
612
* Use local copy of `tooltip.py` from idle.
713
* Allow groups in netcdf files.

README.rst

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ replacement for ncview_ and panoply_.
2121
:target: https://badge.fury.io/py/ncvue
2222
:alt: PyPI version
2323

24+
.. image:: https://img.shields.io/conda/vn/conda-forge/ncvue.svg
25+
:target: https://anaconda.org/conda-forge/ncvue
26+
:alt: Conda version
27+
2428
.. image:: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
2529
:target: https://github.com/mcuntz/ncvue/blob/master/LICENSE
2630
:alt: License
2731

28-
.. image:: https://github.com/mcuntz/ncvue/workflows/Continuous%20Integration/badge.svg?branch=main
29-
:target: https://github.com/mcuntz/ncvue/actions
32+
.. image:: https://github.com/mcuntz/ncvue/actions/workflows/main.yml/badge.svg?branch=main
33+
:target: https://github.com/mcuntz/ncvue/actions/workflows/main.yml
3034
:alt: Build status
3135

3236
About ncvue
@@ -56,54 +60,45 @@ Quick usage guide
5660
.. code-block:: bash
5761
5862
ncvue netcdf_file.nc
63+
ncvue netcdf_file1.nc netcdf_file2.nc
5964
6065
or from within Python:
6166

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

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

77-
When using ``ncvue`` with `jupyter` notebooks, one has to set
78-
`%matplotlib inline` before the import and call of ``ncvue``. You have
79-
set `%matplotlib inline` again if you want to continue having inline
80-
plots in `jupyter` afterwards.
81-
82-
.. code-block:: python
83-
84-
%matplotlib inline
85-
from ncvue import ncvue
86-
ncvue('netcdf_file.nc')
87-
%matplotlib inline
88-
89-
One can also install standalone macOS or Windows applications that
90-
come with everything needed to run ``ncvue`` including Python:
83+
..
84+
One can also install standalone macOS or Windows applications that
85+
come with everything needed to run ``ncvue`` including Python:
9186
92-
- `macOS app`_ (macOS > 10.13 [High Sierra] on Intel)
93-
- `Windows executable`_ (Windows 10)
87+
- `macOS app`_ (macOS > 10.13 [High Sierra] on Intel)
88+
- `Windows executable`_ (Windows 10)
9489

95-
The macOS app should work from macOS 10.13 (High Sierra) onward on
96-
Intel processors. There is no standalone application for macOS on
97-
Apple Silicon (M1) chips because I do not have a paid Apple
98-
Developer ID. Other installation options work, though.
90+
The macOS app should work from macOS 10.13 (High Sierra) onward on
91+
Intel processors. There is no standalone application for macOS on
92+
Apple Silicon (M1) chips because I do not have a paid Apple
93+
Developer ID. Other installation options work, though.
9994

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

108103
General layout
109104
^^^^^^^^^^^^^^
@@ -220,9 +215,9 @@ Installation
220215
------------
221216

222217
``ncvue`` is an application written in Python. If you have Python
223-
installed, then the best is to install ``ncvue`` within the Python
224-
universe. The easiest way to install ``ncvue`` is thence via `pip` if
225-
you have cartopy_ installed already:
218+
installed, then the best is to install ``ncvue`` within the Python
219+
universe. The easiest way to install ``ncvue`` is thence via `pip` if
220+
you have cartopy_ installed already:
226221

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

248244
License
249245
-------
@@ -255,8 +251,9 @@ Copyright (c) 2020-2024 Matthias Cuntz
255251

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

258-
Standalone applications are produced with `cx_Freeze`_, currently
259-
maintained by `Marcelo Duarte`_.
254+
..
255+
Standalone applications are produced with `cx_Freeze`_, currently
256+
maintained by `Marcelo Duarte`_.
260257
261258
The project structure of ``ncvue`` was very originally based on a
262259
template_ provided by `Sebastian Müller`_ but has evolved

cx_freeze_setup.py

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@
33
Make stand-alone version of ncvue with cx_Freeze.
44
55
On macOS, use minimal virtual environment
6-
pyenv virtualenv 3.12.1 install-ncvue
7-
pyenv rehash
8-
pyenv local install-ncvue
9-
pip install --upgrade cython numpy pyshp six
10-
isshapely=$(pip freeze | grep shapely)
11-
if [[ -z ${isshapely} ]] ; then pip uninstall -y shapely ; fi
12-
pip install shapely --no-binary shapely
13-
pip install scipy
14-
pip install matplotlib
15-
pip install pykdtree
16-
pip install netcdf4
17-
pip install cartopy
18-
pip install flake8 # for Emacs
19-
pip install cx_Freeze
20-
# libtiff.5.dylib version of PIL too old for pyproj -> use current from homebrew
21-
mv ~/.pyenv/versions/3.12.1/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib \
22-
~/.pyenv/versions/3.12.1/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib.save
23-
\cp /usr/local/lib/libtiff.5.dylib \
24-
~/.pyenv/versions/3.12.1/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib
6+
# essential subset
7+
if [[ "$(uname -m)" == "arm64" ]] ; then
8+
export OPENBLAS="$(brew --prefix openblas)"
9+
export HDF5_DIR="$(brew --prefix hdf5)"
10+
export GEOS_DIR="$(brew --prefix geos)"
11+
export GEOS_CONFIG="$(brew --prefix geos)/bin/geos-config"
12+
fi
13+
pyenv virtualenv 3.11.7 install-ncvue
14+
pyenv rehash
15+
pyenv local install-ncvue
16+
pyenv rehash
17+
# test if install works
18+
python -m pip install --upgrade cython numpy pyshp six
19+
[[ -z $(python -m pip freeze | grep shapely) ]] && \
20+
python -m pip uninstall -y shapely
21+
python -m pip install shapely --no-binary shapely
22+
python -m pip install scipy matplotlib pykdtree
23+
python -m pip install netcdf4 cartopy flake8
24+
python -m pip install GDAL==$(gdal-config --version) \
25+
--global-option=build_ext --global-option="-I${HOMEBREW_PREFIX}/include"
26+
python -m pip install cartopy
27+
python -m pip install cx_Freeze
28+
# libtiff.5.dylib version of PIL too old for pyproj -> use current from homebrew
29+
mv ~/.pyenv/versions/3.11.7/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib \
30+
~/.pyenv/versions/3.11.7/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib.save
31+
\cp /usr/local/lib/libtiff.5.dylib \
32+
~/.pyenv/versions/3.11.7/envs/install-ncvue/lib/python3.8/site-packages/PIL/.dylibs/libtiff.5.dylib
2533
2634
On Windows, use conda-forge for everything because more up-to-date
2735
# Do not use mkl for smaller executable with PyInstaller/cx_Freeze
@@ -41,6 +49,7 @@
4149
python cx_freeze_setup.py bdist_dmg
4250
Windows installer
4351
python.exe cx_freeze_setup.py bdist_msi
52+
4453
'''
4554
import os
4655
import codecs
@@ -51,7 +60,7 @@
5160
import shutil
5261

5362
from cx_Freeze import setup, Executable
54-
from cx_Freeze.dist import build as _build
63+
# from cx_Freeze.dist import build as _build
5564

5665

5766
# find __version__
@@ -99,24 +108,24 @@ def _post_build_m1(exedir):
99108
shutil.copy2(aa, exedir)
100109

101110

102-
# post build hook
103-
# https://stackoverflow.com/questions/17806485/execute-a-python-script-post-install-using-distutils-setuptools
104-
class build(_build):
105-
def run(self):
106-
_build.run(self)
107-
if sys.platform == 'win32':
108-
self.execute(_post_build_win, (self.build_exe,),
109-
msg='Post-build on Windows')
110-
elif sys.platform == 'darwin':
111-
if platform.machine() == 'arm64':
112-
# self.execute(_post_build_m1, (self.build_exe,),
113-
# msg='Post-build on macOS Apple Silicon (M1)')
114-
pass
115-
else:
116-
self.execute(_post_build_mac, (self.build_exe,),
117-
msg='Post-build on macOS')
118-
else:
119-
pass
111+
# # post build hook
112+
# # https://stackoverflow.com/questions/17806485/execute-a-python-script-post-install-using-distutils-setuptools
113+
# class build(_build):
114+
# def run(self):
115+
# _build.run(self)
116+
# if sys.platform == 'win32':
117+
# self.execute(_post_build_win, (self.build_exe,),
118+
# msg='Post-build on Windows')
119+
# elif sys.platform == 'darwin':
120+
# if platform.machine() == 'arm64':
121+
# # self.execute(_post_build_m1, (self.build_exe,),
122+
# # msg='Post-build on macOS Apple Silicon (M1)')
123+
# pass
124+
# else:
125+
# self.execute(_post_build_mac, (self.build_exe,),
126+
# msg='Post-build on macOS')
127+
# else:
128+
# pass
120129

121130

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

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

131-
script = 'bin/ncvue'
140+
script = 'bin.save/ncvue' # 'src/ncvue/__main__.py'
132141
packages = ['scipy', 'netCDF4'] # others detected automatically
133142
excludes = ['pyflakes', 'mccabe', 'pycodestyle', 'flake8', # flake8
134143
'gtk', 'PyQt4', 'PyQt5', 'wx'] # matplotlib
@@ -213,7 +222,7 @@ def run(self):
213222
setup(name=package,
214223
version=version,
215224
description=doclines,
216-
cmdclass={'build': build},
225+
# cmdclass={'build': build},
217226
options={'build_exe': build_exe_options,
218227
'bdist_mac': bdist_mac_options,
219228
'bdist_dmg': bdist_dmg_options,

0 commit comments

Comments
 (0)