PixTable

class mpdaf.drs.PixTable(filename, xpos=None, ypos=None, lbda=None, data=None, dq=None, stat=None, origin=None, weight=None, primary_header=None, save_as_ima=True, wcs=Unit("pix"), wave=Unit("Angstrom"), unit_data=Unit("ct"))[source]

Bases: object

PixTable class.

This class manages input/output for MUSE pixel table files. The FITS file is opened with memory mapping. Just the primary header and table dimensions are loaded. The methods get_xpos, get_ypos, get_lambda, get_data, get_dq, get_stat and get_origin must be used to get columns data.

Parameters
filenamestr

The FITS file name. None by default.

Attributes
filenamestr

The FITS file name. None if any.

primary_headerastropy.io.fits.Header

The primary header.

nrowsint

Number of rows.

nifuint

Number of merged IFUs that went into this pixel table.

wcsastropy.units.Unit

Type of spatial coordinates of this pixel table (u.pix, u.deg or u.rad)

waveastropy.units.Unit

Type of spectral coordinates of this pixel table

imabool

If True, pixtable is saved as multi-extension FITS image instead of FITS binary table.

Attributes Summary

fluxcal

If True, this pixel table was flux-calibrated.

projection

Return the projection type.

skysub

If True, this pixel table was sky-subtracted.

Methods Summary

copy(self)

Copy PixTable object in a new one and returns it.

extract(self[, filename, sky, lbda, ifu, …])

Extracts a subset of a pixtable using the following criteria:

extract_from_mask(self, mask)

Return a new pixtable extracted with the given mask.

get_column(self, name[, ksel])

Load a column and return it.

get_data(self[, ksel, unit])

Load the data column and return it.

get_dq(self[, ksel])

Load the dq column and return it.

get_exp(self)

Load the exposure numbers and return it as a column.

get_keyword(self, key[, default])

Return the keyword value corresponding to key, adding the keyword prefix ('HIERARCH ESO DRS MUSE PIXTABLE').

get_lambda(self[, ksel, unit])

Load the lambda column and return it.

get_origin(self[, ksel])

Load the origin column and return it.

get_pos_sky(self[, xpos, ypos])

Return the absolute position on the sky in degrees/pixel.

get_row(self, idx)

Return a row of the pixtable, or rows if given a list of indices.

get_stat(self[, ksel, unit])

Load the stat column and return it.

get_weight(self[, ksel])

Load the weight column and return it.

get_xpos(self[, ksel, unit])

Load the xpos column and return it.

get_ypos(self[, ksel, unit])

Load the ypos column and return it.

info(self)

Print information.

mask_column(self[, maskfile])

Compute the mask column corresponding to a mask file.

origin2coords(self, origin)

Converts the origin value and returns (ifu, slice, ypix, xpix).

origin2ifu(self, origin)

Converts the origin value and returns the ifu number.

origin2slice(self, origin)

Converts the origin value and returns the slice number.

origin2xoffset(self, origin[, ifu, sli])

Converts the origin value and returns the x coordinates offset.

origin2xpix(self, origin[, ifu, sli])

Converts the origin value and returns the x coordinates.

origin2ypix(self, origin)

Converts the origin value and returns the y coordinates.

reconstruct_det_image(self[, xstart, …])

Reconstructs the image on the detector from the pixtable.

reconstruct_det_waveimage(self)

Reconstructs an image of wavelength values on the detector from the pixtable.

select_exp(self, exp, col_exp)

Return a mask corresponding to given exposure numbers.

select_ifus(self, ifus[, origin])

Return a mask corresponding to given ifus.

select_lambda(self, lbda[, unit])

Return a mask corresponding to the given wavelength range.

select_sky(self, sky)

Return a mask corresponding to the given aperture on the sky (center, size and shape)

select_slices(self, slices[, origin])

Return a mask corresponding to given slices.

select_stacks(self, stacks[, origin])

Return a mask corresponding to given stacks.

select_xpix(self, xpix[, origin])

Return a mask corresponding to given detector pixels.

select_ypix(self, ypix[, origin])

Return a mask corresponding to given detector pixels.

set_column(self, name, data[, ksel])

Set a column (or a part of it).

set_data(self, data[, ksel, unit])

Set data column (or a part of it).

set_dq(self, dq[, ksel])

Set dq column (or a part of it).

set_keyword(self, key, val)

Set the keyword value corresponding to key, adding the keyword prefix ('HIERARCH ESO DRS MUSE PIXTABLE').

set_lambda(self, lbda[, ksel, unit])

Set lambda column (or a part of it).

set_origin(self, origin[, ksel])

Set origin column (or a part of it).

set_stat(self, stat[, ksel, unit])

Set stat column (or a part of it).

set_weight(self, weight[, ksel])

Set weight column (or a part of it).

set_xpos(self, xpos[, ksel, unit])

