https://github.com/darothen/plot-all-in-ncfile
Simple netCDF plotting utility script.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.5%) to scientific vocabulary
Repository
Simple netCDF plotting utility script.
Basic Info
- Host: GitHub
- Owner: darothen
- License: mit
- Language: Python
- Default Branch: master
- Size: 202 KB
Statistics
- Stars: 8
- Watchers: 2
- Forks: 5
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
plot-all-in-ncfile.py example script.
For convenience, a conda environment has been provided with all the packages used to automate this task. The install process is very straightforward (and unnecessary if you already have a scientific Python setup running with the packages xarray and cartopy):
bash
$ cd path/to/plot-all-in-ncfile.py
$ conda env create -f environment.yml
$ source activate plot-all-in-ncfile
You may want to install the bleeding-edge release of [xray][],
bash
$ pip install git+https://github.com/pydata/xarray.git
From there, just run the script with the "-h" flag for help/usage. A very simple scheme is used to save color formatting between plots. The script has the to read a "colorfile", which is really just a glorified dictionary of dictionaries which has been saved (pickled) to disk. I patched in to use [arxray][]'s tool to automatically infer colormap settings, and if this "colorfile" isn't supplied as an argument, it'll automatically look at all the data for each variable and figure out the best colormap settings and save them in a file with the same basename as the netCDF file being plotted but with the extension .cf. Furthermore, if you supply a colorfile but it doesn't contain details for a variable found in the netCDF file, it will automatically infer it and add it to the colorfile.
Since a colorfile is just a dictionary of dicts, you can easily add to it interactively (or maybe with a special function that automates the task). Here's the dictionary contained in the colorfile generated when looking at some TRMM data:
python
{'rr': {'cmap': <matplotlib.colors.ListedColormap at 0x1169f2390>,
'cnorm': <matplotlib.colors.BoundaryNorm at 0x116064cc0>,
'extend': 'max',
'levels': array([ 0. , 1.5, 3. , 4.5, 6. , 7.5, 9. , 10.5, 12. ,
13.5, 15. , 16.5, 18. , 19.5, 21. , 22.5, 24. , 25.5,
27. , 28.5, 30. , 31.5]),
'vmax': 31.5,
'vmin': 0.0}}
Other options might be to convert these to JSON or YAML and save them on disk in a way that they can be edited by hand; happy to implement that as an example if interested.
Sample Usage
bash
$ ./plot-all-in-ncfile.py TRMM_3B42.1998-2013.daily.1deg.V7.nc -c TRMM_3B42.1998-2013.daily.1deg.V7.cf --sample
This should produce the output image

Owner
- Name: Daniel Rothenberg
- Login: darothen
- Kind: user
- Location: Frederick, CO
- Company: Waymo
- Website: http://www.danielrothenberg.com
- Twitter: danrothenberg
- Repositories: 72
- Profile: https://github.com/darothen
Tech Lead @ Waymo | Weather/Climate Scientist | Pythonista | ex-Chief Scientist @ ClimaCell/Tomorrow.io | Formerly Postdoc Associate @ MIT EAPS/IDSS/CGCS
GitHub Events
Total
- Watch event: 2
Last Year
- Watch event: 2
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0