You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using YAXArrays, DimensionalData
tempo = (Dim{:time}(Date("2022-01-01"):Day(1):Date("2023-01-30")),)
tem =dims(ds, :Ti)
month_length =YAXArray((tem,), daysinmonth.(tem))
month_length_dim =DimArray(daysinmonth.(tem), (tem))
# with yax
g_tempo =groupby(month_length, Ti =>season(; start=December))
sum_days =sum.(g_tempo, dims=:Ti)
# with dim
g_tempo_dim =groupby(month_length_dim, Ti =>season(; start=December))
sum_days_dim =sum.(g_tempo_dim, dims=:Ti)
# no more dropdims available to flatten to a vector, what's the alternative?
g_tempo_dim ./ sum_days_dim # this one looks closer to a solution
ERROR: ArgumentError: axes of the array (1) do not match number of dimensions (2)
Stacktrace:
[1] _dimlengtherror(na::Int64, nd::Int64)
@ DimensionalData ~/.julia/packages/DimensionalData/8RvBF/src/array/array.jl:437
[2] checkdims(n::Int64, dims::Tuple{Ti{DimensionalData.Dimensions.LookupArrays.Sampled{…}}, DimensionalData.Dimensions.AnonDim{Base.OneTo{…}}})
And this one works
g_tempo_dim ./ [1,2,3,4] # g_tempo ./ [1,2,3,4] fails, is the one with yax.
But I think the problem is you need to map the broadcast over the slices:
map(./, g_tempo, sum_days)
# Or depending on what you are broadcastingmap(g -> g ./ sum_days, g_tempo, )
# Or double broadcast, which looks kinda weird:
(./).(g_tempo, sum_days))
Because actually each grouped array in g_tempo needs to be broadcast with sum_days.
I'm not sure if it makes sense to hack broadcast to "make it work".... even in xarray it only works because they hack those methods like mean work like that - cusom methods wont broadcast.
The following fails at a several levels.
This is how the sums look like:
and here the errors:
g_tempo ./ sum_days
And this one works
The text was updated successfully, but these errors were encountered: