obspy.core.trace.Trace.normalize

Trace.normalize(norm=None)[source]

Normalize the trace to its absolute maximum.

Parameters

norm (None or float) – If not None, trace is normalized by dividing by specified value norm instead of dividing by its absolute maximum. If a negative value is specified then its absolute value is used. If it is zero (either through a zero array or by being passed), nothing will happen and the original array will not change.

If trace.data.dtype was integer it is changing to float.

Note

This operation is performed in place on the actual data arrays. The raw data is not accessible anymore afterwards. To keep your original data, use copy() to create a copy of your trace object. This also makes an entry with information on the applied processing in stats.processing of this trace.

Example

>>> tr = Trace(data=np.array([0, -3, 9, 6]))
>>> tr.normalize()  
<...Trace object at 0x...>
>>> tr.data
array([ 0.        , -0.33333333,  1.        ,  0.66666667])
>>> print(tr.stats.processing[0])  
ObsPy ...: normalize(norm=None)
>>> tr = Trace(data=np.array([0.3, -3.5, -9.2, 6.4]))
>>> tr.normalize()  
<...Trace object at 0x...>
>>> tr.data
array([ 0.0326087 , -0.38043478, -1.        ,  0.69565217])
>>> print(tr.stats.processing[0])  
ObsPy ...: normalize(norm=None)