Set xpos column (or a part of it).

set_ypos(self, ypos[, ksel, unit])

Set ypos column (or a part of it).

write(self, filename[, save_as_ima])

Save the object in a FITS file.

Attributes Documentation

fluxcal

If True, this pixel table was flux-calibrated.

projection

Return the projection type.

  • ‘positioned’ for positioned pixtables

  • ‘projected’ for reduced pixtables

skysub

If True, this pixel table was sky-subtracted.

Methods Documentation

copy(self)[source]

Copy PixTable object in a new one and returns it.

extract(self, filename=None, sky=None, lbda=None, ifu=None, sl=None, xpix=None, ypix=None, exp=None, stack=None, method='and')[source]

Extracts a subset of a pixtable using the following criteria:

  • aperture on the sky (center, size and shape)

  • wavelength range

  • IFU numbers

  • slice numbers

  • detector pixels

  • exposure numbers

  • stack numbers

The arguments can be either single value or a list of values to select multiple regions.

Parameters
filenamestr

The FITS filename used to save the resulted object.

sky(float, float, float, char)

(y, x, size, shape) extract an aperture on the sky, defined by a center (y, x) in degrees/pixel, a shape (‘C’ for circular, ‘S’ for square) and size (radius or half side length) in arcsec/pixels.

lbda(float, float)

(min, max) wavelength range in angstrom.

ifuint or list

IFU number.

slint or list

Slice number on the CCD.

xpix(int, int) or list

(min, max) pixel range along the X axis

ypix(int, int) or list

(min, max) pixel range along the Y axis

explist of int

List of exposure numbers

stacklist of int

List of stack numbers

method‘and’ or ‘or’

Logical operation used to merge the criteria

Returns
outPixTable
extract_from_mask(self, mask)[source]

Return a new pixtable extracted with the given mask.

Parameters
masknumpy.ndarray

Mask (array of bool).

Returns
outPixTable
get_column(self, name, ksel=None)[source]

Load a column and return it.

Parameters
namestr or attribute

Name of the column.

kseloutput of np.where

Elements depending on a condition.

Returns
outnumpy.array
get_data(self, ksel=None, unit=None)[source]

Load the data column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

Unit of the returned data.

Returns
outnumpy.array
get_dq(self, ksel=None)[source]

Load the dq column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

Returns
outnumpy.array
get_exp(self)[source]

Load the exposure numbers and return it as a column.

Returns
outnumpy.memmap
get_keyword(self, key, default=None)[source]

Return the keyword value corresponding to key, adding the keyword prefix ('HIERARCH ESO DRS MUSE PIXTABLE').

Parameters
keystr

Keyword.

Returns
outkeyword value
get_lambda(self, ksel=None, unit=None)[source]

Load the lambda column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

Unit of the returned data.

Returns
outnumpy.array
get_origin(self, ksel=None)[source]

Load the origin column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

Returns
outnumpy.array
get_pos_sky(self, xpos=None, ypos=None)[source]

Return the absolute position on the sky in degrees/pixel.

Parameters
xposnumpy.array

xpos values

yposnumpy.array

ypos values

Returns
xpos_sky, ypos_skynumpy.array, numpy.array
get_row(self, idx)[source]

Return a row of the pixtable, or rows if given a list of indices.

Parameters
idxint or list of int or ndarray

The row indices.

Returns
dict

The method returns a dict with a value or array of values for each column of the pixtable.

get_stat(self, ksel=None, unit=None)[source]

Load the stat column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

Unit of the returned data.

Returns
outnumpy.array
get_weight(self, ksel=None)[source]

Load the weight column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

Returns
outnumpy.array
get_xpos(self, ksel=None, unit=None)[source]

Load the xpos column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

Unit of the returned data.

Returns
outnumpy.array
get_ypos(self, ksel=None, unit=None)[source]

Load the ypos column and return it.

Parameters
kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

Unit of the returned data.

Returns
outnumpy.array
info(self)[source]

Print information.

mask_column(self, maskfile=None)[source]

Compute the mask column corresponding to a mask file.

Parameters
maskfilestr

Path to a FITS image file with WCS information, used to mask out bright continuum objects present in the FoV. Values must be 0 for the background and >0 for objects.

Returns
outmpdaf.drs.PixTableMask
origin2coords(self, origin)[source]

Converts the origin value and returns (ifu, slice, ypix, xpix).

Parameters
originint

Origin value.

Returns
out(int, int, float, float)
origin2ifu(self, origin)[source]

Converts the origin value and returns the ifu number.

Parameters
originint

Origin value.

Returns
outint
origin2slice(self, origin)[source]

Converts the origin value and returns the slice number.

Parameters
originint

Origin value.

Returns
outint
origin2xoffset(self, origin, ifu=None, sli=None)[source]

Converts the origin value and returns the x coordinates offset.

