pysep.utils.curtail#

Utilities to curtail station lists based on source receiver parameters or to curtail streams due to missing data etc.

Module Contents#

Functions#

curtail_by_station_distance_azimuth(event, inv[, ...])

Remove stations that are greater than a certain distance from event

quality_check_waveforms_before_processing(st[, ...])

Quality assurance to deal with bad data before running the

quality_check_waveforms_after_processing(st[, ...])

Quality assurance to deal with bad data after preprocessing, because

remove_traces_for_zero_trace_length(st)

Related to Issue #117, traces can be returned from the data center that only

remove_traces_for_bad_data_types(st)

Removed traces from a Stream that have unexpected data types. This might

remove_traces_w_masked_data(st)

Merge operations may produce masked arrays which are data streams with

remove_for_clipped_amplitudes(st)

Removed stations with clipped amplitudes

rename_channels(st)

Rename channels which intermix location names with channel names,

remove_stations_for_missing_channels(st[, ...])

Remove LLNL stations (network=='LL') with missing channels.

remove_stations_for_insufficient_length(st)

Remove stations if the length does not match the mode of all other lengths

subset_streams(st_a, st_b)

Given two streams of data, check if they have the same length. IF they do,

pysep.utils.curtail.curtail_by_station_distance_azimuth(event, inv, mindistance_km=0.0, maxdistance_km=1000000.0, minazimuth=0.0, maxazimuth=360.0)[source]#

Remove stations that are greater than a certain distance from event Replaces the old sta_limit_distance function

Parameters:
  • event (obspy.core.event.Event) – Event object to get location from

  • inv (obspy.core.inventory.Inventory) – inventory object to get locations from

  • mindistance_km (float) – minimum acceptable source-receiver distance in km

  • maxdistance_km (float) – maximum acceptable source-receiver distance in km

  • minazimuth (float) – minimum acceptable azimuth in deg

  • maxazimuth (float) – maximum acceptable azimuth in deg

Return type:

obspy.core.inventory.Inventory

Returns:

a curtailed inventory object which has had stations removed for unacceptable distance and azimuth values

pysep.utils.curtail.quality_check_waveforms_before_processing(st, remove_clipped=True)[source]#

Quality assurance to deal with bad data before running the preprocessing steps. Replaces: do_waveform_QA

Parameters:
  • st (obspy.core.stream.Stream) – Stream object to pass through QA procedures

  • remove_clipped (bool) – boolean flag to turn on/off amplitude clipping check

pysep.utils.curtail.quality_check_waveforms_after_processing(st, remove_insufficient_length=True)[source]#

Quality assurance to deal with bad data after preprocessing, because preprocesing step will merge, filter and rotate data. Replaces: do_waveform_QA

Parameters:
  • st (obspy.core.stream.Stream) – Stream object to pass through QA procedures

  • remove_insufficient_length (bool) – boolean flag to turn on/off insufficient length checker

pysep.utils.curtail.remove_traces_for_zero_trace_length(st)[source]#

Related to Issue #117, traces can be returned from the data center that only have data arrays of length 1, causing their total length in time to be 0s. This will cause preprocessing to break during estimate_prefilter_corners, which requires endtime - starttime > 0.

This function will cut out any traces that exhibit this unique behavior, and is complementary to remove_stations_for_insufficient_length which is run AFTER preprocessing.

This is also run by default as it’s assumed the User does NOT want a waveform with only one data point.

Parameters:

st (obspy.core.stream.Stream) – Stream object to pass through QA procedures

Rtype st:

obspy.core.stream.Stream

Return st:

curtailed stream with zero-length traces removed

pysep.utils.curtail.remove_traces_for_bad_data_types(st)[source]#

Removed traces from a Stream that have unexpected data types. This might occur if e.g., you wildcard the channel and end up grabbing LOG data, which uses letters.

Parameters:

st (obspy.core.stream.Stream) – Stream to check clipping for

Rtype st:

obspy.core.stream.Stream

Return st:

curtailed stream with clipped traces removed

pysep.utils.curtail.remove_traces_w_masked_data(st)[source]#

Merge operations may produce masked arrays which are data streams with gaps in them. Remove these from the stream

pysep.utils.curtail.remove_for_clipped_amplitudes(st)[source]#

Removed stations with clipped amplitudes replaces clipping_handler.remove_clipped TODO where is that clip factor coming from?

Parameters:

st (obspy.core.stream.Stream) – Stream to check clipping for

Rtype st:

obspy.core.stream.Stream

Return st:

curtailed stream with clipped traces removed

pysep.utils.curtail.rename_channels(st)[source]#

Rename channels which intermix location names with channel names, For example: BHX00 -> BHX.00 We are assuming here that channel codes are either: ‘00’ or ‘10’ Historically this is to differentiate STS-1 (00) and STS-2 (10)

Relevant reading: https://ds.iris.edu/ds/newsletter/vol1/no1/1/

specification-of-seismograms-the-location-identifier/

TODO old code strips channels down to 3 letters if they’re 4. But

can’t we have 4 letter channel names? NZ does this.

TODO Do we only expect location codes to be appended to channels?

Parameters:

st (obspy.core.stream.Stream) – Stream to check incorrect channel naming for

Rtype st:

obspy.core.stream.Stream

Return st:

Stream with renamed channels and locations

pysep.utils.curtail.remove_stations_for_missing_channels(st, required_number_channels=3, networks='LL')[source]#

Remove LLNL stations (network==’LL’) with missing channels.

LLNL data is already problematic, so if there are signs of too many issues / problems for a given station then remove that station.

Parameters:
  • st (obspy.core.stream.Stream) – Stream to check missing channels for

  • required_number_channels (int) – expected channels for each station

  • networks (str) – comma-separated list of network codes to check. This defaults to ‘LL’ because this function was meant to parse through LLNL data

pysep.utils.curtail.remove_stations_for_insufficient_length(st)[source]#

Remove stations if the length does not match the mode of all other lengths in the stream, which is assumed to be the expected length

Parameters:

st (obspy.core.stream.Stream) – Stream to check for data gaps and insufficient start and end times

pysep.utils.curtail.subset_streams(st_a, st_b)[source]#

Given two streams of data, check if they have the same length. IF they do, return the streams. If they don’t, subset the streams so they have the same lengths and the same station ids.

Parameters:
  • st_a (obspy.core.stream.Stream) – stream A to check

  • st_b (obspy.core.stream.Stream) – stream B to check

Return type:

tuple of Streams

Returns:

curtailed (or not) streams in the same order as input