Skip to content

Commit

Permalink
Arrayfuncs namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tclements committed Apr 30, 2019
1 parent cc186ef commit fdc7d30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/ArrayFuncs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module ArrayFuncs
export detrend, detrend!, demean, demean!, bandpass, bandpass!, bandstop, bandstop!,
lowpass, lowpass!, highpass, highpass!
import Statistics.mean
import LinearAlgebra.pinv
using DSP
Expand Down Expand Up @@ -460,4 +461,3 @@ end
highpass(A::AbstractArray{<:Union{Float32,Float64},2},freq::Float64,fs::Float64;
corners::Int=4,zerophase::Bool=false) = (U = deepcopy(A);
highpass!(U,freq,fs,corners=corners,zerophase=zerophase);return U)
end
2 changes: 1 addition & 1 deletion src/Noise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ __precompile__()
module Noise

using Dates, DataFrames, DSP, FFTW, Glob, JLD2, LinearAlgebra, SeisIO
include("./ArrayFuncs.jl")
include("ArrayFuncs.jl")
include("tools.jl")
include("slicing.jl")
include("filter.jl")
Expand Down
19 changes: 9 additions & 10 deletions src/compute_fft.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export process_raw, process_raw!, process_fft, compute_fft, whiten, save_fft
import .ArrayFuncs
"""
compute_fft(S::SeisData,freqmin::Float64,freqmax::Float64, fs::Float64
cc_step::Int, cc_len::Int;
Expand Down Expand Up @@ -73,11 +72,11 @@ Checks:
"""
function process_raw!(S::SeisData, fs::Float64)
for ii = 1:S.n
ArrayFuncs.demean!(S[ii].x) # remove mean from channel
demean!(S[ii].x) # remove mean from channel
if fs S.fs
ArrayFuncs.detrend!(S[ii].x) # remove linear trend from channel
ArrayFuncs.taper!(S[ii].x,S[ii].fs) # taper channel ends
ArrayFuncs.lowpass!(S[ii].x,fs/2,S[ii].fs) # lowpass filter before downsampling
detrend!(S[ii].x) # remove linear trend from channel
taper!(S[ii].x,S[ii].fs) # taper channel ends
lowpass!(S[ii].x,fs/2,S[ii].fs) # lowpass filter before downsampling
S[ii] = downsample(S[ii],fs) # downsample to lower fs
end
phase_shift!(S[ii]) # timing offset from sampling period
Expand Down Expand Up @@ -110,12 +109,12 @@ function process_fft(A::AbstractArray,freqmin::Float64, freqmax::Float64,
zerophase::Bool=true)

# pre-process each window
ArrayFuncs.demean!(A)
ArrayFuncs.detrend!(A)
ArrayFuncs.taper!(A,fs)
ArrayFuncs.bandpass!(A,freqmin,freqmax,fs,corners=corners,
demean!(A)
detrend!(A)
taper!(A,fs)
bandpass!(A,freqmin,freqmax,fs,corners=corners,
zerophase=zerophase)
ArrayFuncs.demean!(A)
demean!(A)

# apply one-bit normalization
if time_norm == "one_bit"
Expand Down
9 changes: 4 additions & 5 deletions src/correlation.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cross-correlation module
export clean_up!, clean_up, correlate, compute_cc, next_fast_len, save_corr, load_fft
export correlate_parallel, generate_pairs
import .ArrayFuncs
import Statistics: mean
"""
clean_up!(A,freqmin,freqmax,fs)
Expand All @@ -16,10 +15,10 @@ Demean, detrend, taper and filter time series.
"""
function clean_up!(A::AbstractArray, freqmin::Real, freqmax::Real, fs::Real;
corners::Int=4, zerophase::Bool=true)
ArrayFuncs.demean!(A)
ArrayFuncs.detrend!(A)
ArrayFuncs.taper!(A,fs)
ArrayFuncs.bandpass!(A,freqmin,freqmax,fs,corners=corners,zerophase=zerophase)
demean!(A)
detrend!(A)
taper!(A,fs)
bandpass!(A,freqmin,freqmax,fs,corners=corners,zerophase=zerophase)
return nothing
end
clean_up(A::AbstractArray, freqmin::Real, freqmax::Real, fs::Real;
Expand Down

0 comments on commit fdc7d30

Please sign in to comment.