Skip to content

Commit

Permalink
Merge pull request #6 from TomLav/vimrc
Browse files Browse the repository at this point in the history
Improve robustness of ncmaps, add a .ncviewrc file.
  • Loading branch information
TomLav authored May 11, 2021
2 parents 422ece8 + 82562f0 commit da66475
Show file tree
Hide file tree
Showing 62 changed files with 2,008 additions and 12,831 deletions.
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,52 @@ Oslo (cmcrameri)

![Example of Oslo colormap](images/oslo_example.png)

Eclipse (cmasher)

![Example of Eclipse colormap](images/eclipse_example.png)

## Installation

There are two ways for getting ncview to use the scientific colormaps:
There are two ways for getting `ncview` to use the scientific colormaps:

*Option 1:*
1. Fetch the ncmaps repo from github;
*Option 1: (easiest)*
1. Fetch this repo from github;
2. Define (export) a shell environment variable to the sub-directory `ncmaps/`: `export NCVIEWBASE=</path/to/local/ncmaps/copy>/ncmaps/`.
2. Copy `ncmaps/.ncviewrc` to your HOME: `cp </path/to/local/ncmaps/copy>/ncmaps/.ncviewrc ${HOME}`.

For example: `export NCVIEWBASE=/home/tomlav/software/ncmaps/ncmaps/` (note `ncmaps` twice). You should add the export to your `.profile`.
For example: `export NCVIEWBASE=/home/tomlav/software/ncmaps/ncmaps/` (note `ncmaps` twice) and `cp /home/tomlav/software/ncmaps/ncmaps/.ncviewrc /home/tomlav/`.
You should add the export to your `.profile`.

*Option 2:*
1. Fetch the ncmaps repo from github;
*Option 2: (requires python3)*
1. Fetch this repo from github;
2. Run `python3 write_ncmaps` in the terminal;
3. Define (export) a shell environment variable: `export NCVIEWBASE=${HOME}/.ncmaps`;
2. Copy `${HOME}/.ncmaps/.ncviewrc` to your HOME: `cp ${HOME}/.ncmaps/.ncviewrc ${HOME}/`.

Here again, you should put the `export` command in your `.profile`.

The second option is mainly if you want to develop the package and add more colormaps (please consider making a PR).

In both cases, new colormaps should be available next time you run `ncview`.

