The code is made complex and untidy due to the construction of the log. Now that it has the right functionality, it would be good to wrap the repeated code into functions. Here is a proposal:
Adding a new process:
function logadd_process(d, action, info)
d.log == nothing ? nothing : [d.log; RheoLogItem( (type=:process, action... ), info ) ]
end
log = logadd_process(d, (funct=:resample, params=(), keywords=() ), comment="Resample the data",)
Add analysis:
function logadd_analysis!(d, action, info)
if d.log != nothing
push!(d.log, RheoLogItem( (type=:analysis, action...), info) )
end
end
logadd_analysis!(data, (funct=:dynamicmodelfit, params=(model=model, ), keywords=(p0=p0, lo=lo, hi=hi, rel_tol=rel_tol, weights=weights)),
(comment="Fiting rheological model to frequency spectrum", model_name=model.name, model_params=nt, time_taken=timetaken, stop_reason=ret, error=minf) )
Initialize log:
function loginit(savelog, action, info)
if savelog
RheoLogItem( (type=:source, action...), info )
else
nothing
end
end
This may need revisiting. I think loginit should return the array rather than single RheoLogItem. tbd.
The code is made complex and untidy due to the construction of the log. Now that it has the right functionality, it would be good to wrap the repeated code into functions. Here is a proposal:
Adding a new process:
Add analysis:
Initialize log:
This may need revisiting. I think loginit should return the array rather than single RheoLogItem. tbd.