YAXArrays.jl
YAXArrays.jl copied to clipboard
Custom Struct as outtype in OutDims?
Hello,
I am trying to do GEV estimation using mapCube, using the following logic. The objective is to get the timeseries for each gridpoints and return the GEV model associated with the timeserie, for each gridpoint, storing the following information into a YAXArray:
MaximumLikelihoodAbstractExtremeValueModel
model :
ThresholdExceedance
data : Vector{Float64}[28]
logscale : ϕ ~ 1
shape : ξ ~ 1
θ̂ : [2.0154230098844907, 0.09042541506171095]
Hence, when I try the following:
indims = InDims("Ti")
outdims = OutDims(outtype=MaximumLikelihoodAbstractExtremeValueModel)
I get the error:
ERROR: MethodError: Cannot `convert` an object of type
Type{MaximumLikelihoodAbstractExtremeValueModel} to an object of type
Union{Int64, DataType}
Closest candidates are:
convert(::Type{T}, ::T) where T
@ Base Base.jl:84
Stacktrace:
[1] OutDims(axisdesc::Tuple{}, backend::Symbol, backendargs::@Kwargs{}, update::Bool, artype::Type, chunksize::Symbol, outtype::Type)
@ YAXArrays.DAT ~/.julia/packages/YAXArrays/ppMtD/src/DAT/registration.jl:102
[2] OutDims(; backend::Symbol, update::Bool, artype::Type, chunksize::Symbol, outtype::Type, backendargs::@Kwargs{})
@ YAXArrays.DAT ~/.julia/packages/YAXArrays/ppMtD/src/DAT/registration.jl:134
[3] top-level scope
@ REPL[64]:1
It seems to be possible to assign a custom type to outtype, but I am unsure why it fails for MaximumLikelihoodAbstractExtremeValueModel:
struct foo
a
end
outdims = OutDims(outtype=foo)
OutDims((), :auto, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}(), false, Array, :input, foo)
Thanks for any intput!
The problem is, that your type is a parametric type. And then its type is not DateType but UnionAll. You would have to fix all parameters in the type to use it as outtype. The easiest would be to construct an example value of the type you want to use and call typeof on it to select the exact type that could be used.
We might want to loosen the restriction on the field in OutDims so that this would work without that pre step.
ok! I'm gonna try to do that. Cheers!