Skip to content

Commit

Permalink
minor rseis bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jpjones76 committed Jul 9, 2017
1 parent 5458fa2 commit d93893c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/Formats/batch_read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ function batch_read(files::Array{String,1}; ftype="SAC"::String, fs=0.0::Float64
NF = length(files)

# Parallelize file info read into shared arrays
ts = SharedArray{Int64,1}(NF)
nx = SharedArray{Int32,1}(NF)
rr = SharedArray{Float32,1}(NF)
gain = SharedArray{Float32,1}(NF)
ts = SharedArray(Int64, (NF,))
nx = SharedArray(Int32, (NF,))
rr = SharedArray(Float32, (NF,))
gain = SharedArray(Float32, (NF,))

if ftype == "SAC"
fmt = Array{Type,1}(collect(Main.Base.Iterators.repeated(Float32, NF)))
fmt = Array{Type,1}(collect(repeated(Float32, NF)))
id = getsach(files, ts, nx, gain, rr)
os = 632
elseif ftype == "PASSCAL"
Expand All @@ -44,18 +44,18 @@ function batch_read(files::Array{String,1}; ftype="SAC"::String, fs=0.0::Float64
dt = Float64(1/fs)
end
DT = round(Int, dt*1.0e6)
OS = Array{Int64,1}(collect(Main.Base.Iterators.repeated(os, NF)))
NN = ceil.(Int, nx.*rr./dt)
OS = Array{Int64,1}(collect(repeated(os, NF)))
NN = ceil(Int, nx.*rr./dt)
ei = cumsum(NN)
si = convert(SharedArray{Int64,1}, [0; ei[1:end-1]])
ll = ei[end]

# Shared arrays
xx = SharedArray{Float64,1}(ll)
tt = SharedArray{Int64,1}(ll)
xx = SharedArray(Float64, (ll,))
tt = SharedArray(Int64, (ll,))

# Parallel read into shared array
rr = convert(SharedArray{Float64,1}, round.(Int64, rr.*1.0e6) ./ DT)
rr = convert(SharedArray{Float64,1}, map(Int64, rr.*1.0e6) ./ DT)
par_read(files, nx, rr, si, fmt, gain, ts, DT, os, tt, xx)

# loop over each unique ID
Expand Down Expand Up @@ -203,7 +203,7 @@ function read_bat(j::Int64, fname::String, DT::Int64, os::Int64,
lx = length(x)
i = si[j]
xx[i+1:i+lx] = x
tt[i+1:i+lx] = cumsum([ts[j]; collect(Main.Base.Iterators.repeated(DT, lx-1))])
tt[i+1:i+lx] = cumsum([ts[j]; collect(repeated(DT, lx-1))])
return
end

Expand Down
2 changes: 1 addition & 1 deletion src/Types/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function rdata(io::IOStream)
# float arrays
S.loc[i] = read(io, Float64, 5)
if i64[2] > 0
S.resp[i] = reshape(complex(read(io, Float64, i64[2]), read(io, Float64, i64[2])), div(i64[2],2), 2)
S.resp[i] = reshape(complex.(read(io, Float64, i64[2]), read(io, Float64, i64[2])), div(i64[2],2), 2)
end

# U8
Expand Down

0 comments on commit d93893c

Please sign in to comment.