Skip to content

Commit

Permalink
modify_network: add --ex-date12 option (#1151)
Browse files Browse the repository at this point in the history
This PR adds the capability to exclude interferometric pairs given the list of date12, besides given the ifgram index. The benefit is that it won't change after updating interferogram stack.

+ (cli.)modify_network.py: add --exclude-date12 option to exclude pairs given date1_date2

+ defaults.smallbaselineApp(_auto).cfg: add mintpy.network.excludeDate12 option with auto value of no
  • Loading branch information
yunjunz authored Mar 4, 2024
1 parent 8c33b9a commit 502bfa1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/mintpy/cli/modify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def create_parser(subparsers=None):
'i.e. ifgramStack.h5, date12_list.txt')
parser.add_argument('--exclude-ifg-index', dest='excludeIfgIndex', nargs='*',
help='index of interferograms to remove/drop.\n1 as the first')
parser.add_argument('--exclude-date', dest='excludeDate', nargs='*',
parser.add_argument('--exclude-ifg','--ex-ifg','--ex-date12', dest='excludeDate12', nargs='*',
help='pair(s) to remove/drop in YYYYMMDD_YYYYMMDD format.')
parser.add_argument('--exclude-date','--ex-date', dest='excludeDate', nargs='*',
help='date(s) to remove/drop, all interferograms included date(s) will be removed')
parser.add_argument('--start-date', '--min-date', dest='startDate',
help='remove/drop interferograms with date earlier than start-date in YYMMDD or YYYYMMDD format')
Expand Down Expand Up @@ -109,7 +111,7 @@ def cmd_line_parse(iargs=None):
inps = parser.parse_args(args=iargs)

# import
from mintpy.utils import readfile, utils as ut
from mintpy.utils import ptime, readfile, utils as ut

# check: --mask option
if not os.path.isfile(inps.maskFile):
Expand All @@ -118,15 +120,21 @@ def cmd_line_parse(iargs=None):
# check: --exclude-ifg-index option (convert input index to continuous index list)
inps.excludeIfgIndex = read_input_index_list(inps.excludeIfgIndex, stackFile=inps.file)

# check: --ex-date(12) options
if inps.excludeDate:
inps.exlcudeDate = ptime.yyyymmdd(inps.excludeDate)
if inps.excludeDate12:
inps.excludeDate12 = ptime.yyyymmdd_date12(inps.excludeDate12)

# check: -t / --template option
if inps.template_file:
inps = read_template2inps(inps.template_file, inps)

# check: input arguments (required at least one)
required_args = [
inps.referenceFile, inps.tempBaseMax, inps.perpBaseMax, inps.connNumMax,
inps.excludeIfgIndex, inps.excludeDate, inps.coherenceBased, inps.areaRatioBased,
inps.startDate, inps.endDate, inps.reset, inps.manual,
inps.excludeIfgIndex, inps.excludeDate, inps.excludeDate12, inps.coherenceBased,
inps.areaRatioBased, inps.startDate, inps.endDate, inps.reset, inps.manual,
]
if all(not i for i in required_args + [inps.template_file]):
msg = 'No input option found to remove interferogram, exit.\n'
Expand Down Expand Up @@ -199,6 +207,8 @@ def read_template2inps(template_file, inps):
iDict[key] = ptime.yyyymmdd(value)
elif key == 'excludeDate':
iDict[key] = ptime.yyyymmdd(value.split(','))
elif key == 'excludeDate12':
iDict[key] = ptime.yyyymmdd_date12(value.split(','))
elif key == 'excludeIfgIndex':
iDict[key] += value.split(',')
iDict[key] = read_input_index_list(iDict[key], stackFile=inps.file)
Expand Down
1 change: 1 addition & 0 deletions src/mintpy/defaults/smallbaselineApp.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ mintpy.network.connNumMax = auto #[1-inf, no], auto for no, max number of
mintpy.network.startDate = auto #[20090101 / no], auto for no
mintpy.network.endDate = auto #[20110101 / no], auto for no
mintpy.network.excludeDate = auto #[20080520,20090817 / no], auto for no
mintpy.network.excludeDate12 = auto #[20080520_20090817 / no], auto for no
mintpy.network.excludeIfgIndex = auto #[1:5,25 / no], auto for no, list of ifg index (start from 0)
mintpy.network.referenceFile = auto #[date12_list.txt / ifgramStack.h5 / no], auto for no

Expand Down
1 change: 1 addition & 0 deletions src/mintpy/defaults/smallbaselineApp_auto.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mintpy.network.connNumMax = no
mintpy.network.startDate = no
mintpy.network.endDate = no
mintpy.network.excludeDate = no
mintpy.network.excludeDate12 = no
mintpy.network.excludeIfgIndex = no
mintpy.network.referenceFile = no

Expand Down
9 changes: 9 additions & 0 deletions src/mintpy/modify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ def get_date12_to_drop(inps):
for ifg_idx, date12 in zip(inps.excludeIfgIndex, tempList):
print(f'{ifg_idx} : {date12}')

# excludeDate12
if inps.excludeDate12:
tempList = [i for i in inps.excludeDate12 if i in date12ListAll]
date12_to_drop += tempList
print('--------------------------------------------------')
print(f'Drop ifgrams with the following date12: {len(tempList)}')
for date12 in tempList:
print(date12)

# excludeDate
if inps.excludeDate:
tempList = [i for i in date12ListAll if any(j in inps.excludeDate for j in i.split('_'))]
Expand Down

0 comments on commit 502bfa1

Please sign in to comment.