Skip to content

Commit

Permalink
Add colorbar into loop png
Browse files Browse the repository at this point in the history
  • Loading branch information
yumorishita committed Mar 3, 2021
1 parent d0ba1c6 commit fed3bed
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions LiCSBAS_lib/LiCSBAS_loop_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
=========
Changelog
=========
v1.5.2 20210303 Yu Morishita, GSI
- Use get_cmap in make_loop_png
- Add colorbar in make_loop_png
v1.5.1 20201119 Yu Morishita, GSI
- Change default cmap for wrapped phase from insar to SCM.romaO
v1.5 20201006 Yu Morishita, GSI
Expand All @@ -27,8 +30,8 @@

import os
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 All @@ -43,7 +46,7 @@
def make_loop_matrix(ifgdates):
"""
Make loop matrix (containing 1, -1, 0) from ifgdates.
Inputs:
ifgdates : Unwrapped phase vector at a point without nan (n_ifg)
Expand All @@ -58,7 +61,8 @@ def make_loop_matrix(ifgdates):
for ix_ifg12, ifgd12 in enumerate(ifgdates):
primary12 = ifgd12[0:8]
secondary12 = ifgd12[9:17]
ifgdates23 = [ ifgd for ifgd in ifgdates if ifgd.startswith(secondary12)] # all candidates of ifg23
ifgdates23 = [ ifgd for ifgd in ifgdates if
ifgd.startswith(secondary12)] # all candidates of ifg23

for ifgd23 in ifgdates23: # for each candidate of ifg23
secondary23 = ifgd23[9:17]
Expand Down Expand Up @@ -101,7 +105,7 @@ def read_unw_loop_ph(Aloop1, ifgdates, ifgdir, length, width, bad_ifg=[]):
unw13file = os.path.join(ifgdir, ifgd13, ifgd13+'.unw')
unw13 = io_lib.read_img(unw13file, length, width)
unw13[unw13 == 0] = np.nan # Fill 0 with n

return unw12, unw23, unw13, ifgd12, ifgd23, ifgd13


Expand All @@ -115,15 +119,16 @@ def identify_bad_ifg(bad_ifg_cand, good_ifg):

bad_ifg = list(set(bad_ifg_cand)-set(good_ifg)) # difference
bad_ifg.sort()

return bad_ifg


#%%
#%%
def make_loop_png(unw12, unw23, unw13, loop_ph, png, titles4, cycle):
cmap_wrap = SCM.romaO
cmap_wrap = tools_lib.get_cmap('SCM.romaO')
cmap_loop = tools_lib.get_cmap('SCM.vik')

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

Expand All @@ -136,25 +141,30 @@ def make_loop_png(unw12, unw23, unw13, loop_ph, png, titles4, cycle):
figsize_x = 10
figsize_y = int(figsize_x*length/width+1)
if figsize_y < 3: figsize_y = 3

### Plot
fig = plt.figure(figsize = (figsize_x, figsize_y))

## 3 ifgs
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=cmap_wrap, interpolation='nearest')
im = 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([])
cax = plt.colorbar(im)
cax.set_ticks([])

## loop phase
ax = fig.add_subplot(2, 2, 4) #index start from 1
ax.imshow(loop_ph, vmin=-np.pi, vmax=+np.pi, cmap=SCM.vik, interpolation='nearest')
im = ax.imshow(loop_ph, vmin=-np.pi, vmax=+np.pi, cmap=cmap_loop,
interpolation='nearest')
ax.set_title('{}'.format(titles4[3]))
ax.set_xticklabels([])
ax.set_yticklabels([])
cax = plt.colorbar(im)

plt.tight_layout()
plt.savefig(png)
Expand Down

0 comments on commit fed3bed

Please sign in to comment.