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
hdrastropy.fits.CardList

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

crpixfloat

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

cdeltfloat

Step in wavelength (1.0 by default).

crvalfloat

Coordinates of the reference pixel (0.0 by default).

cunitu.unit

Wavelength unit (Angstrom by default).

ctypestring

Type of the coordinates.

shapeinteger or None

Size of spectrum (no mandatory).

Attributes
shapeinteger

Size of spectrum.

wcsastropy.wcs.WCS

Wavelength coordinates.

Methods Summary

coord(self[, pixel, unit, medium])

Return the coordinate corresponding to pixel.

copy(self)

Copie WaveCoord object in a new one and returns it.

get_crpix(self)

CRPIX getter (reference pixel on the wavelength axis).

get_crval(self[, unit])

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

get_ctype(self)

Return the type of wavelength coordinates.

get_end(self[, unit])

Return the value of the last pixel.

get_range(self[, unit])

Return the wavelength range [Lambda_min,Lambda_max].

get_start(self[, unit])

Return the value of the first pixel.

get_step(self[, unit])

Return the step in wavelength.

info(self[, unit])

Print information.

isEqual(self, other)

Return True if other and self have the same attributes.

pixel(self, lbda[, nearest, unit])

Return the decimal pixel corresponding to the wavelength lbda.

rebin(self, factor)

Rebin to a new coordinate system (in place).

resample(self, step, start[, unit])

Resample to a new coordinate system.

set_crpix(self, x)

CRPIX setter (reference pixel on the wavelength axis).

set_crval(self, x[, unit])

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

set_step(self, x[, unit])

Return the step in wavelength.

to_header(self[, naxis, use_cd])

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

Methods Documentation

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

Return the coordinate corresponding to pixel.

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

Parameters
pixelint, array or None.

Pixel value.

unitastropy.units.Unit

Unit of the wavelength coordinates

mediumstr or None

Medium in which the wavelengths are returned: ‘air’ or ‘vacuum’. If None (default), the wavelength corresponding to the spectrum CTYPE are returned.

Returns
outfloat or array of float
copy(self)[source]

Copie WaveCoord object in a new one and returns it.

get_crpix(self)[source]

CRPIX getter (reference pixel on the wavelength axis).

get_crval(self, unit=None)[source]

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

Parameters
unitastropy.units.Unit

type of the wavelength coordinates

get_ctype(self)[source]

Return the type of wavelength coordinates.

get_end(self, unit=None)[source]

Return the value of the last pixel.

Parameters
unitastropy.units.Unit

type of the wavelength coordinates

get_range(self, unit=None)[source]

Return the wavelength range [Lambda_min,Lambda_max].

Parameters
unitastropy.units.Unit

type of the wavelength coordinates

get_start(self, unit=None)[source]

Return the value of the first pixel.

Parameters
unitastropy.units.Unit

type of the wavelength coordinates

get_step(self, unit=None)[source]

Return the step in wavelength.

Parameters
unitastropy.units.Unit

type of the wavelength coordinates

info(self, unit=None)[source]

Print information.

isEqual(self, other)[source]

Return True if other and self have the same attributes.

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

Return the decimal pixel corresponding to the wavelength lbda.

If nearest=True; returns the nearest integer pixel.

Parameters
lbdafloat or array

wavelength value.

nearestbool

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

unitastropy.units.Unit

type of the wavelength coordinates

Returns
outfloat or integer
rebin(self, factor)[source]

Rebin to a new coordinate system (in place).

Parameters
factorinteger

Factor.

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

Resample to a new coordinate system.

Parameters
startfloat

New wavelength for the pixel 0.

stepfloat

New step.

unitastropy.units.Unit

type of the wavelength coordinates

Returns
outWaveCoord
set_crpix(self, x)[source]

CRPIX setter (reference pixel on the wavelength axis).

set_crval(self, x, unit=None)[source]

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

Parameters
xfloat

value of the reference pixel on the wavelength axis

unitastropy.units.Unit

type of the wavelength coordinates

set_step(self, x, unit=None)[source]

Return the step in wavelength.

Parameters
xfloat

Step value

unitastropy.units.Unit

type of the wavelength coordinates

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

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