## Supported colormaps
*ncmaps* harvests scientific colormaps from the following python modules:
* [matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html)
* [cmocean](https://matplotlib.org/cmocean/)
* [cmcrameri](https://pypi.org/project/cmcrameri/)
* [cmasher](https://cmasher.readthedocs.io/index.html)

These modules must be installed and accessible to your your python implementation (e.g. via *pip* or *conda*) **before** running `write_ncmaps`.
This might require activating a *virtualenv*. Colormap modules that are not available are skipped.
If you choose _Option 2_ above, these modules must be installed and accessible to your your python implementation
(e.g. via *pip* or *conda*) **before** running `write_ncmaps`. This might require activating a *virtualenv*.

Installing the colormaps modules is not required if you choose Option 1 above.

## Notes about ncview
1. The most widely available version of `ncview` _(Ncview 2.1.8 David W. Pierce 8 March 2017)_ has a bug in the way
it loads the colormaps. This bug limits the number of colormaps we can prepare to a maximum of 79.
When triggered, the bug results in ncview refusing to launch with `Error, too many colormaps -- max is 200`.
Should this happen to you, try to: delete your `.ncviewrc` file (in your HOME). If it persists, fetch a new version of this repo.
This bug is the reason why we do not support additional colormaps (e.g. `cmasher`).

## Command-line parameters
2. `ncview` offers a way to enable, disable, and re-order the colormaps (see button `Opts`). The configuration is saved into the
`.ncviewrc` file in your HOME. The `.ncviewrc` file we provide in this package 1) disables all the "legacy" colormaps of `ncview` and
2) orders the colormaps by name (alphabetic). Using our `.ncvirewc` file will overwrite your own preferences. You can start from our
`.ncvirewc` file and further customize your colormaps.

Running `write_ncmaps` should be enough in most cases, but check `write_ncmaps -h`.
![The Opts interface in ncview](images/ncview_opt.png)

## Author
Thomas Lavergne, Norwegian Meteorological Institute
Expand Down
Binary file removed images/eclipse_example.png
Binary file not shown.
Binary file added images/ncview_opt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions ncmaps/.ncviewrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
-1 "STRINGLIST_SAVE_FILE_VERSION" INT 1
0 "NCVIEW_STATE_FILE_VERSION" INT 1
1 "CMAP_acton" INT 1
2 "CMAP_algae" INT 1
3 "CMAP_amp" INT 1
4 "CMAP_balance" INT 1
5 "CMAP_bam" INT 1
6 "CMAP_bamako" INT 1
7 "CMAP_bamO" INT 1
8 "CMAP_batlow" INT 1
9 "CMAP_batlowK" INT 1
10 "CMAP_batlowW" INT 1
11 "CMAP_berlin" INT 1
12 "CMAP_bilbao" INT 1
13 "CMAP_broc" INT 1
14 "CMAP_brocO" INT 1
15 "CMAP_buda" INT 1
16 "CMAP_bukavu" INT 1
17 "CMAP_bwr" INT 1
18 "CMAP_cividis" INT 1
19 "CMAP_coolwarm" INT 1
20 "CMAP_cork" INT 1
21 "CMAP_corkO" INT 1
22 "CMAP_curl" INT 1
23 "CMAP_davos" INT 1
24 "CMAP_deep" INT 1
25 "CMAP_delta" INT 1
26 "CMAP_dense" INT 1
27 "CMAP_devon" INT 1
28 "CMAP_diff" INT 1
29 "CMAP_fes" INT 1
30 "CMAP_gray" INT 1
31 "CMAP_grayC" INT 1
32 "CMAP_haline" INT 1
33 "CMAP_hawaii" INT 1
34 "CMAP_ice" INT 1
35 "CMAP_imola" INT 1
36 "CMAP_inferno" INT 1
37 "CMAP_lajolla" INT 1
38 "CMAP_lapaz" INT 1
39 "CMAP_lisbon" INT 1
40 "CMAP_magma" INT 1
41 "CMAP_matter" INT 1
42 "CMAP_nuuk" INT 1
43 "CMAP_oleron" INT 1
44 "CMAP_oslo" INT 1
45 "CMAP_oxy" INT 1
46 "CMAP_phase" INT 1
47 "CMAP_PiYG" INT 1
48 "CMAP_plasma" INT 1
49 "CMAP_PRGn" INT 1
50 "CMAP_rain" INT 1
51 "CMAP_RdBu" INT 1
52 "CMAP_roma" INT 1
53 "CMAP_romaO" INT 1
54 "CMAP_solar" INT 1
55 "CMAP_speed" INT 1
56 "CMAP_tarn" INT 1
57 "CMAP_tempo" INT 1
58 "CMAP_thermal" INT 1
59 "CMAP_tofino" INT 1
60 "CMAP_tokyo" INT 1
61 "CMAP_topo" INT 1
62 "CMAP_turbid" INT 1
63 "CMAP_turku" INT 1
64 "CMAP_twilight" INT 1
65 "CMAP_twilight_shifted" INT 1
66 "CMAP_vanimo" INT 1
67 "CMAP_vik" INT 1
68 "CMAP_vikO" INT 1
69 "CMAP_viridis" INT 1
70 "CMAP_3gauss" INT 0
71 "CMAP_detail" INT 0
72 "CMAP_ssec" INT 0
73 "CMAP_bright" INT 0
74 "CMAP_banded" INT 0
75 "CMAP_rainbow" INT 0
76 "CMAP_jaisnb" INT 0
77 "CMAP_jaisnc" INT 0
78 "CMAP_jaisnd" INT 0
79 "CMAP_blu_red" INT 0
80 "CMAP_manga" INT 0
81 "CMAP_jet" INT 0
82 "CMAP_wheel" INT 0
83 "CMAP_3saw" INT 0
84 "CMAP_bw" INT 0
85 "CMAP_default" INT 0
86 "CMAP_extrema" INT 0
87 "CMAP_helix" INT 0
88 "CMAP_helix2" INT 0
89 "CMAP_hotres" INT 0
Loading

0 comments on commit da66475

Please sign in to comment.