pyatoa.utils.calculate
Custom math functions for faster calculations in other parts of Pyatoa
Module Contents
Functions
|
Find the absolute maximum of an array |
|
Round value x to nearest base, round 'up','down' or to 'near'est base |
|
Used for mapping mostly, sometimes when adding values to map bounds, you |
|
Helper function to return a list of julian days based on a given |
|
normalize an array from a to b for e.g. plotting, maths |
|
Calculate the amplitude differences between two waveforms, a la. |
|
Logarithmic variance reduction. Approximately Gaussian distributed |
|
Oft repeated calculation of finding the time offset between the start of |
- pyatoa.utils.calculate.abs_max(array)[source]
Find the absolute maximum of an array
- Parameters:
array (np.array) – array to find abs max of
- Return type:
- Returns:
absolute maximum of array
- pyatoa.utils.calculate.myround(x, base=5, choice='near')[source]
Round value x to nearest base, round ‘up’,’down’ or to ‘near’est base
- pyatoa.utils.calculate.enforce_angle_pi(angle, bound=180)[source]
Used for mapping mostly, sometimes when adding values to map bounds, you can cross over the accepted threshold, e.g., angle > 180deg. This function just keeps things within bounds
- https://stackoverflow.com/questions/2320986/
easy-way-to-keeping-angles-between-179-and-180-degrees
- pyatoa.utils.calculate.overlapping_days(origin_time, start_pad=20, end_pad=200)[source]
Helper function to return a list of julian days based on a given origin time with a specific padding on either side. used to catch if an origin time sits too close to midnight and two days need to be fetched
- Parameters:
origin_time (obspy.core.UTCDateTime) – event origin time
start_pad – padding in seconds before the origin time of an event for waveform fetching, to be fed into lower level functions.
end_pad (int) – padding in seconds after the origin time of an event for wavefomr fetching.
- Return type:
- Returns:
list of available julian days
- pyatoa.utils.calculate.normalize_a_to_b(array, a=0, b=1)[source]
normalize an array from a to b for e.g. plotting, maths
- pyatoa.utils.calculate.amplitude_anomaly(a, b, dt)[source]
Calculate the amplitude differences between two waveforms, a la. Equation A2 from Tape et al. 2010, which states that:
DlnA = ln(a/b) = 0.5 * ln[integral(a(t)**2 dt)/integral(b(t)**2 dt)] where a and b represent data and synthetics, respectively
Note
It is expected that a and b have the same value of dt, if they do not, they should be resampled before being passed to this function.
- pyatoa.utils.calculate.vrl(d, s1, s2)[source]
Logarithmic variance reduction. Approximately Gaussian distributed reduction in variance based on full waveform difference. Based on Equation 8 in Tape et al. 2010.
- Parameters:
d (np.array) – data array to compare against synthetic arrays
s1 (np.array) – synthetic array for model 1
s2 (np.array) – synthetic array for model 2
- Return type:
- Returns:
logarithmic variance reduction
- pyatoa.utils.calculate.time_offset(st, origintime)[source]
Oft repeated calculation of finding the time offset between the start of a stream and the origin time of an event. Important when dealing with SPECFEM seismograms, which explicitely start at the time offset value, w.r.t. streams which set starttime at 0 but contain their own origin time information
Note
convention is that if the waveform starts BEFORE the event origin time, then time_offset will be NEGATIVE.
- Parameters:
st (obspy.core.stream.Stream) – stream to check time offset of
origintime (obspy.UTCDateTime) – the origin time of the event
- Return type:
- Returns:
the time offset, or: origintime - stream_origin_time