### CMDimData.jl (using HDF5.jl)

–>https://github.com/ma-laforge/CMDimData.jl

If you want a solution that already deals with input parameter sweeps for:

- running your math simultaneously on all swept values
- storing the results to a single HDF5 file
- plotting the entire dataset (or a subset of it) as if it was a single x,y vector

You might want to give CMDimData.jl a try.

I created an example below assuming those 1000 runs were monte-carlo iterations (though I only did 100):

```
using MDDatasets #Multi-dimensional functionnality
using CMDimData #Environment to save/plot data from MDDatasets
using CMDimData.EasyPlot #Generic plotting facilities
#Use InspectDR as plotting backend:
CMDimData.@includepkg EasyPlotInspect; pdisp = EasyPlotInspect.PlotDisplay()
#Use EasyData (and load HDF5 library):
CMDimData.@includepkg EasyData #Save multi-dimensional dataset to hdf5 file
#==Input data
====================================================#
npts = 200
samples_per_cycle = 50
xrng = 1:npts #Julia range
x = DataF1(1:npts) #x-values as function of 1 argument (vec of {x,y} pairs)
#==Simulation itself
====================================================#
function run_simulation(x, param1, param2)
noise_floor = DataF1(x.x, randn(length(x))*.5)
y = param1*cos(x*(2*pi/samples_per_cycle))+param2
return y+noise_floor
end
#==Run simulation for all parameters (incl. monte-carlo iterations)
====================================================#
#Create/populate multi-dimensional "signal" object:
signal = fill(DataRS, PSweep("MC", collect(1:100))) do i_mc
fill(DataRS, PSweep("param1", [0.5, 1, 1.5])) do param1
#Inner-most sweep: need to specify element type (DataF1):
#(Other (scalar) element types: DataInt/DataFloat/DataComplex)
fill(DataRS{DataF1}, PSweep("param2", [1, 4, 16])) do param2
sig = run_simulation(x, param1, param2)
return sig
end; end; end
#==Generate plot
====================================================#
_title = "Monte-Carlo simulation"
axrange = cons(:a, xyaxes=set(ymin=-5, ymax=20))
line_attr = cons(:a, line = set(style=:solid, width=2))
plot = cons(:plot, axrange, nstrips=1, title=_title,
ystrip1 = set(axislabel="Amplitude", striplabel=""),
xaxis = set(label="Time (s)"),
)
push!(plot,
cons(:wfrm, signal, line_attr, label="result", strip=1),
)
#==Display results in pcoll
====================================================#
#Need a plot collection (multi-plot window), to use plots:
pcoll = push!(cons(:plotcoll, title=""), plot)
gplot = display(pdisp, pcoll)
#==Save data to HDF5 (could also have saved plot)
====================================================#
EasyData.openwriter("output.hdf5") do w
write(w, signal, "simresult")
end
EasyData.openreader("output.hdf5") do r
signal_from_file = EasyData.readdata(r, "simresult")
end
println("Do something to keep last value from being dumped to REPL")
```