예제 #1
0
def xseed2dataless(filename, options):
    files = []
    for item in filename:
        files.extend(glob(item))
    outdir = False
    outfile = False
    if options.output:
        if os.path.isdir(options.output):
            outdir = options.output
        elif len(files) > 1:
            msg = 'More than one filename is given.' + os.linesep
            msg += '\t--output argument will not be used.\n'
            sys.stdout.write(msg)
        else:
            outfile = options.output
    if options.verbose:
        msg = 'Found %s files.' % len(files) + os.linesep
        sys.stdout.write(msg)
    for file in files:
        if not os.path.isfile(file):
            continue
        f = open(file, 'rb')
        if f.read(1) != b'<':
            if options.verbose:
                msg = 'Skipping file %s' % file
                msg += '\t-- not a XML-SEED file' + os.linesep
                sys.stdout.write(msg)
            f.close()
            continue
        f.close()
        if outdir:
            output = os.path.join(outdir,
                                  os.path.basename(file) + os.extsep +
                                  'dataless')
        elif outfile:
            output = outfile
        else:
            output = os.path.basename(file) + os.extsep + 'dataless'
        if options.verbose:
            msg = 'Parsing file %s' % file + os.linesep
            sys.stdout.write(msg)
        try:
            parser = Parser(file, debug=options.debug)
            parser.write_seed(output)
        except Exception as e:
            if options.debug:
                raise
            msg = '\tError parsing file %s' % file + os.linesep
            msg += '\t' + str(e) + os.linesep
            sys.stderr.write(msg)
예제 #2
0
def xseed2dataless(filename, options):
    files = []
    for item in filename:
        files.extend(glob(item))
    outdir = False
    outfile = False
    if options.output:
        if os.path.isdir(options.output):
            outdir = options.output
        elif len(files) > 1:
            msg = 'More than one filename is given.' + os.linesep
            msg += '\t--output argument will not be used.\n'
            sys.stdout.write(msg)
        else:
            outfile = options.output
    if options.verbose:
        msg = 'Found %s files.' % len(files) + os.linesep
        sys.stdout.write(msg)
    for file in files:
        if not os.path.isfile(file):
            continue
        f = open(file, 'rb')
        if f.read(1) != b'<':
            if options.verbose:
                msg = 'Skipping file %s' % file
                msg += '\t-- not a XML-SEED file' + os.linesep
                sys.stdout.write(msg)
            f.close()
            continue
        f.close()
        if outdir:
            output = os.path.join(outdir,
                                  os.path.basename(file) + os.extsep +
                                  'dataless')
        elif outfile:
            output = outfile
        else:
            output = os.path.basename(file) + os.extsep + 'dataless'
        if options.verbose:
            msg = 'Parsing file %s' % file + os.linesep
            sys.stdout.write(msg)
        try:
            parser = Parser(file, debug=options.debug)
            parser.write_seed(output)
        except Exception as e:
            if options.debug:
                raise
            msg = '\tError parsing file %s' % file + os.linesep
            msg += '\t' + str(e) + os.linesep
            sys.stderr.write(msg)
예제 #3
0
def parser_sensor_resp(dir, sName, type):
    par = Parser(dir + '.resp')
    par.write_xseed(dir + '.xml')
    par.write_seed(dir + '.dataless')

    channel = par.blockettes[52][0].channel_identifier
    paz = par.get_paz(channel)
    if (len(paz['zeros']) <= len(paz['poles'])):
        plot_Freq_Amp_Phase(dir + '.freq_amp_phase.png', paz, sName, type)
        (Ymax, Ymin, Tmax, Tmin, Tzero) = plot_Seep_Response(dir + '.impulse.png', paz, sName, type)
        return (paz, Ymax, Ymin, Tmax, Tmin, Tzero)
    else:
        print(
            "sName Error! , zeros number is larger than poles, Can't Calculate Response and Bode Diagram, Check it!!!")
        return (paz, 0, 0, 0, 0, 0)
예제 #4
0
def parser_digitizer_resp(dir, sName):
    filename = dir + '.resp'
    par = Parser(filename)
    par.write_xseed(dir + '.xml')
    par.write_seed(dir + '.dataless')

    channel = par.blockettes[52][0].channel_identifier
    sample_rate = par.blockettes[52][0].sample_rate
    paz = par.get_paz(channel)
    sensitivity = paz['digitizer_gain']
    if (sample_rate < 1):
        sample_rate = 1

    inv = read_inventory(filename, "RESP")
    resp = inv[0][0][0].response
    # print(resp)
    response, freqs = resp.get_evalresp_response(1. / (sample_rate * 2.), 65536 * 16, output="VEL")
    plot_Digitizer_Freq_Amp(dir + '.freq_amp.png', sName, sample_rate, sensitivity, response, freqs)
    return (sample_rate, sensitivity)