Package spectractor :: Module spectractor :: Class Spectractor
[hide private]
[frames] | no frames]

Class Spectractor

source code

Spliner --+
          |
         Spectractor

Class for manipulating set of 1D spectra: collect and unify data. First we read raw data and fds. Than select spectral orders, shift, cut and flat each of them, finally, write to resulting array.

Instance Methods [hide private]
 
__init__(self, spectra, vscl=True, cuts_dct=None, dtype=<type 'list'>, edglim=0, verbose=False) source code
 
get_raw(self, data_pth, fds_pth, pp_pth)
Read binary files containing data, wavelength scale (fds) and ccm (file with flatten polynome points).
source code
 
filler(self, key, lams, dats)
Fill self.fdata depending of its dtype (dictionary or list).
source code
 
take_orders(self, data, fds, polypt, opts, lam=None, ish=0, cuts=None)
Take some orders from given spectrum depending of some conditions.
source code
 
shcut_lams(self, lams, shift=0, cuts=None)
Get fds, shift and cut them depending on given shift and limits.
source code
 
runner(self, lam=None, divs=None, ish=None)
Iterate over the spectra.
source code
 
get_lims(self, lam=None)
Return boundary wavelengths or velocities depending on self.vscl.
source code
 
collect_chains(self, lam, width=4, shift=0, ish=0, wcut=None)
Collect spectra chains containing given wavelength in a given spectral window.
source code
 
get_chains(self, lam, llim=None, hlim=None, divs=None, ish=0, wcut=None)
Collect spectra chains containing given wavelength in a given velocity range.
source code
 
get_atlas(self, llam=None, hlam=None, divs=None, ish=0)
Collect spectra chains in a given wavelength range.
source code

Inherited from Spliner: flat_order, mk_spline, splpl

Method Details [hide private]

__init__(self, spectra, vscl=True, cuts_dct=None, dtype=<type 'list'>, edglim=0, verbose=False)
(Constructor)

source code 
Parameters:
  • spectra - iterable array (named tuple) with spectra parameters: file paths, observation dates etc. These parameters must be present: id, pth, fdspth (path to fds), plpth (path to ccm.txt), Vr (spectrum shift, e.g. heliocentric correction). Others, e.g. jd, are optional and can be used as part of keys in resulting data. This array can be easily constructed from database table
  • vscl - get spectrum chains in velocity scale if True (zero velocity wavelength must be present), use wavelengths scale otherwise
  • cuts_dct - dictionary with number of pixels to cut for spectral orders
  • dtype - data type of resulting array, could be list or dict
  • edglim (integer) - number of pixels to cut at the edges of each spectral order
Overrides: Spliner.__init__

get_raw(self, data_pth, fds_pth, pp_pth)

source code 

Read binary files containing data, wavelength scale (fds) and ccm (file with flatten polynome points).

Parameters:
  • data_pth - path to spectrum data file
  • fds_pth - path to spectrum dispersion curve file
  • pp_pth - path to polynome points file
Returns:
data array, fds array, polynome points dictionary

take_orders(self, data, fds, polypt, opts, lam=None, ish=0, cuts=None)

source code 

Take some orders from given spectrum depending of some conditions. The main conditions are lower and higher wavelength limits and presence of points for flatten polynome (polypt). Here we assume that each order has a fds sorted by wavelength. After selection each selected order becomes flatten and cut using class settings. Resulted chains are collect in self.fdata.

Here we use an opts.Vr property - spectrum shift, for example, heliocentric correction. If self.vshift is True, Vr must be in velocity scale (e.g. km/s), wavelength scale otherwise.

Parameters:
  • data - data as iterable 2D array
  • fds - dispersion curve as 2D array of wavelengths
  • polypt - dictionary with points for flatten polynome plotting
  • lam - wavelength for converting into velocity scale, if self.vscl is True
  • ish - intensity shift for flatted order

shcut_lams(self, lams, shift=0, cuts=None)

source code 

Get fds, shift and cut them depending on given shift and limits. If self.vshift is True, we calculate shift array dlam = (shift*lams)/C, where C is the speed of light.

Parameters:
  • lams - dispersion curve as array of wavelengths
  • shift - spectrum shift, e.g. heliocentric correction
  • cuts - tuple with number of start and end pixels to cut for given order
Returns:
fds chain of wavelengths or velocities, pixel numbers of limiting wavelengths

collect_chains(self, lam, width=4, shift=0, ish=0, wcut=None)

source code 

Collect spectra chains containing given wavelength in a given spectral window.

Parameters:
  • lam - wavelength of interest
  • width - half-width of spectral window in wavelength scale
  • shift - shift of the spectral window for placing lam at the center of the window
  • ish - relative intensity shift for flatted order
  • wcut - tolerance parameter for rejecting partly matching orders. The meaning of the parameter is a shift of chain limiting wavelengths before comparing with window limits. So, some chains can be break with wcut<0 and can be processed with wcut>0. Default is 1
Returns:
dictionary or list with spectra chains, values are tuples and keys are parameters. Type of resulting data are given in dtype

get_chains(self, lam, llim=None, hlim=None, divs=None, ish=0, wcut=None)

source code 

Collect spectra chains containing given wavelength in a given velocity range. At least one of the limits in velocity scale must be set

Parameters:
  • lam - wavelength of interest
  • ish - relative intensity shift for flatted order
  • wcut - tolerance parameter for rejecting partly matching orders. The meaning of the parameter is a shift of chain limiting wavelengths before comparing with window limits. So, some chains can be break with wcut<0 and can be processed with wcut>0. Default is 1
Returns:
dictionary or list with spectra chains, values are tuples and keys are parameters. Type of resulting data are given in dtype

get_atlas(self, llam=None, hlam=None, divs=None, ish=0)

source code 

Collect spectra chains in a given wavelength range. If limit is not set, get all orders in this direction.

Parameters:
  • ish - relative intensity shift for flatted order
Returns:
dictionary or list with spectra chains, values are tuples and keys are parameters. Type of resulting data are given in dtype