Skip to content

Commit

Permalink
Allow for saving FFTs/Corrs from the GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
tclements committed Jul 10, 2020
1 parent d38c04a commit 3c7042a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ export save_fft, load_fft, load_corr, save_corr
Save FFTData `F` to JLD2.
"""
function save_fft(F::FFTData, FFTOUT::String)
# check if FFT DIR exists
# check if FFTDIR exists
FFTOUT = expanduser(FFTOUT)
if isdir(FFTOUT) == false
mkpath(FFTOUT)
end

# check if F is on the GPU
if isa(F.fft,AbstractGPUArray)
F = F |> cpu
end

# create JLD2 file and save FFT
net,sta,loc,chan = split(F.name,'.')
filename = joinpath(FFTOUT,"$(F.name).jld2")
Expand Down Expand Up @@ -75,12 +80,17 @@ end
Save CorrData `C` to JLD2.
"""
function save_corr(C::CorrData, CORROUT::String)
# check if FFT DIR exists
# check if CORRDIR exists
CORROUT = expanduser(CORROUT)
if isdir(CORROUT) == false
mkpath(CORROUT)
end

# check if C is on the GPU
if isa(C.corr,AbstractGPUArray)
C = C |> cpu
end

# create JLD2 file and save correlation
filename = joinpath(CORROUT,"$(C.name).jld2")
file = jldopen(filename, "a+")
Expand Down

0 comments on commit 3c7042a

Please sign in to comment.