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))
|
||||
end
|
||||
|
||||
open("temp/Berggren_B2R.training.csv", "w") do f; writedlm(f, hcat(reim(training)...)); end
|
||||
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
|
||||
exportCSV("temp/Berggren_B2R.csv", (training, exact, extrapolated), ("training", "exact", "extrapolated"))
|
||||
|
||||
scatter(real.(training),imag.(training), label="training")
|
||||
scatter!(real.(exact),imag.(exact), label="exact")
|
||||
|
|
|
|||
|
|
@ -85,9 +85,7 @@ for c in extrapolating_c
|
|||
push!(extrapolated, nearest(evals, current_E))
|
||||
end
|
||||
|
||||
open("temp/HO_B2R.training.csv", "w") do f; writedlm(f, hcat(reim(training)...)); end
|
||||
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
|
||||
exportCSV("temp/HO_B2R.csv", (training, exact, extrapolated), ("training", "exact", "extrapolated"))
|
||||
|
||||
scatter(real.(training),imag.(training), label="training")
|
||||
scatter!(real.(exact),imag.(exact), label="exact")
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ for c in extrapolating_c
|
|||
push!(extrapolated, nearest(evals, current_E))
|
||||
end
|
||||
|
||||
open("temp/NCSM.training.csv", "w") do f; writedlm(f, hcat(reim(training)...)); end
|
||||
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
|
||||
exportCSV("temp/NCSM.csv", (training, exact, extrapolated), ("training", "exact", "extrapolated"))
|
||||
|
||||
scatter(real.(training),imag.(training), label="training")
|
||||
scatter!(real.(exact),imag.(exact), label="exact")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Plots, DelimitedFiles
|
||||
using Plots
|
||||
include("../helper.jl")
|
||||
include("../p_space.jl")
|
||||
|
||||
# contour
|
||||
|
|
@ -51,14 +52,7 @@ for (j, c) in enumerate(extrapolate_points)
|
|||
extrapolate_E[j] = evals[i]
|
||||
end
|
||||
|
||||
open("temp/2b_GSM.csv", "w") do f
|
||||
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
|
||||
exportCSV("temp/2b_GSM.csv", (training_E, exact_E, extrapolate_E), ("training", "exact", "extrapolated"))
|
||||
|
||||
scatter(real.(training_E), imag.(training_E), label="training")
|
||||
scatter!(real.(exact_E), imag.(exact_E), label="exact")
|
||||
|
|
|
|||
20
helper.jl
20
helper.jl
|
|
@ -1,4 +1,4 @@
|
|||
using LinearAlgebra
|
||||
using LinearAlgebra, DelimitedFiles
|
||||
|
||||
"Sum over array while minimizing catastrophic cancellation as much as possible"
|
||||
function better_sum(arr::Array{Float64})
|
||||
|
|
@ -30,3 +30,21 @@ end
|
|||
|
||||
"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)...))[:])
|
||||
|
||||
"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