Skip to content

Commit 5a93dbf

Browse files
committed
Small bug fix for all nan loop phase
1 parent 2c7ef38 commit 5a93dbf

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

bin/LiCSBAS12_loop_closure.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
"""
3-
v1.6 20210311 Yu Morishita, GSI
3+
v1.6.1 20210405 Yu Morishita, GSI
44
55
========
66
Overview
@@ -65,6 +65,8 @@
6565
"""
6666
#%% Change log
6767
'''
68+
v1.6.1 20210405 Yu Morishita, GSI
69+
- Bug fix when all pixels are nan in loop phase
6870
v1.6 20210311 Yu Morishita, GSI
6971
- Add --rm_ifg_list option
7072
v1.5.3 20201118 Yu Morishita, GSI
@@ -102,7 +104,6 @@
102104
import numpy as np
103105
import datetime as dt
104106
import multiprocessing as multi
105-
import SCM
106107
import LiCSBAS_io_lib as io_lib
107108
import LiCSBAS_loop_lib as loop_lib
108109
import LiCSBAS_tools_lib as tools_lib
@@ -124,7 +125,7 @@ def main(argv=None):
124125
argv = sys.argv
125126

126127
start = time.time()
127-
ver="1.6"; date=20210311; author="Y. Morishita"
128+
ver="1.6.1"; date=20210405; author="Y. Morishita"
128129
print("\n{} ver{} {} {}".format(os.path.basename(argv[0]), ver, date, author), flush=True)
129130
print("{} {}".format(os.path.basename(argv[0]), ' '.join(argv[1:])), flush=True)
130131

@@ -506,8 +507,8 @@ def main(argv=None):
506507
#%% Output loop info, move bad_loop_png
507508
loop_info_file = os.path.join(loopdir, 'loop_info.txt')
508509
f = open(loop_info_file, 'w')
509-
print('# loop_thre: {} rad. *: Removed w/o ref, **: Removed w/ ref'.format(
510-
loop_thre), file=f)
510+
print('# loop_thre: {} rad'.format(loop_thre), file=f)
511+
print('# *: Removed w/o ref, **: No ref, ***: Removed w/ ref', file=f)
511512
if rm_ifg_list:
512513
print('# +: Removed by manually indicating in {}'.format(rm_ifg_list),
513514
file=f)
@@ -539,9 +540,12 @@ def main(argv=None):
539540
elif ifgd12 in rm_ifg or ifgd23 in rm_ifg or ifgd13 in rm_ifg:
540541
badloopflag1 = '+'
541542
shutil.move(looppngfile, badlooppngfile)
542-
elif ifgd12 in bad_ifg2 or ifgd23 in bad_ifg2 or ifgd13 in bad_ifg2:
543+
elif ifgd12 in noref_ifg or ifgd23 in noref_ifg or ifgd13 in noref_ifg:
543544
badloopflag2 = '**'
544545
shutil.move(looppngfile, badlooppngfile)
546+
elif ifgd12 in bad_ifg2 or ifgd23 in bad_ifg2 or ifgd13 in bad_ifg2:
547+
badloopflag2 = '***'
548+
shutil.move(looppngfile, badlooppngfile)
545549
elif ifgd12 in bad_ifg_cand_res or ifgd23 in bad_ifg_cand_res or ifgd13 in bad_ifg_cand_res:
546550
badloopflag1 = '/'
547551
if os.path.exists(looppngfile):
@@ -730,14 +734,19 @@ def loop_closure_1st_wrapper(i):
730734

731735
## Calculate loop phase and check n bias (2pi*n)
732736
loop_ph = unw12+unw23-unw13
733-
loop_2pin = int(np.round(np.nanmedian(loop_ph)/(2*np.pi)))*2*np.pi
734-
loop_ph = loop_ph-loop_2pin #unbias 2pi x n
735737

736-
if multi_prime:
737-
bias = np.nanmedian(loop_ph)
738-
loop_ph = loop_ph - bias # unbias inconsistent fraction phase
738+
if np.all(np.isnan(loop_ph)):
739+
bias = np.nan
740+
rms = np.inf
741+
else:
742+
loop_2pin = np.round(np.nanmedian(loop_ph)/(2*np.pi))*2*np.pi
743+
loop_ph = loop_ph-loop_2pin #unbias 2pi x n
739744

740-
rms = np.sqrt(np.nanmean(loop_ph**2))
745+
if multi_prime:
746+
bias = np.nanmedian(loop_ph)
747+
loop_ph = loop_ph - bias # unbias inconsistent fraction phase
748+
749+
rms = np.sqrt(np.nanmean(loop_ph**2))
741750

742751
### Output png. If exist in old, move to save time
743752
imd1 = ifgd12[:8]
@@ -784,12 +793,14 @@ def loop_closure_2nd_wrapper(args):
784793

785794
## Calculate loop phase and rms at points
786795
loop_ph = unw12+unw23-unw13
787-
loop_2pin = int(np.round(np.nanmedian(loop_ph)/(2*np.pi)))*2*np.pi
788-
loop_ph = loop_ph-loop_2pin #unbias
789796

790-
if multi_prime:
791-
bias = np.nanmedian(loop_ph)
792-
loop_ph = loop_ph - bias # unbias inconsistent fraction phase
797+
if not np.all(np.isnan(loop_ph)):
798+
loop_2pin = np.round(np.nanmedian(loop_ph)/(2*np.pi))*2*np.pi
799+
loop_ph = loop_ph-loop_2pin #unbias 2pi x n
800+
801+
if multi_prime:
802+
bias = np.nanmedian(loop_ph)
803+
loop_ph = loop_ph - bias # unbias inconsistent fraction phase
793804

794805
ns_loop_ph1 = ns_loop_ph1 + ~np.isnan(loop_ph)
795806

0 commit comments

Comments
 (0)