rearrange sac header writer
I think there is a problem with the SAC header construction.
here
Line 1862 in 92c4c62
self.st = append_sac_headers(self.st, self.event, self.inv)
pysep constructs the SAC header (before the trim), which means that it calculates the B value from the stream start time here
Line 1868 in 92c4c62
self.st = self.preprocess()
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
I modified pysep.py moving the preprocess (where the trim occurs) before the sac header.
the proprocess routine assumed that a sac header was already written but only to write the scale_factor value, so I move this writing out of the routine after the sac header construction
Thank you @casarotti! Great catch on the incorrect SAC header construction, indeed b and e were not constructed correctly, both because of the trimming but also because e did not account for b. I just added two comments on making the changes slightly more explicit if you wouldn't mind implementing. Happy to merge after that.
merging this in and will make the suggested modifications in devel branch, thanks @casarotti for the PR!