def plot_grace(station_name, filename, out_dir): grace_ts = gps_io_functions.read_grace(filename) plt.figure() plt.plot_date(grace_ts.dtarray, grace_ts.u, '-b') plt.plot_date(grace_ts.dtarray, grace_ts.v, '-g') plt.plot_date(grace_ts.dtarray, grace_ts.w, '-r') plt.legend(['east', 'north', 'vertical']) plt.grid(True) plt.xlabel('Time') plt.ylabel('Displacement (mm)') plt.savefig(out_dir + station_name + "_gracets.eps") return
def remove_seasonals_by_GRACE(Data, grace_dir): # Here we use pre-computed GRACE load model time series to correct the GPS time series. # We recognize that the horizontals will be bad, and that the resolution of GRACE is coarse. # For these reasons, this is not an important part of the analysis. # Read and interpolate GRACE loading model # Subtract the GRACE model # Remove a trend from the GPS data # Return the object. filename = grace_dir + "scaled_" + Data.name + "_PREM_model_ts.txt"; if not os.path.isfile(filename): print("Error! GRACE not found for %s" % Data.name); print("Returning placeholder object."); wimpyObj = get_wimpy_object(Data) return wimpyObj, wimpyObj; # If the station has been pre-computed with GRACE: Data = gps_ts_functions.remove_nans(Data); [grace_model] = gps_io_functions.read_grace(filename); my_paired_ts = grace_ts_functions.pair_GPSGRACE(Data, grace_model); decyear = gps_ts_functions.get_float_times(my_paired_ts.dtarray); # Subtract the GRACE object dE_filt, dN_filt, dU_filt = [], [], []; for i in range(len(my_paired_ts.dtarray)): dE_filt.append(my_paired_ts.east[i] - my_paired_ts.u[i]); dN_filt.append(my_paired_ts.north[i] - my_paired_ts.v[i]); dU_filt.append(my_paired_ts.vert[i] - my_paired_ts.w[i]); # A Simple detrending dE_detrended = np.zeros(np.shape(decyear)); dN_detrended = np.zeros(np.shape(decyear)); dU_detrended = np.zeros(np.shape(decyear)); east_coef = np.polyfit(decyear, dE_filt, 1)[0]; for i in range(len(dE_filt)): dE_detrended[i] = dE_filt[i] - east_coef * decyear[i] - (dE_filt[0] - east_coef * decyear[0]); north_coef = np.polyfit(decyear, dN_filt, 1)[0]; for i in range(len(dN_filt)): dN_detrended[i] = (dN_filt[i] - north_coef * decyear[i]) - (dN_filt[0] - north_coef * decyear[0]); vert_coef = np.polyfit(decyear, dU_filt, 1)[0]; for i in range(len(dU_filt)): dU_detrended[i] = (dU_filt[i] - vert_coef * decyear[i]) - (dU_filt[0] - vert_coef * decyear[0]); detrended = gps_io_functions.Timeseries(name=Data.name, coords=Data.coords, dtarray=my_paired_ts.dtarray, dN=dN_detrended, dE=dE_detrended, dU=dU_detrended, Sn=my_paired_ts.N_err, Se=my_paired_ts.E_err, Su=my_paired_ts.V_err, EQtimes=Data.EQtimes); trended = gps_io_functions.Timeseries(name=Data.name, coords=Data.coords, dtarray=my_paired_ts.dtarray, dN=dN_filt, dE=dE_filt, dU=dU_filt, Sn=my_paired_ts.N_err, Se=my_paired_ts.E_err, Su=my_paired_ts.V_err, EQtimes=Data.EQtimes); return detrended, trended; # 0 = successful completion
def get_grace(data_config_file, station): Params = gps_io_functions.read_config_file(data_config_file) filename = Params.grace_dir + "scaled_" + station + "_PREM_model_ts.txt" [myData] = gps_io_functions.read_grace(filename) Offset = offsets.get_empty_offsets() return [myData, Offset, Offset]
def grace_inputs(file_list): dataobj_list = [] for item in file_list: grace_ts = gps_io_functions.read_grace(item) dataobj_list.append(grace_ts) return [dataobj_list]