Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first test case pull request #1

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/DataAssimilationBenchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#######################################################################################################################
########################################################################################################################
module DataAssimilationBenchmarks
########################################################################################################################
########################################################################################################################
Expand All @@ -21,12 +21,12 @@ function Info()
print(" ")
printstyled("_",color=2)
print(" _ _ ")
printstyled("_ \n",color=13)
printstyled("_ \n",color=13)
print(" | __ \\ | | /\\ ")
printstyled("(_)",color=9)
printstyled(" (_)",color=2)
print(" | | | ")
printstyled("(_) \n",color=13)
printstyled("(_) \n",color=13)
print(" | | | | __ _| |_ __ _ / \\ ___ ___ _ _ __ ___ _| | __ _| |_ _ ___ _ __ \n")
print(" | | | |/ _` | __/ _` | / /\\ \\ / __/ __| | '_ ` _ \\| | |/ _` | __| |/ _ \\| '_ \\ \n")
print(" | |__| | (_| | || (_| |/ ____ \\\\__ \\__ \\ | | | | | | | | (_| | |_| | (_) | | | | \n")
Expand Down Expand Up @@ -55,7 +55,7 @@ function Info()
print(" This is my personal data asimilation benchmark research code with an emphasis on testing and validation\n")
print(" of ensemble-based filters and smoothers in chaotic toy models. DataAssimilationBenchmarks is a wrapper\n")
print(" library including the core numerical solvers for ordinary and stochastic differential equations,\n")
print(" solvers for data assimilation routines and the core process model code for running twin experiments\n")
print(" solvers for data assimilation routines and the core process model code for running twin experiments\n")
print(" with benchmark models. These methods can be run stand-alone in other programs by calling these\n")
print(" functions from the DeSolvers, EnsembleKalmanSchemes and L96 sub-modules from this library.\n")
print(" Future solvers and models will be added as sub-modules in the methods and models directories respectively.\n")
Expand Down
36 changes: 36 additions & 0 deletions test/RunTest.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
########################################################################################################################
module RunTest
########################################################################################################################
########################################################################################################################
# imports and exports
using DataAssimilationBenchmarks.DeSolvers
using DataAssimilationBenchmarks.L96
using Test

########################################################################################################################
########################################################################################################################
# first testset using Euler Maruyama
@testset "Euler Maruyama" begin
# initial conditions and arguments
x = zeros(40)
# step size
h = 0.01
# forced parameter
f = 8.0
kwargs = Dict{String, Any}(
"h" => h,
"diffusion" => 0.0,
"dx_params" => [f],
"dx_dt" => L96.dx_dt,
)
# parameters to test
# em_step! writes over x in place
em_step!(x, 0.0, kwargs)
# evaluate test pass/fail if the vector of x is equal to (f*h) in every instance
@test sum(x .== (f*h)) == 40
# if conditions are true, pass
end

########################################################################################################################

end
66 changes: 61 additions & 5 deletions test/TestTimeSeriesGeneration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,73 @@
module TestTimeSeriesGeneration
#######################################################################################################################
# imports and exports
using DeSovlers
using DeSolvers

#######################################################################################################################


""" Most of NewFunc.jl goes here"""

for some_number of steps

end
#######################################################################################################################
module TestTimeSeriesGeneration
#######################################################################################################################
# imports and exports
using DeSolvers

#######################################################################################################################

function l96(x, f)
x_m_2 = cat(x[end-1:end], x[1:end-2])
x_m_1 = cat(x[end:end], x[1:end-1])
x_p_1 = cat(x[2:end], x[1:1], dims = 2)

dxdt = (x_p_1-x_m_2).*x_m_1 - x + f

end
#one step forward

f = 8.0
spin = 100
h = 0.001
nanl = 1000
sys_dim = 40
diffusion = 0.1
tanl = 0.1
seed = 0

#fore_steps = int(tanl/h)
fore_steps = (tanl/h)

#np.random.seed(seed)
using Random
Random.seed!(seed)


#xt = np.ones(sys_dim)
xt = ones(sys_dim)

#for i in range(int(spin / h)):
#xt = l96_em_sde(xt, h, [f, diffusion])

#tobs = np.zeros ([sys_dim, nanl])
tobs = zeros(sys_dim, nanl)
#for i in range(nanl)
for i in range(0, stop = nanl)
#for j in range(fore_steps)
for j in range(0, stop = fore_steps)
xt = l96_em_sde(xt, h, [f, diffusion])
tobs[1:i] = xt
end
end


return some_data_array
params = [spin, h, diffusion, f, seed]
#time_series = ["tobs": tobs, "params": params]
time_series = ["tobs"::tobs, "params"::params]
fname = "time_series_data_seed_" * string(seed) * ".txt"
#f = open(fname, "wb")
f = open(fname, "w")
#pickle.dump (time_series, f)
dumpval = dump(fname)
f.close()
end