Skip to content

Commit

Permalink
using isapprox to check equality.
Browse files Browse the repository at this point in the history
  • Loading branch information
iancze committed Feb 13, 2016
1 parent ae9ea12 commit c4b2f91
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/visibilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ function DataVis(fname::AbstractString, flagged::Bool=false)
# Convert from Hz to wavelengths in μm
lams = cc ./ freqs * 1e4 # [μm]

uu = read(fid["uu"])
vv = read(fid["vv"])
real = read(fid["real"])
imag = read(fid["imag"])
uu = read(fid, "uu")
vv = read(fid, "vv")
real = read(fid, "real")
imag = read(fid, "imag")
VV = real + imag .* im # Complex visibility
weight = read(fid["weight"]) # [1/Jy^2]
# invsig = sqrt(read(fid["weight"])) # convert from [1/Jy^2] to [1/Jy]
flag = read(fid["flag"])
println(typeof(flag))
weight = read(fid, "weight") # [1/Jy^2]

flag = convert(Array{Bool}, read(fid["flag"]))
flag = convert(Array{Bool}, read(fid, "flag"))
close(fid)

nlam = length(lams)
Expand Down Expand Up @@ -177,11 +174,11 @@ function copy_flags(source::AbstractString, dest::AbstractString)
fid_source = h5open(source, "r") # read only
fid_dest = h5open(dest, "r+") # append mode

@assert fid_source["uu"][:,:] == fid_dest["uu"][:,:] "UU spacings between datasets do not match, make sure you have loaded $source with flagged=true."
@assert fid_source["vv"][:,:] == fid_dest["vv"][:,:] "VV spacings between dataset do not match, make sure you have loaded $source with flagged=true."
@assert fid_source["weight"][:,:] == fid_dest["weight"][:,:] "Weights between dataset do not match, make sure you have loaded $source with flagged=true."
@assert isapprox(read(fid_source, "uu"), read(fid_dest, "uu")) "UU spacings between datasets do not match, make sure you have loaded $source with flagged=true."
@assert isapprox(read(fid_source, "vv"), read(fid_dest, "vv")) "VV spacings between dataset do not match, make sure you have loaded $source with flagged=true."
@assert isapprox(read(fid_source, "weight"), read(fid_dest, "weight")) "Weights between dataset do not match, make sure you have loaded $source with flagged=true."

fid_dest["flag"] = fid_source["flag"][:,:]
fid_dest["flag"] = read(fid_source, "flag")

close(fid_source)
close(fid_dest)
Expand Down

0 comments on commit c4b2f91

Please sign in to comment.