brutus_tools module¶
brutus: a set of Python modules to process datacubes from integral field spectrographs.
Copyright (C) 2016, F.P.A. Vogt
This file contains general tools for the brutus routines to fit the stellar continuum and the emission lines in an IFU data cube.
Created April 2016, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au
-
brutus_tools.
delog_rebin
(lams, spec, old_lams, sampling=1)[source]¶ Undoes the log_rebin function.
This function is designed to undo the brutus_tools.log_rebin function. Of course, this is not perfect, but setting sampling >1 helps avoid losses.
Args: - lams: 1-D numpy array
The log-rebined wavelength array.
- spec: 1-D numpy array
The log-rebinned spectra.
- old_lams: 1-D numpy array
The original (linear) wavelength array.
- sampling: int [default: 1]
Amount of resampling (1 = no resampling).
Returns: - old_lams, old_spec: 1-D numpy array, 1-D numpy array
The delog-rebinned wavelength and spectra.
Notes: This function only deals with calculating the bin edges, and then feeds this to spec_rebin.
See also: log_rebin()
-
brutus_tools.
hdu_add_brutus
(hdu, procstep)[source]¶ Adds dedicated brutus keywords to a FITS file header.
Args: - hdu: FITS hdu
The destination hdu to which the brutus keywords must be added.
- procstep: string
The name of the processing step creating the FITS file.
Returns: - out: FITS header
The newheader with brutus info included.
-
brutus_tools.
hdu_add_lams
(newhdu, refheader)[source]¶ Adds the wavelength information from a reference header to a new hdu.
Args: - newhdu: FITS hdu
The destination hdu to which the wavelength keywords must be added.
- refheader: FITS header
The reference header, from which to transer the wavelength keywords.
Returns: - out: FITS hdu
The newheader with wavelength info included.
Notes: Keywords transfered are ‘CTYPE3’, ‘CUNIT3’, ‘CD3_3’, ‘CRPIX3’, ‘CRVAL3’, ‘CD1_3’, ‘CD2_3’, ‘CD3_1’ and ‘CD3_2’.
-
brutus_tools.
hdu_add_wcs
(newhdu, refheader)[source]¶ Adds the WCS coordinates from a reference header to a new hdu.
Args: - newheader: FITS hdu
The destination hdu to which the WCS keywords must be added.
- refheader: FITS header
The reference header, from which to transer the WCS keywords.
Returns: - out: FITS hdu
The new hdu with WCS info included.
Notes: Keywords transfered are ‘CRPIX1’, ‘CD1_1’, ‘CTYPE1’, ‘CUNIT1’, ‘CRPIX2’, ‘CD2_2’, ‘CTYPE2’, ‘CUNIT2’, ‘CD1_2’, ‘CD2_1’, ‘CRVAL1’ and ‘CRVAL2’.
-
brutus_tools.
init_worker
()[source]¶ Handles KeyboardInterrupt during multiprocessing.
Notes: See https://noswap.com/blog/python-multiprocessing-keyboardinterrupt
-
brutus_tools.
inst_resolution
(inst='MUSE', get_ff=False, show_plot=False)[source]¶ Returns the functional resolution of an instrument as a function of the wavelength.
Returns a callable function of the wavelength (in Angstroem !).
Args: - inst: string [default: ‘MUSE’]
The name tag referring to a given instrument.
- get_ff: bool [default: False]
Whether to recompute the given function from a reference dataset or not. Only valid with inst = ‘MUSE’.
- show_plot: bool [default: False]
Whether to make a plot of the function.
Returns: - R(lambda): function
A function that takes a float (lambda in Angstroem, and returns the corresponding value of the chosen instrument resolution.
Notes: Supported instruments: ‘MUSE’
-
brutus_tools.
log_rebin
(lams, spec, sampling=1, velscale=None)[source]¶ Logarithmically rebin a spectrum.
This function rebins a linear spectrum in log bins. It basically redistribute light into the new bins, while conserving the flux density.
Args: - lams: 1-D numpy array
The input (linear) bin wavelengths, in Angstroem.
- spec: 1-D numpy array
The input spectrum.
- sampling: int [default:1]
Amount of resampling (1 = no resampling).
- velscale: float [default: None]
The logarithmic bin size in km/s (None = choose default given sampling).
Returns: - new_lams, new_spec, velscale: 1-D array, 1-D array, float
The new spectral bin centers in Angstroem, the reshaped spectrum, and the associated velscale (in km/s).
Notes: Inspired by log_rebin inside ppxf_util, but without the one magic line I don’t understand (replaced by a “dumb” for-loop instead). Wraps around spec_rebin. If velscale is set, sampling has no effect. The logarithmic bin centers are the geometric means of the logarithmic bin edges. Unlike ppxf_util.log_rebin, return the new bin centers in Angstroem.
-
brutus_tools.
spec_rebin
(borders, new_borders, spec)[source]¶ Rebin an array to new bins, while conserving the flux density.
This function rebins a spectrum from one grid to another, assuming the two grids start and end at the same spot. Conserves the flux density in each bin.
Args: - borders: 1-D numpy array
The edges of the initial spectrum bins.
- new_borders: 1-D numpy array
The edges of the new spectrum bins.
- spec: 1-D numpy array
The spectrum to rebin, with len(spec) = len(borders)-1.
Returns: - out: 1-D numpy array
The rebinned spectrum, with size = len(new_borders)-1.