Parameters
originint

Origin value.

Returns
outfloat
origin2xpix(self, origin, ifu=None, sli=None)[source]

Converts the origin value and returns the x coordinates.

Parameters
originint

Origin value.

Returns
outfloat
origin2ypix(self, origin)[source]

Converts the origin value and returns the y coordinates.

Parameters
originint

Origin value.

Returns
outfloat
reconstruct_det_image(self, xstart=None, ystart=None, xstop=None, ystop=None)[source]

Reconstructs the image on the detector from the pixtable.

The pixtable must concerns only one IFU, otherwise an exception is raised.

Returns
outImage
reconstruct_det_waveimage(self)[source]

Reconstructs an image of wavelength values on the detector from the pixtable. The pixtable must concerns only one IFU, otherwise an exception is raised.

Returns
outImage
select_exp(self, exp, col_exp)[source]

Return a mask corresponding to given exposure numbers.

Parameters
explist of int

List of exposure numbers

Returns
outarray of bool

mask

select_ifus(self, ifus, origin=None)[source]

Return a mask corresponding to given ifus.

Parameters
ifuint or list

IFU number.

Returns
outarray of bool

mask

select_lambda(self, lbda, unit=Unit("Angstrom"))[source]

Return a mask corresponding to the given wavelength range.

Parameters
lbda(float, float)

(min, max) wavelength range in angstrom.

unitastropy.units.Unit

Unit of the wavelengths in input.

Returns
outarray of bool

mask

select_sky(self, sky)[source]

Return a mask corresponding to the given aperture on the sky (center, size and shape)

Parameters
sky(float, float, float, char)

(y, x, size, shape) extract an aperture on the sky, defined by a center (y, x) in degrees/pixel, a shape (‘C’ for circular, ‘S’ for square) and size (radius or half side length) in arcsec/pixels.

Returns
outarray of bool

mask

select_slices(self, slices, origin=None)[source]

Return a mask corresponding to given slices.

Parameters
sliceslist of int

Slice number on the CCD.

Returns
outarray of bool

mask

select_stacks(self, stacks, origin=None)[source]

Return a mask corresponding to given stacks.

Parameters
stackslist of int

Stacks numbers (1,2,3 or 4)

Returns
——-
outarray of bool

mask

select_xpix(self, xpix, origin=None)[source]

Return a mask corresponding to given detector pixels.

Parameters
xpixlist

[(min, max)] pixel range along the X axis

Returns
outarray of bool

mask

select_ypix(self, ypix, origin=None)[source]

Return a mask corresponding to given detector pixels.

Parameters
ypixlist

[(min, max)] pixel range along the Y axis

Returns
outarray of bool

mask

set_column(self, name, data, ksel=None)[source]

Set a column (or a part of it).

Parameters
namestr or attribute

Name of the column.

datanumpy.array

data values

kseloutput of np.where

Elements depending on a condition.

set_data(self, data, ksel=None, unit=None)[source]

Set data column (or a part of it).

Parameters
datanumpy.array

data values

kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

unit of the data column in input.

set_dq(self, dq, ksel=None)[source]

Set dq column (or a part of it).

Parameters
dqnumpy.array

dq values

kseloutput of np.where

Elements depending on a condition.

set_keyword(self, key, val)[source]

Set the keyword value corresponding to key, adding the keyword prefix ('HIERARCH ESO DRS MUSE PIXTABLE').

Parameters
keystr

Keyword.

valstr or int or float

Value.

set_lambda(self, lbda, ksel=None, unit=None)[source]

Set lambda column (or a part of it).

Parameters
lbdanumpy.array

lbda values

kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

unit of the lambda column in input.

set_origin(self, origin, ksel=None)[source]

Set origin column (or a part of it).

Parameters
originnumpy.array

origin values

kseloutput of np.where

Elements depending on a condition.

set_stat(self, stat, ksel=None, unit=None)[source]

Set stat column (or a part of it).

Parameters
statnumpy.array

stat values

kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

unit of the stat column in input.

set_weight(self, weight, ksel=None)[source]

Set weight column (or a part of it).

Parameters
weightnumpy.array

weight values

kseloutput of np.where

Elements depending on a condition.

set_xpos(self, xpos, ksel=None, unit=None)[source]

Set xpos column (or a part of it).

Parameters
xposnumpy.array

xpos values

kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

unit of the xpos column in input.

set_ypos(self, ypos, ksel=None, unit=None)[source]

Set ypos column (or a part of it).

Parameters
yposnumpy.array

ypos values

kseloutput of np.where

Elements depending on a condition.

unitastropy.units.Unit

unit of the ypos column in input.

write(self, filename, save_as_ima=True)[source]

Save the object in a FITS file.

Parameters
filenamestr

The FITS filename.

save_as_imabool

If True, pixtable is saved as multi-extension FITS image instead of FITS binary table.