Skip to content

Are there any helper functions for extending a dimension of an DimArray #970

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

Open
alex-s-gardner opened this issue Apr 8, 2025 · 5 comments
Labels
question Further information is requested

Comments

@alex-s-gardner
Copy link
Contributor

alex-s-gardner commented Apr 8, 2025

I have a DimArray

da = rand(X(1:10), Y(1:10))

And later in my workflow I'd like add values at X == 11. Right now that looks like:

da2 = fill(NaN, X(1:11), Y(1:10))
da2[At(1:10), : ] = da;
da = da2

This looks a bit uglier as the number of dims grow. I'm wondering if my current approach is best practice or if there is a helper function (that I haven't been able to find) to simplify this operation as I'm guessing this operation is relatively common.

@rafaqz
Copy link
Owner

rafaqz commented Apr 9, 2025

cat(da1, da2; dims=X) ?
(Hmm maybe I don't totally get what you're doing)

Rasters has extend, maybe that's what you want.

I guess Rasters should just accept any AbstractDimArray, the problem is what to use for the missing values

@asinghvi17
Copy link
Collaborator

Could always force a kwarg fill...

@alex-s-gardner
Copy link
Contributor Author

cat() is what I was looking for, thanks.

da = rand(X(1:10), Y(1:10))
da2 = fill(NaN, X(11:11), Y(1:10))
da = cat(da, da2, dims=:X)

@asinghvi17
Copy link
Collaborator

This would still be nice to have

@asinghvi17 asinghvi17 reopened this Apr 9, 2025
@rafaqz
Copy link
Owner

rafaqz commented Apr 9, 2025

We could move extend here I guess.

@rafaqz rafaqz added the question Further information is requested label May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants