jpjones76 / SeisIO.jl

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

resample! errors on NodalData #65

Closed tclements closed 3 years ago

tclements commented 3 years ago

Working on SeisIO#master with Julia 1.5.0, trying to resample some NodalData, which throws an error. Here is a MWE:

using SeisIO, SeisIO.Nodal 
ND = NodalData(rand(Float32,1000,10),Dict{String,Any}(),Int64[],0) # initialize from random matrix
ND.fs = ones(10) .* 1000. # set fs = 1000 Hz 
resample(ND,fs=200.) # resample to 200 Hz 
ERROR: MethodError: no method matching deleteat!(::SubArray{Float32,1,Array{Float32,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}, ::UnitRange{Int64})
Closest candidates are:
  deleteat!(::SentinelArrays.MissingVector, ::Any) at /home/timclements/.julia/packages/SentinelArrays/Ubf17/src/missingvector.jl:51
  deleteat!(::BitArray{1}, ::UnitRange{Int64}) at bitarray.jl:942
  deleteat!(::BitArray{1}, ::Any) at bitarray.jl:966
  ...
Stacktrace:
 [1] cheap_resample!(::Array{Int64,2}, ::SubArray{Float32,1,Array{Float32,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}, ::Float64, ::Float64) at /home/timclements/.julia/dev/SeisIO/src/Processing/resample.jl:31
 [2] resample!(::NodalData; chans::Array{Int64,1}, fs::Float64) at /home/timclements/.julia/dev/SeisIO/src/Processing/resample.jl:72
 [3] #resample#153 at /home/timclements/.julia/dev/SeisIO/src/Processing/resample.jl:99 [inlined]
 [4] top-level scope at REPL[38]:1

cheap_resample! is throwing an error when trying to delete a 1D view of a matrix.

I can write a new version of cheap_resample for 2D arrays. My solution is to overwrite the existing data column by column, then trim the excess rows in the case of downsampling (upsampling requires a vcat).

jpjones76 commented 3 years ago

Merging PR #68 to dev now... Travis-CI is very busy again today, but tests will complete "eventually".

jpjones76 commented 3 years ago

Merged into master. Going to close this for now. Thank you for the PR!