brutifus package

Submodules

brutifus.brutifus module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains the master brutifus routines. Most of these routines call sub-routines, after setting the scene/loading datasets/etc …

Any processing step MUST have a dediacted routine in this file called ‘run_XXX’, which can then refer to any existing/new brutifus/Python module.

Created November 2018, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au


This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

brutifus.brutifus.run(procsteps_fn, params_fn)[source]

Run a given set of brutifus processing steps with certain parameters.

Parameters
  • procsteps_fn (string) – filename containing the processing steps

  • params_fn (string) – filename containing the scientific parameters

brutifus.brutifus.run_adjust_WCS(fn_list, params, suffix=None, name_in=None, name_out=None)[source]

Adjust the WCS solution of the cube using Gaia.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (str) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (str) – name tag to identify which cube to use to run the routine

  • name_out (str) – name tag to identify which cube comes out of the routine

Returns

The updated dictionary of filenames.

Return type

dict

Note

Proper motions for the GAIA entries are propagated to the DATE-OBS of the data. Source identification in white-light image based on photutils.DAOStarFinder

Todo

Avoid using a hard-coded pixel FWHM for the cross-correlation?

brutifus.brutifus.run_crude_snr_maps(fn_list, params, suffix=None, name_in=None, zcorr_lams=False)[source]

Computes a crude S/N ratio for a continuum range or emission line.

This function computes the SNR maps for the continuum or emission lines. It also creates a map of spaxels with any signal at all. The resulting maps are saved to a fits file with full header and WCS coordinates.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (str) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (str) – name tag to identify which cube to use to run the routine.

  • zcorr_lams (bool) – True -> correct the wavelength range for the target redshift.

Returns

The updated dictionary of filenames.

Return type

dict

Note

This function is a “first guess” of the SNR for latter use in the code. A more reliable measure of the SNR for the emission line should be computed after they have been fitted.

brutifus.brutifus.run_fit_continuum(fn_list, params, suffix=None, name_in=None, start_row=None, end_row=None, method='lowess')[source]

Fits the stellar/nebular continuum using a specific method.

This function fits the continuum in the datacube. It is designed to use multiprocessing to speed things up on good computers. It deals with the data columns-per-columns, and can be restarted mid-course, in case of a crash.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (str) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (str) – name tag to identify which cube to use to run the routine

  • start_row (int) – the row from which to sart the fitting. None for min.

  • end_row (int) – the row on which to end the fitting (inclusive). None for max.

  • method (str) – which method to use for the fitting ?

Returns

The updated dictionary of filenames.

Return type

dict

brutifus.brutifus.run_gal_dered(fn_list, params, suffix=None, name_in=None, name_out=None)[source]

Corrects for Galactic extinction, given the Ab and Av extinction.

This function derives the Alambda value for any wavelength, and corrects the data to correct for our “local” extinction. Intended for extragalactic sources.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (str) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (str) – name tag to identify which cube to use to run the routine

  • name_out (str) – name tag to identify which cube comes out of the routine

Returns

The updated dictionary of filenames.

Return type

dict

Note

To reproduce the approach from NED, use the Ab and Av value for you object from there, and set curve='f99', rv=3.1 in the params file.

brutifus.brutifus.run_make_continuum_cube(fn_list, params, suffix=None, method='lowess')[source]

Assemble a continuum cube from the individually-pickled fits.

This function is designed to construct a “usable and decent” datacube out of the mess generated by the continuum fitting function, i.e. out of the many pickle files generated.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (str) – The tag of this step, to be used in all files generated for rapid id.

  • method (str) – which fits to gather ?

Returns

The updated dictionary of filenames.

Return type

dict

brutifus.brutifus.run_plot_BW(fn_list, params, suffix=None, name_in=None, bands=[[7500.0, 9300.0]], conts=[[None, None]], stretches=['arcsinh'], plims=[[10.0, 99.5]], vlims=[[None, None]], gauss_blurs=[None])[source]

Make some B&W images from slices in the cube.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (string) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (string) – name tag to identify which cube to use to run the routine

  • bands (list) – A list of wavelength pairs.

  • conts (list) – A list of wavelength pairs channels associated continuum regions.

  • stretches (list) – The stretches to apply to the data, e.g. ‘linear’, ‘log’, ‘arcsinh’.

  • plims (list) – The limiting percentiles for the plot

  • vlims (list) – The limiting values for the plot (superseeds stretch_plims)

  • gauss_blurs (list) – Radius of gaussian blur, None for nothing

