Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a splitdims? #877

Open
tiemvanderdeure opened this issue Dec 3, 2024 · 6 comments
Open

add a splitdims? #877

tiemvanderdeure opened this issue Dec 3, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@tiemvanderdeure
Copy link
Collaborator

Would it be worth having something that is effectively the opposite of mergedims - to split dims with Tuple eltype into two separate dims?

Just to come with an example from the documentation:

julia> A = rand(X(1:0.01:2), Ti(tempo))
julia> minimum.(groupby(A, Ti=>yearmonth))

This now leaves us with a Sampled{Tuple{Int64, Int64}} Ti dimension. I think it'd be neat to be able to do splitdims(B, Ti => (:year, :month))

@tiemvanderdeure
Copy link
Collaborator Author

Or maybe even splitdims(A, Ti => (year, month) => (:year, :month) could be possible?

@rafaqz
Copy link
Owner

rafaqz commented Dec 3, 2024

We have unmergedims already, is that not enough?

@tiemvanderdeure
Copy link
Collaborator Author

I had a look, but it only works for MergedLookup. Although I guess in this case one could wrap the Ti dimension in a MergedLookup

@tiemvanderdeure
Copy link
Collaborator Author

Okay I tried this approach and this is the best I could do with unmergedims.

A = rand(X(1:0.01:2), Ti(tempo))
B = minimum.(groupby(A, Ti=>yearmonth))
C = rebuild(B, dims = (Ti(Rasters.DD.MergedLookup(val(lookup(dims(B, Ti))), (Dim{:year}(1:2), Dim{:month}(1:12)))),))
unmergedims(C, (:year, :month))

set for some reason didn't work so I had to use rebuild. Probably there is a better way to do it's not very obvious. But maybe the way is to improve unmergedims rather than add another function.

@rafaqz
Copy link
Owner

rafaqz commented Dec 3, 2024

Yeah that's too hard. let's make unmergedims work on anything.

@rafaqz rafaqz added the enhancement New feature or request label Dec 13, 2024
@tiemvanderdeure
Copy link
Collaborator Author

I realized that this is in some ways similar to #739 - maybe we can use some of the internals? The dims to be split are kind of like table columns (and they could also miss some values etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants