diff --git a/src/DataStructures/DataSetUncertain.jl b/src/DataStructures/DataSetUncertain.jl index a6beeaa..06edb91 100644 --- a/src/DataStructures/DataSetUncertain.jl +++ b/src/DataStructures/DataSetUncertain.jl @@ -37,6 +37,7 @@ struct DataSetUncertain{BesselCorrection} <: AbstractUnknownUncertaintyDataSet ynames::AbstractVector{<:AbstractString} name::Union{<:AbstractString,<:Symbol} + DataSetUncertain(DS::AbstractDataSet; kwargs...) = DataSetUncertain(xdata(DS), ydata(DS), dims(DS); xnames=xnames(DS), ynames=ynames(DS), kwargs...) function DataSetUncertain(X::AbstractArray, Y::AbstractArray, dims::Tuple{Int,Int,Int}=(size(X,1), ConsistentElDims(X), ConsistentElDims(Y)); kwargs...) @info "Assuming error model σ(x,y,c) = exp10.(c)" errmod = ydim(dims) == 1 ? ((x,y,c::AbstractVector)->inv(exp10(c[1]))) : (x,y,c::AbstractVector)->Diagonal(inv.(exp10.(c))) @@ -50,6 +51,7 @@ struct DataSetUncertain{BesselCorrection} <: AbstractUnknownUncertaintyDataSet size(X,1) != size(Y,1) && throw("Inconsistent number of x-values and y-values given: $(size(X,1)) != $(size(Y,1)). Specify a tuple (Npoints, xdim, ydim) in the constructor.") DataSetUncertain(Unwind(X), Unwind(Y), inverrormodel, testp, (size(X,1), ConsistentElDims(X), ConsistentElDims(Y)); kwargs...) end + DataSetUncertain(DS::AbstractDataSet, inverrormodel::Function, testp::AbstractVector=0.1ones(ydim(DS)); kwargs...) = DataSetUncertain(xdata(DS), ydata(DS), inverrormodel, testp, dims(DS); xnames=xnames(DS), ynames=ynames(DS), kwargs...) function DataSetUncertain(x::AbstractVector, y::AbstractVector, inverrormodel::Function, testp::AbstractVector, dims::Tuple{Int,Int,Int}; kwargs...) @info "Assuming error parameters always given by last $(length(testp)) parameters." DataSetUncertain(x, y, inverrormodel, DefaultErrorModel(length(testp)), testp, dims; kwargs...) diff --git a/src/DataStructures/UnknownVarianceDataSet.jl b/src/DataStructures/UnknownVarianceDataSet.jl index bee0206..a90e4d6 100644 --- a/src/DataStructures/UnknownVarianceDataSet.jl +++ b/src/DataStructures/UnknownVarianceDataSet.jl @@ -39,17 +39,17 @@ struct UnknownVarianceDataSet{BesselCorrection} <: AbstractUnknownUncertaintyDat ynames::AbstractVector{<:AbstractString} name::Union{<:AbstractString,<:Symbol} - function UnknownVarianceDataSet(x::AbstractArray, y::AbstractArray, Testpx::AbstractVector, Testpy::AbstractVector; kwargs...) - UnknownVarianceDataSet(x, y; testpx=Testpx, testpy=Testpy, kwargs...) - end + UnknownVarianceDataSet(DS::AbstractDataSet; kwargs...) = UnknownVarianceDataSet(xdata(DS), ydata(DS), dims(DS); xnames=xnames(DS), ynames=ynames(DS), kwargs...) function UnknownVarianceDataSet(X::AbstractArray, Y::AbstractArray, dims::Tuple{Int,Int,Int}=(size(X,1), ConsistentElDims(X), ConsistentElDims(Y)); - testpx::AbstractVector=zeros(xdim(dims)), testpy::AbstractVector=zeros(ydim(dims)), kwargs...) - size(X,1) != size(Y,1) && throw("Inconsistent number of x-values and y-values given: $(size(X,1)) != $(size(Y,1)). Specify a tuple (Npoints, xdim, ydim) in the constructor.") + testpx::AbstractVector=0.1ones(xdim(dims)), testpy::AbstractVector=0.1ones(ydim(dims)), kwargs...) @info "Assuming error models σ(x,y,c) = exp10.(c)" xerrmod = xdim(dims) == 1 ? ((x,y,c::AbstractVector)->inv(exp10(c[1]))) : (x,y,c::AbstractVector)->Diagonal(inv.(exp10.(c))) yerrmod = ydim(dims) == 1 ? ((x,y,c::AbstractVector)->inv(exp10(c[1]))) : (x,y,c::AbstractVector)->Diagonal(inv.(exp10.(c))) UnknownVarianceDataSet(Unwind(X), Unwind(Y), xerrmod, yerrmod, testpx, testpy, dims; kwargs...) end + function UnknownVarianceDataSet(DS::AbstractDataSet, invxerrormodel::Function, invyerrormodel::Function, testpx::AbstractVector=0.1ones(xdim(DS)), testpy::AbstractVector=0.1ones(ydim(DS)); kwargs...) + UnknownVarianceDataSet(xdata(DS), ydata(DS), invxerrormodel, invyerrormodel, testpx, testpy, dims(DS); xnames=xnames(DS), ynames=ynames(DS), kwargs...) + end function UnknownVarianceDataSet(x::AbstractVector, y::AbstractVector, invXvariancemodel::Function, invYvariancemodel::Function, testpx::AbstractVector, testpy::AbstractVector, dims::Tuple{Int,Int,Int}=(size(X,1), ConsistentElDims(X), ConsistentElDims(Y)); kwargs...) @info "Assuming error parameters always given by last ($(length(testpx)),$(length(testpy))) parameters respectively."