Returns

The updated dictionary of filenames.

Return type

dictionary

brutifus.brutifus.run_plot_RGB(fn_list, params, suffix=None, name_in=None, bands=[[7500.0, 9300.0, 6000.0, 7500.0, 4800.0, 6000.0]], conts=[[None, None, None]], stretches=[['arcsinh', 'arcsinh', 'arcsinh']], plims=[[10.0, 99.5, 10.0, 99.5, 10.0, 99.5]], vlims=[[None, None, None, None, None, None]], gauss_blurs=[[None, None, None]])[source]

Make some RGB images from slices in the raw cube.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (string) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (string) – name tag to identify which cube to use to run the routine

  • bands (list) – A list of 3 wavelength pairs.

  • conts (list) – A list of 3 wavelength pairs: channels associated continuum regions.

  • stretches (list) – The stretches to apply to each slice: ‘linear’, ‘log’, ‘arcsinh’, …

  • plims (list) – The limiting percentiles for the plot

  • vlims (list) – The limiting values for the plot (superseeds stretch_plims)

  • gauss_blurs (list) – Radius of gaussian blur, None for nothing

Returns

The updated dictionary of filenames.

Return type

dictionary

brutifus.brutifus.run_sky_sub(fn_list, params, suffix=None, name_in=None, name_out=None)[source]

Performs a manual sky subtraction, when the observation strategy was flawed.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (str) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (str) – name tag to identify which cube to use to run the routine

  • name_out (str) – name tag to identify which cube comes out of the routine

Returns

The updated dictionary of filenames.

Return type

dict

brutifus.brutifus.run_subtract_continuum(fn_list, params, suffix=None, name_in=None, name_out=None, method=None)[source]

Subtracts the sky from a given cube.

Parameters
  • fn_list (dict) – The dictionary containing all filenames created by brutifus.

  • params (dict) – The dictionary containing all paramaters set by the user.

  • suffix (str) – The tag of this step, to be used in all files generated for rapid id.

  • name_in (str) – name tag to identify which cube to use to run the routine

  • name_out (str) – name tag to identify which cube comes out of the routine

Returns

The updated dictionary of filenames.

Return type

dict

brutifus.brutifus_cof module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains functions related to the continuum fitting inside brutifus.

Created November 2018, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au

brutifus.brutifus_cof.lowess_fit(spec, lams, frac=0.05, it=5)[source]

Fit a spectrum using a Locally Weighted Scatterplot Smoothing approach.

Wraps around statsmodels.nonparametric.smoothers_lowess.lowess().

Parameters
  • spec (1-D numpy array) – The input spectrum.

  • lams (1-D numpy array) – The corresponding wavelength array.

  • frac (float [default:0.05]) – Between 0 and 1. The fraction of the data used when estimating each y-value. [From the statsmodel lowess function]

  • it (int [default:5]) – The number of residual-based reweightings to perform. [From the statsmodel lowess function]

Returns

The fitted array, with size equal to spec.

Return type

numpy array

Note

This function fits a spectrum using a LOWESS (Locally Weighted Scatterplot Smoothing) technique, described in: Cleveland, W.S. (1979) Robust Locally Weighted Regression and Smoothing Scatterplots. Journal of the American Statistical Association 74 (368): 829-836.

This is robust to outliers (hot pixels, cosmics), and is also efficient to ignore emission lines. frac=0.05 and it=5 seem to work very fine for spectra of any SNR, both lousy with no continuum, and good ones in the center of galaxies - modulo the stellar absorption features which are of course “ignored” by the LOWESS routine.

..warning:: If you have broad emission line in the spectrum, you want to be very

careful with LOWESS !!!

brutifus.brutifus_metadata module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains some global metadata used throughout the brutifus code.

Created November 2018-2019, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au

brutifus.brutifus_metadata.get_fn_list_fn(target)[source]

Returns the filename of the storage pickle for all the filenames used by the code

Parameters

target (string) – name of the target/object to be processed

Returns

the pickled dictionary filename

Return type

string

brutifus.brutifus_plots module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains tools for the brutifus routines to create pretty plots seamlessly.

Created November 2018, F.P.A. Vogt - - frederic.vogt@alumni.anu.edu.au

brutifus.brutifus_plots.crosshair(inner_r=1, pa=0)[source]

The path of an emtpy cross, useful for indicating targets without crowding the field.

Params inner_r

empty inner radius. Default=1 (gap = tick length = 1/3 marker width)

Params pa

position angle (degrees)

Returns

path

Return type

matplotlib.path.Path

brutifus.brutifus_plots.finetune_WCSAxes(im_ax)[source]

Fine-tune the look of WCSAxes plots to my liking.

Currently, this changes the tick label format to show integer seconds, sets the separators to hms/d ‘ “, enables minor ticks, and tweaks the axis labels to be R.A. and Dec. (with dots!).

Parameters

im_ax (matplotlib.axes) – the axes to be improved

Returns

(ra,dec), the axes coordinates.

Return type

matplotlib ax.coords

brutifus.brutifus_plots.get_fig_dims(nx, ny)[source]
Returns all the necessary figure dimensions for gridspec, given the size of the

image to plot.

Parameters
  • nx (int) – number of pixels along x axis

  • ny (int) – number of pixels along y axis

Returns

list containing the figure parameters [width, height, height_ratios, width_ratios, left, right, botom, top, wspace, hspace]

Return type

list

brutifus.brutifus_plots.get_im_interval(pmin=10, pmax=99.9, vmin=None, vmax=None)[source]

Returns an interval, to feed the ImageNormalize routine from Astropy.

Parameters
  • pmin (float) – lower-limit percentile

  • pmax (float) – upper-limit percentile

  • vmin (float) – absolute lower limit

  • vmax (float) – absolute upper limit

Returns

an astropy.visualization.interval thingy …

Return type

astropy.visualization.interval

Note

Specifying both vmin and vmax will override pmin and pmax.

brutifus.brutifus_plots.get_im_stretch(stretch)[source]

Returns a stretch to feed the ImageNormalize routine from Astropy.

Parameters

stretch (string) – short name for the stretch I want. Possibilities are ‘arcsinh’ or ‘linear’.

Returns

A astropy.visualization.stretch thingy …

Return type

astropy.visualization.stretch

brutifus.brutifus_plots.make_2Dplot(fn, ext=0, ofn='plot.pdf', stretch='arcsinh', vlims=[None, None], plims=[10.0, 99.99], gauss_blur=None, cmap=None, cblabel=None, scalebar=None)[source]

Creates an image from a 2-D fits image with WCS info.

Parameters
  • fn (string) – The filename (+path!) fo the fits file to display.

  • ext (int) – The extension of the image to display. The data in this extension MUST be 2-D.

  • ofn (string) – The output filename (+path!)

  • stretch (string) – The stretch of the image, fed to aplpy.FITSFigure. ‘linear’, ‘arcsinh’, …

  • vmin (float) – If set, the lower bound of the colorbar

  • vmax (float) – If set, the upper bound of the colorbar

  • pmin (float) – If set, the lower percentile bound of the colorbar

  • pmax (float) – If set, the upper percentile bound of the colorbar

  • cmap (string) – If set, the colormap to use. Use ‘alligator’ for the special brutifus cmap.

  • cblabel (string) – If set, the label of the colorbar.

  • scalebar (list of len(3)) – If set, adds a scale bar to the plot. Format: [lenght arcsec, length kpc, loc, unit]

Returns

a list containing the figure, the ax1 and the plot filename.

Return type

list

Note

This function absolutely requires WCS coordinates, and a 2-D array.

brutifus.brutifus_plots.make_RGBplot(fns, ofn, ext=[0, 0, 0], stretch=['linear', 'linear', 'linear'], plims=[0.25, 99.75, 0.25, 99.75, 0.25, 99.75], vlims=[None, None, None, None, None, None], gauss_blur=[None, None, None], title=None, scalebar=None)[source]

Creates an RGB image from three fits files.

