This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.jl
52 lines (41 loc) · 1.48 KB
/
main.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using LinearAlgebra
using Ripserer
using Plots
using NPZ
using Chain
# println(ARGS[1])
torus = @chain npzread("torus.npy") reshape(_, :, 3)
println("torus size", torus |> size)
# function annulus(n, r1=1, r2=2, offset=(0, 0))
# result = Tuple{Float64,Float64}[]
# while length(result) < n
# point = 2 * r2 * rand(2) .- r2
# if r1 < norm(point) < r2
# push!(result, (point[1] + offset[1], point[2] + offset[2]))
# end
# end
# return result
# end
#
# data = annulus(300)
# println("annulus", data |> typeof, data |> size)
data = torus |> eachrow |> collect
# data = [ i for i in size(torus)[1] ]
# # println(data |> size)
# println(torus |> eachrow |> collect |> typeof)
# # println(torus |> typeof, torus |> size, torus |> eachrow |> vec |> typeof, torus |> vec |> size)
println("ripping...")
diagram_cocycles = ripserer(data; reps=true)
println("ripped.")
exit()
# plot(torus[:, 1], torus[:, 2], torus[:, 3], seriestype=:scatter, show=true)
# println("torus plotted")
# readline()
diagram_cocycles = ripserer(data; reps=true)
most_persistent_co = diagram_cocycles[2][end]
filtration = diagram_cocycles[2].filtration
midpoint = (death(most_persistent_co) - birth(most_persistent_co)) / 2
reconstructed_at_midpoint = reconstruct_cycle(filtration, most_persistent_co, midpoint)
scatter(data; label="data", markersize=2, aspect_ratio=1)
print(reconstructed_at_midpoint |> shape)
plot!(reconstructed_at_midpoint, data; label="reconstruction", show=true)