How to rotate and slice a cube for pV diagrams
A position-velocity diagram is typically along slice along a direction in the RA/DEC plane with a given position angle. The y-axis consist of the velocities along that slice. How to do this? Currently there's no task but one can use the tools in CASA.
Here's a recipe:
1) rotate the input cube by a given position angle (to align the slice in the vertical direction):
#open the image
ia.open('original.image')
#rotate by the position angle and write out a new, rotated cube
ia.rotate(pa='45deg',outfile='rotated.image')
# close the image
ia.close('original.image')
You now have a rotated cube 'rotated.image'
2) now create a box region by finding the bottom left corner (blc) and top right corner (trc) pixel coordinates. Attach this to a variable, here 'mybox'
mybox=rg.box(blc=[65,152],trc=[215,187])
3) bin along one of the axes within that region, drop the degenerate axis, write to a new file 'slice.image'
ia.open('rotated.image')
ia.rebin(region=mybox,outfile='slice.image',bin=[1,35,1,1],dropdeg=True)
ia.close('rotated.image')
4) load the slice into the viewer - don't forget that the axes need to be swapped in the control panel (in 'Display Axes' e.g. Declination vs Frequency). Unfortunately, the coordinates are now a bit scrambled as they mix RA and Dec. Safest is to display the x-axis as pixels via 'Axis Label Properties' -> 'World or Pixel coordinates' -> 'Pixel'