Parameters
  • fns (list) – The filename (+path!) fo the 3 fits file to display (in R, G and B orders).

  • ofn (str) – The filneame (+path) of the output file.

  • ext (list) – What HDU extension to read ?

  • stretch (list) – The stretch to apply to the data, e.g. ‘linear’, ‘log’, ‘arcsinh’.

  • plims (list) – The limiting percentiles for the plot, as [pmin_r, pmax_r, pmin_g, pmax_g, pmin_b, pmax_b]

  • vlims (list) – The limting values for the plot (superseeds plims), as [vmin_r, vmax_r, vmin_g, vmax_g, vmin_b, vmax_b]

  • gauss_blur (list) – list of radius (in pixels) for gaussian_blur. None = no blur

  • title (str) – Title to display above the image

  • scalebar (list) – If set, adds a scale bar to the plot. Format: [lenght arcsec, length kpc, loc, unit]

Returns

a list containing the figure, the ax1 and the plot filename.

Return type

list

brutifus.brutifus_plots.make_galred_plot(lams, alams, etau, Ab, Av, ofn)[source]

Plots the extinction Alambda and flux correction factor for galactic extinction.

Parameters
  • lams (float) – The wavelength nodes.

  • alams – The corresponding values of Alambda.

  • etau – The flux correction factor, i.e. F_(unextinct)/F_(observed).

  • Ab – The value of Ab.

  • Av – The value of Av.

  • ofn (string) – path+name of where to save the plot

brutifus.brutifus_plots.reverse_colourmap(cdict)[source]

Returns the inverted colorbar dictionary.

I most definitely got this from the web somewhere … Stackoverflow?

Params cdict

a colorbar dictionary

Returns

the flipped dictionary

Return type

dict

brutifus.brutifus_plots.show_scale(ax, scale_length=<Quantity 10. arcsec>, scale_text=None, scale_loc='lower left')[source]

Adds a scalebar to a given 2D plot.

Parameters
  • ax – The axes to which to add the sale.

  • scale_length – The scale length in astropy.units

  • scale_text – the string to print as the scalebar, or None

  • scale_loc – string [default: ‘top left’] The location of the scale bar. e.g ‘top right’, ‘bottom left’, etc …

brutifus.brutifus_red module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains several function and tools used by the brutifus routines to correct emission line fluxes for galactic and extragalactic reddening.

Created November 2018, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au

brutifus.brutifus_red.D_fm90(x, gamma, x0)[source]

The UV points from Fitzpatrick & Massa (1990).

Parameters
  • x (float) – Wavelength in 1/microns.

  • gamma (float) – The gamma factor.

  • x0 – The x0 factor.

brutifus.brutifus_red.F_fm90(x)[source]

The UV points from Fitzpatrick & Massa (1990).

Parameters

x (float) – Wavelength in 1/microns.

brutifus.brutifus_red.alam(lams, ab, av, curve='f99', rv=None, rva=4.3)[source]

Calculate the value of A_lambda for different extinction/attenuation laws.

Parameters
  • lams (numpy array) – The values at which to evaluate the attenuation/extinction.

  • ab (float) – The extinction in B (e.g. according to NED)

  • av – The extinction in V (e.g. according to NED)

  • curve (str) – extinction/attenuation curve to use: ‘f99’, ‘fd05’, ‘cal00’, ‘cal00*’, ‘ccm89’

  • rv (float) – The value of Rv.

  • rva (float) – The value of Rva, if using curve=’fd05’.

Note

To reproduce the values given in NED, set curve=’f99’, and rv=3.1. The default value of Rv will depend on the curve used (if not specified). rv=3.1 for ‘f99’, rv=3.08 for ‘fd05’, rv=4.05 for ‘cal00’ and ‘cal00*’, and rv=3.1 for ‘ccm89’. ‘cal00*’ includes a 0.44 correction factor to derive the stellar extinction.

brutifus.brutifus_red.cal00_ke(lams, rv)[source]

The Calzetti (2000) law.

Parameters
  • lams (numpy array) – the wavelength array in Angstroem.

  • rv (float) – the Rv value

Returns

ke from Calzetti (2000)

Return type

numpy array

Note

This does NOT include the 0.44 correction factor to apply for stellar extinction.

brutifus.brutifus_red.ccm89_alav(lams, rv)[source]

The law from Caredelli, Clayton and Mathis (1989).

Parameters
  • lams (numpy array) – the wavelength array in Angstroem

  • rv (float) – the Rv value

Returns

alav from CCM 1989.

Return type

numpy array

brutifus.brutifus_red.check()[source]

Visually check the reddening routines with some plots.

