-
Notifications
You must be signed in to change notification settings - Fork 0
00_convert_seisandb_to_csvfiles.py
Glenn Thompson edited this page Nov 9, 2021
·
3 revisions
main() is called which calls processSeisanYearMonth() one month at a time. Optionally, a start date and/or maximum number of S-files to process can be supplied. Various flags can also be set to modify the behavior of deeper function calls, e.g. bool_overwrite to overwrite existing files.
processSeisanYearMonth():
- calls get_sfile_list()
- loops over each S-file in the returned list, reading it in to an Sfile object, and constructing the paths to the linked WAV-files,
- if there is a linked WAV-file with 'MVO' in the filename, this indicates it comes from the MVO Digital seismic network, so then processWAV() is called on it, returning the contents in a dict called eventrow. More info on processWAV() is given later
- parameters 'sfile', 'main class' and 'subclass' are added to this dict, and eventrow is then added to a list of dicts
- once all S-files for the year/month have been processed, the list of dicts is turned into a DataFrame and saved as a CSV file called
reawav_MVOE_YYYYMM.csvfile
processWAV():
- calls wavfile2paths() to set various paths
- missing directories are created, and if bool_overwrite is set, corresponding files are deleted
- WAV2picklefile() is called and returns a Stream object.
- Each Trace object is checked to ensure it has at least 1000 samples.
- Stream object is subsetted to seismic components only.
- Stream2logfile() is called.
- Stream2png() is called, if bool_make_png_files True
- If tr.stats.metrics.energy does not already exist:
- Call add_ampengfft_metrics(), returning an IceWeb object which contains an enhanced Stream object.
- Call plot_spectrograms() if spectrogram plot does not already exists and bool_make_png_files True.
- Remove spectrogram data from IceWeb object - too bulky to store, and not needed now spectrogram plotted.
- Write enhanced Stream object to pickle file.
- Call metrics2tracedf() and return a trace DataFrame
- Call tracedf2eventdf() and return a wavrow dict.
WAV2picklefile():
- Read the pickle file if it already exists and return, otherwise:
- Read wavfile into Stream object
- Check it has Trace objects
- Call libMVO.fix_trace_id()
- Loop over Trace objects:
- Loop over Trace objects again and remove trace objects with quality factor <=0
- Write pickle file if Stream object has Trace objects
- Return Stream object
Stream2logfile() pretty prints tr.stats to a log file.
Stream2png() saves seismic and infrasound PNG files, if they do not already exist.
add_ampengfft_metrics(st):
- calls IceWeb.icewebSpectrogram(st) and returns an IceWeb spectrogram object, iwsobj
- precomputes the spectrograms
- computes the amplitude spectrum
- calls ampengfft
plot_spectrograms() plots free scale and fixed scale spectrogram plots, saves to PNG files.
metrics2tracedf():
tracedf2eventdf():