| 1 |
Slicing multi-dimensional data cubes |
| 2 |
==================================== |
| 3 |
|
| 4 |
How to slice data cubes |
| 5 |
----------------------- |
| 6 |
|
| 7 |
APLpy supports extracting a slice from n-dimensional FITS cubes, and |
| 8 |
re-ordering dimensions. The two key arguments to |
| 9 |
:class:`~aplpy.FITSFigure` to control this are ``dimensions`` and |
| 10 |
``slices``. These arguments can also be passed to :meth:`~aplpy.FITSFigure.show_contour`. |
| 11 |
|
| 12 |
The ``dimensions`` argument is used to specify which dimensions should be used |
| 13 |
for the x- and y-axis respectively (zero based). The default values are ``[0, |
| 14 |
1]`` which means that the x-axis should use the first dimension in the FITS |
| 15 |
cube, and the y-axis should use the second dimension. For a 2-dimensional FITS |
| 16 |
file, this means that one can use ``[1, 0]`` to flip the axes. For a FITS cube |
| 17 |
with R.A., Declination, and Velocity, ``[0, 2]`` would make a R.A.-Velocity |
| 18 |
plot. |
| 19 |
|
| 20 |
The ``slices`` argument gives the pixels slice to extract from the remaining |
| 21 |
dimensions, skipping the dimensions used, so ``slices`` should be a list with |
| 22 |
length n-2 where n is the number of dimensions in the FITS file. For example, |
| 23 |
if one has a FITS file with R.A., Declination, Velocity, and Time (in that |
| 24 |
order), then: |
| 25 |
|
| 26 |
* ``dimensions=[0, 1]`` means the plot will be an R.A-Declination plot, and |
| 27 |
``slices=[33, 56]`` means that pixel slices 33 and 56 will be used in |
| 28 |
Velocity and Time respectively (in this case, ``dimensions`` does not need |
| 29 |
to be specified since it defaults to ``[0, 1]``) |
| 30 |
|
| 31 |
* ``dimensions=[0, 2]`` means the plot will be an R.A-Velocity plot, and |
| 32 |
``slices=[22, 56]`` means that pixel slices 22 and 56 will be used in |
| 33 |
Declination and Time respectively. |
| 34 |
|
| 35 |
* ``dimensions=[3, 2]`` means the plot will be a Time-Velocity plot, and |
| 36 |
``slices=[10, 22]`` means that pixel slices 10 and 22 will be used in R.A |
| 37 |
and Declination respectively. |
| 38 |
|
| 39 |
See :ref:`arbitrary` for information on formatting the labels when |
| 40 |
non-longitude/latitude coordinates are used. |
| 41 |
|
| 42 |
Aspect ratio |
| 43 |
------------ |
| 44 |
|
| 45 |
When plotting images in sky coordinates, APLpy makes pixel square by default, |
| 46 |
but it is possible to change this. When calling |
| 47 |
:meth:`~aplpy.FITSFigure.show_grayscale` or |
| 48 |
:meth:`~aplpy.FITSFigure.show_colorscale`, simply add ``aspect='auto'`` |
| 49 |
which will override the ``aspect='equal'`` default. The ``aspect='auto'`` is |
| 50 |
demonstrated below. |
| 51 |
|
| 52 |
Example |
| 53 |
------- |
| 54 |
|
| 55 |
The following examples demonstrates this functionality in use |
| 56 |
|
| 57 |
.. plot:: |
| 58 |
:context: reset |
| 59 |
:include-source: |
| 60 |
|
| 61 |
from astropy.utils.data import get_pkg_data_filename |
| 62 |
co_cube = get_pkg_data_filename('l1448/l1448_13co.fits') |
| 63 |
|
| 64 |
import aplpy |
| 65 |
|
| 66 |
f = aplpy.FITSFigure(co_cube, slices=[30], figsize=(8, 6)) |
| 67 |
f.show_colorscale() |
| 68 |
f.add_grid() |
| 69 |
f.tick_labels.set_font(size='x-small') |
| 70 |
f.axis_labels.set_font(size='small') |
| 71 |
|
| 72 |
.. plot:: |
| 73 |
:context: reset |
| 74 |
:include-source: |
| 75 |
|
| 76 |
from astropy.utils.data import get_pkg_data_filename |
| 77 |
co_cube = get_pkg_data_filename('l1448/l1448_13co.fits') |
| 78 |
|
| 79 |
import aplpy |
| 80 |
|
| 81 |
f = aplpy.FITSFigure(co_cube, slices=[30], |
| 82 |
dimensions=[1, 0], figsize=(8, 6)) |
| 83 |
f.show_colorscale() |
| 84 |
f.add_grid() |
| 85 |
f.tick_labels.set_font(size='x-small') |
| 86 |
f.axis_labels.set_font(size='small') |
| 87 |
|
| 88 |
.. plot:: |
| 89 |
:context: reset |
| 90 |
:include-source: |
| 91 |
|
| 92 |
from astropy.utils.data import get_pkg_data_filename |
| 93 |
co_cube = get_pkg_data_filename('l1448/l1448_13co.fits') |
| 94 |
|
| 95 |
import aplpy |
| 96 |
|
| 97 |
f = aplpy.FITSFigure(co_cube, dimensions=[2, 1], |
| 98 |
slices=[50], figsize=(8, 6)) |
| 99 |
f.show_colorscale(aspect='auto') |
| 100 |
f.add_grid() |
| 101 |
f.tick_labels.set_font(size='x-small') |
| 102 |
f.axis_labels.set_font(size='small') |
| 103 |
f.tick_labels.set_xformat('%.1f') |