Пример #1
0
def obspy_fullresp_RESP(input_dics, trace, resp_file, Address, unit='DIS',
                        BP_filter=(0.008, 0.012, 3.0, 4.0), inform='N/N'):
    """
    Instrument correction using dataless seed --->
    equivalent to full response file steps: detrend, demean, taper, filter,
    deconvolution
    :param input_dics:
    :param trace:
    :param resp_file:
    :param Address:
    :param unit:
    :param BP_filter:
    :param inform:
    :return:
    """
    dataless_parser = Parser(resp_file)
    seedresp = {'filename': dataless_parser, 'units': unit}

    try:
        if input_dics['resample_corr']:
            trace = resample_trace(trace,
                                   des_sr=input_dics['resample_corr'],
                                   resample_method=
                                   input_dics['resample_method'])
        trace.detrend('linear')
        trace.simulate(seedresp=seedresp, paz_remove=None, paz_simulate=None,
                       remove_sensitivity=True, simulate_sensitivity=False,
                       water_level=input_dics['water_level'],
                       zero_mean=True, taper=True,
                       taper_fraction=0.05, pre_filt=eval(BP_filter),
                       pitsasim=False, sacsim=True)
        # Remove the following line since we want to keep
        # the units as it is in the stationXML
        # trace.data *= 1.e9
        trace_identity = '%s.%s.%s.%s' % (trace.stats['network'],
                                          trace.stats['station'],
                                          trace.stats['location'],
                                          trace.stats['channel'])
        if input_dics['mseed'] == 'N':
            trace.write(os.path.join(Address, '%s.%s' % (unit.lower(),
                                                         trace_identity)),
                        format='SAC')
        else:
            trace.write(os.path.join(Address, '%s.%s' % (unit.lower(),
                                                         trace_identity)),
                        format='MSEED')

        if unit.lower() == 'dis':
            unit_print = 'displacement'
        elif unit.lower() == 'vel':
            unit_print = 'velocity'
        elif unit.lower() == 'acc':
            unit_print = 'acceleration'
        else:
            unit_print = 'UNKNOWN'
        print '%s -- instrument correction to %s for: %s' \
              % (inform, unit_print, trace_identity)

    except Exception as e:
        print '%s -- %s' % (inform, e)
Пример #2
0
def obspy_fullresp_RESP(input_dics,
                        trace,
                        resp_file,
                        Address,
                        unit='DIS',
                        BP_filter=(0.008, 0.012, 3.0, 4.0),
                        inform='N/N'):
    """
    Instrument correction using dataless seed --->
    equivalent to full response file steps: detrend, demean, taper, filter,
    deconvolution
    :param input_dics:
    :param trace:
    :param resp_file:
    :param Address:
    :param unit:
    :param BP_filter:
    :param inform:
    :return:
    """
    dataless_parser = Parser(resp_file)
    seedresp = {'filename': dataless_parser, 'units': unit}

    try:
        if input_dics['resample_corr']:
            trace = resample_trace(
                trace,
                des_sr=input_dics['resample_corr'],
                resample_method=input_dics['resample_method'])
        trace.detrend('linear')
        trace.simulate(seedresp=seedresp,
                       paz_remove=None,
                       paz_simulate=None,
                       remove_sensitivity=True,
                       simulate_sensitivity=False,
                       water_level=input_dics['water_level'],
                       zero_mean=True,
                       taper=True,
                       taper_fraction=0.05,
                       pre_filt=eval(BP_filter),
                       pitsasim=False,
                       sacsim=True)
        # Remove the following line since we want to keep
        # the units as it is in the stationXML
        # trace.data *= 1.e9
        trace_identity = '%s.%s.%s.%s' % (
            trace.stats['network'], trace.stats['station'],
            trace.stats['location'], trace.stats['channel'])
        if input_dics['mseed'] == 'N':
            trace.write(os.path.join(Address,
                                     '%s.%s' % (unit.lower(), trace_identity)),
                        format='SAC')
        else:
            trace.write(os.path.join(Address,
                                     '%s.%s' % (unit.lower(), trace_identity)),
                        format='MSEED')

        if unit.lower() == 'dis':
            unit_print = 'displacement'
        elif unit.lower() == 'vel':
            unit_print = 'velocity'
        elif unit.lower() == 'acc':
            unit_print = 'acceleration'
        else:
            unit_print = 'UNKNOWN'
        print '%s -- instrument correction to %s for: %s' \
              % (inform, unit_print, trace_identity)

    except Exception as e:
        print '%s -- %s' % (inform, e)
