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

Export supplemental gps CSV file #952

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions src/mintpy/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# from mintpy.utils import plot as pp


import csv
import datetime as dt
import os
import warnings
Expand Down Expand Up @@ -1178,6 +1179,19 @@ def plot_gps(ax, SNWE, inps, metadata=dict(), print_msg=True):
redo=inps.gps_redo,
)

# create CSV reflecting plotting changes imposed on input GPS data
# read GPS velocity from CSV file
csv_file = f'gps_{inps.gps_component}.csv'
vprint(f'write rereferenced GPS observations to file: {csv_file}')
og_csv = os.path.join(os.path.dirname(metadata['FILE_PATH']),
os.path.basename(csv_file))
update_csv = os.path.join(os.path.dirname(metadata['FILE_PATH']),
'reref_' + os.path.basename(csv_file))
col_names = ['Site', 'Lon', 'Lat', 'Displacement', 'Velocity']
num_col = len(col_names)
col_types = ['U10'] + ['f8'] * (num_col - 1)
fc = np.genfromtxt(og_csv, dtype=col_types, delimiter=',', names=True)

# reference GPS
if inps.ref_gps_site:
ref_ind = site_names.tolist().index(inps.ref_gps_site)
Expand All @@ -1188,8 +1202,23 @@ def plot_gps(ax, SNWE, inps, metadata=dict(), print_msg=True):
if not np.isnan(ref_val):
site_obs -= ref_val

# update CSV values
fc[col_names[-1]] -= fc[col_names[-1]][ref_ind]
fc[col_names[-2]] -= fc[col_names[-2]][ref_ind]

# scale to the same unit as InSAR
site_obs *= unit_fac
fc[col_names[-1]] *= unit_fac
fc[col_names[-2]] *= unit_fac

# write updated CSV file
data_list_update = []
for i in fc:
data_list_update.append(i)
with open(update_csv, 'w') as fc2:
fcw = csv.writer(fc2)
fcw.writerow(col_names)
fcw.writerows(data_list_update)

# exclude sites
if inps.ex_gps_sites:
Expand Down