Sfile_util — EQcorrscan 0.0.8 documentation

# Sfile_util

Part of the EQcorrscan module to read nordic format s-files and write them EQcorrscan is a python module designed to run match filter routines for seismology, within it are routines for integration to seisan and obspy. With obspy integration (which is necessary) all main waveform formats can be read in and output.

Code generated by Calum John Chamberlain of Victoria University of Wellington, 2015.

Copyright 2015 Calum Chamberlain

This file is part of EQcorrscan.

> EQcorrscan is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

> EQcorrscan is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

> You should have received a copy of the GNU General Public License along with EQcorrscan. If not, see <http://www.gnu.org/licenses/>.

class `Sfile_util.` `EVENTINFO`(time=<mock.Mock object at 0x4091810>, loc_mod_ind=' ', dist_ind=' ', ev_id=' ', latitude=nan, longitude=nan, depth=nan, depth_ind=' ', loc_ind=' ', agency=' ', nsta=0, t_RMS=nan, Mag_1=nan, Mag_1_type=' ', Mag_1_agency=' ', Mag_2=nan, Mag_2_type=' ', Mag_2_agency=' ', Mag_3=nan, Mag_3_type=' ', Mag_3_agency=' ')

  Header information for seisan events, again all fields can be left blank for a default empty header. The print function for header will print important information, but not as seen in an S-file.

  For more information on parameters see the seisan manual.

  Attributes:

    type time: | obspy.UTCDateTime
    param time: | Event origin time
    type loc_mod_ind:
    | str
    param loc_mod_ind:
    type dist_ind: | str
    param dist_ind: | Distance flag, usually ‘L’ for local, ‘R’ for regional and ‘D’ for distant
    type ev_id: | str
    param ev_id: | Often blank, ‘E’ denotes explosion and fixes depth to 0km
    type latitude: | float
    param latitude: | Hypocentre latitude in decimal degrees
    type longitude: | float
    param lognitude:
    | Hypocentre longitude in decimal degrees
    type depth: | float
    param depth: | hypocentre depth in km
    type depth_ind: | str
    param depth_ind:
    type loc_ind: | str
    param loc_ind: |
    type agency: | str
    param agency: | Reporting agency, three letters
    type nsta: | int
    param nsta: | Number of stations recording
    type t_RMS: | float
    param t_RMS: | Root-mean-squared time residual
    type Mag_1: | float
    param Mag_1: | first magnitude
    type Mag_1_type:
    | str
    param Mag_1_type:
    | Type of magnitude for Mag_1 (‘L’, ‘C’, ‘W’)
    type Mag_1_agency:
    | str
    param Mag_1_agency:
    | Reporting agency for Mag_1
    type Mag_2: | float
    param Mag_2: | second magnitude
    type Mag_2_type:
    | str
    param Mag_2_type:
    | Type of magnitude for Mag_2 (‘L’, ‘C’, ‘W’)
    type Mag_2_agency:
    | str
    param Mag_2_agency:
    | Reporting agency for Mag_2
    type Mag_3: | float
    param Mag_3: | third magnitude
    type Mag_3_type:
    | str
    param Mag_3_type:
    | Type of magnitude for Mag_3 (‘L’, ‘C’, ‘W’)
    type Mag_3_agency:
    | str
    param Mag_3_agency:
    | Reporting agency for Mag_3

