WaveCoord

class mpdaf.obj.WaveCoord(hdr=None, crpix=1.0, cdelt=1.0, crval=1.0, cunit=Unit("Angstrom"), ctype='LINEAR', shape=None)[source]

Bases: object

WaveCoord class manages world coordinates in spectral direction.

Parameters:

hdr : astropy.fits.CardList

A FITS header. If hdr is not None, WaveCoord object is created from this header and other parameters are not used.

crpix : float

Reference pixel coordinates. 1.0 by default. Note that for crpix definition, the first pixel in the spectrum has pixel coordinates.

cdelt : float

Step in wavelength (1.0 by default).

crval : float

Coordinates of the reference pixel (0.0 by default).

cunit : u.unit

Wavelength unit (Angstrom by default).

ctype : string

Type of the coordinates.

shape : integer or None

Size of spectrum (no mandatory).

Attributes

shape (integer) Size of spectrum.
wcs (astropy.wcs.WCS) Wavelength coordinates.

Methods Summary

coord([pixel, unit]) Return the coordinate corresponding to pixel.
copy() Copie WaveCoord object in a new one and returns it.
get_crpix() CRPIX getter (reference pixel on the wavelength axis).
get_crval([unit]) CRVAL getter (value of the reference pixel on the wavelength axis).
get_ctype() Return the type of wavelength coordinates.
get_end([unit]) Return the value of the last pixel.
get_range([unit]) Return the wavelength range [Lambda_min,Lambda_max].
get_start([unit]) Return the value of the first pixel.
get_step([unit]) Return the step in wavelength.
info([unit]) Print information.
isEqual(other) Return True if other and self have the same attributes.
pixel(lbda[, nearest, unit]) Return the decimal pixel corresponding to the wavelength lbda.
rebin(factor) Rebin to a new coordinate system (in place).
resample(step, start[, unit]) Resample to a new coordinate system.
set_crpix(x) CRPIX setter (reference pixel on the wavelength axis).
set_crval(x[, unit]) CRVAL getter (value of the reference pixel on the wavelength axis).
set_step(x[, unit]) Return the step in wavelength.
to_header([naxis, use_cd]) Generate a astropy.fits header object with the WCS information.

Methods Documentation

coord(pixel=None, unit=None)[source]

Return the coordinate corresponding to pixel.

If pixel is None (default value), the full coordinate array is returned.

Parameters:

pixel : int, array or None.

pixel value.

unit : astropy.units.Unit

type of the wavelength coordinates

Returns:

out : float or array of float

copy()[source]

Copie WaveCoord object in a new one and returns it.

get_crpix()[source]

CRPIX getter (reference pixel on the wavelength axis).

get_crval(unit=None)[source]

CRVAL getter (value of the reference pixel on the wavelength axis).

Parameters:

unit : astropy.units.Unit

type of the wavelength coordinates

get_ctype()[source]

Return the type of wavelength coordinates.

get_end(unit=None)[source]

Return the value of the last pixel.

Parameters:

unit : astropy.units.Unit

type of the wavelength coordinates

get_range(unit=None)[source]

Return the wavelength range [Lambda_min,Lambda_max].

Parameters:

unit : astropy.units.Unit

type of the wavelength coordinates

get_start(unit=None)[source]

Return the value of the first pixel.

Parameters:

unit : astropy.units.Unit

type of the wavelength coordinates

get_step(unit=None)[source]

Return the step in wavelength.

Parameters:

unit : astropy.units.Unit

type of the wavelength coordinates

info(unit=None)[source]

Print information.

isEqual(other)[source]

Return True if other and self have the same attributes.

pixel(lbda, nearest=False, unit=None)[source]

Return the decimal pixel corresponding to the wavelength lbda.

If nearest=True; returns the nearest integer pixel.

Parameters:

lbda : float or array

wavelength value.

nearest : bool

If nearest is True returns the nearest integer pixel in place of the decimal pixel.

unit : astropy.units.Unit

type of the wavelength coordinates

Returns:

out : float or integer

rebin(factor)[source]

Rebin to a new coordinate system (in place).

Parameters:

factor : integer

Factor.

Returns:

out : WaveCoord

resample(step, start, unit=None)[source]

Resample to a new coordinate system.

Parameters:

start : float

New wavelength for the pixel 0.

step : float

New step.

unit : astropy.units.Unit

type of the wavelength coordinates

Returns:

out : WaveCoord

set_crpix(x)[source]

CRPIX setter (reference pixel on the wavelength axis).

set_crval(x, unit=None)[source]

CRVAL getter (value of the reference pixel on the wavelength axis).

Parameters:

x : float

value of the reference pixel on the wavelength axis

unit : astropy.units.Unit

type of the wavelength coordinates

set_step(x, unit=None)[source]

Return the step in wavelength.

Parameters:

x : float

Step value

unit : astropy.units.Unit

type of the wavelength coordinates

to_header(naxis=1, use_cd=False)[source]

Generate a astropy.fits header object with the WCS information.