CSV export to one file
This commit is contained in:
parent
cac2733bb8
commit
325e5bd7e5
|
|
@ -128,9 +128,7 @@ for c in extrapolating_c
|
||||||
push!(extrapolated, nearest(evals, current_E))
|
push!(extrapolated, nearest(evals, current_E))
|
||||||
end
|
end
|
||||||
|
|
||||||
open("temp/Berggren_B2R.training.csv", "w") do f; writedlm(f, hcat(reim(training)...)); end
|
exportCSV("temp/Berggren_B2R.csv", (training, exact, extrapolated), ("training", "exact", "extrapolated"))
|
||||||
open("temp/Berggren_B2R.exact.csv", "w") do f; writedlm(f, hcat(reim(exact)...)); end
|
|
||||||
open("temp/Berggren_B2R.extrapolated.csv", "w") do f; writedlm(f, hcat(reim(extrapolated)...)); end
|
|
||||||
|
|
||||||
scatter(real.(training),imag.(training), label="training")
|
scatter(real.(training),imag.(training), label="training")
|
||||||
scatter!(real.(exact),imag.(exact), label="exact")
|
scatter!(real.(exact),imag.(exact), label="exact")
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,7 @@ for c in extrapolating_c
|
||||||
push!(extrapolated, nearest(evals, current_E))
|
push!(extrapolated, nearest(evals, current_E))
|
||||||
end
|
end
|
||||||
|
|
||||||
open("temp/HO_B2R.training.csv", "w") do f; writedlm(f, hcat(reim(training)...)); end
|
exportCSV("temp/HO_B2R.csv", (training, exact, extrapolated), ("training", "exact", "extrapolated"))
|
||||||
open("temp/HO_B2R.exact.csv", "w") do f; writedlm(f, hcat(reim(exact)...)); end
|
|
||||||
open("temp/HO_B2R.extrapolated.csv", "w") do f; writedlm(f, hcat(reim(extrapolated)...)); end
|
|
||||||
|
|
||||||
scatter(real.(training),imag.(training), label="training")
|
scatter(real.(training),imag.(training), label="training")
|
||||||
scatter!(real.(exact),imag.(exact), label="exact")
|
scatter!(real.(exact),imag.(exact), label="exact")
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,7 @@ for c in extrapolating_c
|
||||||
push!(extrapolated, nearest(evals, current_E))
|
push!(extrapolated, nearest(evals, current_E))
|
||||||
end
|
end
|
||||||
|
|
||||||
open("temp/NCSM.training.csv", "w") do f; writedlm(f, hcat(reim(training)...)); end
|
exportCSV("temp/NCSM.csv", (training, exact, extrapolated), ("training", "exact", "extrapolated"))
|
||||||
open("temp/NCSM.exact.csv", "w") do f; writedlm(f, hcat(reim(exact)...)); end
|
|
||||||
open("temp/NCSM.extrapolated.csv", "w") do f; writedlm(f, hcat(reim(extrapolated)...)); end
|
|
||||||
|
|
||||||
scatter(real.(training),imag.(training), label="training")
|
scatter(real.(training),imag.(training), label="training")
|
||||||
scatter!(real.(exact),imag.(exact), label="exact")
|
scatter!(real.(exact),imag.(exact), label="exact")
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Plots, DelimitedFiles
|
using Plots
|
||||||
|
include("../helper.jl")
|
||||||
include("../p_space.jl")
|
include("../p_space.jl")
|
||||||
|
|
||||||
# contour
|
# contour
|
||||||
|
|
@ -51,14 +52,7 @@ for (j, c) in enumerate(extrapolate_points)
|
||||||
extrapolate_E[j] = evals[i]
|
extrapolate_E[j] = evals[i]
|
||||||
end
|
end
|
||||||
|
|
||||||
open("temp/2b_GSM.csv", "w") do f
|
exportCSV("temp/2b_GSM.csv", (training_E, exact_E, extrapolate_E), ("training", "exact", "extrapolated"))
|
||||||
write(f, "# training \n")
|
|
||||||
writedlm(f, hcat(reim(training_E)...))
|
|
||||||
write(f, "# exact \n")
|
|
||||||
writedlm(f, hcat(reim(exact_E)...))
|
|
||||||
write(f, "# extrapolate \n")
|
|
||||||
writedlm(f, hcat(reim(extrapolate_E)...))
|
|
||||||
end
|
|
||||||
|
|
||||||
scatter(real.(training_E), imag.(training_E), label="training")
|
scatter(real.(training_E), imag.(training_E), label="training")
|
||||||
scatter!(real.(exact_E), imag.(exact_E), label="exact")
|
scatter!(real.(exact_E), imag.(exact_E), label="exact")
|
||||||
|
|
|
||||||
22
helper.jl
22
helper.jl
|
|
@ -1,4 +1,4 @@
|
||||||
using LinearAlgebra
|
using LinearAlgebra, DelimitedFiles
|
||||||
|
|
||||||
"Sum over array while minimizing catastrophic cancellation as much as possible"
|
"Sum over array while minimizing catastrophic cancellation as much as possible"
|
||||||
function better_sum(arr::Array{Float64})
|
function better_sum(arr::Array{Float64})
|
||||||
|
|
@ -29,4 +29,22 @@ function kron_sum(A::AbstractMatrix, B::AbstractMatrix)
|
||||||
end
|
end
|
||||||
|
|
||||||
"Flattened vector version of Iterators.product(...) with index hierachy reversed -- leftmost index has the highest hierachy"
|
"Flattened vector version of Iterators.product(...) with index hierachy reversed -- leftmost index has the highest hierachy"
|
||||||
iter_prod(args...) = reverse.(collect(Iterators.product(reverse(args)...))[:])
|
iter_prod(args...) = reverse.(collect(Iterators.product(reverse(args)...))[:])
|
||||||
|
|
||||||
|
"Export CSV data for a scatter plot taking in data as a list of complex vectors (x=Re, y=Im), and a list of corresponding labels, typically used for EC results"
|
||||||
|
function exportCSV(file::String, data, labels=nothing)
|
||||||
|
columns = ["x" "y" "label"]
|
||||||
|
|
||||||
|
if isnothing(labels)
|
||||||
|
columns[end] = ""
|
||||||
|
labels = fill("", length(data))
|
||||||
|
end
|
||||||
|
|
||||||
|
open(file, "w") do f
|
||||||
|
writedlm(f, columns)
|
||||||
|
for (d, label) in zip(data, labels)
|
||||||
|
l = fill(label, length(d))
|
||||||
|
writedlm(f, hcat(reim(d)..., l))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue