Data extraction issue for 8H and 9H networks
I am experiencing an issue with Pysep while downloading data for stations in the 8H and 9H networks. Despite setting seconds_before_ref: 100 and seconds_after_ref: 300 in the .yaml file, the extracted data starts earlier than -100 seconds from the reference time. Additionally, when viewed in SAC, the event appears to occur before the origin time for some stations, which is incorrect.
This problem is specific to the 8H and 9H networks, while other stations behave as expected. The input DOC
file and SAC output image for a particular station are attached.
2016-12-12T220444_HINDU_KUSH.docx
Hi @Rinku-274, thanks for bringing this issue. It's slightly concerning that this is happening only for certain networks while other stations are behaving as expected, that makes me think it's a data/metadata issue for 8H and 9H networks, rather than a PySEP issue, since some things are working as expected. Is there any information in the log file that suggests PySEP is shifting the origin time? Also can you point me towards a specific station where this is working? It would be useful to see the comparison between them.
I think there is a problem with the SAC header construction.
here https://github.com/adjtomo/pysep/blob/92c4c62b7fc900a80f9e0ca2a345faf3e62298e8/pysep/pysep.py#L1862 pysep constructs the SAC header (before the trim), which means that it calculates the B value from the stream start time
here https://github.com/adjtomo/pysep/blob/92c4c62b7fc900a80f9e0ca2a345faf3e62298e8/pysep/pysep.py#L1868 pysep calls the preprocess routine and trims the waves, setting the new stream start time.
Then it writes the SAC files (with the new start time and the previously defined header).
When the SAC file is read back, OBSPY takes into account the start time (defined by the trim) and the B value, and adjusts nzsec, nzmsec. which will be used later to create the origin time.
So the origin time is modified in the sac files
If you agree with this analysis, I can submit a commit where the SAC header definition comes after the trim.