class `Sfile_util.` `PICK`(station=' ', channel=' ', impulsivity=' ', phase=' ', weight=999, polarity=' ', time=<mock.Mock object at 0x4091810>, coda=999, amplitude=nan, peri=nan, azimuth=nan, velocity=nan, AIN=999, SNR=nan, azimuthres=999, timeres=nan, finalweight=999, distance=nan, CAZ=999)

  Pick information for seisan implimentation, note all fields can be left blank to obtain a default pick: picks have a print function which will print them as they would be seen in an S-file.

  Attributes:

    type station: | str
    param station: | Station name, less than five charectars required as standard
    type channel: | str
    param channel: | Two or three charactar channel name, stored as two charactars in S-file
    type impulsivity:
    | str
    param impulsivity:
    | either ‘C’ or ‘D’ for compressive and dilatational
    type phase: | str
    param phase: | Any allowable phase name in two characters
    type weight: | int
    param weight: | 0-4 with 0=100%, 4=0%, use weight=9 for unknown timing
    type polarity: | str
    type time: | obspy.UTCDateTime()
    param time: | Pick time as an obspy.UTCDateTime object
    type coda: | int
    param coda: | Length of coda in seconds
    type amplitude: | float
    param amplitude:
    | Amplitude (zero-peak), type is given in phase
    type peri: | float
    param peri: | Period of amplitude
    type azimuth: | float
    param azimuth: | Direction of approach in degrees
    type velocity: | float
    param velocity: | Phase velocity (km/s)
    type AIN: | int
    param AIN: | Angle of incidence.
    type SNR: | float
    param SNR: | Signal to noise ratio
    type azimuthres:
    | int
    param azimuthres:
    | Residual azimuth
    type timeres: | float
    param timeres: | Time residual in seconds
    type finalweight:
    | int
    param finalweight:
    | Final weight used in location
    type distance: | float
    param distance: | Source-reciever distance in km
    type CAZ: | int
    param CAZ: | Azimuth at source.

  `write`(filename)

    Public function to write the pick to a file

    Parameters: | filename (str) – Path to file to write to - will append to file

`Sfile_util.` `_float_conv`(string)

  Convenience tool to convert from string to float, if empty string return NaN rather than an error

`Sfile_util.` `_int_conv`(string)

  Convenience tool to convert from string to integer, if empty string return a 999 rather than an error

`Sfile_util.` `_str_conv`(number, rounded=False)

  Convenience tool to convert a number, either float or into into a string, if the int is 999, or the float is NaN, returns empty string.

`Sfile_util.` `blanksfile`(wavefile, evtype, userID, outdir, overwrite=False, evtime=False)

  Module to generate an empty s-file with a populated header for a given waveform.

  Parameters: | wavefile (String) – Wavefile to associate with this S-file, the timing of the S-file will be taken from this file if evtime is not set evtype (String) – L,R,D userID (String) – 4-charectar SEISAN USER ID outdir (String) – Location to write S-file overwrite (Bool) – Overwrite an existing S-file, default=False evtime (UTCDateTime) – If given this will set the timing of the S-file
  Returns: | String, S-file name

`Sfile_util.` `populateSfile`(sfilename, picks)

  Module to populate a blank nordic format S-file with pick information, arguments required are the filename of the blank s-file and the picks where picks is a dictionary of picks including station, channel, impulsivity, phase, weight, polarity, time, coda, amplitude, peri, azimuth, velocity, SNR, azimuth residual, Time-residual, final weight, epicentral distance & azimuth from event to station.

  This is a full pick line information from the seisan manual, P. 341

  Parameters: | sfilename (str) – Path to S-file to populate, must have a header already picks (List of :class: PICK) – List of the picks to be written out

`Sfile_util.` `readheader`(sfilename)

  Fucntion to read the header information from a seisan nordic format S-file.

  Parameters: | sfilename (str) – Path to the s-file
  Returns: |
  class: | EVENTINFO

`Sfile_util.` `readpicks`(sfilename)

  Function to read pick information from the s-file

  Parameters: | sfilename (String) – Path to sfile
  Returns: | List of :class: PICK

`Sfile_util.` `readwavename`(sfilename)

  Convenience function to extract the waveform filename from the s-file, returns a list of waveform names found in the s-file as multiples can be present.

  Parameters: | sfilename (str) – Path to the sfile
  Returns: | List of str

`Sfile_util.` `test_rw`()

  Function to test the functions herein.