Make some quick plots to test the reddening functions of brutifus, by comparing with the original papers. And make sure I did not mess things up …

brutifus.brutifus_red.extragalactic_red(lam, hahb, hahb_0, curve='fd05', rv=None, rva=4.3)[source]

Calculate the extragalactic attenuation (based on Halpha/Hbeta).

Parameters
  • lam (float) – The wavelength at which to evaluate the attenuation/extinction.

  • hahb (numpy array) – The observed Halpha/Hbeta flux ratio. Can be a 2-D map.

  • hahb_0 (float) – The reference theoretical unreddened Halpha/Hbeta flux ratio.

  • curve (str) – Which extinction/attenuation curve to use.

  • rv (float) – Rv value.

  • rva (float) – The value of Rva, if using curve=’fd05’.

Returns

The ratio of Flux_(unattenuated)/ Flux_(attenuated)

Return type

numpy array

Note

See also Vogt+ (2013), Appendix A. By default, Rv=3.08 and Rva=4.3, which gives a curve vey close to that of Calzetti (2000) below the 2000 Ansgtroem bump. Supported curves are fd05, f99, ccm89, cal00 and cal00*. cal00* includes a 0.44 correction factor to derive the stellar extinction.

brutifus.brutifus_red.f99_alebv(lams, rv=3.1)[source]

The spline-interpolated Fitzpatrick, PASP (1999) Alambda/E(B-V) function.

Parameters
  • lams (numpy array) – The wavelengths in Angstroem.

  • rv (float) – The Rv value.

brutifus.brutifus_red.fd05_elvebv(lams, rv=3.08, rva=4.3)[source]

Compute E(lambda-V)/E(B-V) according to Fischera&Dopita (2005), given Rv and Rva.

This function reproduces Table 1 in the article. Unlike in Appendix 1 of Vogt et al. (2013), this function relies on the polynomials defined in the text to reproduce the values of E(lambda-V)/E(B-V) for any Rv and Rva.

Parameters
  • lams (numpy array) – The wavelengths at which to evaluate the attenutation.

  • rv (float) – The Rv value, following Fischera & Dopita.

  • rva (float) – The Rva value, following Fischera & Dopita.

Returns

The value of E(lambda-V)/E(B-V), as in Table 1 and Fig.3 of the article.

Return type

numpy array

Note

By default, Rv = 3.08 and Rva = 4.3, which gives a curve vey close to that of Calzetti (2000) below the 2000 Ansgtroem bump. Thanks to R. Sutherland at ANU/RSAA for sharing his reddening code (included in MAPPINGS V), which helped me implement this function properly.

brutifus.brutifus_red.galactic_red(lams, ab, av, curve='f99', rv=None, rva=4.5)[source]

Calculate the galactic extinction for a given sight-line, using Ab and Av.

Parameters
  • lams (numpy array) – The values at which to evaluate the attenuation/extinction.

  • ab (float) – The extinction in B (e.g. according to NED).

  • av (float) – The extinction in V (e.g. according to NED).

  • curve (str) – extinction/attenuation curve to use: ‘f99’, ‘fd05’, ‘cal00’, ‘cal00*’, ‘ccm89’

  • rv (float) – Rv value.

  • rva (float) – The value of Rva, if using curve=’fd05’.

Returns

The ratio of Flux_(unreddened)/ Flux_(observed).

Return type

numpy array

Note

To follow NED, set curve=’f99’, and rv = 3.1. The default value of Rv will depend on the curve used (if not specified). rv=3.1 for ‘f99’, rv=3.08 for fd05, rv=4.05 for ‘cal00’ and ‘cal00*’, and rv=3.1 for ‘ccm89’. cal00* includes a 0.44 correction factor to derive the stellar extinction.

brutifus.brutifus_red.hahb_to_av(hahb, hahb_0, curve='fd05', rv=None, rva=4.3)[source]

Get the reddening in Av mag, from Ha/Hb ratio.

Parameters
  • ha_hb (numpy array) – The flux ratio of Halpha to Hbeta (NOT the log!)

  • ha_hb_0 (float) – The theoretical value of Halpha/Hbeta. (2.86 for SB, more for AGNs)

  • curve (str) – Which reddeing law to use ?

  • rv (float) – The value of Rv to use. None for the default.

Returns

The corrseponding values of Av.

Return type

1D numpy array

Note

