Skip to content

Commit

Permalink
Change default cmap for wrapped phase from insar to SCM.romaO
Browse files Browse the repository at this point in the history
  • Loading branch information
yumorishita committed Nov 19, 2020
1 parent d835a0b commit ee9a54c
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 59 deletions.
11 changes: 5 additions & 6 deletions LiCSBAS_lib/LiCSBAS_loop_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
=========
Changelog
=========
v1.5.1 20201119 Yu Morishita, GSI
- Change default cmap for wrapped phase from insar to SCM.romaO
v1.5 20201006 Yu Morishita, GSI
- Update make_loop_png
v1.4 20200828 Yu Morishita, GSI
Expand All @@ -27,7 +29,6 @@
import numpy as np
import SCM
import LiCSBAS_io_lib as io_lib
import LiCSBAS_tools_lib as tools_lib

os.environ['QT_QPA_PLATFORM']='offscreen'
import warnings
Expand Down Expand Up @@ -120,12 +121,10 @@ def identify_bad_ifg(bad_ifg_cand, good_ifg):

#%%
def make_loop_png(unw12, unw23, unw13, loop_ph, png, titles4, cycle):
### Load color map for InSAR
cdict = tools_lib.cmap_insar()
plt.register_cmap(cmap=mpl.colors.LinearSegmentedColormap('insar', cdict))
plt.rcParams['axes.titlesize'] = 10
cmap_wrap = SCM.romaO

### Settings
plt.rcParams['axes.titlesize'] = 10
data = [unw12, unw23, unw13]

