The time offset value is very important for writing adjoint sources, as it correctly sets the start time of the adjoint source (used when USER_T0 is set in SPECFEM, which sets time before event origin time).
Currently Pyatoa can only grab time offset information by taking the different between Trace.stats.starttime and Event.preferred_origin().time. However if not Event object is given, which may be the case for synthetic-inversions, or if not Event metadata is available, then time offset is incorrectly set to 0.
To fix this we need to add another option which grabs time offset information from the synthetic waveforms Trace.stats.time_offset which should be set correctly by Pyatoa.utils.read.read_sem().
This should take precedence over the Event option, and a log message should be posted if time offset is guessed at 0. Fix should look something like:
if hasattr(self.st_syn[0].stats, "time_offset"):
self.stats.time_offset_sec = self.st_syn[0].stats.time_offset
elif self.event is not None:
self.stats.time_offset_sec = (self.st_syn[0].stats.starttime -
self.event.preferred_origin().time
)
else:
logger.warning("cannot find information relating to time offset, setting 0")
self.stats.time_offset_sec = 0
logger.info(f"time offset is {self.stats.time_offset_sec}s")
The time offset value is very important for writing adjoint sources, as it correctly sets the start time of the adjoint source (used when
USER_T0
is set in SPECFEM, which sets time before event origin time).Currently Pyatoa can only grab time offset information by taking the different between
Trace.stats.starttime
andEvent.preferred_origin().time
. However if not Event object is given, which may be the case for synthetic-inversions, or if not Event metadata is available, then time offset is incorrectly set to 0.https://github.com/adjtomo/pyatoa/blob/fd33b8f48a005f29d6502c26fbb2fc3d73c9efc4/pyatoa/core/manager.py#L663-L670
To fix this we need to add another option which grabs time offset information from the synthetic waveforms
Trace.stats.time_offset
which should be set correctly byPyatoa.utils.read.read_sem()
.https://github.com/adjtomo/pyatoa/blob/fd33b8f48a005f29d6502c26fbb2fc3d73c9efc4/pyatoa/utils/read.py#L105-L108
This should take precedence over the Event option, and a log message should be posted if time offset is guessed at 0. Fix should look something like: