コード例 #1
0
def remove_by_model(Data0, data_config_file):
    # Right now configured for the Hines data.
    starttime1 = dt.datetime.strptime("20100403", "%Y%m%d");
    endtime1 = dt.datetime.strptime("20100405", "%Y%m%d");
    starttime2 = dt.datetime.strptime("20200328", "%Y%m%d");
    endtime2 = dt.datetime.strptime("20200330", "%Y%m%d");

    # Input Hines data.
    model_data = get_station_hines(Data0.name, data_config_file);

    if not model_data:  # if None
        return Data0;
    if len(Data0.dtarray) == 0:  # if empty
        return Data0;

    if model_data.dtarray[-1] < Data0.dtarray[-1]:
        print("\nWARNING! Trying to use a short postseismic model to fix a long GNSS time series.");
        print("PROBLEMS MAY OCCUR- tread carefully!!\n\n");

    # These will be the same size.
    Data0, model = gps_ts_functions.pair_gps_model_keeping_gps(Data0, model_data);
    # pair_gps_model_keeping_gps leaves data outside of the model timespan
    # Data0, model = gps_ts_functions.pair_gps_model(Data0, model_data);  # removes data outside of the model timespan.

    # Subtract the model from the data.
    dtarray, dE_gps, dN_gps, dU_gps = [], [], [], [];
    Se_gps, Sn_gps, Su_gps = [], [], [];
    for i in range(len(Data0.dtarray)):
        dtarray.append(Data0.dtarray[i]);
        dE_gps.append(Data0.dE[i] - model.dE[i]);
        dN_gps.append(Data0.dN[i] - model.dN[i]);
        dU_gps.append(Data0.dU[i] - model.dU[i]);
        Se_gps.append(Data0.Se[i]);
        Sn_gps.append(Data0.Sn[i]);
        Su_gps.append(Data0.Su[i]);

    # In this method, we correct for offsets at the beginning and end of the modeled time series.
    interval1 = [starttime1, endtime1];
    east_offset1 = offsets.fit_single_offset(dtarray, dE_gps, interval1, 20);
    north_offset1 = offsets.fit_single_offset(dtarray, dN_gps, interval1, 20);
    vert_offset1 = offsets.fit_single_offset(dtarray, dU_gps, interval1, 20);
    interval2 = [starttime2, endtime2];
    east_offset2 = offsets.fit_single_offset(dtarray, dE_gps, interval2, 20);
    north_offset2 = offsets.fit_single_offset(dtarray, dN_gps, interval2, 20);
    vert_offset2 = offsets.fit_single_offset(dtarray, dU_gps, interval2, 20);

    offsets_obj = offsets.Offsets(e_offsets=[east_offset1, east_offset2],
                                  n_offsets=[north_offset1, north_offset2], u_offsets=[vert_offset1, vert_offset2],
                                  evdts=[starttime1, starttime2]);

    corrected_data = gps_io_functions.Timeseries(name=Data0.name, coords=Data0.coords, dtarray=dtarray, dE=dE_gps,
                                                 dN=dN_gps, dU=dU_gps, Se=Se_gps, Sn=Sn_gps, Su=Su_gps,
                                                 EQtimes=Data0.EQtimes);
    corrected_data = offsets.remove_offsets(corrected_data, offsets_obj);
    return corrected_data;
コード例 #2
0
def get_pbo_offsets(station, offsets_dir):
    print("Offset table for station %s:" % station)
    try:
        table = subprocess.check_output("grep " + station + " " + offsets_dir +
                                        "cwu*.off",
                                        shell=True)
    except subprocess.CalledProcessError:  # if we have no earthquakes in the event files...
        table = []
    if len(table) > 0:
        table = table.decode()
        # needed when switching to python 3
    print(table)
    [e_offsets, n_offsets, u_offsets, evdts] = parse_antenna_table_pbo(table)
    PBO_offsets = offsets.Offsets(e_offsets=e_offsets,
                                  n_offsets=n_offsets,
                                  u_offsets=u_offsets,
                                  evdts=evdts)
    return PBO_offsets
コード例 #3
0
def get_cwu_earthquakes(station, earthquakes_dir):
    print("Earthquake table for station %s:" % station)
    # Read the offset table
    try:
        table = subprocess.check_output("grep " + station + " " +
                                        earthquakes_dir + "cwu*kalts.evt",
                                        shell=True)
    except subprocess.CalledProcessError:  # if we have no earthquakes in the event files...
        table = []
    if len(table) > 0:
        table = table.decode()
        # needed when switching to python 3
    print(table)
    [e_offsets, n_offsets, u_offsets,
     evdts] = parse_earthquake_table_pbo(table)
    CWU_earthquakes = offsets.Offsets(e_offsets=e_offsets,
                                      n_offsets=n_offsets,
                                      u_offsets=u_offsets,
                                      evdts=evdts)
    return CWU_earthquakes