jpjones76 / SeisIO.jl

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

resample! throws error when fs == S[1].fs #23

Closed tclements closed 4 years ago

tclements commented 4 years ago

resample!(S::GphysData;chans::Union{Integer, UnitRange, Array{Int64,1}}=Int64[], fs::Float64=0.0) throws an error when the resampling frequency fs == minimum(S.fs[chans[S.fs[chans] .> 0.0]]). The default should probably be to return nothing as in resample!(C::GphysChannel, f0::Float64)

S = get_data("FDSN", "UW.LON..BHZ", src="IRIS",s="2019-01-01",t=600)
resample(S,fs=S[1].fs)
ERROR: frequencies must be less than the Nyquist frequency 1.0
Stacktrace:
 [1] normalize_freq at /home/timclements/.julia/packages/DSP/wwKNu/src/Filters/design.jl:241 [inlined]
 [2] #Lowpass#22 at /home/timclements/.julia/packages/DSP/wwKNu/src/Filters/design.jl:256 [inlined]
 [3] Type at /home/timclements/.julia/packages/DSP/wwKNu/src/Filters/design.jl:256 [inlined]
 [4] resample_filter(::Rational{Int64}, ::Float64, ::Int64) at /home/timclements/.julia/packages/DSP/wwKNu/src/Filters/design.jl:649
 [5] resample_filter at /home/timclements/.julia/packages/DSP/wwKNu/src/Filters/design.jl:630 [inlined]
 [6] mkresample(::Float32) at /home/timclements/.julia/packages/SeisIO/4Sap1/src/Processing/resample.jl:6
 [7] #resample!#158(::Array{Int64,1}, ::Float64, ::Function, ::SeisData) at /home/timclements/.julia/packages/SeisIO/4Sap1/src/Processing/resample.jl:61
 [8] #resample#159 at ./none:0 [inlined]
 [9] (::getfield(DSP.Filters, Symbol("#kw##resample")))(::NamedTuple{(:fs,),Tuple{Float64}}, ::typeof(resample), ::SeisData) at ./none:0
 [10] top-level scope at none:0
tclements commented 4 years ago

Closing, confirmed working as expected. Needed to update SeisIO version

jpjones76 commented 4 years ago

Thank you for confirming. I was sitting here sputtering "...what did DSP do this time", because I knew I'd fixed something just like this two weeks ago.

On a related note: once the manuscript is done I plan to rewrite several processing routines to work exclusively in the frequency domain. Weird issues like this are caused by my import and override of DSP built-ins; the syntax and structure are extremely arcane, seemingly by their design. At some point the performance improvements stop being worth that extra effort...