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

Dimension metadata #660

Closed
xzackli opened this issue Mar 5, 2024 · 3 comments
Closed

Dimension metadata #660

xzackli opened this issue Mar 5, 2024 · 3 comments

Comments

@xzackli
Copy link

xzackli commented Mar 5, 2024

I couldn't figure out how to attach metadata to a Dimension, is this possible? I can wrap a MetaArrays.jl or similar, but it seems like a lookup might already have this functionality?

I love your package! I use it to analyze astrophysical data (perhaps similar to ecological modeling). I spent some time today writing an extension with hackish FFT compatibility, as I'd like to preserve a phase in the fourier conjugate dimension so I can reconstruct the spatial frequencies when I inverse FFT.

@rafaqz
Copy link
Owner

rafaqz commented Mar 5, 2024

You can! But it goes in the lookup, as Dimension is just a wrapper.

Theres even a helper to do it without constructing the lookup:

x =X(10:20; metadata=Dict())

When you put x in a DimArray format will put the metadata dict in the lookup for you.

For FFT you may also want to extend Lookup if you need anything more than metadata, like custom dispatch. You can extend AbstractSampled to keep most of the selectors etc working as normal.

@xzackli
Copy link
Author

xzackli commented Mar 5, 2024

Thank you! Yes, that's just what I was looking for. I'd initially gotten confused by

ERROR: UndefVarError: `AutoLookup` not defined

when trying this out in my own Dimensions. That's my own error: I believe it's because the macro evaluates in the calling context, and I hadn't imported AutoLookup.

using DimensionalData: @dim, XDim, AutoLookup
@dim X2 XDim
x = X2(10:20; metadata=Dict())

Thank you again for writing such a useful package!

@xzackli xzackli closed this as completed Mar 5, 2024
@rafaqz
Copy link
Owner

rafaqz commented Mar 5, 2024

Probably should need to import that!

Maybe a bug in the macro.

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

No branches or pull requests

2 participants