Пример #3
0
def obspy_fullresp_STXML(input_dics,
                         trace,
                         stxml_file,
                         Address,
                         unit='DIS',
                         BP_filter=(0.008, 0.012, 3.0, 4.0),
                         inform='N/N'):
    """
    Instrument correction using station_XML --->
    equivalent to full response file steps: detrend, demean, taper, filter,
    deconvolution
    :param input_dics:
    :param trace:
    :param stxml_file:
    :param Address:
    :param unit:
    :param BP_filter:
    :param inform:
    :return:
    """
    try:
        if input_dics['resample_corr']:
            trace = resample_trace(
                trace,
                des_sr=input_dics['resample_corr'],
                resample_method=input_dics['resample_method'])
        trace.detrend('linear')
        # To keep it consistant with obspy.remove_response method!
        if unit.lower() == 'dis':
            unit = 'DISP'
            unit_write = 'dis'
        else:
            unit_write = unit.lower()

        inv = read_inventory(stxml_file, format="stationxml")
        trace.attach_response(inv)
        trace.remove_response(output=unit,
                              water_level=input_dics['water_level'],
                              pre_filt=eval(BP_filter),
                              zero_mean=True,
                              taper=True,
                              taper_fraction=0.05)
        # Remove the following line to keep the units
        # as it is in the stationXML
        # trace.data *= 1.e9

        trace_identity = '%s.%s.%s.%s' % (
            trace.stats['network'], trace.stats['station'],
            trace.stats['location'], trace.stats['channel'])
        if input_dics['mseed'] == 'N':
            trace.write(os.path.join(Address,
                                     '%s.%s' % (unit_write, trace_identity)),
                        format='SAC')
        else:
            trace.write(os.path.join(Address,
                                     '%s.%s' % (unit_write, trace_identity)),
                        format='MSEED')

        if unit.lower() == 'disp':
            unit_print = 'displacement'
        elif unit.lower() == 'vel':
            unit_print = 'velocity'
        elif unit.lower() == 'acc':
            unit_print = 'acceleration'
        else:
            unit_print = 'UNKNOWN'
        print '%s -- instrument correction to %s for: %s' \
              % (inform, unit_print, trace_identity)

    except Exception as e:
        print '%s -- %s' % (inform, e)
Пример #4
0
def obspy_fullresp_STXML(input_dics, trace, stxml_file, Address, unit='DIS',
                         BP_filter=(0.008, 0.012, 3.0, 4.0), inform='N/N'):
    """
    Instrument correction using station_XML --->
    equivalent to full response file steps: detrend, demean, taper, filter,
    deconvolution
    :param input_dics:
    :param trace:
    :param stxml_file:
    :param Address:
    :param unit:
    :param BP_filter:
    :param inform:
    :return:
    """
    try:
        if input_dics['resample_corr']:
            trace = resample_trace(trace,
                                   des_sr=input_dics['resample_corr'],
                                   resample_method=
                                   input_dics['resample_method'])
        trace.detrend('linear')
        # To keep it consistant with obspy.remove_response method!
        if unit.lower() == 'dis':
            unit = 'DISP'
            unit_write = 'dis'
        else:
            unit_write = unit.lower()

        inv = read_inventory(stxml_file, format="stationxml")
        trace.attach_response(inv)
        trace.remove_response(output=unit,
                              water_level=input_dics['water_level'],
                              pre_filt=eval(BP_filter), zero_mean=True,
                              taper=True, taper_fraction=0.05)
        # Remove the following line to keep the units
        # as it is in the stationXML
        # trace.data *= 1.e9

        trace_identity = '%s.%s.%s.%s' % (trace.stats['network'],
                                          trace.stats['station'],
                                          trace.stats['location'],
                                          trace.stats['channel'])
        if input_dics['mseed'] == 'N':
            trace.write(os.path.join(
                Address, '%s.%s' % (unit_write, trace_identity)), format='SAC')
        else:
            trace.write(
                os.path.join(Address, '%s.%s' % (unit_write, trace_identity)),
                format='MSEED')

        if unit.lower() == 'disp':
            unit_print = 'displacement'
        elif unit.lower() == 'vel':
            unit_print = 'velocity'
        elif unit.lower() == 'acc':
            unit_print = 'acceleration'
        else:
            unit_print = 'UNKNOWN'
        print '%s -- instrument correction to %s for: %s' \
              % (inform, unit_print, trace_identity)

    except Exception as e:
        print '%s -- %s' % (inform, e)