[go: up one dir, main page]

File: arithmetic.rst

package info (click to toggle)
spectral-cube 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,960 kB
  • sloc: python: 12,408; makefile: 154
file content (24 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Spectral Cube Arithmetic
========================

Simple arithmetic operations between cubes and scalars, broadcastable numpy
arrays, and other cubes are possible.  However, such operations should be
performed with caution because they require loading the whole cube into memory
and will generally create a new cube in memory.

Examples::

    >>> import astropy.units as u
    >>> from astropy.utils import data
    >>> fn = data.get_pkg_data_filename('tests/data/example_cube.fits', 'spectral_cube')
    >>> from spectral_cube import SpectralCube
    >>> cube = SpectralCube.read(fn)
    >>> cube2 = cube * 2
    >>> cube3 = cube + 1.5 * u.Jy / u.beam
    >>> cube4 = cube2 + cube3

Each of these cubes is a new cube in memory.  Note that for addition and
subtraction, the units must be equivalent to those of the cube.

Please see :ref:`doc_handling_large_datasets` for details on how to perform
arithmetic operations on a small subset of data at a time.