Open ThomasLecocq opened 2 years ago
I am not into these data formats, but I think cleanest would be to apply calib in generic read according to stats and not passing apply_calib to underlying read routines. plotting routines should not automatically apply calib. But I think other suggested solutions are adequate, too.
While working on
io.kinemetrics
I noticed an issue (I think) with theapply_calib
behaviour: (noteapply_calib
only applies to, I think:gse
,knet
,kinemetrics
and maybe others, providing atr.stats.calib!=1
)obspy.core.stream.read
doesn't pass theapply_calib
kwarg to the_generic_reader
:https://github.com/obspy/obspy/blob/2af06db830f99f41f2f4f0c43323b6ddd1e45905/obspy/core/stream.py#L195-L207
which results, if
apply_calib=True
(it's not passed):Stream
returned by_generic_reader
has the raw data.stats.calib
are equal to 1.1694431304931641e-06then, the end of the generic
read
routine: https://github.com/obspy/obspy/blob/2af06db830f99f41f2f4f0c43323b6ddd1e45905/obspy/core/stream.py#L237-L239applies the calibration to the data. So, at this point, I have what I wanted, but...
This case has a strong impact when plotting with
Stream.plot
, as the routine applies thetr.stats.calib
automatically: https://github.com/obspy/obspy/blob/2af06db830f99f41f2f4f0c43323b6ddd1e45905/obspy/imaging/waveform.py#L690 which results in apparent (it's not in the data) very very small values!First solution:
Passing the
apply_calib
to the modules.When modifying the behaviour, such that
apply_calib=True
is passed to the_generic_reader
:Stream
by_generic_reader
has the calibrated data.stats.calib
are equal to 1.0read
routine doesn't do anything (multiplies by 1).Second solution:
Either: should this chunk of the read routine reset the
Trace.stats.calib = 1
Third solution
should the plotting routines not automatically apply calibration ? But in this case, what's the meaning/purpose of having the
trace.stats.calib
to be different from 1 as it as already been applied, to go back to raw counts ?