Handling NetCDF Files using XArray for Absolute Beginners
Python 3 interface for ecCodes
closest thing to API docs: ecCodes API examples
some interesting articles: How-to Articles
another possible API ref: This package is the Python interface to ecCodes.
another alternative: cfgrib uses xarray
Python interface to map GRIB files to the Unidata’s Common Data Model v4 following the CF Conventions. The high level API is designed to support a GRIB engine for xarray and it is inspired by netCDF4-python and h5netcdf. Low level access and decoding is performed via the ECMWF ecCodes library.
yet another alternative: Metview's Python Interface Metview's Python interface is currently available on internal ECMWF desktop machines, lxc and on the Member State server ecgate as well as the HPCF. It is also on github and PyPi and can be installed with the command "pip install metview".
This seems interesting:
Magics
What is Magics
Magics uses the Terralib library in cooperation with Brazil's INPE.
their confluence pages: All updates
alpha code from ncep: application , description
https://github.com/jswhit/pygrib
wgrib (possibly lame): https://github.com/Liam-Deacon/wgrib-python
Exactly what we want, but very old: hrrr notebook
Python 3 interface for ecCodes: https://confluence.ecmwf.int/display/ECC/Python+3+interface+for+ecCodes
ecCodes Home: https://confluence.ecmwf.int/display/ECC/ecCodes+Home
here goes:
pygrib: git repo: https://github.com/jswhit/pygrib
docs: https://jswhit.github.io/pygrib/docs/index.html
CMake Error at cmake/ecbuild_log.cmake:196 (message):
CRITICAL - ecBuild is untested for this operating system: [CYGWIN]
-- refusing to continue. Disable this check with -DDISABLE_OS_CHECK=ON
Rebuild with that flag and in /home/Wendell_CTR_Turner (with '_' as /home/Wendell CTR Turner has spaces in it)
07:51:01 build $ cmake -DDISABLE_OS_CHECK=ON -DENABLE_FORTRAN=OFF ../eccodes-2.18.0-Source
08:09:19 build $ ctest
0% tests passed, 32 tests failed out of 32
08:10:39 tests $ ./unit_tests.exe -h
C:/Users/Public/cygwin/home/Wendell CTR Turner/pkgs/eccodes/build/tests/unit_tests.exe: error while loading shared libraries: cygeccodes.dll: cannot open shared object file: No such file or dir
ectory
heck, maybe it was a space in the filename, proceeding anyway...
08:10:48 tests $ make install
08:19:53 build $ pip3.7 install eccodes
Collecting eccodes
Successfully installed eccodes-0.9.9
and eccodes on wwtlaptop:
>>>>>>>>>>>>>>> WARNING:
wendell@home:/usr/bin
> mv python python2_old
wendell@home:/usr/bin
> cp python3.7 python
<< some cmake warnings about OLD something or other >>
-- Could NOT find NetCDF (missing: NetCDF_LIBRARIES) (found version "4.7.3")
-- Could NOT find package NetCDF required for feature NETCDF -- Provide NetCDF location with -DNETCDF_PATH=/...
-- Feature NETCDF was not enabled (also not requested) -- following required packages weren't found: NetCDF
-- Found PythonInterp: /usr/bin/python (found version "3.7.7")
-- Found Python: TRUE
-- Found package Python required for feature PYTHON
-- Found NumPy: version "1.19.0" /usr/lib/python3.7/site-packages/numpy/core/include
$ ctest
0% tests passed, 28 tests failed out of 28
pygrib on wwtlaptop:
> git clone https://github.com/jswhit/pygrib.git
d/l something interesting from here:
in: ~/cssi/hrrr_testing
wendell@home:~/cssi/hrrr_testing
> jupyter notebook
file is: hrrr.t18z.wrfsfcf00.grib2
following code at: https://github.com/scollis/HRRR/blob/master/notebooks/HRRR%20Grib.ipynb
nothing in cygwin packages
> pip3.7 install --upgrade matplotlib
Collecting matplotlib
Downloading matplotlib-3.3.2.tar.gz (37.9 MB):w
basemap:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#basemap
source (approx 100 mb):
https://github.com/matplotlib/basemap/releases/
However, that says:
Final Release
@WeatherGod WeatherGod released this on Aug 6
This is quite likely the last release ever of
basemap. Please move development efforts over
to Cartopy!
> cd basemap-1.2.2rel
> export GEOS_DIR=/usr
wendell@home:~/cssi/hrrr_testing/basemap-1.2.2rel
> python3.7 setup.py install
NOPE.
> python3.7 setup.py install
...
Finished processing dependencies for basemap==1.2.1
HOWEVER, basemap did NOT get installed
trying geos instructions from: https://peak5390.wordpress.com/2012/12/08/matplotlib-basemap-tutorial-installing-matplotlib-and-basemap/
then:
cd ~/cssi/hrrr_testing/basemap-1.2.2rel/examples
jupyter notebook
New -> Python3
from __future__ import (absolute_import, division, print_function)
#wt: from mpl_toolkits.basemap import Basemap
import sys
sys.path.append("/home/wendell/cssi/hrrr_testing/basemap-1.2.2rel/lib/mpl_toolkits")
import basemap
import numpy as np
import matplotlib.pyplot as plt
# read in topo data (on a regular lat/lon grid)
etopo=np.loadtxt('etopo20data.gz')
lons=np.loadtxt('etopo20lons.gz')
lats=np.loadtxt('etopo20lats.gz')
# create Basemap instance for Robinson projection.
#wt: m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]))
m = basemap.Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]))
# make filled contour plot.
x, y = m(*np.meshgrid(lons, lats))
cs = m.contourf(x,y,etopo,30,cmap=plt.cm.jet)
# draw coastlines.
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-60.,90.,30.),labels=[1,0,0,0])
m.drawmeridians(np.arange(0.,360.,60.),labels=[0,0,0,1],fontsize=12)
m.colorbar(location='bottom',pad='10%')
# add a title.
plt.title('Robinson Projection')
plt.show()
Yipee! a map shows up!
https://polar.ncep.noaa.gov/waves/examples/usingpython.shtml
a notebook using cartopy: https://github.com/rsignell-usgs/notebook/blob/master/Siphon/hrrr_wind-ncep.py
https://www.activestate.com/blog/plotting-data-in-python-matplotlib-vs-plotly/
Matplotlib vs Plotly: Plotting Data with Matplotlib
Matplotlib is quite possibly the simplest way to plot data in Python. It is similar to plotting in MATLAB, allowing users full control over fonts, line styles, colors, and axes properties. This allows for complete customization and fine control over the aesthetics of each plot, albeit with a lot of additional lines of code. There are many third-party packages that extend the functionality of matplotlib such as Basemap and Cartopy, which are ideal for plotting geospatial and map-like data. Seaborn and Holoviews provide higher level interfaces, which results in a more intuitive experience. Matplotlib is also integrated into the pandas package, which provides a quick and efficient tool for exploratory analysis.
Clearly, matplotlib and the extensive third-party packages that are built upon it, provide powerful tools for plotting data of various types. Despite being syntactically tedious, it is an excellent way to produce quality static visualizations worthy of publications or professional presentations.
Matplotlib vs Plotly: Plotting Data with Plotly
Plotly is another great Python visualization tool that’s capable of handling geographical, scientific, statistical, and financial data. The company behind Plotly, also known as Plotly, makes an entire suite of visualization tools for multiple programming languages, all of which create interactive web-based visualizations and even web applications. Plotly has several advantages over matplotlib. One of the main advantages is that only a few lines of codes are necessary to create aesthetically pleasing, interactive plots. The interactivity also offers a number of advantages over static matplotlib plots:
Just like matplotlib, Plotly also has a few tools that allow it to easily integrate with pandas to make plotting even more efficient.
Matplotlib vs Plotly: Conclusions
To summarize, matplotlib is a quick and straightforward tool for creating visualizations within Python. The verbosity required to make anything more than a basic plot makes it more suitable for an initial exploratory analysis or a minimalist design. Matplotlib is also a great place for new Python users to start their data visualization education, because each plot element is declared explicitly in a logical manner.
Plotly, on the other hand, is a more sophisticated data visualization tool that is better suited for creating elaborate plots more efficiently. The interactivity and elegant aesthetics that come with plotly are benefits that cannot be ignored.