diff --git a/examples/contamination/contamination-efast.jl b/examples/contamination/contamination-efast.jl index 2a720454..16165e71 100644 --- a/examples/contamination/contamination-efast.jl +++ b/examples/contamination/contamination-efast.jl @@ -11,5 +11,5 @@ Mads.wellon!(md, "w20a") # use well w20a if !isdefined(Mads, :efastresult) efast_results = Mads.efast(md; N=1000, seed=2016) end -Mads.plotobsSAresults(md, efastresult; filter=r"w13a", filename="w13a-efast.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]", separate_files=true) -Mads.plotobsSAresults(md, efastresult; filter=r"w20a", filename="w20a-efast.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]", separate_files=true) \ No newline at end of file +Mads.plotobsSAresults(md, efastresult; filter=r"w13a", filename="w13a-efast.svg", xtitle="Time [a]", ytitle="Concentration [ppb]", separate_files=true) +Mads.plotobsSAresults(md, efastresult; filter=r"w20a", filename="w20a-efast.svg", xtitle="Time [a]", ytitle="Concentration [ppb]", separate_files=true) diff --git a/examples/contamination/contamination-saltelli.jl b/examples/contamination/contamination-saltelli.jl index 94942f18..6c612924 100644 --- a/examples/contamination/contamination-saltelli.jl +++ b/examples/contamination/contamination-saltelli.jl @@ -11,5 +11,5 @@ Mads.wellon!(md, "w20a") # use well w20a if !isdefined(Mads, :saltelliresult) saltelli_results = Mads.saltelli(md; N=10000, seed=2016) end -Mads.plotobsSAresults(md, saltelliresult; filter=r"w13a", filename="w13a-saltelli.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]", separate_files=true) -Mads.plotobsSAresults(md, saltelliresult; filter=r"w20a", filename="w20a-saltelli.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]", separate_files=true) \ No newline at end of file +Mads.plotobsSAresults(md, saltelliresult; filter=r"w13a", filename="w13a-saltelli.svg", xtitle="Time [a]", ytitle="Concentration [ppb]", separate_files=true) +Mads.plotobsSAresults(md, saltelliresult; filter=r"w20a", filename="w20a-saltelli.svg", xtitle="Time [a]", ytitle="Concentration [ppb]", separate_files=true) diff --git a/examples/contamination/contamination-w03-w13-svr-efast-mads.jl b/examples/contamination/contamination-w03-w13-svr-efast-mads.jl index 0044c9bb..119abfcb 100644 --- a/examples/contamination/contamination-w03-w13-svr-efast-mads.jl +++ b/examples/contamination/contamination-w03-w13-svr-efast-mads.jl @@ -11,7 +11,7 @@ svrexec, svrread, svrsave, svrclean = Mads.makesvrmodel(md, 1000) numberofsamples = 100 paramdict = Mads.getparamrandom(md, numberofsamples) -paramarray = hcat(map(i->collect(paramdict[i]), keys(paramdict))...) +paramarray = hcat(map(i -> collect(paramdict[i]), keys(paramdict))...) @time predictions = Mads.forward(md, paramdict)' Mads.madsinfo("Model predictions ...") @@ -34,10 +34,10 @@ mdsvr["Julia model"] = svrexec mdsvr["Filename"] = "$rootname-svr.mads" sasvr = Mads.efast(mdsvr) -Mads.plotobsSAresults(mdsvr, sasvr, format="PNG") +Mads.plotobsSAresults(mdsvr, sasvr; format="PNG") Mads.display("$rootname-svr-efast-385.png") svrsave() svrclean() svrread() -svrclean() \ No newline at end of file +svrclean() diff --git a/examples/contamination/contamination-w03-w13-svr-efast.jl b/examples/contamination/contamination-w03-w13-svr-efast.jl index 6bcec0c1..a00a734b 100644 --- a/examples/contamination/contamination-w03-w13-svr-efast.jl +++ b/examples/contamination/contamination-w03-w13-svr-efast.jl @@ -10,7 +10,7 @@ Mads.wellon!(md, "w13a") # use well w13a numberofsamples = 100 if !isdefined(Mads, :predictions) || size(predictions) != numberofsamples paramdict = Mads.getparamrandom(md, numberofsamples) - paramarray = hcat(map(i->collect(paramdict[i]), keys(paramdict))...) + paramarray = hcat(map(i -> collect(paramdict[i]), keys(paramdict))...) predictions = Mads.forward(md, paramdict)' end @@ -19,9 +19,9 @@ Mads.spaghettiplot(md, predictions; keyword="w13a-training-set", format="PNG") Mads.display("$rootname-w13a-training-set-$numberofsamples-spaghetti.png") svrpredictions = Array{Float64}(undef, 0, numberofsamples) -for i=1:50 - pmodel = SVR.train(predictions[i,:], paramarray'; eps=0.001, C=10000.); - y_pr = SVR.predict(pmodel, paramarray'); +for i = 1:50 + pmodel = SVR.train(predictions[i, :], paramarray'; eps=0.001, C=10000.0) + y_pr = SVR.predict(pmodel, paramarray') SVR.freemodel(pmodel) svrpredictions = [svrpredictions; y_pr'] end @@ -29,4 +29,4 @@ end Mads.madsinfo("SVR predictions ...") Mads.spaghettiplot(md, svrpredictions; keyword="w13a-svr", format="PNG") -Mads.display("$rootname-w13a-svr-$numberofsamples-spaghetti.png") \ No newline at end of file +Mads.display("$rootname-w13a-svr-$numberofsamples-spaghetti.png") diff --git a/examples/contamination/contamination-w03.jl b/examples/contamination/contamination-w03.jl index f129d7b9..80aa1542 100644 --- a/examples/contamination/contamination-w03.jl +++ b/examples/contamination/contamination-w03.jl @@ -12,9 +12,9 @@ Mads.wellon!(md, "w20a") # use well w20a numberofsamples = 10 paramdict = Mads.getparamrandom(md, numberofsamples) -paramarray = hcat(map(i->collect(paramdict[i]), keys(paramdict))...) +paramarray = hcat(map(i -> collect(paramdict[i]), keys(paramdict))...) predictions = Mads.forward(md, paramdict)' -wd = Mads.getwelldata(md, time=true)' +wd = Mads.getwelldata(md; time=true)' # data = Array{Float64}(undef, 0, size(paramarray, 2) + size(wd, 2) + 1) # for i = 1:numberofsamples @@ -34,4 +34,4 @@ Mads.scatterplotsamples(md, permutedims(mcmcchain.value), rootname * "-bayes.png posterior_predictions = Mads.forward(md, permutedims(mcmcchain.value)) Mads.madsinfo("Posterior (Bayesian) spaghetti plot ...") -Mads.spaghettiplot(md, posterior_predictions; keyword="w13a_w20a-posterior", format="PNG") \ No newline at end of file +Mads.spaghettiplot(md, posterior_predictions; keyword="w13a_w20a-posterior", format="PNG") diff --git a/examples/contamination/contamination-w04-w13-svr-efast-mads.jl b/examples/contamination/contamination-w04-w13-svr-efast-mads.jl index 1dc660d1..6b622afe 100644 --- a/examples/contamination/contamination-w04-w13-svr-efast-mads.jl +++ b/examples/contamination/contamination-w04-w13-svr-efast-mads.jl @@ -11,18 +11,18 @@ svrexec, svrread, svrsave, svrclean = Mads.makesvrmodel(md, 100) numberofsamples = 100 paramdict = Mads.getparamrandom(md, numberofsamples) -paramarray = hcat(map(i->collect(paramdict[i]), keys(paramdict))...) +paramarray = hcat(map(i -> collect(paramdict[i]), keys(paramdict))...) @time predictions = Mads.forward(md, paramdict)' Mads.madsinfo("Model predictions ...") -Mads.spaghettiplot(md, predictions, keyword="w13a-model", format="PNG") +Mads.spaghettiplot(md, predictions; keyword="w13a-model", format="PNG") Mads.display("$rootname-w13a-model-$numberofsamples-spaghetti.png") @time svrpredictions = svrexec(paramarray) @info("SVR discrepancy $(maximum(abs.(svrpredictions .- predictions)))") Mads.madsinfo("SVR predictions ...") -Mads.spaghettiplot(md, svrpredictions, keyword="w13a-svr", format="PNG") +Mads.spaghettiplot(md, svrpredictions; keyword="w13a-svr", format="PNG") Mads.display("$rootname-w13a-svr-$numberofsamples-spaghetti.png") sa = Mads.efast(md) @@ -34,10 +34,10 @@ mdsvr["Julia model"] = svrexec mdsvr["Filename"] = "$rootname-svr.mads" sasvr = Mads.efast(mdsvr) -Mads.plotobsSAresults(mdsvr, sasvr, format="PNG") +Mads.plotobsSAresults(mdsvr, sasvr; format="PNG") Mads.display("$rootname-svr-efast-385.png") svrsave() svrclean() svrread() -svrclean() \ No newline at end of file +svrclean() diff --git a/examples/contamination/contamination-w04-w13-svr-efast.jl b/examples/contamination/contamination-w04-w13-svr-efast.jl index 78d9744c..cb4fa82a 100644 --- a/examples/contamination/contamination-w04-w13-svr-efast.jl +++ b/examples/contamination/contamination-w04-w13-svr-efast.jl @@ -10,7 +10,7 @@ Mads.wellon!(md, "w13a") # use well w13a numberofsamples = 100 if !isdefined(Mads, :predictions) || size(predictions) != numberofsamples paramdict = Mads.getparamrandom(md, numberofsamples) - paramarray = hcat(map(i->collect(paramdict[i]), keys(paramdict))...) + paramarray = hcat(map(i -> collect(paramdict[i]), keys(paramdict))...) predictions = Mads.forward(md, paramdict)' end @@ -19,8 +19,8 @@ Mads.spaghettiplot(md, predictions; keyword="w13a-training-set", format="PNG") Mads.display("$rootname-w13a-training-set-$numberofsamples-spaghetti.png") svrpredictions = Array{Float64}(undef, 0, numberofsamples) -for i=1:50 - pmodel = SVR.train(predictions[i,:], paramarray'; eps=0.001, C=10000.) +for i = 1:50 + pmodel = SVR.train(predictions[i, :], paramarray'; eps=0.001, C=10000.0) y_pr = SVR.predict(pmodel, paramarray') SVR.freemodel(pmodel) svrpredictions = [svrpredictions; y_pr'] diff --git a/examples/contamination/contamination.jl b/examples/contamination/contamination.jl index c10d1b96..db36a5c2 100644 --- a/examples/contamination/contamination.jl +++ b/examples/contamination/contamination.jl @@ -17,18 +17,18 @@ Mads.showallparameters(md) # show all the model parameters Mads.showparameters(md) # show all the adjustable model parameters # use all wells -Mads.plotmadsproblem(md; keyword = "all_wells") # display the well locations and the initial source location +Mads.plotmadsproblem(md; keyword="all_wells") # display the well locations and the initial source location forward_predictions = Mads.forward(md) # execute forward model simulation based on initial parameter guesses -Mads.plotmatches(md, forward_predictions; xtitle = "Time [a]", ytitle = "Concentration [ppb]") # plot initial matches +Mads.plotmatches(md, forward_predictions; xtitle="Time [a]", ytitle="Concentration [ppb]") # plot initial matches Mads.display("w01-match.svg") inverse_parameters, inverse_results = Mads.calibrate(md) # perform model calibration inverse_predictions = Mads.forward(md, inverse_parameters) # execute forward model simulation based on calibrated values -Mads.plotmatches(md, inverse_predictions; xtitle = "Time [a]", ytitle = "Concentration [ppb]") # plot calibrated matches +Mads.plotmatches(md, inverse_predictions; xtitle="Time [a]", ytitle="Concentration [ppb]") # plot calibrated matches Mads.display("w01-match.svg") # use only two wells @@ -37,28 +37,28 @@ Mads.wellon!(md, "w13a") # use well w13a Mads.wellon!(md, "w20a") # use well w20a Mads.showobservations(md) # show all the observations -Mads.plotmadsproblem(md; keyword = "w13a_w20a") # display the well locations and the initial source location +Mads.plotmadsproblem(md; keyword="w13a_w20a") # display the well locations and the initial source location forward_predictions = Mads.forward(md) # execute a forward model simulation based on the initial parameter guesses -Mads.plotmatches(md, forward_predictions, filename = rootname * "-w13a_w20a-init-match.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]") # plot initial matches +Mads.plotmatches(md, forward_predictions; filename=rootname * "-w13a_w20a-init-match.svg", xtitle="Time [a]", ytitle="Concentration [ppb]") # plot initial matches Mads.display("w01-w13a_w20a-init-match.svg") inverse_parameters, inverse_results = Mads.calibrate(md) # perform model calibration inverse_predictions = Mads.forward(md, inverse_parameters) # execute a forward model simulation based on the calibrated values -Mads.plotmatches(md, inverse_predictions; filename = rootname * "-w13a_w20a-calib-match.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]") # plot calibrated matches +Mads.plotmatches(md, inverse_predictions; filename=rootname * "-w13a_w20a-calib-match.svg", xtitle="Time [a]", ytitle="Concentration [ppb]") # plot calibrated matches Mads.display("w01-w13a_w20a-calib-match.svg") # Sensitivity analysis: spaghetti plots based on prior parameter uncertainty ranges Mads.madsinfo("Prior spaghetti plot ...") paramvalues = Mads.getparamrandom(md, 100) -Mads.spaghettiplot(md, paramvalues; keyword = "w13a_w20a-prior", xtitle = "Time [a]", ytitle = "Concentration [ppb]") +Mads.spaghettiplot(md, paramvalues; keyword="w13a_w20a-prior", xtitle="Time [a]", ytitle="Concentration [ppb]") Mads.display("w01-w13a_w20a-prior-100-spaghetti.svg") Mads.madsinfo("Bayesian sampling ...") -mcmcchain = Mads.bayessampling(md, seed = 20151001) +mcmcchain = Mads.bayessampling(md; seed=20151001) Mads.madsinfo("Bayesian scatter plots ...") Mads.scatterplotsamples(md, permutedims(mcmcchain.value), rootname * "-bayes.png") @@ -68,7 +68,7 @@ Mads.display(rootname * "-bayes.png") mcmcvalues = Mads.paramarray2dict(md, permutedims(mcmcchain.value)) Mads.madsinfo("Posterior (Bayesian) spaghetti plot ...") -Mads.spaghettiplot(md, mcmcvalues, keyword = "w13a_w20a-posterior", format = "PNG", xtitle = "Time [a]", ytitle = "Concentration [ppb]") +Mads.spaghettiplot(md, mcmcvalues; keyword="w13a_w20a-posterior", format="PNG", xtitle="Time [a]", ytitle="Concentration [ppb]") Mads.display("w01-w13a_w20a-posterior-1000-spaghetti.png") # Create a new problem (example) @@ -90,27 +90,27 @@ md_new["Sources"][1]["gauss"]["dy"]["init"] = 0 # set a point source md_new["Sources"][1]["gauss"]["dz"]["init"] = 0 # set a point source new_forward_predictions = Mads.forward(md_new) # execute a forward model simulation Mads.setobservationtargets!(md_new, new_forward_predictions) # set calibration targets to match the forward model predictions -Mads.plotmatches(md_new, new_forward_predictions; filename = rootname * "-new-problem.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]") +Mads.plotmatches(md_new, new_forward_predictions; filename=rootname * "-new-problem.svg", xtitle="Time [a]", ytitle="Concentration [ppb]") Mads.display("w01-new-problem.svg") Mads.dumpyamlmadsfile(md_new, "w01-new-problem.mads") # write out a new mads input file # Calibrate with random initial guesses Mads.allwellsoff!(md_new) # turn off all wells Mads.wellon!(md_new, "w13a") # use well w13a -Mads.calibraterandom(md_new, 10; seed = 20151001) # calibrate 10 times with random initial guesses +Mads.calibraterandom(md_new, 10; seed=20151001) # calibrate 10 times with random initial guesses # Global sensitivity analysis using Saltelli's method -saltelli_results = Mads.saltelli(md; N = 1000, seed = 2016) -Mads.plotobsSAresults(md, saltelliresult; filter = r"w13a", filename = "w13a-saltelli.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]") +saltelli_results = Mads.saltelli(md; N=1000, seed=2016) +Mads.plotobsSAresults(md, saltelliresult; filter=r"w13a", filename="w13a-saltelli.svg", xtitle="Time [a]", ytitle="Concentration [ppb]") Mads.display("w13a-saltelli.svg") -Mads.plotobsSAresults(md, saltelliresult; filter = r"w20a", filename = "w20a-saltelli.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]") +Mads.plotobsSAresults(md, saltelliresult; filter=r"w20a", filename="w20a-saltelli.svg", xtitle="Time [a]", ytitle="Concentration [ppb]") Mads.display("w20a-saltelli.svg") # Global sensitivity analysis using Saltelli's eFAST method -efast_results = Mads.efast(md; N = 1000, seed = 2016) -Mads.plotobsSAresults(md, efastresult, filter = r"w13a", filename = "w13a-efast.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]") +efast_results = Mads.efast(md; N=1000, seed=2016) +Mads.plotobsSAresults(md, efastresult; filter=r"w13a", filename="w13a-efast.svg", xtitle="Time [a]", ytitle="Concentration [ppb]") Mads.display("w13a-efast.svg") -Mads.plotobsSAresults(md, efastresult; filter = r"w20a", filename = "w20a-efast.svg", xtitle = "Time [a]", ytitle = "Concentration [ppb]") +Mads.plotobsSAresults(md, efastresult; filter=r"w20a", filename="w20a-efast.svg", xtitle="Time [a]", ytitle="Concentration [ppb]") Mads.display("w20a-efast.svg") cd(currentdir) diff --git a/examples/contamination/runtests.jl b/examples/contamination/runtests.jl index d502329c..ea45f9c5 100644 --- a/examples/contamination/runtests.jl +++ b/examples/contamination/runtests.jl @@ -82,8 +82,8 @@ if !haskey(ENV, "MADS_NO_GADFLY") Mads.spaghettiplots(md, paramvalues; keyword="w13a_w20a") Mads.spaghettiplot(md, paramvalues; keyword="w13a_w20a") s = splitdir(rootname) - for filesinadir in Mads.searchdir(Regex(string(s[2], "-w13a_w20a", "[.]*", "spaghetti.svg")), path=s[1]) - Mads.rmfile(filesinadir, path=s[1]) + for filesinadir in Mads.searchdir(Regex(string(s[2], "-w13a_w20a", "[.]*", "spaghetti.svg")); path=s[1]) + Mads.rmfile(filesinadir; path=s[1]) end sa_results = Mads.saltelli(md; N=5, seed=2015) @@ -108,43 +108,42 @@ Test.@testset "Contamination" begin Test.@test forward_predictions_source == forward_predictions Test.@test isapprox(sum(abs.(forward_predictions_vector .- good_forward_predictions)), 0, atol=1e-4) Test.@test isapprox(sum(abs.(jacobian .- good_jacobian)), 0, atol=1e-4) - Test.@test isapprox(Statistics.mean([abs.(param_values[i] - [40.0,4.0,15.0][i]) for i=1:3]), 0, atol=1e-4) + Test.@test isapprox(Statistics.mean([abs.(param_values[i] - [40.0, 4.0, 15.0][i]) for i = 1:3]), 0, atol=1e-4) Test.@test all(Mads.getwelldata(md) .== [1608.0 2113.0; 1491.0 1479.0; 3.0 3.0]) - t = isapprox(Statistics.mean([abs.(samples[i] - good_samples[i]) for i=1:size(good_samples)[1]+20]), 0, atol=1e-4) + t = isapprox(Statistics.mean([abs.(samples[i] - good_samples[i]) for i = 1:(size(good_samples)[1] + 20)]), 0; atol=1e-4) if t - Test.@test isapprox(Statistics.mean([abs.(samples[i] - good_samples[i]) for i=1:size(good_samples)[1]+20]), 0, atol=1e-4) + Test.@test isapprox(Statistics.mean([abs.(samples[i] - good_samples[i]) for i = 1:(size(good_samples)[1] + 20)]), 0, atol=1e-4) else @show samples end - t = isapprox(Statistics.mean([abs.(llhoods[i] - good_llhoods[i]) for i=1:size(good_llhoods)[1]]), 0, atol=1e-4) + t = isapprox(Statistics.mean([abs.(llhoods[i] - good_llhoods[i]) for i = 1:size(good_llhoods)[1]]), 0; atol=1e-4) if t - Test.@test isapprox(Statistics.mean([abs.(llhoods[i] - good_llhoods[i]) for i=1:size(good_llhoods)[1]]), 0, atol=1e-4) + Test.@test isapprox(Statistics.mean([abs.(llhoods[i] - good_llhoods[i]) for i = 1:size(good_llhoods)[1]]), 0, atol=1e-4) else @show good_llhoods @show llhoods end - - t = isapprox(Statistics.mean([abs.(newllhoods[i] - good_newllhoods[i]) for i=1:size(newllhoods)[1]]), 0, atol=1e-3) + t = isapprox(Statistics.mean([abs.(newllhoods[i] - good_newllhoods[i]) for i = 1:size(newllhoods)[1]]), 0; atol=1e-3) if t - Test.@test isapprox(Statistics.mean([abs.(newllhoods[i] - good_newllhoods[i]) for i=1:size(newllhoods)[1]]), 0, atol=1e-3) + Test.@test isapprox(Statistics.mean([abs.(newllhoods[i] - good_newllhoods[i]) for i = 1:size(newllhoods)[1]]), 0, atol=1e-3) else @show good_newllhoods @show newllhoods end - t = isapprox(Statistics.mean([abs.(Mads.computemass(md; time=50.0)[i] - (550.0,0)[i]) for i=1:2]), 0, atol=1e-5) + t = isapprox(Statistics.mean([abs.(Mads.computemass(md; time=50.0)[i] - (550.0, 0)[i]) for i = 1:2]), 0; atol=1e-5) if t - Test.@test isapprox(Statistics.mean([abs.(Mads.computemass(md; time=50.0)[i] - (550.0,0)[i]) for i=1:2]), 0, atol=1e-5) + Test.@test isapprox(Statistics.mean([abs.(Mads.computemass(md; time=50.0)[i] - (550.0, 0)[i]) for i = 1:2]), 0, atol=1e-5) else @show Mads.computemass(md; time=50.0) end - t = isapprox(Statistics.mean([abs.(Mads.computemass(md)[i] - (550.0,0)[i]) for i=1:2]), 0, atol=1e-5) + t = isapprox(Statistics.mean([abs.(Mads.computemass(md)[i] - (550.0, 0)[i]) for i = 1:2]), 0; atol=1e-5) if t - Test.@test isapprox(Statistics.mean([abs.(Mads.computemass(md)[i] - (550.0,0)[i]) for i=1:2]), 0, atol=1e-5) + Test.@test isapprox(Statistics.mean([abs.(Mads.computemass(md)[i] - (550.0, 0)[i]) for i = 1:2]), 0, atol=1e-5) else @show Mads.computemass(md) end @@ -153,16 +152,16 @@ Test.@testset "Contamination" begin good_inverse_preds = JLD2.load(joinpath(workdir, "test_results", "inverse_predictions.jld2"), "inverse_predictions") # Testing time-based well data against itself - ssr = 0. - for i=1:size(good_welldata_time)[1] - for j=1:size(good_welldata_time)[2] - ssr += (welldata_time[i*j] - good_welldata_time[i*j])^2 + ssr = 0.0 + for i = 1:size(good_welldata_time)[1] + for j = 1:size(good_welldata_time)[2] + ssr += (welldata_time[i * j] - good_welldata_time[i * j])^2 end end - t = isapprox(ssr, 0., atol=1e-8) + t = isapprox(ssr, 0.0; atol=1e-8) if t - Test.@test isapprox(ssr, 0., atol=1e-8) + Test.@test isapprox(ssr, 0.0, atol=1e-8) else @show welldata_time @show good_welldata_time @@ -170,14 +169,14 @@ Test.@testset "Contamination" begin end # Testing inverse predictions against itself - ssr = 0. + ssr = 0.0 for obskey in union(Set(keys(inverse_predictions)), Set(keys(good_inverse_preds))) ssr += (inverse_predictions[obskey] - good_inverse_preds[obskey])^2 end - t = isapprox(ssr, 0., atol=1e-8) + t = isapprox(ssr, 0.0; atol=1e-8) if t - Test.@test isapprox(ssr, 0., atol=1e-8) + Test.@test isapprox(ssr, 0.0, atol=1e-8) else @show inverse_predictions @show good_inverse_preds @@ -189,10 +188,10 @@ Mads.@stdouterrcapture Mads.addsource!(md) Mads.@stdouterrcapture Mads.removesource!(md) Mads.rmfile(joinpath(workdir, "w01-w13a_w20a-match.svg")) -Mads.rmfile(joinpath(workdir,"w01-w13a_w20a.initialresults")) -Mads.rmfile(joinpath(workdir,"w01-w13a_w20a_saltelli_5.jld2")) +Mads.rmfile(joinpath(workdir, "w01-w13a_w20a.initialresults")) +Mads.rmfile(joinpath(workdir, "w01-w13a_w20a_saltelli_5.jld2")) Mads.veryquietoff() Mads.graphon() -:passed \ No newline at end of file +:passed diff --git a/examples/contamination/w01short.jl b/examples/contamination/w01short.jl index 4c191239..bd89ab7b 100644 --- a/examples/contamination/w01short.jl +++ b/examples/contamination/w01short.jl @@ -42,7 +42,7 @@ paramkeys = Mads.getparamkeys(md) optparamkeys = Mads.getoptparamkeys(md) # get all the parameter initial values -paramdict_init = OrderedCollections.OrderedDict(zip(paramkeys, map(key->md["Parameters"][key]["init"], paramkeys))) +paramdict_init = OrderedCollections.OrderedDict(zip(paramkeys, map(key -> md["Parameters"][key]["init"], paramkeys))) # create a function to compute concentrations computeconcentrations = Mads.makecomputeconcentrations(md) @@ -57,7 +57,7 @@ forward_preds2 = Mads.forward(md) Mads.madsinfo("Manual sensitivity analysis ...") numberofsamples = 10 -paramvalues=Mads.getparamrandom(md, numberofsamples) +paramvalues = Mads.getparamrandom(md, numberofsamples) Mads.allwellsoff!(md) Mads.wellon!(md, "w1a") Mads.spaghettiplots(md, paramvalues; keyword="w1a") @@ -66,10 +66,10 @@ Mads.spaghettiplots(md, paramvalues; keyword="w1a") result = Mads.calibrate(md; show_trace=true) # perform global SA analysis (saltelli) -saltelliresultm = Mads.saltelli(md;N=500) -Mads.plotwellSAresults(md,saltelliresultm,"w1a") -saltelliresultb = Mads.saltellibrute(md,N=500) -Mads.plotwellSAresults(md,saltelliresultb,"w1a") +saltelliresultm = Mads.saltelli(md; N=500) +Mads.plotwellSAresults(md, saltelliresultm, "w1a") +saltelliresultb = Mads.saltellibrute(md; N=500) +Mads.plotwellSAresults(md, saltelliresultb, "w1a") # save saltelli results f = open("$rootname-SA-results.json", "w") @@ -83,23 +83,23 @@ saltelliresult = JSON.parsefile("$rootname-SA-results.json"; ordered=true, use_m Mads.printSAresults(md, result) # plot global SA results for a given observation point -Mads.plotwellSAresults(md,result,"w1a") +Mads.plotwellSAresults(md, result, "w1a") # parameter space exploration Mads.madsinfo("Parameter space exploration ...") numberofsamples = 100 -paramvalues=Mads.getparamrandom(md, numberofsamples) -Y = Array{Float64}(undef, length(md["Observations"]),numberofsamples * length(paramvalues)) +paramvalues = Mads.getparamrandom(md, numberofsamples) +Y = Array{Float64}(undef, length(md["Observations"]), numberofsamples * length(paramvalues)) k = 0 for paramkey in keys(paramvalues) - for i in 1:numberofsamples + for i = 1:numberofsamples original = paramdict[paramkey] paramdict[paramkey] = paramvalues[paramkey][i] # set the value for each parameter forward_preds = computeconcentrations(paramdict) paramdict[paramkey] = original j = 1 for obskey in keys(forward_preds) - Y[j,i + k] = forward_preds[obskey] + Y[j, i + k] = forward_preds[obskey] j += 1 end end