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

converting microns to wave number #881

Open
alexmaragko opened this issue Jun 7, 2023 · 6 comments
Open

converting microns to wave number #881

alexmaragko opened this issue Jun 7, 2023 · 6 comments

Comments

@alexmaragko
Copy link

I have a spectral cube object where the spectral_axis is in microns (u.um) and I would like to update it, or alternatively create a new cube, in wave numbers (1/u.cm).

new_cube = cube.with_spectral_unit(1/u.cm) does not work because it requires an equivalencies=u.spectral(), but with_spectral_unit takes the velocity_convention argument with the ‘relativistic’, ‘radio’, or ‘optical’ options.

cube.spectral_axis.to(1/u.cm, equivalencies=u.spectral()) does the job but I am not sure how to create a new cube that has this as the spectral axis.

@keflavich
Copy link
Contributor

Thevelocity_convention keyword should be optional. cube.with_spectral_unit should then just work. All conversions of velocity coordinates automatically use the .spectral equivalency.

If you get an error leaving velocity_convention unspecified - that's a legit bug that we should fix, but put in velocity_convention='radio' as a placeholder

@alexmaragko
Copy link
Author

alexmaragko commented Jun 7, 2023

Giving new_cube = cube.with_spectral_unit(1/u.cm) returns *** KeyError: 'wavenumber', and the same error is given even if I include velocity_convention='radio'

@keflavich
Copy link
Contributor

Ah, then this is a deeper issue; it may be that the FITS standard does not support wavenumber? I'll have to dig more deeply to be sure

@alexmaragko
Copy link
Author

Thanks. Is there currently a way to create a new cube using cube.spectral_axis.to(1/u.cm, equivalencies=u.spectral()) which works as expected?

@keflavich
Copy link
Contributor

No, the framework underlying all of what spectral-cube does is the FITS-WCS library. If FITS doesn't support a unit, we can't serialize the data or compute transformations b/w systems

@keflavich
Copy link
Contributor

Ah, but FITS does support wavenumber; this might be a simple fix

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