Skip to content

Commit 67577b6

Browse files
committed
adjust cmy to green in center
+ adjust cmy colormap to be green in the center and orange for positive value by default. + update colormap file url + bugs fix + suppress matplotlib user warning in plot_network.py
1 parent 3536098 commit 67577b6

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

docs/resources/colormaps/README.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
## Custom colormaps
22

3-
MintPy support all colormaps from [Matplotlib](https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html) and custom colormap files in **.cpt** (color palette tables) format. To add your own colormap, drop the corresponding .cpt file in `$MINTPY/docs/resources/colormaps`.
3+
MintPy support the following colormaps:
44

5-
To use `vik` colormap in view.py for example:
5+
+ [Matplotlib colormaps](https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html)
6+
+ Custom colormaps: `cmy` and `dismph`
7+
+ Custom colormaps in **.cpt** (color palette tables) format. To add your own colormap, drop the corresponding .cpt file in `$MINTPY/docs/resources/colormaps`.
8+
9+
We recommend to use cyclic colormap `cmy` for wrapped phase/displacement measurement.
10+
11+
<p align="left">
12+
<img width="280" src="https://yunjunzhang.files.wordpress.com/2020/01/cmap_cmy-1.png">
13+
</p>
14+
15+
To use colormap `cmy` in view.py:
616

717
```bash
8-
view.py velocity.h5 -c vik
18+
view.py velocity.h5 -c cmy
919
```
1020

11-
The default colormap for phase/displacement data is `cmy`:
21+
To use colormap `cmy` in python:
1222

13-
<p align="left">
14-
<img width="280" src="https://yunjunzhang.files.wordpress.com/2020/01/cmap_cmy.png">
15-
</p>
23+
```python
24+
from mintpy.colors import ColormapExt
25+
cmap = ColormapExt('cmy').colromap
26+
```
1627

1728
### Colormaps from [GMT](http://www.soest.hawaii.edu/gmt/) ###
1829

mintpy/objects/colors.py

+3
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ def get_single_colormap(self, cmap_name, cmap_lut=256):
229229
rgbs[255,0] = 0
230230
rgbs[255,1] = 255
231231
rgbs[255,2] = 255
232+
233+
rgbs = np.roll(rgbs, int(256/2-214), axis=0) #shift green to the center
234+
rgbs = np.flipud(rgbs) #flip up-down so that orange is in the later half (positive)
232235

233236
# color list --> colormap object
234237
colormap = LinearSegmentedColormap.from_list('cmy', rgbs/255., N=cmap_lut)

mintpy/objects/stack.py

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
'ramp' :'m',
9797
'displacement' :'m',
9898

99+
'temporalCoherence' :'1',
99100
'velocity' :'m/year',
100101
'acceleration' :'m/year^2',
101102
'mask' :'1',

mintpy/plot_network.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
from mintpy.utils import (readfile,
1616
utils as ut,
1717
plot as pp)
18+
# suppress UserWarning from matplotlib
19+
import warnings
20+
warnings.filterwarnings("ignore", category=UserWarning, module="matplotlib")
1821

1922

2023
########################### Sub Function #############################

mintpy/view.py

+2
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ def plot_slice(ax, data, metadata, inps=None):
399399
if not inps:
400400
inps = cmd_line_parse([''])
401401
inps = update_inps_with_file_metadata(inps, metadata)
402+
if isinstance(inps.colormap, str):
403+
inps.colormap = pp.ColormapExt(inps.colormap).colormap
402404

403405
# read DEM
404406
if inps.dem_file:

0 commit comments

Comments
 (0)