-
Notifications
You must be signed in to change notification settings - Fork 260
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
Allow GPS
class to work with other image projections
#1079
base: main
Are you sure you want to change the base?
Changes from all commits
082e8ea
70b515a
5563131
2b18f0f
2d64373
4ca6363
c510318
04ae8c8
4874bda
045ea87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,13 @@ | |
import numpy as np | ||
from pyproj import Geod | ||
|
||
from mintpy.objects.coord import coordinate | ||
from mintpy.utils import ptime, readfile, time_func, utils1 as ut | ||
from mintpy.utils import ( | ||
ptime, | ||
readfile, | ||
time_func, | ||
utils0 as ut0, | ||
utils1 as ut, | ||
) | ||
|
||
UNR_SITE_LIST_FILE = 'http://geodesy.unr.edu/NGLStationPages/DataHoldings.txt' | ||
|
||
|
@@ -457,7 +462,7 @@ def displacement_enu2los(self, inc_angle:float, az_angle:float, gps_comp='enu2lo | |
"""Convert displacement in ENU to LOS direction. | ||
|
||
Parameters: inc_angle - float, LOS incidence angle in degree | ||
az_angle - float, LOS aziuth angle in degree | ||
az_angle - float, LOS azimuth angle in degree | ||
from the north, defined as positive in clock-wise direction | ||
gps_comp - str, GPS components used to convert to LOS direction | ||
horz_az_angle - float, fault azimuth angle used to convert horizontal to fault-parallel | ||
|
@@ -493,12 +498,8 @@ def get_los_geometry(self, geom_obj, print_msg=False): | |
if isinstance(geom_obj, str): | ||
# geometry file | ||
atr = readfile.read_attribute(geom_obj) | ||
coord = coordinate(atr, lookup_file=geom_obj) | ||
y, x = coord.geo2radar(lat, lon, print_msg=print_msg)[0:2] | ||
# check against image boundary | ||
y = max(0, y); y = min(int(atr['LENGTH'])-1, y) | ||
x = max(0, x); x = min(int(atr['WIDTH'])-1, x) | ||
box = (x, y, x+1, y+1) | ||
row, col = ut0.get_image_rowcol(atr, lat=lat, lon=lon) | ||
box = (col, row, col+1, row+1) | ||
inc_angle = readfile.read(geom_obj, datasetName='incidenceAngle', box=box, print_msg=print_msg)[0][0,0] | ||
az_angle = readfile.read(geom_obj, datasetName='azimuthAngle', box=box, print_msg=print_msg)[0][0,0] | ||
|
||
|
@@ -508,10 +509,30 @@ def get_los_geometry(self, geom_obj, print_msg=False): | |
az_angle = ut.heading2azimuth_angle(float(geom_obj['HEADING'])) | ||
|
||
else: | ||
raise ValueError(f'input geom_obj is neight str nor dict: {geom_obj}') | ||
raise ValueError(f'input geom_obj is neither str nor dict: {geom_obj}') | ||
|
||
return inc_angle, az_angle | ||
return inc_angle or np.nan, az_angle or np.nan | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just curious: in this syntax, when will the |
||
|
||
def get_image_values(self, filename, datasetName=None, pad: int = 0, print_msg=False): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is not used currently anywhere, so it's fine with me. For your information: from my experience, given a GNSS site, we either interpolate InSAR or average multiple InSAR pixels around the GNSS site. Personally, I have not gotten a good result yet by comparing GNSS and its nearest InSAR pixel yet. |
||
"""Read the value from `filename` at the pixel nearest to the GPS station. | ||
|
||
Parameters: atr - dict, mintpy attributes that includes "EPSG" | ||
datasetName - str, If `filename` is an HDF5 file, dataset to read from | ||
pad - int, default = 0. Number of pixels of padding to read around | ||
the nearest pixel. | ||
`pad=0` only reads the closes pixel. | ||
`pad=1` will return a 3x3 ndarray of image values. | ||
Returns: scalar, (or ndarray if `pad > 1`) | ||
The values closes to the GPS station in `filename`. | ||
""" | ||
lat, lon = self.get_stat_lat_lon(print_msg=print_msg) | ||
|
||
atr = readfile.read_attribute(filename) | ||
row, col = ut0.get_image_rowcol(atr, lat=lat, lon=lon) | ||
|
||
box = (col - pad, row - pad, col + pad + 1, row + pad + 1) | ||
values = readfile.read(filename, datasetName=datasetName, box=box, print_msg=print_msg)[0] | ||
return np.squeeze(values) | ||
|
||
def read_gps_los_displacement(self, geom_obj, start_date=None, end_date=None, ref_site=None, | ||
gps_comp='enu2los', horz_az_angle=-90., print_msg=False): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utils0
is imported withinutil1
already, so we don't need an extrautils0 as ut0
here. This is a messy part in mintpy, and the current logic is: 1)utils1
imports everything fromutils0
; 2)utils
imports everything fromutils0
andutils1
.