Commit 225ac7af authored by Javier's avatar Javier

minor bugs in comp_t0 + error normalization t2E

error finding non-defined id
parent 9c245c00
...@@ -469,19 +469,21 @@ function comp_t0(Y::YData, plat::Vector{Int64}; L::Int64, pl::Bool=false, ...@@ -469,19 +469,21 @@ function comp_t0(Y::YData, plat::Vector{Int64}; L::Int64, pl::Bool=false,
replica = size.([Ysl], 1) replica = size.([Ysl], 1)
#Truncation #Truncation
n_ws = findfirst(x-> x == ws.str2id[id], ws.map_nob) if id in keys(ADerrors.wsg.str2id)
if !isnothing(n_ws) n_ws = findfirst(x-> x == ws.str2id[id], ws.map_nob)
ivrep_ws = ws.fluc[n_ws].ivrep if !isnothing(n_ws)
ivrep_ws = ws.fluc[n_ws].ivrep
if length(ivrep_ws) != 1 if length(ivrep_ws) != 1
error("Different number of replicas") error("Different number of replicas")
end end
if replica[1] > ivrep_ws[1] if replica[1] > ivrep_ws[1]
println("Automatic truncation in Ysl ", ivrep_ws[1], " / ", replica[1], ". R = 1") println("Automatic truncation in Ysl ", ivrep_ws[1], " / ", replica[1], ". R = 1")
Ysl = Ysl[1:ivrep_ws[1], :, :] Ysl = Ysl[1:ivrep_ws[1], :, :]
elseif replica[1] < ivrep_ws[1] elseif replica[1] < ivrep_ws[1]
error("Automatic truncation failed. R = 1\nTry using truncate_data!") error("Automatic truncation failed. R = 1\nTry using truncate_data!")
end
end end
end end
...@@ -552,26 +554,29 @@ function comp_t0(Y::Vector{YData}, plat::Vector{Int64}; L::Int64, pl::Bool=false ...@@ -552,26 +554,29 @@ function comp_t0(Y::Vector{YData}, plat::Vector{Int64}; L::Int64, pl::Bool=false
if !all(id .== id[1]) if !all(id .== id[1])
error("IDs are not equal") error("IDs are not equal")
end end
id = id[1]
#Truncation #Truncation
n_ws = findfirst(x-> x == ws.str2id[id[1]], ws.map_nob) if id in keys(ADerrors.wsg.str2id)
if !isnothing(n_ws) n_ws = findfirst(x-> x == ws.str2id[id], ws.map_nob)
ivrep_ws = ws.fluc[n_ws].ivrep if !isnothing(n_ws)
ivrep_ws = ws.fluc[n_ws].ivrep
if length(replica) != length(ivrep_ws) if length(replica) != length(ivrep_ws)
error("Different number of replicas") error("Different number of replicas")
end end
for k = 1:length(replica) for k = 1:length(replica)
if replica[k] > ivrep_ws[k] if replica[k] > ivrep_ws[k]
println("Automatic truncation in Ysl ", ivrep_ws[k], " / ", replica[k], ". R = ", k) println("Automatic truncation in Ysl ", ivrep_ws[k], " / ", replica[k], ". R = ", k)
Ysl[k] = Ysl[k][1:ivrep_ws[k], :, :] Ysl[k] = Ysl[k][1:ivrep_ws[k], :, :]
elseif replica[k] < ivrep_ws[k] elseif replica[k] < ivrep_ws[k]
error("Automatic truncation failed. R = ", replica[k], "\nTry using truncate_data!") error("Automatic truncation failed. R = ", replica[k], "\nTry using truncate_data!")
end
end end
replica = size.(Ysl, 1)
end end
replica = size.(Ysl, 1)
end end
Ysl = isnothing(rw) ? Ysl : apply_rw(Ysl, rw) Ysl = isnothing(rw) ? Ysl : apply_rw(Ysl, rw)
tmp = Ysl[1] tmp = Ysl[1]
[tmp = cat(tmp, Ysl[k], dims=1) for k = 2:nr] [tmp = cat(tmp, Ysl[k], dims=1) for k = 2:nr]
...@@ -583,7 +588,7 @@ function comp_t0(Y::Vector{YData}, plat::Vector{Int64}; L::Int64, pl::Bool=false ...@@ -583,7 +588,7 @@ function comp_t0(Y::Vector{YData}, plat::Vector{Int64}; L::Int64, pl::Bool=false
for i = 1:xmax for i = 1:xmax
k = 1 k = 1
for j = nt0-dt0:nt0+dt0 for j = nt0-dt0:nt0+dt0
Y_aux[i, k] = uwreal(tmp[:, i, j], id[1], replica) Y_aux[i, k] = uwreal(tmp[:, i, j], id, replica)
k = k + 1 k = k + 1
end end
end end
...@@ -629,6 +634,10 @@ end ...@@ -629,6 +634,10 @@ end
function t0_guess(t::Vector{Float64}, Ysl::Array{Float64, 3}, plat::Vector{Int64}, L::Int64) function t0_guess(t::Vector{Float64}, Ysl::Array{Float64, 3}, plat::Vector{Int64}, L::Int64)
t2E_ax = t.^2 .* mean(mean(Ysl[:, plat[1]:plat[2], :], dims=2), dims=1)[1, 1, :] / L^3 t2E_ax = t.^2 .* mean(mean(Ysl[:, plat[1]:plat[2], :], dims=2), dims=1)[1, 1, :] / L^3
#look for values t2E: t2E > 0.3 and 0.0 < t2E_ax < 0.3
if !(any(t2E_ax .> 0.3) && any((t2E_ax .< 0.3) .& (t2E_ax .> 0.0)))
error("Error finding solutions. Check volume normalization!")
end
t0_aux = minimum(abs.(t2E_ax .- 0.3)) t0_aux = minimum(abs.(t2E_ax .- 0.3))
nt0 = findfirst(x-> abs(x - 0.3) == t0_aux, t2E_ax) #index closest value to t0 nt0 = findfirst(x-> abs(x - 0.3) == t0_aux, t2E_ax) #index closest value to t0
return nt0 return nt0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment