radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
98 stars 65 forks source link

Conversion function from Feed to Stokes and back #735

Open preshanth opened 3 years ago

preshanth commented 3 years ago

I have written up some basic conversion functions going from feed basis to stokes and back. Should this ideally be a class of its own or is it a better fit inside stokes_spectral_cube.

keflavich commented 3 years ago

What should this look like to a user? Does it make sense to do, e.g.,

stokes_XY_cube = stokes_I_cube.as_stokes(['X','Y'])

like that? Or would you suggest a different kind of interface?

(I don't work with polarization cubes much, so tell us what the UI should look like)

preshanth commented 3 years ago

Yeah something along those line. That allows us to check if the conversion is actually possible and provide cubes back either in stokes or in feed.

stokes_XX_cube, stokes_YY_cube = stokes_I_cube.as_feed(basis='linear') or something along the lines of stokes_cube = feed_cube.to_stokes()

keflavich commented 3 years ago

OK, I think the as_feed or to_feeds approach makes sense, but going the other way, we'd probably need StokesCube(feeds={'xx':stokes_XX_cube, 'yy': stokes_YY_cube}) or something like that. It may be better to have these be functions rather than class methods for symmetry, then?

preshanth commented 3 years ago

I am leaning towards the having the cubes be convertible from one stokes to every other possible stokes. That might be a good method to have in the class rather than a stand alone function. I am debugging something similar for CASA in C++ right now so is not that much of a stretch. I think both @kitchi and I have some time to contribute to this code as we will use spectral_cube under the hood for our image plane primary beam correction package.