length, width = unw12.shape
Expand All @@ -145,7 +144,7 @@ def make_loop_png(unw12, unw23, unw13, loop_ph, png, titles4, cycle):
for i in range(3):
data_wrapped = np.angle(np.exp(1j*(data[i]/cycle))*cycle)
ax = fig.add_subplot(2, 2, i+1) #index start from 1
ax.imshow(data_wrapped, vmin=-np.pi, vmax=+np.pi, cmap='insar', interpolation='nearest')
ax.imshow(data_wrapped, vmin=-np.pi, vmax=+np.pi, cmap=cmap_wrap, interpolation='nearest')
ax.set_title('{}'.format(titles4[i]))
ax.set_xticklabels([])
ax.set_yticklabels([])
Expand Down
2 changes: 1 addition & 1 deletion LiCSBAS_lib/LiCSBAS_tools_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def comp_size_time(file_remote, file_local):
#%%
def cmap_insar():
"""
How to use cmap_insar:
How to use cmap_insar (GAMMA standard rainbow cmap):
import matplotlib as mpl
from matplotlib import pyplot as plt
cdict = cmap_insar()
Expand Down
17 changes: 8 additions & 9 deletions bin/LiCSBAS02_ml_prep.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python3
"""
v1.7.3 202011118 Yu Morishita, GSI
v1.7.4 202011119 Yu Morishita, GSI
========
Overview
========
This script converts GeoTIFF files of unw and cc to float32 and uint8 format, respectively, for further time series analysis, and also downsamples (multilooks) data if specified. Existing files are not re-created to save time, i.e., only the newly available data will be processed.
====================
Expand Down Expand Up @@ -48,6 +45,8 @@
"""
#%% Change log
'''
v1.7.4 20201119 Yu Morishita, GSI
- Change default cmap for wrapped phase from insar to SCM.romaO
v1.7.3 20201118 Yu Morishita, GSI
- Again Bug fix of multiprocessing
v1.7.2 20201116 Yu Morishita, GSI
Expand Down Expand Up @@ -82,7 +81,6 @@
#%% Import
import getopt
import os
import re
import sys
import time
import shutil
Expand All @@ -91,6 +89,7 @@
import numpy as np
import subprocess as subp
import multiprocessing as multi
import SCM
import LiCSBAS_io_lib as io_lib
import LiCSBAS_tools_lib as tools_lib
import LiCSBAS_plot_lib as plot_lib
Expand All @@ -109,12 +108,12 @@ def main(argv=None):
argv = sys.argv

start = time.time()
ver="1.7.3"; date=202011118; author="Y. Morishita"
ver="1.7.4"; date=20201119; author="Y. Morishita"
print("\n{} ver{} {} {}".format(os.path.basename(argv[0]), ver, date, author), flush=True)
print("{} {}".format(os.path.basename(argv[0]), ' '.join(argv[1:])), flush=True)

### For parallel processing
global ifgdates2, geocdir, outdir, nlook, n_valid_thre, cycle, cmap
global ifgdates2, geocdir, outdir, nlook, n_valid_thre, cycle, cmap_wrap


#%% Set default
Expand All @@ -127,7 +126,7 @@ def main(argv=None):
except:
n_para = multi.cpu_count()

cmap = 'insar'
cmap_wrap = SCM.romaO
cycle = 3
n_valid_thre = 0.5
q = multi.get_context('fork')
Expand Down Expand Up @@ -444,7 +443,7 @@ def convert_wrapper(i):

### Make png
unwpngfile = os.path.join(ifgdir1, ifgd+'.unw.png')
plot_lib.make_im_png(np.angle(np.exp(1j*unw/cycle)*cycle), unwpngfile, cmap, ifgd+'.unw', vmin=-np.pi, vmax=np.pi, cbar=False)
plot_lib.make_im_png(np.angle(np.exp(1j*unw/cycle)*cycle), unwpngfile, cmap_wrap, ifgd+'.unw', vmin=-np.pi, vmax=np.pi, cbar=False)

return 0

Expand Down
15 changes: 9 additions & 6 deletions bin/LiCSBAS03op_GACOS.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
v1.5.4 20201119 Yu Morishita, GSI
v1.5.5 20201119 Yu Morishita, GSI
This script applies a tropospheric correction to unw data using GACOS data. GACOS data may be automatically downloaded from COMET-LiCS web at step01 (if available), or could be externally obtained by requesting on a GACOS web (http://www.gacos.net/).
If you request the GACOS data through the GACOS web, the dates and time of interest can be found in baselines and slc.mli.par, respectively. These are also available on the COMET-LiCS web portal. Once the GACOS data are ready, download the tar.gz, uncompress it, and put into GACOS dir.
Expand Down Expand Up @@ -49,6 +49,8 @@
"""
#%% Change log
'''
v1.5.5 20201119 Yu Morishita, GSI
- Change default cmap for wrapped phase from insar to SCM.romaO
v1.5.4 20201119 Yu Morishita, GSI
- New GACOS format (ztd.tif) available
v1.5.3 20201118 Yu Morishita, GSI
Expand Down Expand Up @@ -85,6 +87,7 @@
import numpy as np
from osgeo import gdal
import multiprocessing as multi
import SCM
import LiCSBAS_io_lib as io_lib
import LiCSBAS_tools_lib as tools_lib
import LiCSBAS_plot_lib as plot_lib
Expand Down Expand Up @@ -159,14 +162,14 @@ def main(argv=None):
argv = sys.argv

start = time.time()
ver="1.5.4"; date=20201119; author="Y. Morishita"
ver="1.5.5"; date=20201119; author="Y. Morishita"
print("\n{} ver{} {} {}".format(os.path.basename(argv[0]), ver, date, author), flush=True)
print("{} {}".format(os.path.basename(argv[0]), ' '.join(argv[1:])), flush=True)

### For parallel processing
global imdates2, gacosdir, outputBounds, width_geo, length_geo, resampleAlg,\
sltddir, LOSu, m2r_coef, fillholeflag, ifgdates2,\
in_dir, out_dir, length_unw, width_unw, cycle
in_dir, out_dir, length_unw, width_unw, cycle, cmap_wrap


#%% Set default
Expand All @@ -181,7 +184,7 @@ def main(argv=None):
n_para = multi.cpu_count()

q = multi.get_context('fork')

cmap_wrap = SCM.romaO

#%% Read options
try:
Expand Down Expand Up @@ -532,12 +535,12 @@ def correct_wrapper(i):
data3 = [np.angle(np.exp(1j*(data/cycle))*cycle) for data in [unw, unw_cor, dsltd]]
title3 = ['unw_org (STD: {:.1f} rad)'.format(std_unw), 'unw_cor (STD: {:.1f} rad)'.format(std_unwcor), 'dsltd ({:.1f}% reduced)'.format(rate)]
pngfile = os.path.join(out_dir1, ifgd+'.gacos.png')
plot_lib.make_3im_png(data3, pngfile, 'insar', title3, vmin=-np.pi, vmax=np.pi, cbar=False)
plot_lib.make_3im_png(data3, pngfile, cmap_wrap, title3, vmin=-np.pi, vmax=np.pi, cbar=False)

## Output png for corrected unw
pngfile = os.path.join(out_dir1, ifgd+'.unw.png')
title = '{} ({}pi/cycle)'.format(ifgd, cycle*2)
plot_lib.make_im_png(np.angle(np.exp(1j*unw_cor/cycle)*cycle), pngfile, 'insar', title, -np.pi, np.pi, cbar=False)
plot_lib.make_im_png(np.angle(np.exp(1j*unw_cor/cycle)*cycle), pngfile, cmap_wrap, title, -np.pi, np.pi, cbar=False)

return 2, [ifgd, std_unw, std_unwcor, rate]

Expand Down
15 changes: 8 additions & 7 deletions bin/LiCSBAS04op_mask_unw.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python3
"""
v1.3.3 20201118 Yu Morishita, GSI
v1.3.4 20201119 Yu Morishita, GSI
========
Overview
========
This script masks specified areas or low coherence areas in the unw data. The masking is effective when the unw data include areas which have many unwrapping errors and are not of interest, and can improve the result of Step 1-2 (loop closure). Existing files are not re-created to save time, i.e., only the newly available data will be processed. This step is optional.
===============
Expand Down Expand Up @@ -42,6 +39,8 @@
"""
#%% Change log
'''
v1.3.4 20201119 Yu Morishita, GSI
- Change default cmap for wrapped phase from insar to SCM.romaO
v1.3.3 20201118 Yu Morishita, GSI
- Again Bug fix of multiprocessing
v1.3.2 20201116 Yu Morishita, GSI
Expand All @@ -67,6 +66,7 @@
import time
import numpy as np
import multiprocessing as multi
import SCM
import LiCSBAS_io_lib as io_lib
import LiCSBAS_tools_lib as tools_lib
import LiCSBAS_plot_lib as plot_lib
Expand All @@ -84,12 +84,12 @@ def main(argv=None):
argv = sys.argv

