I am trying to process “C3”, that is, correlations of codas of “C1” seismic noise correlations.
C1 correlations (my .SAC input files) are made of 2 halves regarding time concept, one which is causal (positive time serie) and another one which is non causal (negative time serie). The way ObsPy plots these is with an UTC time reference but that is all right.
For my task, I trim/split into two these C1, and I obtain my input codas, so that I have got a positive time coda and a negative time coda. This is now my enquiry: as well as I need to generate/write a .SAC file that contains the positive coda, I need to save the reversed time coda, but now changing the X axis data to a “clockwise” time sequence, that is, reversing the reversed time sequence of this coda (like in a mirror effect concerning the time axis)
Does anyone know if there is any sentence/command to directly reverse these time sequences? I mean, as it can be done, for example, with IRIS SAC software and its REVERSE command… If there is not such command, how could I make this to work out?
I tried to reverse the time and amplitude arrays by myself, but I do not think this is the easiest way to proceed.
import numpy as np stA=read('COR_AMTX_ANMO.SAC') #an example C1 input file trA=stA #taking the first and only trace in the stream trcopA=trA.copy() trcopAtrim=trcopA.trim(endtime=negoriginA) #trimming of the "negative time half". NegoriginA is a UTC time value previously defined dataA=trcopAtrim.data timeA= np.array(trcopAtrim.times()) #definition of X and Y arrays revdataA=dataA[::-1] #reversal of sequences for both time and amplitude revtimeA=timeA[::-1]
I also used Matplotlib to reverse the X axis and show how I want my traces to look like (but this is just a plot, my data are not modified so it is not very usefull)
import matplotlib.pyplot as plt fig=plt.figure(figsize=(15,5)) plt.plot(trcopAtrim) plt.xlim(5001, 0) #reversal of x axis in the plot to get the mirror effect