def compute(dataobj_list, offsetobj_list, eqobj_list, fit_table, grace_dir,start_time_infl, end_time_infl,start_time_velo, end_time_velo, seasonal_type, N, Wn): # Initialize output objects noeq_objects = []; east_filt=[]; north_filt=[]; vert_filt=[]; east_inf_time=[]; north_inf_time=[]; vert_inf_time=[]; east_change=[]; north_change=[]; vert_change=[]; for i in range(len(dataobj_list)): # Remove the earthquakes and offsets newobj=offsets.remove_antenna_offsets(dataobj_list[i], offsetobj_list[i]); newobj=offsets.remove_earthquakes(newobj,eqobj_list[i]); newobj=gps_ts_functions.remove_outliers(newobj,15); # 15mm horizontal outliers newobj=gps_seasonal_removals.make_detrended_ts(newobj, 1, seasonal_type, fit_table, grace_dir); # can remove seasonals a few ways noeq_objects.append(newobj); print(dataobj_list[i].name); # Get the inflection points in the timeseries float_dtarray = gps_ts_functions.get_float_times(newobj.dtarray); [east_filtered, e_inflection_time, echange]=inflection_with_butterworth(newobj.dtarray, float_dtarray, newobj.dE, N, Wn, start_time_infl, end_time_infl,start_time_velo, end_time_velo); [north_filtered, n_inflection_time, nchange]=inflection_with_butterworth(newobj.dtarray, float_dtarray, newobj.dN, N, Wn, start_time_infl, end_time_infl,start_time_velo, end_time_velo); [vert_filtered, v_inflection_time, vchange]=inflection_with_butterworth(newobj.dtarray, float_dtarray, newobj.dU, N, Wn, start_time_infl, end_time_infl,start_time_velo, end_time_velo); east_filt.append(east_filtered); north_filt.append(north_filtered); vert_filt.append(vert_filtered); east_inf_time.append(e_inflection_time); north_inf_time.append(n_inflection_time); vert_inf_time.append(v_inflection_time); east_change.append(echange); north_change.append(nchange); vert_change.append(vchange); return [noeq_objects, east_filt, north_filt, vert_filt, east_inf_time, north_inf_time, vert_inf_time, east_change, north_change, vert_change];
def compute(myData, offset_obj, eq_obj, outliers_def, outdir): for i in range(len(myData)): newData = myData[i] newData = offsets.remove_antenna_offsets(newData, offset_obj[i]) newData = gps_ts_functions.remove_outliers(newData, outliers_def) newData = offsets.remove_earthquakes(newData, eq_obj[i]) stl_filt = gps_seasonal_removals.make_detrended_ts(newData, 1, 'stl') outputs(stl_filt, outdir) return
def get_detrended_gps_station(station_name): datasource = 'pbo' [newData, offset_obj, eq_obj] = gps_input_pipeline.get_station_data(station_name, datasource) newData = offsets.remove_antenna_offsets(newData, offset_obj) newData = gps_ts_functions.remove_outliers(newData, 5) # mm for outliers newData = offsets.remove_earthquakes(newData, eq_obj) trend_out = gps_seasonal_removals.make_detrended_ts(newData, 1, 'notch') return trend_out
def compute(dataobj_list, offsetobj_list, eqobj_list, distances, data_config_file): latitudes_list = [i.coords[1] for i in dataobj_list] sorted_objects = [x for _, x in sorted(zip(latitudes_list, dataobj_list))] # the raw, sorted data. sorted_offsets = [ x for _, x in sorted(zip(latitudes_list, offsetobj_list)) ] # the raw, sorted data. sorted_eqs = [x for _, x in sorted(zip(latitudes_list, eqobj_list))] # the raw, sorted data. sorted_distances = [x for _, x in sorted(zip(latitudes_list, distances))] # the sorted distances. detrended_objects = [] no_offset_objects = [] no_offsets_no_trends = [] no_offsets_no_trends_no_seasons = [] # Detrended objects (or objects with trends and no offsets; depends on what you want.) for i in range(len(sorted_objects)): newobj = gps_seasonal_removals.make_detrended_ts( sorted_objects[i], 0, 'lssq', data_config_file) detrended_objects.append(newobj) # still has offsets, doesn't have trends newobj = offsets.remove_offsets(sorted_objects[i], sorted_offsets[i]) newobj = offsets.remove_offsets(newobj, sorted_eqs[i]) no_offset_objects.append(newobj) # still has trends, doesn't have offsets # Objects with no earthquakes or seasonals for i in range(len(dataobj_list)): # Remove the steps earthquakes newobj = offsets.remove_offsets(sorted_objects[i], sorted_offsets[i]) newobj = offsets.remove_offsets(newobj, sorted_eqs[i]) newobj = gps_ts_functions.remove_outliers(newobj, 20) # 20mm outlier definition # The detrended TS without earthquakes stage1obj = gps_seasonal_removals.make_detrended_ts( newobj, 0, 'lssq', data_config_file) no_offsets_no_trends.append(stage1obj) # The detrended TS without earthquakes or seasonals stage2obj = gps_seasonal_removals.make_detrended_ts( stage1obj, 1, 'lssq', data_config_file) no_offsets_no_trends_no_seasons.append(stage2obj) return [ detrended_objects, no_offset_objects, no_offsets_no_trends, no_offsets_no_trends_no_seasons, sorted_distances ]
def compute(myData, offset_obj, eq_obj, MyParams): newData = myData if MyParams.offsets_remove == 1: # First step: remove offsets and earthquakes newData = offsets.remove_antenna_offsets(newData, offset_obj) if MyParams.outliers_remove == 1: # Second step: remove outliers newData = gps_ts_functions.remove_outliers(newData, MyParams.outliers_def) if MyParams.earthquakes_remove == 1: newData = offsets.remove_earthquakes(newData, eq_obj) trend_out = gps_seasonal_removals.make_detrended_ts( newData, MyParams.seasonals_remove, MyParams.seasonals_type, MyParams.fit_table, MyParams.grace_dir) return [newData, trend_out]
def compute(myData, offset_obj, eq_obj, MyParams, starttime, endtime): if starttime is None: starttime = myData.dtarray[0] if endtime is None: endtime = myData.dtarray[-1] newData = gps_ts_functions.impose_time_limits(myData, starttime, endtime) if MyParams.offsets_remove == 1: # Remove offsets and antenna changes newData = offsets.remove_offsets(newData, offset_obj) if MyParams.outliers_remove == 1: # Remove outliers newData = gps_ts_functions.remove_outliers(newData, MyParams.outliers_def) if MyParams.earthquakes_remove == 1: # Remove earthquakes newData = offsets.remove_offsets(newData, eq_obj) trend_out = gps_seasonal_removals.make_detrended_ts( newData, MyParams.seasonals_remove, MyParams.seasonals_type, MyParams.data_config_file) return [newData, trend_out]
def compute(myData, offset_obj, eq_obj, MyParams): newData=myData; if MyParams.offsets_remove==1: # First step: remove offsets and earthquakes newData=offsets.remove_antenna_offsets(newData, offset_obj); if MyParams.outliers_remove==1: # Second step: remove outliers newData=gps_ts_functions.remove_outliers(newData, MyParams.outliers_def); if MyParams.earthquakes_remove==1: newData=offsets.remove_earthquakes(newData, eq_obj); # A few different types of seasonal removal. notrend=gps_seasonal_removals.make_detrended_ts(newData, 0, 'lssq'); lssq_fit=gps_seasonal_removals.make_detrended_ts(newData, 1, 'lssq'); notch_filt=gps_seasonal_removals.make_detrended_ts(newData, 1, 'notch'); grace_filt=gps_seasonal_removals.make_detrended_ts(newData, 1, 'grace'); stl_filt=gps_seasonal_removals.make_detrended_ts(newData, 1, 'stl'); # stl_filt=gps_seasonal_removals.make_detrended_ts(newData, 1, 'lssq'); return [notrend, lssq_fit, notch_filt, grace_filt, stl_filt];
def read_station_ts(gps_bbox, gps_reference, remove_coseismic=0): """A reading function specific to Brawley right now. """ blacklist = [] network = 'pbo' station_names, _, _ = stations_within_radius.get_stations_within_box( gnss_object.gps_data_config_file, coord_box=gps_bbox, network=network) print(station_names) [dataobj_list, offsetobj_list, eqobj_list, _] = \ gps_input_pipeline.multi_station_inputs(station_names, blacklist, network, "NA", gnss_object.gps_data_config_file) # Importing BRAW [myData, offset_obj, eq_obj ] = gps_input_pipeline.get_station_data("BRAW", "unr", gnss_object.gps_data_config_file, refframe="NA") myData = gps_ts_functions.impose_time_limits( myData, dt.datetime.strptime("20080505", "%Y%m%d"), dt.datetime.strptime("20200101", "%Y%m%d")) dataobj_list.append(myData) offsetobj_list.append(offset_obj) eqobj_list.append(eq_obj) # Now we are doing a bit of adjustments, for seasonal corrections and base station. cleaned_objects = [] for i in range(len(dataobj_list)): one_object = dataobj_list[i] newobj = offsets.remove_offsets(one_object, offsetobj_list[i]) # will remove antenna offsets from everything if newobj.name == 'BRAW': newobj = gps_seasonal_removals.make_detrended_ts( newobj, seasonals_remove=1, seasonals_type="lssq", data_config_file=gnss_object.gps_data_config_file, remove_trend=0) else: newobj = gps_seasonal_removals.make_detrended_ts( newobj, seasonals_remove=1, seasonals_type="nldas", data_config_file=gnss_object.gps_data_config_file, remove_trend=0) if remove_coseismic: print("Removing coseismic offsets") newobj = offsets.remove_offsets(newobj, eqobj_list[i]) newobj = gps_ts_functions.remove_outliers(newobj, 20) # 20mm outlier definition # Here we detrend using pre-2010 velocities, # assuming tectonic strain accumulation won't contribute to geothermal field deformation. # Remove the postseismic by the Hines model endtime = dt.datetime.strptime("2010-04-01", "%Y-%m-%d") [east_slope, north_slope, vert_slope, _, _, _] = gps_ts_functions.get_slope(newobj, endtime=endtime, missing_fraction=0.2) east_params = [east_slope, 0, 0, 0, 0] north_params = [north_slope, 0, 0, 0, 0] vert_params = [vert_slope, 0, 0, 0, 0] newobj = gps_postseismic_remove.remove_by_model( newobj, gnss_object.gps_data_config_file) # This will actually remove the coseismic offset if within the window. newobj = gps_ts_functions.detrend_data_by_value( newobj, east_params, north_params, vert_params) cleaned_objects.append(newobj) # Subtracting the reference GPS station. ref_dataobjlist = [] reference_station = [ x for x in cleaned_objects if x.name == gps_reference ][0] for one_object in cleaned_objects: refobj = gps_ts_functions.get_referenced_data(one_object, reference_station) ref_dataobjlist.append(refobj) return ref_dataobjlist