start = time.time()
ver="1.3.3"; date=20201118; author="Y. Morishita"
ver="1.3.4"; date=20201119; author="Y. Morishita"
print("\n{} ver{} {} {}".format(os.path.basename(argv[0]), ver, date, author), flush=True)
print("{} {}".format(os.path.basename(argv[0]), ' '.join(argv[1:])), flush=True)

### For paralell processing
global ifgdates2, in_dir, out_dir, length, width, bool_mask, cycle
global ifgdates2, in_dir, out_dir, length, width, bool_mask, cycle, cmap_wrap


#%% Set default
Expand All @@ -104,6 +104,7 @@ def main(argv=None):
n_para = multi.cpu_count()

cmap_noise = 'viridis'
cmap_wrap = SCM.romaO
q = multi.get_context('fork')


Expand Down Expand Up @@ -314,7 +315,7 @@ def mask_wrapper(ifgix):
## Output png for masked unw
pngfile = os.path.join(out_dir1, ifgd+'.unw.png')
title = '{} ({}pi/cycle)'.format(ifgd, cycle*2)
plot_lib.make_im_png(np.angle(np.exp(1j*unw/cycle)*cycle), pngfile, 'insar', title, -np.pi, np.pi, cbar=False)
plot_lib.make_im_png(np.angle(np.exp(1j*unw/cycle)*cycle), pngfile, cmap_wrap, title, -np.pi, np.pi, cbar=False)


