Problems reading CSS waveform files - Is there a trick that I need to know?

Good morning,
I am working on an Obspy / python based instrument calibration package for whole-system instrument response calibrations. The network that I’m working with is using the CSS3.0 waveform format, but I cannot for the life of me get Obspy to import it. I have been given four sample files:

43090920.bhe
43090920.bhn
43090920.bhz
DGS14309.wfd

I can supply these files if someone can help me figure out how to import the data?
In the mean time, I have placed them over at github at this location:

https://github.com/tychoaussie/sample_data

I need to be able to bring in the sensor data for doing some FFT signal analysis but up until now, I have totally struck out in getting the data open in Obspy. Is the CSS in Obspy something different than CSSS2.0 or CSS3.0? If so, is there a way of reading in the 3.0 waveform format ?

I’m at the Kazakhstan KNDC at the moment, in case any of you happen to be driving through Almaty and want to give me a hand with this!

  • Thanks for reading, and bigger thanks if you happen to have any insights,

-Dan Burk
Michigan State University

The wdf header file (which you need to feed to read()) points to some
waveform files that are missing. If you remove the lines referring to
files 43090919.bh* you can read it with

read("DGS14309.wfd", format="CSS")

(Not sure why file type detection is not working..)

cheers,
Tobias

Thanks for the tips, Tobias, but I still cannot open the files.
Here’s what I have thus far, in order to validate the .wdf file:

Hi Dan,

there's a few problems in your code, mainly you didn't close the
outfile, and it ended up empty. I *strongly* recommend using the with
construct for file handling.
Also, reading those lines with indexing by character position is pretty
dangerous, I would recommend .split() on the single lines (you ended up
trying to read your output file with some spaces at the end of the
filename, note the quick and dirty .strip() for fixing).

The following works, hope you're good now. All the best for the field
work. :wink:

cheers,
T

import sys,os
from obspy import read

infile = "DGS14309.wfd"
dir = "."
with open(infile,'r') as f:
    lines = f.readlines()

outfile=infile[:-4]+'_bak'+infile[-4:]
with open(outfile,'w') as fout:

    for i in range(0,len(lines)):
        candidate=os.path.join(dir, lines[i][213:255]).strip()
        if os.path.isfile(candidate):
            print "{} is a real file.".format(candidate)
            fout.writelines(lines[i])
        else:
            print "{} does not exist.".format(candidate)

    if os.path.isfile(outfile):
        print outfile+" has been created."
    else:
        print outfile + "does not yet exist."

st = read(outfile,format="css")
print st
st.plot()