-
-
Save Datseris/f39147ab8ac68dd1231895f796b0f2dd to your computer and use it in GitHub Desktop.
Attractor featurizing unexpected -1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DynamicalSystems, OrdinaryDiffEq, Statistics, GLMakie | |
diffeq = (alg = Tsit5(), dt = 0.005, adaptive = false) | |
F = 6.886 | |
G = 1.347 | |
a = 0.255 | |
b = 4.0 | |
p = @ntuple F G a b | |
ds = Systems.lorenz84(; p...) | |
function feat1(A, t) | |
x = A[:, 1] | |
[minimum(x), std(x)] | |
end | |
function feat2(A, t) | |
x, y, z = columns(A) | |
[std(x), std(y)*std(z)] | |
end | |
function feat3(A, t) | |
g = exp(genentropy(A, 0.1; q = 0)) | |
x = minimum(A[:,1]) | |
return [g,x] | |
end | |
function feat4(A, t) | |
g = exp(genentropy(A, 0.1; q = 0)) | |
p = estimate_period(A[:,1], :zc) | |
p = isnan(p) ? 0 : p | |
return [g,p] | |
end | |
feats = [feat1 feat2; feat3 feat4] | |
labels = [("min(x)", "std(x)"), | |
("box cov.", "min(x)"), ("std(x)", "std(y)*std(z)"), ("box cov.", "period")] | |
labels = reshape(labels, (2,2)) | |
u0s = Vector{Float64}[] | |
colors_correct = [] | |
fs = [Vector{Float64}[] for i in 1:2, j in 1:2] | |
cs = [[] for i in 1:2, j in 1:2] | |
I = CartesianIndices(basins) | |
for n in round.(Int, range(1, length(basins); length = 100)) | |
u0 = ChaosTools.generate_ic_on_grid(grid, I[n]) | |
push!(u0s, u0) | |
push!(colors_correct, (COLORS[basins[n]], 0.5)) | |
# Collect features | |
A = trajectory(ds, 100, u0; Ttr = 100, Δt = 1, diffeq) | |
for i in 1:2; for j in 1:2 | |
f = feats[i,j](A, nothing) | |
push!(fs[i,j], f) | |
end; end | |
end | |
metric = Euclidean() | |
min_neighbors = 2 | |
fig = Figure(); display(fig) | |
axs = [Axis(fig[i,j]; xlabel = labels[i,j][1], ylabel = labels[i,j][2]) for i in 1:2, j in 1:2] | |
for i in 1:2; for j in 1:2 | |
f = fs[i,j] | |
features = reduce(hcat, f) | |
class_labels, = ChaosTools.classify_features_clustering(features, min_neighbors, metric) | |
strokecolor = [COLORS[c == -1 ? 4 : c] for c in class_labels] | |
scatter!(axs[i,j], features; | |
markersize = 10, color = :transparent, strokecolor, strokewidth = 4) | |
end; end | |
Makie.save(plotsdir("attractors_presentation", "lorenz84_clustering.png"), fig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh damn, yeah, its because before this block of code I had another one that computed the basins with the AttractorsviaRecurrences... Will fix soon!