Helper Classes
tiskitpy.util_classes.CleanSequence
- class tiskitpy.util_classes.CleanSequence
Bases:
objectRoutines to handle channel cleaning information lists.
Can store the information in Trace objects (Trace.stats[‘clean_sequence’]) and add or remove this information from the trace’s “location” code.
Can also match seed_ids independently of whether the clean sequence has been added to the location code.
Current clean_sequence codes are: - “-{seed_id}”: the given channel’s coherent part has been subtracted from this channel (
DataCleaner) - “ROT” for simple rotation (CleanRotator) - “ZEROS” if selected data has been zeroed (TimeSpans)In :classL`SpectralDensity` objects, they are stored in the property
_clean_sequencesand textually integrated in theinputandoutputcoordinatesIn
ReceiverFunctionobjects, CleanSequence is used to match channels with different levels of processing (it finds the original seed_id to compare)A string representation can be generated using the string method
A string representation can be placed in or removed from a Trace/Stream’s seed id using the
tag()anduntag()methods- complete_seed_id(verbose=False)
Change string to a seed_id
Checks if there are 3 dots. If not, adds “missing” dots to beginning
- static seed_id(tiskitpy_id)
Converts a tiskitpy_id to its base seed_id
- Parameters:
tiskitpy_id (str) – tiskitpy_id
- Returns:
the seed_id
- Return type:
(str)
- static seedid_tag(tr_st, out_format='minimal')
Add the CleanSequence’s string representation to Trace(s) seed_id
This is useful for using obspy to plot each channel separately
This is problematic if you want to link to the inventory (to correct for the instrument response, for example)
- For example, if trace.stats.clean_sequence = [
‘XX.STA.00.BHX’, ‘XX.STA.00.BHY’, ‘XX.STA.00.BDH’, ‘XX.STA.01.BDH’]
and the input trace id is ‘XX.STA.00.BHZ’, the new trace id will be ‘XX.STA.00-X-Y-0_H-1_H.BHZ’
- static seedid_untag(tr_st)
Remove the CleanSequence’s string representation from the Trace(s) seed_id
This is useful for linking to the inventory (for example, for the instrument response)
This is problematic for using obspy.plot() (plots cleaned channels on same line as uncleaned)
- Parameters:
tr_st (
obspy.core.Traceor obspy.core.Trace) – Trace or Stream to remove clean_sequence info from the loc- Returns:
new_tr_st (
obspy.core.Traceor obspy.core.Trace)
- static string(inp, out_format='minimal')
Returns the clean_sequence’s string representation
The form is “-” + id0 + “-” + id1 + …
By default, idx are minimized to contain the least characters uniquely identifying the seed id, from right to left
- Parameters:
inp (:class:`obspy.core.Trace or `obspy.core.Stream) – Trace or Stream from which to get the clean_sequence(s)
out_format (str) – how to format the output: ‘minimal’: return the shortest string possible ‘min_code’: use the shortest string containing full codes ‘full’: return the full seedid string for each cleaned channel
- Returns:
depending on whether you input Trace or Stream
- Return type:
(str or list)
- static tag(inp, clean_code, cleaned_ids=None, verbose=False)
Tag Trace stats with a clean_code
- Parameters:
inp (
Trace,Stream, list or None) – the object to tagclean_code (str or list of str) – transformation code (‘ROT’, …) or the seed_id of the cleaned channel If a list, each str in the list will be appended
cleaned_ids (list) – a list of which Stream ids to apply to (can use wildcards). If None, applies to all of the Stream traces
- Returns:
trace, stream, or list with modified clean_sequence
- Return type:
outp (
Trace,Stream, or list)- Raises:
ValueError if cleaned_ids is not None and trace_or_stream is a Trace –
TypeError if inp is not a Trace, Stream, list or NoneType –
- static tiskitpy_id(seed_id, clean_sequence)
Returns a tiskitpy_id, based on a seed_id and a clean_sequence list
- Parameters:
seed_id (str) – a valid seed_id (has three ‘.’s)
clean_sequence (list of str) – ordered list of cleaning steps: either seed_ids or transformation codes
- Returns:
the tiskitpy_id
- Return type:
(str)
tiskitpy.util_classes.SeisRotate
- class tiskitpy.util_classes.SeisRotate(stream, uselogvar=False, max_reject_sync=0.01, H_over_Z=1.0, N_E_comps=('1', '2'))
Bases:
objectClass to clean tilt noise from OBS vertical channel through non-deforming rotation
- calc_zrotate_opt(lowcut=0.001, hicut=0.005, ignore_spans=None, uselogvar=None)
Calculate the Z channel rotation angle that minimizes tilt noise
- Parameters:
lowcut (float) – low passband frequency in which to evaluate variance reduction
hicut (float) – high passpand frequency “” “” “”
ignore_spans (
TimeSpans`) – time spans to ignoreuselogvar (bool) – use logarithmic variance estimate
- Returns: (tuple)
angle (float): tilt angle (degrees, 0 means no tilt correction) azimuth (float): tilt azimuth (degrees) var_red (float): obtained reduction in variance (0 to 1)
The default (lowcut, hicut) values of (0.001, 0.005) correspond to the band where removing tilt noise generally has the greatest effect on the Z signal (at the low frequency end of the noise notch)
You can input the returned angles to rotateSeis.zrotate() to get the properly rotated data
- copy()
- Returns:
Copy of SeisRotate object.
- Return type:
- plot()
- static separate_streams(stream)
Separates input stream into seismometer and “other”
There must be one channel name ending in Z, one ending in N or 1 and one ending in E or 2
- Parameters:
stream (Stream) – 3+ component data stream
- Returns:
stream containt 3C seismometer channels other_stream (Stream): all other channels, or None
- Return type:
seis_stream (Stream)
- stream()
Return obspy 3-component stream()
- zrotate(angle, azimuth, horiz_also=True)
Rotate a seismometer’s vertical component
- Parameters:
angle (float) – angle towards vertical by which to rotate (degrees)
azimuth (float) – azimuth (CW from N) at which to rotate (degrees)
horiz_also (bool) – rotate horizontal components as well? (to retain orthogonality)
- I would set horiz_also to:
- False for the Guralp CMG-3T, which independently levels the three
components
- True for the Trillium T240, which centers without rotation
(according to Dr Wieland)