See also Vogt+ (2013), Appendix A. By default, Rv = 3.08 and Rva = 4.3, which gives a curve vey close to that of Calzetti (2000) below the 2000 Ansgtroem bump.

brutifus.brutifus_tools module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains general tools for the brutifus routines to fit the stellar continuum and the emission lines in an IFU data cube.

Created November 2018, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au

brutifus.brutifus_tools.extract_cube(fn, inst)[source]

Extracts the data and error associated with a given datacube.

Parameters
  • fn (string) – relative path to file

  • inst (string) – Name of the instrument that took the data

Returns

[[lams,data,error], [header0, header_data, header_error]]

Return type

list

brutifus.brutifus_tools.hdu_add_brutifus(hdu, procstep)[source]

Adds dedicated brutifus keywords to a FITS file header.

Parameters
  • hdu – The destination hdu to which the brutifus keywords must be added.

  • procstep (str) – The name of the processing step creating the FITS file.

Returns

The newheader with brutifus info included.

brutifus.brutifus_tools.hdu_add_lams(newhdu, refheader)[source]

Adds the wavelength information from a reference header to a new hdu.

Parameters
  • newhdu – The destination hdu to which the wavelength keywords must be added.

  • refheader – The reference header, from which to transer the wavelength keywords.

Returns

FITS HDU, the newheader with wavelength info included.

Note

Keywords transfered are ‘CTYPE3’, ‘CUNIT3’, ‘CD3_3’, ‘CRPIX3’, ‘CRVAL3’, ‘CD1_3’, ‘CD2_3’, ‘CD3_1’ and ‘CD3_2’.

brutifus.brutifus_tools.hdu_add_wcs(newhdu, refheader)[source]

Adds the WCS coordinates from a reference header to a new hdu.

Parameters
  • newheader – The destination hdu to which the WCS keywords must be added.

  • refheader – The reference header, from which to transer the WCS keywords.

Returns

The new hdu with WCS info included.

Note

Keywords transfered are ‘CRPIX1’, ‘CD1_1’, ‘CTYPE1’, ‘CUNIT1’, ‘CRPIX2’, ‘CD2_2’, ‘CTYPE2’, ‘CUNIT2’, ‘CD1_2’, ‘CD2_1’, ‘CRVAL1’ and ‘CRVAL2’.

brutifus.brutifus_tools.init_worker()[source]

Handles KeyboardInterrupt during multiprocessing.

brutifus.brutifus_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 !).

Parameters
  • inst (str) – The name tag referring to a given instrument.

  • get_ff (bool) – Whether to recompute the given function from a reference dataset or not. Only valid with inst = ‘MUSE’.

  • show_plot (bool) – Whether to make a plot of the function.

Returns

A function that takes a float (lambda in Angstroem), and returns the corresponding value of the chosen instrument resolution.

Return type

func

Note

Supported instruments: ‘MUSE’

brutifus.brutifus_tools.nearest_2dpoint(point, points)[source]

Returns the nearest neighbor from a bung of points, and the distance

Parameters
  • point (numpy array) – 1x2 array with x, y coord

  • points (numpy array) – Nx2 array with x, y coords

Returns

the min distance, the delta-x and delta-y, and the closest point

Return type

list

brutifus.brutifus_version module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains the version of the code.

Created August 2019, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au

brutifus.brutifus_wcs module

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file contains WCS-related function for the higher-leve brutifus routines.

Created August 2019, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au

brutifus.brutifus_wcs.get_linear_WCS_corr(fn, obstime=None, verbose=True, suffix=None, target=None)[source]

Identify the linear offset between Gaia and the WCS solution of a given 2D image.

Parameters
  • fn (string) – 2D FITS image filename (and location)

  • obstime (astropy.Time()) – Observing time and date

  • suffix (str) – the tag of this step (for plot filename)

  • target (str) – target name (for plot filename)

  • verbose (bool) – print some info to screen

Returns

(dx,dy), the linear offsets in pixels

Return type

tuple

Note

Assumes the image is in the primary extension.

Module contents

brutifus: a set of Python modules to process datacubes from integral field spectrographs.

Copyright (C) 2018-2019, F.P.A. Vogt


This file specifies the kind of functions that are made directly available to the user.

Created November 2018, F.P.A. Vogt - frederic.vogt@alumni.anu.edu.au