diff --git a/Project.toml b/Project.toml index 3ab572f..81d6439 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SeisNoise" uuid = "8cc7c3c0-6b5d-11e9-39fe-c9cd0236e08b" -authors = ["timclements "] -version = "0.5.3" +authors = ["Tim Clements "] +version = "0.5.4" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -14,20 +14,20 @@ Glob = "c27321d9-0574-5035-807b-f59d2c89b15c" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -SeisIO = "b372bb87-02dd-52bb-bcf6-c30dd83fd342" +SeisBase = "8b7dfb90-41a7-4c72-9751-87603311c074" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] Adapt = "1.0.1, 2.0, 3.0" -CUDA = "2, 3" +CUDA = "2, 3, 4, 5" DSP = "0.6, 0.7" FFTW = "1.1, 1.2, 1.3, 1.4" -GPUArrays = "3.1, 4.0, 5.0, 6.2, 7.0, 8.0" -Glob = "1.2" +GPUArrays = "3.1, 4.0, 5.0, 6.2, 7.0, 8.0, 9.0" +Glob = "1.2, 1.3" JLD2 = "0.1, 0.2, 0.3, 0.4" RecipesBase = "1.1" -SeisIO = "1.0, 1.1, 1.2" -StatsBase = "0.32,0.33" +SeisBase = "0.1.0" +StatsBase = "0.32,0.33,0.34" julia = "1" diff --git a/README.md b/README.md index c9c3774..a35f51b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ From the Julia command prompt: ```julia julia>] -(@v1.6) pkg> add SeisNoise +(@v1.9) pkg> add SeisNoise ``` Or, equivalently, via the `Pkg` API: @@ -23,14 +23,14 @@ julia> import Pkg; Pkg.add("SeisNoise") We recommend using the latest version of SeisNoise by updating with the Julia package manager: ```julia -(@v1.6) pkg> update SeisNoise +(@v1.9) pkg> update SeisNoise ``` ## Package Features ![flow](/docs/src/assets/SeisNoise-DataFlow.jpg) - - Built upon [SeisIO](https://seisio.readthedocs.io/en/latest/) for easy and fast I/O. + - Built upon [SeisBase](https://juliaseismo.github.io/SeisBase.jl/dev/) for easy and fast I/O. - Custom structures for storing Raw Data, Fourier Transforms of data, and cross-correlations - CPU/GPU compatible functions for cross-correlation. - Methods for [*dv/v* measurements](https://github.com/tclements/SeisDvv.jl). @@ -144,4 +144,4 @@ If you use SeisNoise in your work, please star the package and cite our work [DO ``` ## Contributing -We welcome folks interested in contributing to SeisNoise. Please [open an issue](https://github.com/tclements/SeisNoise.jl/issues/new) to let us know about bug reports, new methods/code, and or feature requests/usage cases. If you would like to submit a pull request (PR), please include accompanying [tests](https://github.com/tclements/SeisNoise.jl/tree/master/test). +We welcome folks interested in contributing to SeisNoise. Please [open an issue](https://github.com/JuliaSeismo/SeisNoise.jl/issues/new) to let us know about bug reports, new methods/code, and or feature requests/usage cases. If you would like to submit a pull request (PR), please include accompanying [tests](https://github.com/JuliaSeismo/SeisNoise.jl/tree/master/test). diff --git a/docs/make.jl b/docs/make.jl index 8476b6d..f0525d3 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -22,7 +22,7 @@ makedocs( ) deploydocs( - repo = "github.com/tclements/SeisNoise.jl.git", + repo = "github.com/JuliaSeismo/SeisNoise.jl.git", target = "build", deps = nothing, make = nothing, diff --git a/docs/src/contributing.md b/docs/src/contributing.md index 9ec3f54..b5a8997 100644 --- a/docs/src/contributing.md +++ b/docs/src/contributing.md @@ -41,7 +41,7 @@ is anything you need to know beforehand. The easiest way to get involved is to report issues you encounter when using SeisNoise or by requesting something you think is missing. -* Head over to the [issues](https://github.com/tclements/SeisNoise.jl/issues) page. +* Head over to the [issues](https://github.com/JuliaSeismo/SeisNoise.jl/issues) page. * Search to see if your issue already exists or has even been solved previously. * If you indeed have a new issue or request, click the "New Issue" button. * Please be as specific as possible. Include the version of the code you were using, as @@ -55,7 +55,7 @@ SeisNoise or by requesting something you think is missing. * Install git on your system if it is not already there (install XCode command line tools on a Mac or git bash on Windows). * Login to your GitHub account and make a fork of the - [SeisNoise repository](https://github.com/tclements/SeisNoise.jl) by + [SeisNoise repository](https://github.com/JuliaSeismo/SeisNoise.jl) by clicking the "Fork" button. * Clone your fork of the SeisNoise repository (in terminal on Mac/Linux or git shell/ GUI on Windows) in the location you'd like to keep it. @@ -65,7 +65,7 @@ SeisNoise or by requesting something you think is missing. * Navigate to that folder in the terminal or in Anaconda Prompt if you're on Windows. * Connect your repository to the upstream (main project). ``` - git remote add SeisNoise https://github.com/tclements/SeisNoise.jl.git + git remote add SeisNoise https://github.com/JuliaSeismo/SeisNoise.jl.git ``` * Create the development environment by opening Julia via `julia --project` then typing in `] instantiate`. This will install all the dependencies in the Project.toml @@ -84,7 +84,7 @@ written a [guide](https://chris.beams.io/posts/git-commit/) on how to write good commit messages. When you think your changes are ready to be merged into the main repository, -push to your fork and [submit a pull request](https://github.com/tclements/SeisNoise.jl/compare/). +push to your fork and [submit a pull request](https://github.com/JuliaSeismo/SeisNoise.jl/compare/). **Working on your first Pull Request?** You can learn how from this _free_ video series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github), Aaron Meurer's [tutorial on the git workflow](https://www.asmeurer.com/git-workflow/), or the guide [“How to Contribute to Open Source"](https://opensource.guide/how-to-contribute/). diff --git a/docs/src/using_gpus.md b/docs/src/using_gpus.md index 974b74a..1334f05 100644 --- a/docs/src/using_gpus.md +++ b/docs/src/using_gpus.md @@ -6,7 +6,7 @@ are possible. !!! tip "Running on GPUs" If you are having issues with running SeisNoise on a GPU or setting things up, - please [open an issue](https://github.com/tclements/SeisNoise.jl/issues/new) + please [open an issue](https://github.com/JuliaSeismo/SeisNoise.jl/issues/new) and we'll do our best to help out! ## When to use a GPU diff --git a/src/ArrayFuncs.jl b/src/ArrayFuncs.jl index 47af774..e46412f 100644 --- a/src/ArrayFuncs.jl +++ b/src/ArrayFuncs.jl @@ -1,4 +1,4 @@ -import SeisIO: demean, demean!, taper, taper!,detrend, detrend! +import SeisBase: demean, demean!, taper, taper!,detrend, detrend! export detrend, detrend!, taper, taper!, demean, demean!, hanningwindow # Signal processing functions for arrays (rather than SeisData or SeisChannel) diff --git a/src/SeisNoise.jl b/src/SeisNoise.jl index c3e2dba..7125b3e 100644 --- a/src/SeisNoise.jl +++ b/src/SeisNoise.jl @@ -1,6 +1,6 @@ module SeisNoise -using Dates, DSP, FFTW, Glob, JLD2, LinearAlgebra, SeisIO, SeisIO.Nodal +using Dates, DSP, FFTW, Glob, JLD2, LinearAlgebra, SeisBase, SeisBase.Nodal using Statistics, StatsBase, CUDA, Adapt, GPUArrays, RecipesBase # check use of cuda diff --git a/src/Types/NoiseData.jl b/src/Types/NoiseData.jl index 59f852d..e682bf5 100644 --- a/src/Types/NoiseData.jl +++ b/src/Types/NoiseData.jl @@ -1,10 +1,10 @@ import Base: in, +, -, *, ==, convert, isempty, isequal, length, push!, sizeof, append! import Base: lastindex, firstindex, getindex, setindex!, sort, sort! -import SeisIO: GeoLoc, PZResp, InstrumentResponse +import SeisBase: GeoLoc, PZResp, InstrumentResponse export RawData, FFTData, CorrData, gpu, cpu, sort, sort!, append! export isequal, isempty, length, +, == -# Many thanks to SeisIO for inspiration for NoiseData objects +# Many thanks to SeisBase for inspiration for NoiseData objects const datafields = (:x,:fft,:corr) @@ -28,7 +28,7 @@ A structure for raw ambient noise data. | :cc_len | Raw data window length in seconds. | | :cc_step | Spacing between windows in seconds. | | :time_norm | Apply one-bit whitening with "one_bit". | -| :resp | SeisIO InstrumentResponse object | +| :resp | SeisBase InstrumentResponse object | | :misc | Dictionary for non-critical information. | | :notes | Timestamped notes; includes automatically-logged acquisition and | | | processing information. | @@ -185,7 +185,7 @@ A structure for fourier transforms (FFT) of ambient noise data. | :cc_step | Spacing between windows in number of points. | | :whitened | Whitening applied. | :time_norm | Apply one-bit whitening with "one_bit". | -| :resp | SeisIO InstrumentResponse object | +| :resp | SeisBase InstrumentResponse object | | :misc | Dictionary for non-critical information. | | :notes | Timestamped notes; includes automatically-logged acquisition and | | | processing information. | @@ -282,7 +282,7 @@ A structure for cross-correlations of ambient noise data. | :cc_step | Spacing between windows in number of points. | | :whitened | Whitening applied. | :time_norm | Apply one-bit whitening with "one_bit". | -| :resp | SeisIO InstrumentResponse object | +| :resp | SeisBase InstrumentResponse object | | :misc | Dictionary for non-critical information. | | :notes | Timestamped notes; includes automatically-logged acquisition and | | | processing information. | diff --git a/src/Types/show.jl b/src/Types/show.jl index edc3883..9b26ba5 100644 --- a/src/Types/show.jl +++ b/src/Types/show.jl @@ -26,19 +26,19 @@ function show(io::IO, R::RawData) fstr = uppercase(String(f)) print(io, lpad(fstr, show_os-2), ": ") if f == :notes || f == :misc - SeisIO.show_str(io, String[string(length(targ), " entries")], w, N) + SeisBase.show_str(io, String[string(length(targ), " entries")], w, N) elseif (t <: AbstractFloat || t <: InstrumentPosition || t<: InstrumentResponse) println(io, repr("text/plain", targ, context=:compact=>true)) elseif f == :t if length(R.t) > 0 - SeisIO.show_str(io, String[timestamp(R.t[1]), " (", string(length(R.t)), " windows)"], w, N) + SeisBase.show_str(io, String[timestamp(R.t[1]), " (", string(length(R.t)), " windows)"], w, N) else - SeisIO.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) + SeisBase.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) end elseif f == :x - SeisIO.show_str(io, String[summary(targ)], w, N) + SeisBase.show_str(io, String[summary(targ)], w, N) else - SeisIO.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) + SeisBase.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) end end end @@ -63,19 +63,19 @@ function show(io::IO, F::FFTData) fstr = uppercase(String(f)) print(io, lpad(fstr, show_os-2), ": ") if f == :notes || f == :misc - SeisIO.show_str(io, String[string(length(targ), " entries")], w, N) + SeisBase.show_str(io, String[string(length(targ), " entries")], w, N) elseif (t <: AbstractFloat || t <: InstrumentPosition || t<: InstrumentResponse) println(io, repr("text/plain", targ, context=:compact=>true)) elseif f == :t if length(F.t) > 0 - SeisIO.show_str(io, String[timestamp(F.t[1]), " (", string(length(F.t)), " FFTs)"], w, N) + SeisBase.show_str(io, String[timestamp(F.t[1]), " (", string(length(F.t)), " FFTs)"], w, N) else - SeisIO.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) + SeisBase.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) end elseif f == :fft - SeisIO.show_str(io, String[summary(targ)], w, N) + SeisBase.show_str(io, String[summary(targ)], w, N) else - SeisIO.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) + SeisBase.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) end end end @@ -99,19 +99,19 @@ function show(io::IO, C::CorrData) fstr = uppercase(String(f)) print(io, lpad(fstr, show_os-2), ": ") if f == :notes || f == :misc - SeisIO.show_str(io, String[string(length(targ), " entries")], w, N) + SeisBase.show_str(io, String[string(length(targ), " entries")], w, N) elseif (t <: AbstractFloat || t <: InstrumentPosition || t<: InstrumentResponse) println(io, repr("text/plain", targ, context=:compact=>true)) elseif f == :t if length(C.t) > 0 - SeisIO.show_str(io, String[timestamp(C.t[1]), " (", string(length(C.t)), " Corrs)"], w, N) + SeisBase.show_str(io, String[timestamp(C.t[1]), " (", string(length(C.t)), " Corrs)"], w, N) else - SeisIO.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) + SeisBase.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) end elseif f == :corr - SeisIO.show_str(io, String[summary(targ)], w, N) + SeisBase.show_str(io, String[summary(targ)], w, N) else - SeisIO.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) + SeisBase.show_str(io, String[repr("text/plain", targ, context=:compact=>true)], w, N) end end end diff --git a/src/filter.jl b/src/filter.jl index 22bb56b..7328cb3 100644 --- a/src/filter.jl +++ b/src/filter.jl @@ -1,5 +1,5 @@ import DSP: resample -import SeisIO: resample, resample! +import SeisBase: resample, resample! export bandpass, bandpass!, bandstop, bandstop!, lowpass, lowpass! export highpass, highpass!, taper, taper!, envelope export resample, resample! @@ -409,23 +409,23 @@ end """ resample!(R, fs) -Resample data in `RawData` R to new sampling rate `fs`. +Resample data in `RawData` R to new sampling rate `fs`. # Arguments -- `R::RawData`: RawData to resample. +- `R::RawData`: RawData to resample. - `fs::Real`: New sampling frequency. """ function resample!(R::RawData,fs::Real) @assert fs > 0 "New fs must be greater than 0!" if R.fs == fs - return nothing + return nothing end T = eltype(R.x) rate = T(fs / R.fs) R.x = resample_kernel(R.x, rate) R.fs = Float64(fs) if (R.freqmax < fs / 2) && (rate < 1.0) - R.freqmax = Float64(fs / 2) + R.freqmax = Float64(fs / 2) end return nothing end @@ -434,30 +434,30 @@ resample(R::RawData,fs::Real) = (U = deepcopy(R); resample!(U,fs); return U) """ resample!(C, fs) -Resample data in CorrData` C to new sampling rate `fs`. +Resample data in CorrData` C to new sampling rate `fs`. # Arguments -- `C::CorrData`: CorrData to resample. +- `C::CorrData`: CorrData to resample. - `fs::Real`: New sampling frequency. """ function resample!(C::CorrData,fs::Real) @assert fs > 0 "New fs must be greater than 0!" - if C.fs == fs - return nothing + if C.fs == fs + return nothing end T = eltype(C.corr) rate = T(fs / C.fs) C.corr = resample_kernel(C.corr, rate) C.fs = Float64(fs) if (C.freqmax < fs / 2) && (rate < 1.0) - C.freqmax = Float64(fs / 2) + C.freqmax = Float64(fs / 2) end return nothing end resample(C::CorrData,fs::Real) = (U = deepcopy(C); resample!(U,fs); return U) function resample_kernel(x::AbstractMatrix,rate::Real) - T = eltype(x) + T = eltype(x) h = resample_filter(rate) self = FIRFilter(h, rate) @@ -469,7 +469,7 @@ function resample_kernel(x::AbstractMatrix,rate::Real) # b) set the ϕ index of the PFB (fractional part of τ) setphase!(self, τ) - # calculate number of zeros + # calculate number of zeros Nrows, Ncols = size(x) outLen = ceil(Int, Nrows*rate) reqInlen = inputlength(self, outLen) @@ -485,4 +485,4 @@ function resample_kernel(x::AbstractMatrix,rate::Real) out[1:xlength,ii] .= filt(deepcopy(self), xPadded[:,ii]) end return out -end \ No newline at end of file +end diff --git a/src/slicing.jl b/src/slicing.jl index 77f59af..0c87396 100644 --- a/src/slicing.jl +++ b/src/slicing.jl @@ -1,4 +1,4 @@ -import SeisIO: sync +import SeisBase: sync export start_end, slide, nearest_start_end, slide_ind, sync const μs = 1.0e-6 const sμ = 1000000.0 @@ -9,7 +9,7 @@ const sμ = 1000000.0 Return start and endtimes of SeisChannel in DateTime format. """ function start_end(C::SeisChannel) - return u2d.(SeisIO.t_win(C.t,C.fs) * 1e-6) + return u2d.(SeisBase.t_win(C.t,C.fs) * 1e-6) end """ @@ -101,7 +101,7 @@ slide(C::SeisChannel, cc_len::Real, cc_step::Real) = slide(C.x,cc_len,cc_step,C. Return best possible start, end times for data in `C` given the `cc_step` and `cc_len`. """ function nearest_start_end(C::SeisChannel, cc_len::Float64, cc_step::Float64) - su,eu = SeisIO.t_win(C.t,C.fs) * μs + su,eu = SeisBase.t_win(C.t,C.fs) * μs su = round(su,digits=4) # round due to numerical roundoff error eu = round(eu,digits=4) # round due to numerical roundoff error ideal_start = d2u(DateTime(Date(u2d(su)))) # midnight of same day diff --git a/test/runtests.jl b/test/runtests.jl index 62d2914..83e1c5d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,11 +1,10 @@ -using Dates +using Dates using FFTW using Glob -using SeisIO +using SeisBase using SeisNoise using Statistics using Test -import StatsBase: sample include("test_NoiseData.jl") include("test_show.jl") diff --git a/test/test_correlation.jl b/test/test_correlation.jl index c25c5e5..de11fe5 100644 --- a/test/test_correlation.jl +++ b/test/test_correlation.jl @@ -69,7 +69,7 @@ rand_id() = string(rand_net(), ".", rand_sta(), ".", rand_loc(), ".HH", rand('A' @test Cclean.freqmin == freqmin @test Cclean.freqmax == freqmax @test CInt.freqmin == freqmin - @test CInt.freqmax == freqmax + @test CInt.freqmax == freqmax # test in-place clean_up!(C,freqmin,freqmax) @@ -107,7 +107,7 @@ end @test all([t[maxinds[ii][1]] == 0 for ii in length(maxinds)]) # test correlation with FFTData - Ch = SeisIO.RandSeis.randSeisChannel(c=false,s=true) + Ch = SeisBase.RandSeis.randSeisChannel(c=false,s=true) ungap!(Ch) Ch.x = rand(T,Int(cc_len*Nwin*fs +1)) .- T(0.5) Ch.fs = fs @@ -125,7 +125,7 @@ end @test all([t[maxinds[ii][1]] == 0 for ii in length(maxinds)]) # test max args @test C.rotated == false # test rotation @test C.corr_type == "CC" # test cross-correlation - @test C.maxlag == CInt.maxlag + @test C.maxlag == CInt.maxlag @test C.corr == CInt.corr # test windows that do not overlap @@ -186,7 +186,7 @@ end Fhigh = whiten(F,freqmin,fs/2,fs,N,pad=pad) @test all(abs.(Fhigh[end-pad:end,:]) .< 1.) - # test with integer arguments + # test with integer arguments FInt = whiten(F,Int(freqmin),Int(freqmax),Int(fs),N,pad=pad) # test in-place @@ -195,7 +195,7 @@ end @test F == FInt # test FFTData - Ch = SeisIO.RandSeis.randSeisChannel(c=false,s=true) + Ch = SeisBase.RandSeis.randSeisChannel(c=false,s=true) Ch.loc = GeoLoc() ungap!(Ch) Ch.x = rand(T,Int(cc_len*Nwin*fs +1)) .- T(0.5) @@ -230,7 +230,7 @@ end @test Fhigh.freqmin == freqmin @test Fhigh.freqmax == F.freqmax - # test with integer input + # test with integer input FInt = whiten(F,Int(freqmin),Int(freqmax)) @test FInt.freqmin == freqmin @test FInt.freqmax == freqmax @@ -270,9 +270,9 @@ end @test Rhigh.freqmin == freqmin @test Rhigh.freqmax == R.freqmax - # test with integer input + # test with integer input RInt = whiten(R,Int(freqmin),Int(freqmax)) - @test RInt.freqmin == freqmin + @test RInt.freqmin == freqmin @test RInt.freqmax == freqmax # test in-place diff --git a/test/test_deprecated.jl b/test/test_deprecated.jl index 7b2d1fd..7e30e35 100644 --- a/test/test_deprecated.jl +++ b/test/test_deprecated.jl @@ -45,7 +45,7 @@ end @testset "compute cc" begin cc_len = 40.96 # length of noise window cc_step = 40.96 # step between windows - Ch = SeisIO.RandSeis.randSeisChannel(c=false,s=true) + Ch = SeisBase.RandSeis.randSeisChannel(c=false,s=true) ungap!(Ch) Ch.x = rand(T,Int(cc_len*Nwin*fs +1)) .- T(0.5) Ch.fs = fs diff --git a/test/test_rotation.jl b/test/test_rotation.jl index e32a668..c8532c9 100644 --- a/test/test_rotation.jl +++ b/test/test_rotation.jl @@ -13,7 +13,7 @@ starttime = d2u(DateTime(Date(now()))) # starttime for SeisChanel / SeisData @testset "rotation" begin - Ch = SeisIO.RandSeis.randSeisChannel(c=false,s=true) + Ch = SeisBase.RandSeis.randSeisChannel(c=false,s=true) ungap!(Ch) Ch.x = rand(T,Int(cc_len*Nwin*fs +1)) .- T(0.5) Ch.fs = fs diff --git a/test/test_stacking.jl b/test/test_stacking.jl index 7f0bf80..55d815d 100644 --- a/test/test_stacking.jl +++ b/test/test_stacking.jl @@ -1,4 +1,4 @@ -# test stacking +# testSeisNoise.stacking T = Float32 fs = 100. # sampling rate @@ -19,43 +19,43 @@ starttime = d2u(DateTime(Date(now()))) # starttime for SeisChanel / SeisData C.t = collect(0.:3600.:(Nwin-1)*3600.) .+ starttime # test daystack - Cnew = stack(C) + Cnew = SeisNoise.stack(C) @test Cnew.t == [starttime] @test size(Cnew.corr) == (N,1) - # test hour stack -> this does nothing - Cnew = stack(C,interval=Hour(1)) + # test hourSeisNoise.stack -> this does nothing + Cnew = SeisNoise.stack(C,interval=Hour(1)) @test Cnew.t == C.t @test Cnew.corr == C.corr - # test 2hour stack - Cnew = stack(C,interval=Hour(2)) + # test 2hourSeisNoise.stack + Cnew = SeisNoise.stack(C,interval=Hour(2)) @test Cnew.t == collect(0.:7200.:(Nwin-1)*3600.) .+ starttime @test size(Cnew.corr) == (N,5) - # test 2hour stack w/ robuststack - Cnew = stack(C,interval=Hour(2),stacktype=robuststack) + # test 2hourSeisNoise.stack w/ robuststack + Cnew = SeisNoise.stack(C,interval=Hour(2),stacktype=robuststack) @test Cnew.t == collect(0.:7200.:(Nwin-1)*3600.) .+ starttime @test size(Cnew.corr) == (N,5) # test allstack - Cnew = stack(C,allstack=true) + Cnew = SeisNoise.stack(C,allstack=true) @test Cnew.t == [starttime] @test size(Cnew.corr) == (N,1) # test allstack w/ robuststack - Cnew = stack(C,allstack=true,stacktype=robuststack) + Cnew = SeisNoise.stack(C,allstack=true,stacktype=robuststack) @test Cnew.t == [starttime] @test size(Cnew.corr) == (N,1) # test inplace - Cnew = stack(C) - stack!(C) + Cnew = SeisNoise.stack(C) + SeisNoise.stack!(C) @test Cnew.corr == C.corr @test Cnew.t == C.t end -@testset "robust stack" begin +@testset "robustSeisNoise.stack" begin A = rand(T,N,Nwin) .+ T.(sin.(range(0.,10π,length=N))) B = robuststack(A) @test size(B) == (N,1) @@ -87,35 +87,35 @@ end @test Cnew.t == C.t end -@testset "median mute" begin +@testset "median mute" begin A = rand(T,N,Nwin) high = 2. low = 0.5 - # set two out of 10 to have large amplute + # set two out of 10 to have large amplute A[:,1] .*= 1000 # set two out of 10 to have small amplitude A[:,2] ./= 1000 - # test indexes for 0 < medianamp < high + # test indexes for 0 < medianamp < high ind = SeisNoise.medianmuteind(A, high) @test length(ind) == Nwin - 1 - # test indexes for low < medianamp < high + # test indexes for low < medianamp < high ind = SeisNoise.medianmuteind(A, high, low) @test length(ind) == Nwin - 2 - # test when low > high + # test when low > high @test_throws AssertionError SeisNoise.medianmuteind(A, low, high) # test with Nans # set two columns to have NaNs - A[rand(1:N,3),3] .= NaN + A[rand(1:N,3),3] .= NaN ind = SeisNoise.medianmuteind(A, high, low) @test length(ind) == Nwin - 3 # test with Infs # set two columns to have Infs - A[rand(1:N,3),4] .= Inf + A[rand(1:N,3),4] .= Inf ind = SeisNoise.medianmuteind(A, high, low) @test length(ind) == Nwin - 4 @@ -123,9 +123,9 @@ end C = CorrData() C.corr = A C.fs = fs - C.t = collect(0.:3600.:(Nwin-1)*3600.) .+ starttime + C.t = collect(0.:3600.:(Nwin-1)*3600.) .+ starttime - # test allocating version + # test allocating version Cnew = medianmute(deepcopy(C), high) @test Cnew != C @test size(Cnew.corr) == (N,7) @@ -137,12 +137,12 @@ end @test size(Cnew.corr) == (N,6) @test length(Cnew.t) == 6 - # test in-place version + # test in-place version medianmute!(C, high, low) - @test C == Cnew + @test C == Cnew end -@testset "phase weighted stack " begin +@testset "phase weightedSeisNoise.stack " begin A = rand(T,N,Nwin) .+ T.(sin.(range(0.,10π,length=N))) B = pws(A) @test size(B) == (N,1) @@ -205,43 +205,43 @@ end @test_throws ArgumentError remove_nan(C) end -@testset "smooth CorrData" begin +@testset "smooth CorrData" begin C = CorrData() A = rand(T,10001,Nwin) C.corr = A # time vector is [T00:00:00, T01:00:00, T02:00:00, ...] C.t = collect(0.:3600.:(Nwin-1)*3600.) .+ starttime - # smooth every 2 hours + # smooth every 2 hours Cnew = smooth(C,Hour(2)) # test that 2nd correlation is mean of first two hours @test Cnew.corr[:,2] == vec(mean(C.corr[:,1:2],dims=2)) - # add two hours to last 5 correlations - C.t[3:10] .+= 3600 * 3 + # add two hours to last 5 correlations + C.t[3:10] .+= 3600 * 3 Cnew = smooth(C,Hour(3)) # test that 2nd correlation is mean of first two hours @test Cnew.corr[:,2] == vec(mean(C.corr[:,1:2],dims=2)) - # test that 3rd correlation remains unchanged + # test that 3rd correlation remains unchanged @test Cnew.corr[:,3] == C.corr[:,3] # test that 5th correlation is mean of 3:5 @test Cnew.corr[:,5] == vec(mean(C.corr[:,3:5],dims=2)) - # randomize starttimes + # randomize starttimes C.t = collect(0.:3600.:(Nwin-1)*3600.) .+ starttime - ind = sample(1:Nwin,Nwin,replace=false) + ind = SeisNoise.sample(1:Nwin,Nwin,replace=false) Cnew = smooth(C[ind],Hour(2)) - # test correlations are ordered + # test correlations are ordered @test all(diff(Cnew.t) .== 3600) @test Cnew.corr[:,2] == vec(mean(C.corr[:,1:2],dims=2)) - # change time vector to Days + # change time vector to Days C.t = collect(0.:3600.:(Nwin-1)*3600.) .* 24 .+ starttime Cnew = smooth(C,Day(3)) @test Cnew.corr[:,3] == vec(mean(C.corr[:,1:3],dims=2)) - # test inplace version + # test inplace version smooth!(C,Day(3)) @test Cnew == C end @@ -261,7 +261,7 @@ end @test eltype(Cnew.corr) == eltype(C.corr) @test Cnew.maxlag == newlag - # test with Int + # test with Int CInt = shorten(C,Int(newlag)) @test size(CInt.corr) == (Int(newlag * fs * 2 + 1),Nwin) @test eltype(CInt.corr) == eltype(C.corr) @@ -279,7 +279,7 @@ end newlag = -5. @test_throws AssertionError shorten(C,newlag) - # test where newlag % (1/C.fs) != 0 + # test where newlag % (1/C.fs) != 0 newlag = π Cpi = shorten(C,π) @test Cpi.maxlag == 3.14