#%% main
Expand Down
15 changes: 8 additions & 7 deletions bin/LiCSBAS05op_clip_unw.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python3
"""
v1.2.3 20201118 Yu Morishita, GSI
v1.2.4 20201119 Yu Morishita, GSI
========
Overview
========
This script clips a specified rectangular area of interest from unw and cc data. The clipping can make the data size smaller and processing faster, and improve the result of Step 1-2 (loop closure). Existing files are not re-created to save time, i.e., only the newly available data will be processed. This step is optional.
===============
Expand Down Expand Up @@ -42,6 +39,8 @@
"""
#%% Change log
'''
v1.2.4 20201119 Yu Morishita, GSI
- Change default cmap for wrapped phase from insar to SCM.romaO
v1.2.3 20201118 Yu Morishita, GSI
- Again Bug fix of multiprocessing
v1.2.2 20201116 Yu Morishita, GSI
Expand All @@ -67,6 +66,7 @@
import time
import numpy as np
import multiprocessing as multi
import SCM
import LiCSBAS_io_lib as io_lib
import LiCSBAS_tools_lib as tools_lib
import LiCSBAS_plot_lib as plot_lib
Expand All @@ -85,12 +85,12 @@ def main(argv=None):
argv = sys.argv

start = time.time()
ver="1.2.3"; date=20201118; author="Y. Morishita"
ver="1.2.4"; date=20201119; author="Y. Morishita"
print("\n{} ver{} {} {}".format(os.path.basename(argv[0]), ver, date, author), flush=True)
print("{} {}".format(os.path.basename(argv[0]), ' '.join(argv[1:])), flush=True)

### For parallel processing
global ifgdates2, in_dir, out_dir, length, width, x1, x2, y1, y2,cycle
global ifgdates2, in_dir, out_dir, length, width, x1, x2, y1, y2,cycle, cmap_wrap


#%% Set default
Expand All @@ -104,6 +104,7 @@ def main(argv=None):
n_para = multi.cpu_count()

q = multi.get_context('fork')
cmap_wrap = SCM.romaO


#%% Read options
Expand Down Expand Up @@ -333,7 +334,7 @@ def clip_wrapper(ifgix):
## Output png for corrected unw
pngfile = os.path.join(out_dir1, ifgd+'.unw.png')
title = '{} ({}pi/cycle)'.format(ifgd, cycle*2)
plot_lib.make_im_png(np.angle(np.exp(1j*unw/cycle)*cycle), pngfile, 'insar', title, -np.pi, np.pi, cbar=False)
plot_lib.make_im_png(np.angle(np.exp(1j*unw/cycle)*cycle), pngfile, cmap_wrap, title, -np.pi, np.pi, cbar=False)


#%% main
Expand Down
14 changes: 7 additions & 7 deletions bin/LiCSBAS13_sb_inv.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python3
"""
v1.4.5 20201118 Yu Morishita, GSI
v1.4.6 20201119 Yu Morishita, GSI
========
Overview
========
This script inverts the SB network of unw to obtain the time series and velocity
using NSBAS (López-Quiroz et al., 2009; Doin et al., 2011) approach.
A stable reference point is determined after the inversion. RMS of the time series
Expand Down Expand Up @@ -72,6 +69,8 @@
"""
#%% Change log
'''
v1.4.6 20201119 Yu Morishita, GSI
- Change default cmap for wrapped phase from insar to SCM.romaO
v1.4.5 20201118 Yu Morishita, GSI
- Again Bug fix of multiprocessing
v1.4.4 20201116 Yu Morishita, GSI
Expand Down Expand Up @@ -132,14 +131,14 @@ def main(argv=None):
argv = sys.argv

start = time.time()
ver="1.4.5"; date=20201118; author="Y. Morishita"
ver="1.4.6"; date=20201119; author="Y. Morishita"
print("\n{} ver{} {} {}".format(os.path.basename(argv[0]), ver, date, author), flush=True)
print("{} {}".format(os.path.basename(argv[0]), ' '.join(argv[1:])), flush=True)

## For parallel processing
global n_para_gap, G, Aloop, unwpatch, imdates, incdir, ifgdir, length, width,\
coef_r2m, ifgdates, ref_unw, cycle, keep_incfile, resdir, restxtfile, \
cmap_vel, wavelength
cmap_vel, cmap_wrap, wavelength


#%% Set default
Expand All @@ -161,6 +160,7 @@ def main(argv=None):
cmap_vel = SCM.roma.reversed()
cmap_noise = 'viridis'
cmap_noise_r = 'viridis_r'
cmap_wrap = SCM.romaO
q = multi.get_context('fork')


Expand Down Expand Up @@ -827,7 +827,7 @@ def inc_png_wrapper(imx):
data3 = [np.angle(np.exp(1j*(data/coef_r2m/cycle))*cycle) for data in [unw, inc, inc-unw]]
title3 = ['Daisy-chain IFG ({}pi/cycle)'.format(cycle*2), 'Inverted ({}pi/cycle)'.format(cycle*2), 'Difference ({}pi/cycle)'.format(cycle*2)]
pngfile = os.path.join(incdir, '{}.increment.png'.format(ifgd))
plot_lib.make_3im_png(data3, pngfile, 'insar', title3, vmin=-np.pi, vmax=np.pi, cbar=False)
plot_lib.make_3im_png(data3, pngfile, cmap_wrap, title3, vmin=-np.pi, vmax=np.pi, cbar=False)

if not keep_incfile:
os.remove(incfile)
Expand Down
Loading

0 comments on commit ee9a54c

Please sign in to comment.