using FileIO
using LinearAlgebra
using Parameters
include("network_sims.jl")
include("random_matrices.jl")

output_dir = "results2-analysis"

N = 3000
g = 1.5
etas = [-0.3, 0.0, 0.3]
s = 0.0
J_seed = 5000
h0_seed = 8000

dt = 0.01
t_bound = 300.0
wait = 200.0
savedunits = 10
timesteps = round(Int64, (t_bound - wait) / dt)
ts = dt .* collect(1:timesteps)

activity = Array{Float64,3}(undef, timesteps, savedunits, length(etas))
eigval_parts = Array{Float64,3}(undef, N, 2, length(etas))

for (i, eta) in enumerate(etas)
    J = generate_J(N, eta, seed=J_seed)
    h0 = generate_nv(N, Float64, seed=h0_seed)
    A = sim_activity(J, g, h0, s=s, dt=dt, t_bound=t_bound)
    activity[:,:,i] = view(A, 1:savedunits, 
            round(Int, wait / dt) + 1:round(Int, t_bound / dt))'

    eigval_parts[:,1,i] = real(eigvals(J))
    eigval_parts[:,2,i] = imag(eigvals(J))
end 

fn = "example_activity_and_eigvals_results2.jld2"
out = Dict{String,Any}()
@pack! out = ts, activity, eigval_parts
save(joinpath(output_dir, fn), out)
