Skip to content

Commit

Permalink
Merge branch 'insarlab:main' into add_diff_resampling
Browse files Browse the repository at this point in the history
  • Loading branch information
eedyyidi authored Nov 21, 2024
2 parents 699bf0b + c7e77cc commit a93ffea
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
rev: "v5.0.0"
hooks:
- id: check-added-large-files
args: ['--maxkb=20']
Expand Down Expand Up @@ -36,7 +36,7 @@ repos:
'--combine-as']

- repo: https://github.com/asottile/pyupgrade
rev: "v3.17.0"
rev: "v3.19.0"
hooks:
- id: pyupgrade
name: modernize python
Expand Down
38 changes: 32 additions & 6 deletions docs/dir_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ $DATA_DIR/GalapagosSenDT128
│   ├── 20141213_20141225
│   │   └── 20141213_20141225.txt
│   └── ...
├── reference
│ ├── data.rsc #generated by prep_isce.py
│   ├── IW1
│   ├── IW1.xml
│   ├── IW2
│   └── IW2.xml
├── ion
│   ├── 20141213_20141225
| │   ├── ion_cal
| | | ├── filt.ion
| | | ├── filt.ion.vrt
| | | ├── filt.ion.xml
| | | ├── raw_no_projection.cor
| | | ├── raw_no_projection.cor.vrt
| | | ├── raw_no_projection.cor.xml
| | | ├── ...
| | └── ...
| ├── 20141213_20150307
| └── ...
├── ion_dates
| ├── 20141213.ion
| ├── 20141213.ion.vrt
| ├── 20141213.ion.xml
| └── ...
├── merged
│   ├── geom_reference
│   │   ├── hgt.rdr
Expand Down Expand Up @@ -55,6 +67,12 @@ $DATA_DIR/GalapagosSenDT128
│   │   ├── ...
│   ├── 20141213_20150307
│ └── ...
├── reference
│ ├── data.rsc #generated by prep_isce.py
│   ├── IW1
│   ├── IW1.xml
│   ├── IW2
│   └── IW2.xml
├── secondarys
│ ├── 20141225
│ │   ├── IW1
Expand All @@ -78,6 +96,9 @@ mintpy.load.baselineDir = $DATA_DIR/GalapagosSenDT128/baselines
mintpy.load.unwFile = $DATA_DIR/GalapagosSenDT128/merged/interferograms/*/filt_*.unw
mintpy.load.corFile = $DATA_DIR/GalapagosSenDT128/merged/interferograms/*/filt_*.cor
mintpy.load.connCompFile = $DATA_DIR/GalapagosSenDT128/merged/interferograms/*/filt_*.unw.conncomp
##---------ionosphere stack (optional):
mintpy.load.ionUnwFile = $DATA_DIR/GalapagosSenDT128/ion/*/ion_cal/filt.ion
mintpy.load.ionCorFile = $DATA_DIR/GalapagosSenDT128/ion/*/ion_cal/raw_no_projection.cor
##---------geometry datasets:
mintpy.load.demFile = $DATA_DIR/GalapagosSenDT128/merged/geom_reference/hgt.rdr
mintpy.load.lookupYFile = $DATA_DIR/GalapagosSenDT128/merged/geom_reference/lat.rdr
Expand Down Expand Up @@ -187,6 +208,8 @@ mintpy.load.baselineDir = $DATA_DIR/KirishimaAlosAT424/baselines
mintpy.load.unwFile = $DATA_DIR/KirishimaAlosAT424/Igrams/*/filt_*.unw
mintpy.load.corFile = $DATA_DIR/KirishimaAlosAT424/Igrams/*/filt_*.cor
mintpy.load.connCompFile = $DATA_DIR/KirishimaAlosAT424/Igrams/*/filt_*.unw.conncomp
##---------ionosphere stack (optional):
mintpy.load.ionUnwFile = $DATA_DIR/KirishimaAlosAT424/ionosphere/*/iono*.filt
##---------geometry datasets:
mintpy.load.demFile = $DATA_DIR/KirishimaAlosAT424/geom_reference/hgt.rdr
mintpy.load.lookupYFile = $DATA_DIR/KirishimaAlosAT424/geom_reference/lat.rdr
Expand Down Expand Up @@ -294,6 +317,9 @@ mintpy.load.baselineDir = $DATA_DIR/NCalAlos2DT169/baseline
mintpy.load.unwFile = $DATA_DIR/NCalAlos2DT169/pairs/*-*/insar/filt_*-*_5rlks_28alks.unw
mintpy.load.corFile = $DATA_DIR/NCalAlos2DT169/pairs/*-*/insar/*-*_5rlks_28alks.cor
mintpy.load.connCompFile = $DATA_DIR/NCalAlos2DT169/pairs/*-*/insar/filt_*-*_5rlks_28alks.unw.conncomp
##---------ionosphere stack (optional):
mintpy.load.ionUnwFile = $DATA_DIR/NCalAlos2DT169/pairs_ion/*-*/ion/ion_cal/filt_ion_*.ion
mintpy.load.ionCorFile = $DATA_DIR/NCalAlos2DT169/pairs_ion/*-*/ion/ion_cal/diff_*.cor
##---------geometry datasets:
mintpy.load.demFile = $DATA_DIR/NCalAlos2DT169/dates_res*/150408/insar/*_5rlks_28alks.hgt
mintpy.load.lookupYFile = $DATA_DIR/NCalAlos2DT169/dates_res*/150408/insar/*_5rlks_28alks.lat
Expand Down
2 changes: 1 addition & 1 deletion docs/google_earth.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ MintPy use [pyKML](https://pythonhosted.org/pykml/) to generate KMZ (Keyhole Mar

### 1. Displacement time-series ###

`save_kmz_timeseries.py` takes 3D displacement time-series file and outputs a KMZ file with interactive time-seires plot.
`save_kmz_timeseries.py` takes 3D displacement time-series file and outputs a KMZ file with interactive time-series plot.

<p align="center">
<img src="https://insarlab.github.io/figs/docs/mintpy/GoogleEarth-FernandinaSenD128-TS.jpg">
Expand Down
5 changes: 4 additions & 1 deletion src/mintpy/cli/modify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ def cmd_line_parse(iargs=None):
inps.excludeIfgIndex = read_input_index_list(inps.excludeIfgIndex, stackFile=inps.file)

# check: --ex-date(12) options
# and ignore , in the inputs
if inps.excludeDate:
inps.exlcudeDate = ptime.yyyymmdd(inps.excludeDate)
inps.excludeDate = ' '.join(inps.excludeDate).replace(',', ' ').split()
inps.excludeDate = ptime.yyyymmdd(inps.excludeDate)
if inps.excludeDate12:
inps.excludeDat12e = ' '.join(inps.excludeDate12).replace(',', ' ').split()
inps.excludeDate12 = ptime.yyyymmdd_date12(inps.excludeDate12)

# check: -t / --template option
Expand Down
2 changes: 1 addition & 1 deletion src/mintpy/defaults/mintpy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobqueue:
death-timeout: 60 # Number of seconds to wait if a worker can not find a scheduler
local-directory: null # Location of fast local storage like /scratch or $TMPDIR

# LSF resource manager options
# Slurm resource manager options
shebang: "#!/usr/bin/env bash"
queue: null
project: null
Expand Down
19 changes: 15 additions & 4 deletions src/mintpy/objects/gnss.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def search_gnss(SNWE, start_date=None, end_date=None, source='UNR', site_list_fi

# ensure that site data formatting is consistent
sites['site'] = np.array([site.upper() for site in sites['site']])
sites['lon'][sites['lon'] > 180] -= 360 # ensure lon values in (-180, 180]
# ensure longitude values in (-180, 180]
sites['lon'] = ut.standardize_longitude(sites['lon'], limit='-180to180')
vprint(f'load {len(sites["site"]):d} GNSS sites with fields: {" ".join(sites.keys())}')

# limit in space
Expand Down Expand Up @@ -867,6 +868,9 @@ def get_site_lat_lon(self, print_msg=False) -> (float, float):

data = np.loadtxt(self.file, dtype=bytes, skiprows=1, max_rows=10)
self.site_lat, self.site_lon = data[0, 20:22].astype(float)
# ensure longitude in the range of (-180, 180]
self.site_lon = ut.standardize_longitude(self.site_lon, limit='-180to180')

return self.site_lat, self.site_lon


Expand Down Expand Up @@ -987,8 +991,9 @@ def get_site_lat_lon(self, print_msg=False) -> (float, float):
# longitude
lon_line = [x for x in lines if x.startswith('# East Longitude')][0].strip('\n')
self.site_lon = float(lon_line.split()[-1])
# ensure longitude in the range of (-180, 180]
self.site_lon -= 0 if self.site_lon <= 180 else 360

# ensure longitude in the range of (-180, 180]
self.site_lon = ut.standardize_longitude(self.site_lon, limit='-180to180')

return self.site_lat, self.site_lon

Expand Down Expand Up @@ -1094,6 +1099,8 @@ def get_site_lat_lon(self, print_msg=False) -> (float, float):
# format
self.site_lat = float(site_lat)
self.site_lon = float(site_lon)
# ensure longitude in the range of (-180, 180]
self.site_lon = ut.standardize_longitude(self.site_lon, limit='-180to180')

if print_msg == True:
print(f'\t{self.site_lat:f}, {self.site_lon:f}')
Expand Down Expand Up @@ -1185,7 +1192,11 @@ def get_site_lat_lon(self, print_msg=False) -> (str, str):
"""
sites = read_GENERIC_site_list('GenericList.txt')
ind = sites['site'].tolist().index(self.site)
return sites['lat'][ind], sites['lon'][ind]
site_lat, site_lon = sites['lat'][ind], sites['lon'][ind]
# ensure longitude in the range of (-180, 180]
site_lon = ut.standardize_longitude(site_lon, limit='-180to180')

return site_lat, site_lon


def read_displacement(self, start_date=None, end_date=None, print_msg=True, display=False):
Expand Down
2 changes: 1 addition & 1 deletion src/mintpy/utils/readfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def read_binary_file(fname, datasetName=None, box=None, xstep=1, ystep=1):
cpx_band = 'magnitude'

elif fext in ['.mli', '.rmli']:
byte_order = 'little-endian'
byte_order = 'little-endian' # big-endian

# SNAP
# BEAM-DIMAP data format
Expand Down
24 changes: 24 additions & 0 deletions src/mintpy/utils/utils0.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,30 @@ def touch(fname_list, times=None):


################################## Coordinate ##########################################
def standardize_longitude(lon, limit='-180to180'):
"""Normalize the longitude value range into (-180, 180] or [0, 360).
Parameters: lon - float / np.ndarray, longitude in degree
limit - str, -180to180 or 0to360
Returns: lon - float / np.ndarray, longitude in degree
"""
lon = np.asarray(lon)

# ensure data within (-180, 360)
lon = np.where(lon >= 360, lon - 360, lon)
lon = np.where(lon <= -180, lon + 360, lon)

# range option 1: ensure data within (-180, 180]
if limit == '-180to180':
lon = np.where(lon > 180, lon - 360, lon)

# range option 2: ensure data within [0, 360)
elif limit == '0to360' and np.nanmin(lon) < 0:
lon = np.where(lon < 0, lon + 360, lon)

return float(lon) if np.isscalar(lon) else lon


def utm_zone2epsg_code(utm_zone):
"""Convert UTM Zone string to EPSG code.
Expand Down
10 changes: 8 additions & 2 deletions src/mintpy/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ def check_map_projection(inps, metadata, print_msg=True):
msg = 'initiate cartopy map projection: '
if inps.coord_unit.startswith('deg'):
inps.map_proj_obj = ccrs.PlateCarree()
vprint(msg + 'PlateCarree')
print(msg + 'PlateCarree')

elif inps.coord_unit.startswith('meter'):
if 'UTM_ZONE' in metadata.keys():
utm_zone = metadata['UTM_ZONE']
inps.map_proj_obj = ccrs.UTM(utm_zone)
vprint(msg + f'UTM zone {utm_zone}')
print(msg + f'UTM zone {utm_zone}')

# check --lalo-label (works for PlateCarree only)
if inps.lalo_label:
Expand Down Expand Up @@ -1652,9 +1652,15 @@ def plot(self):
no_data_val = readfile.get_no_data_value(self.file)
if self.no_data_value is not None:
vprint(f'masking pixels with NO_DATA_VALUE of {self.no_data_value}')
# convert integer to floating to enable masking with nan
if np.issubdtype(data.dtype, np.integer):
data = np.array(data, np.float32)
data[data == self.no_data_value] = np.nan
elif no_data_val is not None and not np.isnan(no_data_val):
vprint(f'masking pixels with NO_DATA_VALUE of {no_data_val}')
# convert integer to floating to enable masking with nan
if np.issubdtype(data.dtype, np.integer):
data = np.array(data, np.float32)
data[data == no_data_val] = np.nan

# update/save mask info
Expand Down

0 comments on commit a93ffea

Please sign in to comment.