diff --git a/src/mintpy/spatial_filter.py b/src/mintpy/spatial_filter.py index 0507e67b0..f9a0e96a0 100644 --- a/src/mintpy/spatial_filter.py +++ b/src/mintpy/spatial_filter.py @@ -71,15 +71,17 @@ def filter_data(data, filter_type, filter_par=None): and regional mean results are separate. """ - local_kernel = morphology.disk(filter_par[0], np.float32) - local_kernel = np.pad(local_kernel,filter_par[1] - filter_par[0],mode='constant') + local_kernel = morphology.disk(filter_par[0], dtype=np.float32) + local_kernel = np.pad(local_kernel, pad_width=int(filter_par[1]-filter_par[0]), mode='constant') - regional_kernel = morphology.disk(filter_par[1], np.float32) + regional_kernel = morphology.disk(filter_par[1], dtype=np.float32) regional_kernel[local_kernel == 1] = 0 + # normalize local_kernel /= local_kernel.sum(axis=(0,1)) regional_kernel /= regional_kernel.sum(axis=(0,1)) + # double-difference kernel combined_kernel = regional_kernel - local_kernel data_filt = ndimage.convolve(data, combined_kernel) @@ -107,7 +109,8 @@ def filter_file(fname, ds_names=None, filter_type='lowpass_gaussian', filter_par # Info filter_type = filter_type.lower() atr = readfile.read_attribute(fname) - msg = 'filtering {} file: {} using {} filter'.format(atr['FILE_TYPE'], fname, filter_type) + print(f'input file: {fname}, file type: {atr["FILE_TYPE"]}') + print(f'filter type: {filter_type}') if filter_type.endswith('avg'): if not filter_par: @@ -115,7 +118,7 @@ def filter_file(fname, ds_names=None, filter_type='lowpass_gaussian', filter_par elif isinstance(filter_par, list): filter_par = filter_par[0] filter_par = int(filter_par) - msg += f' with kernel size of {filter_par}' + print(f'filter parameter: kernel size = {filter_par}') elif filter_type.endswith('gaussian'): if not filter_par: @@ -123,14 +126,13 @@ def filter_file(fname, ds_names=None, filter_type='lowpass_gaussian', filter_par elif isinstance(filter_par, list): filter_par = filter_par[0] filter_par = float(filter_par) - msg += f' with sigma of {filter_par:.1f}' + print(f'filter parameter: sigma = {filter_par:.1f}') elif filter_type == 'double_difference': if not filter_par: filter_par = [1, 10] local, regional = int(filter_par[0]), int(filter_par[1]) - msg += f' with local/regional kernel sizes of {local}/{regional}' - print(msg) + print(f'filter parameter: local / regional kernel sizes = {local} / {regional}') # output filename if not fname_out: diff --git a/src/mintpy/utils/isce_utils.py b/src/mintpy/utils/isce_utils.py index d37392434..7765213ea 100644 --- a/src/mintpy/utils/isce_utils.py +++ b/src/mintpy/utils/isce_utils.py @@ -385,10 +385,12 @@ def extract_alosStack_metadata(meta_file, geom_dir): meta['LON_REF3'] = str(data[-1-edge, 0+edge]) meta['LON_REF4'] = str(data[-1-edge, -1-edge]) - los_file = glob.glob(os.path.join(geom_dir, f'*_{rlooks}rlks_{alooks}alks.los'))[0] - data = np.memmap(los_file, dtype='float32', mode='r', shape=(length*2, width))[0:length*2:2, :] - inc_angle = data[int(length/2), int(width/2)] - meta['CENTER_INCIDENCE_ANGLE'] = str(inc_angle) + # CENTER_INCIDENCE_ANGLE is optional + los_files = glob.glob(os.path.join(geom_dir, f'*_{rlooks}rlks_{alooks}alks.los')) + if len(los_files) > 0: + data = np.memmap(los_files[0], dtype='float32', mode='r', shape=(length*2, width))[0:length*2:2, :] + inc_angle = data[int(length/2), int(width/2)] + meta['CENTER_INCIDENCE_ANGLE'] = str(inc_angle) pointingDirection = {'right': -1, 'left' :1} meta['ANTENNA_SIDE'] = str(pointingDirection[track.pointingDirection]) diff --git a/src/mintpy/utils/readfile.py b/src/mintpy/utils/readfile.py index 4a4863ea8..182a6e1e7 100644 --- a/src/mintpy/utils/readfile.py +++ b/src/mintpy/utils/readfile.py @@ -1322,7 +1322,7 @@ def auto_no_data_value(meta): # known file types # isce2: dense offsets from topsApp.py - if processor == 'isce' and fbase.endswith('dense_offsets') and fext == '.bil' and num_band == 2: + if processor == 'isce' and fname.endswith('dense_offsets.bil') and num_band == 2: no_data_value = -10000. else: diff --git a/src/mintpy/utils/writefile.py b/src/mintpy/utils/writefile.py index 2575ece05..3384a84ba 100644 --- a/src/mintpy/utils/writefile.py +++ b/src/mintpy/utils/writefile.py @@ -171,7 +171,8 @@ def write(datasetDict, out_file, metadata=None, ref_file=None, compression=None, data_list = [data_list[0], data_list[0]] meta['BANDS'] = 2 - elif fext in ['.cor', '.hgt']: + elif fext in ['.cor']: + # remove .hgt as it can be float64 in isce2. meta['DATA_TYPE'] = 'float32' meta['INTERLEAVE'] = 'BIL' if meta.get('PROCESSOR', 'isce') == 'roipac':