jpjones76 / SeisIO.jl

Julia language support for geophysical time series data
http://seisio.readthedocs.org
Other
47 stars 21 forks source link

sync!(C::SeisChannel) does not update C.t #79

Open tclements opened 3 years ago

tclements commented 3 years ago

On SeisIO v1.2.0

(@v1.5) pkg> st
Status `~/.julia/environments/v1.5/Project.toml`
  [b372bb87] SeisIO v1.2.0

Using sync! on a SeisChannel does not update the time matrix but an allocating sync does. MWE:

using SeisIO, Dates
S = SeisIO.RandSeis.randSeisData(s=1.,c=0.,nx=100000,fs_min=10.)
ungap!(S)
C = deepcopy(S[1])
s = u2d(SeisIO.starttime(C.t,C.fs) * 1e-6)

# do an allocating sync 
Cnew = sync(C,s=s,t=s+Minute(1))

# do an in-place sync!
sync!(C,s=s,t=s+Minute(1))

# check time matrices 
C.t == Cnew.t
# false 

C.t
# 2×2 Array{Int64,2}:
#       1  1612457405025612
# 100106                 0

Cnew.t 
# 2×2 Array{Int64,2}:
#    1  1612457405050612
# 2400                 0

C.t == S.t[1]
# true

# but the time series are truncated 
C.x == Cnew.x 
# true 

size(C.x,1) < size(S.x[1],1)
# true  

I believe this is due to the type promotion in sync!(C::SeisChannel). We might need to write a sync! method for SeisChannel rather than using type promotion and calling the method for SeisData.

jpjones76 commented 3 years ago

I think you're right, and my SeisChannel sync! method falls into the scoping abyss. Flagging as a bug.