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

Feature request: Create DataAxis from vector instead of dict #2718

Closed
F00lWise opened this issue Apr 23, 2021 · 6 comments
Closed

Feature request: Create DataAxis from vector instead of dict #2718

F00lWise opened this issue Apr 23, 2021 · 6 comments

Comments

@F00lWise
Copy link

F00lWise commented Apr 23, 2021

Hey guys,
having discovered hyperspy some weeks back, it has been hugely helpful in analyzing a spectroscopy dataset with 4 independent dimensions. However, I just found that one of the stepper motors was using steps, so that the true scanned axis is no longer linear, but totally irregular.

I have been looking excitedly at the development for non-uniform axis support and I was wondering if a non-uniform axis could not be created by a call like this:

axis1 = sort(np.random.random(10))
axis2 = sort(np.random.random(100)
s = hs.signals.Signal1D(np.random.random((10, 100)), axes=[axis1, axis2])

I suppose the vector would have to represent the middles, rather than the edges of the signal, although that is technically not precise if the true data is continuous.
This kind of syntax would also allow a functional axis (see #1927, #2398) by simply evaluating the function first and passing it as a vector, thereby relieving the programmer of learning the axis dictionary syntax.
It would also automatically solve #2692.
@thomasaarholt suggested this could make a nice option for #2399 .

Thanks so much for all your work!

@ericpre
Copy link
Member

ericpre commented Apr 23, 2021

Is it not already implemented in #2399? See https://hyperspy--2399.org.readthedocs.build/en/2399/user_guide/axes.html#non-uniform-data-axis

@thomasaarholt
Copy link
Contributor

What do you think, @F00lWise? Is the following enough?

dict0 = {'axis': np.arange(12)**2}
s = hs.signals.Signal1D(np.ones(12), axes=[dict0])

@F00lWise
Copy link
Author

F00lWise commented Apr 27, 2021

Wow awesome I had not seen that yet! I will try that out immediately! :D
Thank you all so much!

@F00lWise
Copy link
Author

... actually, can I install it yet? (Sorry, noob question.)

@thomasaarholt
Copy link
Contributor

Yep. If you haven't been using git, then the easiest is to do pip install https://github.com/hyperspy/hyperspy/archive/refs/heads/non_uniform_axes.zip, in the terminal. Otherwise you could look up "checking out a pull request" on git, or use the new github pr tool.

@F00lWise
Copy link
Author

It works :))))

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

3 participants