Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support UAVSAR reading and SET correction #722

Merged
merged 3 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mintpy/ifgram_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ def cmd_line_parse(iargs=None):
inps.outfile = ['timeseries.h5', 'temporalCoherence.h5', 'numInvIfgram.h5']

elif inps.obsDatasetName.startswith('azimuthOffset'):
inps.outfile = ['timeseriesAz.h5', 'residualInvAz.h5', 'numInvOffset.h5']
inps.outfile = ['timeseriesAz.h5', 'residualInvAz.h5', 'numInvOffAz.h5']

elif inps.obsDatasetName.startswith('rangeOffset'):
inps.outfile = ['timeseriesRg.h5', 'residualInvRg.h5', 'numInvOffset.h5']
inps.outfile = ['timeseriesRg.h5', 'residualInvRg.h5', 'numInvOffRg.h5']

elif inps.obsDatasetName.startswith('ion'):
inps.outfile = ['timeseriesIon.h5', 'temporalCoherenceIon.h5', 'numInvIon.h5']
Expand Down Expand Up @@ -711,7 +711,7 @@ def mask_stack_obs(stack_obs, stack_obj, box, mask_ds_name=None, mask_threshold=
msk_snr = np.multiply(msk_data <= mask_threshold * 5, obs_snr >= min_snr)
msk[msk_snr] = 1
if print_msg:
print('keep pixels with {} <= {} and SNR >= {}'.format(mask_ds_name, mask_threshold*5, min_snr))
print('keep pixels with {} <= {} and SNR >= {}'.format(mask_ds_name, mask_threshold*5, min_snr))

else:
raise ValueError('Un-recognized mask dataset name: {}'.format(mask_ds_name))
Expand Down
10 changes: 8 additions & 2 deletions mintpy/objects/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,14 @@ def mark_lat_lon_anomoly(lat, lon):

# parameter 1 - lalo_step (output grid)
if self.lalo_step is None:
self.lalo_step = ((src_lat1 - src_lat0) / (lut_lat.shape[0] - 1),
(src_lon1 - src_lon0) / (lut_lat.shape[1] - 1))
try:
lat_c = (src_lat0 + src_lat1) / 2.
lat_step, lon_step = ut.auto_lat_lon_step_size(self.src_meta, lat_c)
except AttributeError:
lat_step = (src_lat1 - src_lat0) / (lut_lat.shape[0] - 1)
lon_step = (src_lon1 - src_lon0) / (lut_lat.shape[1] - 1)
self.lalo_step = (abs(lat_step) * -1., abs(lon_step))

else:
# ensure lat/lon step sign
self.lalo_step = (abs(self.lalo_step[0]) * -1.,
Expand Down
49 changes: 44 additions & 5 deletions mintpy/prep_isce.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import glob
import argparse
import numpy as np
from mintpy.utils import ptime, readfile, writefile, isce_utils


Expand All @@ -24,8 +25,9 @@
prep_isce.py -m 20120507_slc_crop.xml -g ./geometry #for stripmapApp
prep_isce.py -d "pairs/*-*/insar" -m "pairs/*-*/150408.track.xml" -b baseline -g dates_resampled/150408/insar #for alosStack with 150408 as ref date

# offset stack from topsStack
prep_isce.py -d ./merged/offsets -f filtAz*.off -m ./reference/IW1.xml -b ./baselines -g ./merged/offsets/geom_reference
# offset stack
prep_isce.py -d ./offsets -f *Off*.bip -m ./../reference/IW1.xml -b ./../baselines -g ./offsets/geom_reference #for topsStack
prep_isce.py -d ./offsets -f *Off*.bip -m ./SLC/*/data.dat -b random -g ./geometry #for UAVSAR coregStack
"""

def create_parser():
Expand All @@ -52,7 +54,9 @@ def create_parser():

# geometry
parser.add_argument('-b', '--baseline-dir', dest='baselineDir', type=str, default=None,
help='Directory with baselines ')
help='Directory with baselines.'
'Set "random" to generate baseline with random value from [-10,10].'
'Set "random-100" to generate baseline with random value from [-100,100].')
parser.add_argument('-g', '--geometry-dir', dest='geometryDir', type=str, default=None, required=True,
help='Directory with geometry files ')
parser.add_argument('--geom-files', dest='geometryFiles', type=str, nargs='*',
Expand All @@ -77,6 +81,10 @@ def cmd_line_parse(iargs = None):
else:
raise FileNotFoundError(inps.metaFile)

# random baseline input checking
if inps.baselineDir.lower().startswith('rand'):
inps.baselineDir = inps.baselineDir.lower().replace('_','-')

return inps


Expand Down Expand Up @@ -156,6 +164,27 @@ def prepare_geometry(geom_dir, geom_files=[], metadata=dict(), processor='tops',
return


def gen_random_baseline_timeseries(dset_dir, dset_file, max_bperp=10):
"""Generate a baseline time series with random values.
"""
# list of dates
fnames = glob.glob(os.path.join(dset_dir, '*', dset_file))
date12s = sorted([os.path.basename(os.path.dirname(x)) for x in fnames])
date1s = [x.split('_')[0] for x in date12s]
date2s = [x.split('_')[1] for x in date12s]
date_list = sorted(list(set(date1s + date2s)))

# list of bperp
bperp_list = [0] + np.random.randint(-max_bperp, max_bperp, len(date_list)-1).tolist()

# prepare output
bDict = {}
for date_str, bperp in zip(date_list, bperp_list):
bDict[date_str] = [bperp, bperp]

return bDict


def prepare_stack(inputDir, filePattern, metadata=dict(), baseline_dict=dict(), processor='tops', update_mode=True):
print('preparing RSC file for ', filePattern)
if processor in ['tops', 'stripmap']:
Expand Down Expand Up @@ -221,8 +250,18 @@ def main(iargs=None):
# read baseline info
baseline_dict = {}
if inps.baselineDir:
baseline_dict = isce_utils.read_baseline_timeseries(inps.baselineDir,
processor=inps.processor)
if inps.baselineDir.startswith('rand') and inps.dsetDir and inps.dsetFiles:
if '-' in inps.baselineDir:
max_bperp = float(inps.baselineDir.split('-')[1])
else:
max_bperp = 10
baseline_dict = gen_random_baseline_timeseries(dset_dir=inps.dsetDir,
dset_file=inps.dsetFiles[0],
max_bperp=max_bperp)

else:
baseline_dict = isce_utils.read_baseline_timeseries(inps.baselineDir,
processor=inps.processor)

# prepare metadata for ifgram file
if inps.dsetDir and inps.dsetFiles:
Expand Down
2 changes: 1 addition & 1 deletion mintpy/smallbaselineApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def generate_ifgram_aux_file(self):
dsNames = readfile.get_dataset_list(stack_file)
mask_file = os.path.join(self.workDir, 'maskConnComp.h5')
coh_file = os.path.join(self.workDir, 'avgSpatialCoh.h5')
snr_file = os.path.join(self.workDir, 'avgSpatialSnr.h5')
snr_file = os.path.join(self.workDir, 'avgSpatialSNR.h5')

# 1) generate mask file from the common connected components
if any('phase' in i.lower() for i in dsNames):
Expand Down
18 changes: 13 additions & 5 deletions mintpy/solid_earth_tides.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,31 @@ def get_datetime_list(ts_file, date_wise_acq_time=False):
sensingMid = [dt.datetime.strptime(i, date_str_format) for i in sensingMidStr]

elif date_wise_acq_time and all(os.path.isdir(i) for i in xml_dirs):
# opt 2. read sensingMid in xml files
# opt 2. read sensingMid in xml files [for Sentinel-1 with topsStack]
print('read exact datetime info in XML files from ISCE-2/topsStack results in directory:', proj_dir)
from mintpy.utils import isce_utils
sensingMid = isce_utils.get_sensing_datetime_list(proj_dir, date_list=date_list)[0]

# plot
plot_sensingMid_variation(sensingMid)

elif "T" in date_list[0]:
# opt 3. use the time info in the `date` dataset [as provided by UAVSAR stack]
date_format = ptime.get_date_str_format(date_list[0])
sensingMid = [dt.datetime.strptime(i, date_format) for i in date_list]

else:
# opt 3. use constant time of the day for all acquisitions
msg = 'Use the same time of the day for all acquisitions from CENTER_LINE_UTC\n'
msg += 'With <= 1 min variation for Sentinel-1A/B for example, this simplication has negligible impact on SET calculation.'
print(msg)
# opt 4. use constant time of the day for all acquisitions
atr = readfile.read_attribute(ts_file)
utc_sec = dt.timedelta(seconds=float(atr['CENTER_LINE_UTC']))
sensingMid = [dt.datetime.strptime(i, '%Y%m%d') + utc_sec for i in date_list]

msg = 'Use the same time of the day for all acquisitions from CENTER_LINE_UTC\n'
if atr.get('PLATFORM', 'Unknow').lower().startswith('sen'):
msg += 'With <= 1 min variation for Sentinel-1A/B for example, this simplication has negligible impact on SET calculation.'
print(msg)


return sensingMid


Expand Down
4 changes: 3 additions & 1 deletion mintpy/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,9 @@ def prepare_dem_background(dem, inps=None, print_msg=True):
vmax=inps.shade_max)
dem_shade[np.isnan(dem_shade[:, :, 0])] = np.nan
if print_msg:
print('show shaded relief DEM')
msg = f'show shaded relief DEM [min/max: {inps.shade_min}/{inps.shade_max} m; '
msg += f'exag: {inps.shade_exag}; az/alt deg: {inps.shade_azdeg}/{inps.shade_altdeg}]'
print(msg)

# prepare contour
if inps.disp_dem_contour:
Expand Down
Loading