Skip to main content
`Ctrl`+`K`

# NDData

class astropy.nddata.NDData(data, uncertainty=None, mask=None, wcs=None, meta=None, unit=None, copy=False, psf=None)

  Bases: `NDDataBase`

  A container for `numpy.ndarray`-based datasets, using the `NDDataBase` interface.

  The key distinction from raw `numpy.ndarray` is the presence of additional metadata such as uncertainty, mask, unit, a coordinate system and/or a dictionary containing further meta information. This class only provides a container for storing such datasets. For further functionality take a look at the `See also` section.

  See also: https://docs.astropy.org/en/stable/nddata/

  Parameters:
    data `numpy.ndarray` astropy:-like or `NDData` astropy:-like

      The dataset.

    uncertainty `any` type, optional

      Uncertainty in the dataset. Should have an attribute `uncertainty_type` that defines what kind of uncertainty is stored, for example `"std"` for standard deviation or `"var"` for variance. A metaclass defining such an interface is `NDUncertainty` - but isn’t mandatory. If the uncertainty has no such attribute the uncertainty is stored as `UnknownUncertainty`. Defaults to `None`.

    mask `any` type, optional

      Mask for the dataset. Masks should follow the `numpy` convention that valid data points are marked by `False` and invalid ones with `True`. Defaults to `None`.

    wcs `any` type, optional

      World coordinate system (WCS) for the dataset. Default is `None`.

    meta `dict` astropy:-like `object`, optional

      Additional meta information about the dataset. If no meta is provided an empty dict is created. Default is `None`.

    unit astropy:unit-like, optional

      Unit for the dataset. Strings that can be converted to a `Unit` are allowed. Default is `None`.

    copy `bool`, optional

      Indicates whether to save the arguments as copy. `True` copies every attribute before saving it while `False` tries to save every parameter as reference. Note however that it is not always possible to save the input as reference. Default is `False`.

      Added in version 1.2.

    psf `numpy.ndarray` or `python:None`, optional

      Image representation of the PSF. In order for convolution to be flux- preserving, this should generally be normalized to sum to unity.

  Raises:
    `TypeError`

      In case `data` or `meta` don’t meet the restrictions.

  See also

  `NDDataRef`
  `NDDataArray`

  Notes

  Each attribute can be accessed through the homonymous instance attribute: `data` in a `NDData` object can be accessed through the `data` attribute:

      >>> from astropy.nddata import NDData
      >>> nd = NDData([1,2,3])
      >>> nd.data
      array([1, 2, 3])

  Given a conflicting implicit and an explicit parameter during initialization, for example the `data` is a `Quantity` and the unit parameter is not `None`, then the implicit parameter is replaced (without conversion) by the explicit one and a warning is issued:

      >>> import numpy as np
      >>> import astropy.units as u
      >>> q = np.array([1,2,3,4]) * u.m
      >>> nd2 = NDData(q, unit=u.cm)
      INFO: overwriting Quantity's current unit with specified unit. [astropy.nddata.nddata]
      >>> nd2.data
      array([100., 200., 300., 400.])
      >>> nd2.unit
      Unit("cm")

  Attributes Summary

  `data` | `ndarray`-like : The stored dataset.
  `mask` | any type : Mask for the dataset, if any.
  `meta` |
  `psf` | Image representation of the PSF for the dataset.
  `uncertainty` | any type : Uncertainty in the dataset, if any.
  `unit` | `Unit` : Unit for the dataset, if any.
  `wcs` | any type : A world coordinate system (WCS) for the dataset, if any.

  Attributes Documentation

  data

    `ndarray`-like : The stored dataset.

  mask

    any type : Mask for the dataset, if any.

    Masks should follow the `numpy` convention that valid data points are marked by `False` and invalid ones with `True`.

  meta = None
  psf
  uncertainty

    any type : Uncertainty in the dataset, if any.

    Should have an attribute `uncertainty_type` that defines what kind of uncertainty is stored, such as `'std'` for standard deviation or `'var'` for variance. A metaclass defining such an interface is `NDUncertainty` but isn’t mandatory.

  unit

    `Unit` : Unit for the dataset, if any.

  wcs

    any type : A world coordinate system (WCS) for the dataset, if any.