From e9fd51caf9d2f77de3aaf9e43e79d74192886f3e Mon Sep 17 00:00:00 2001 From: monty Date: Wed, 24 Jan 2024 15:52:33 -0700 Subject: [PATCH] work --- src/MadsIO.jl | 32 +++++++++++++++++++++++++++++++- src/MadsPlot.jl | 4 ++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/MadsIO.jl b/src/MadsIO.jl index 7413a491..be2bc1da 100644 --- a/src/MadsIO.jl +++ b/src/MadsIO.jl @@ -1768,8 +1768,38 @@ function testlinks() rm(link) end -function jld2append(fname, varname, data) +function jldappend(fname::AbstractString, varname::AbstractString, data::Any) + JLD.jldopen(fname, true, true, true, false, true) do file + file[varname] = data + end +end + +function jld2append(fname::AbstractString, varname::AbstractString, data::Any) JLD2.jldopen(fname, "a+") do file file[varname] = data end +end + +function jld2haskey(fname::AbstractString, varnames...) + flag = true + JLD2.jldopen(fname, "r") do file + for varname in varnames + if !haskey(file, varname) + flag = false + end + end + end + return flag +end + +function jldhaskey(fname::AbstractString, varnames...) + flag = true + JLD.jldopen(fname, "r") do file + for varname in varnames + if !haskey(file, varname) + flag = false + end + end + end + return flag end \ No newline at end of file diff --git a/src/MadsPlot.jl b/src/MadsPlot.jl index 8fb71a7a..68dfa809 100644 --- a/src/MadsPlot.jl +++ b/src/MadsPlot.jl @@ -877,7 +877,7 @@ function spaghettiplot(madsdata::AbstractDict, dictarray::AbstractDict; seed::In end spaghettiplot(madsdata::AbstractDict, Y; kw...) end -function spaghettiplot(madsdata::AbstractDict, matrix::AbstractMatrix; plotdata::Bool=true, filename::AbstractString="", keyword::AbstractString="", format::AbstractString="", title::AbstractString="", xtitle::AbstractString="", ytitle::AbstractString="", yfit::Bool=false, obs_plot_dots::Bool=true, linewidth::Measures.AbsoluteLength=2Gadfly.pt, pointsize::Measures.AbsoluteLength=4Gadfly.pt, grayscale::Bool=false, alpha::Number=0.3, xmin::Any=nothing, xmax::Any=nothing, ymin::Any=nothing, ymax::Any=nothing, quiet::Bool=!Mads.graphoutput, colors::AbstractVector=["red", "blue", "green", "cyan", "magenta", "yellow"], plot_nontargets::Bool=false, gm::AbstractVector=[]) +function spaghettiplot(madsdata::AbstractDict, matrix::AbstractMatrix; plotdata::Bool=true, filename::AbstractString="", keyword::AbstractString="", format::AbstractString="", title::AbstractString="", xtitle::AbstractString="", ytitle::AbstractString="", yfit::Bool=false, obs_plot_dots::Bool=true, linewidth::Measures.AbsoluteLength=2Gadfly.pt, pointsize::Measures.AbsoluteLength=4Gadfly.pt, grayscale::Bool=false, alpha::Number=0.2, alphas::AbstractVector=[alpha], xmin::Any=nothing, xmax::Any=nothing, ymin::Any=nothing, ymax::Any=nothing, quiet::Bool=!Mads.graphoutput, colors::AbstractVector=["red", "blue", "green", "cyan", "magenta", "yellow"], plot_nontargets::Bool=false, gm::AbstractVector=[]) madsinfo("Spaghetti plots for all the selected model parameter (type != null) ...\n") rootname = getmadsrootname(madsdata) obskeys = Mads.getobskeys(madsdata) @@ -939,7 +939,7 @@ function spaghettiplot(madsdata::AbstractDict, matrix::AbstractMatrix; plotdata: pl = Gadfly.plot(pa..., Gadfly.layer(Y, x=repeat(t; inner=numberofsamples), y=Gadfly.Col.value(1:numberofsamples...), color=colindex, group=colindex, Gadfly.Geom.line()), Gadfly.Scale.color_discrete(colormap), - Gadfly.Theme(key_position=:none, line_width=linewidth, point_size=pointsize, highlight_width=0Gadfly.pt, discrete_highlight_color=c->nothing, alphas=[alpha]), + Gadfly.Theme(key_position=:none, line_width=linewidth, point_size=pointsize, highlight_width=0Gadfly.pt, discrete_highlight_color=c->nothing, alphas=alphas), Gadfly.Guide.title(title), Gadfly.Guide.XLabel(xtitle; orientation=:horizontal), Gadfly.Guide.YLabel(ytitle; orientation=:vertical), gm...)