1. Data Reduction - HeloiseS/FUSS GitHub Wiki

It is important to note that the following was written for the reduction of FORS2 data. This may not be optimal/ may not work for data taken using other instruments.

IRAF routines

The IRAF CL routines included in FUSS are the following:

They are small automation on the IRAF data reduction process and make use of standard IRAF tasks. To learn all about spectroscopy in IRAF see the documentation.

Some of them (arc_apertures.cl, toascii_pol.cl and toascii_flux.cl) internally call PYTHON scripts to perform tasks that are more easily done in PYTHON than in IRAF (e.g renaming files). I don't go into the detail of what these small python scripts do, but if you are going to use any of the aforementioned tasks on your computer you should check that the path to the PYTHON tasks they call is correct.

first_calibs.cl

This script performs initial calibrations: It creates and removes the Master Bias and the Master Flat, and also creates the Master ARC. The script called first_calibs_no_flat.cl does the same thing but ignores Flat removal. This might seem odd, but spectropolarimetry does not absolutely require flat field removal since polarimetry is a differential effect. I tend to do flat removal because most of the time I'm eventually going to combine the polarised spectra into a flux spectrum (for which flat fielding is necessary). If not, then doing flats is just an extra step which can introduce oddities in the reduced spectrum if the response function is not well fitted.

arc_apertures.cl

After defining the apertures on all the science frames (using apall), calibration arc images need to be created for each science frame by cutting out the same apertures in the Master Arc: I do this with arc_apertures.cl. It also adds a line to the headers of the SCIENCE_*.ms.fits images specifying the name of the calibration arc image. This information will be used by the task identify.

disp2.cl

This new task might seem overkill, but since I always use the dispcor task twice I've created this new task that deletes the output of dispcor and bring the parameter file up for me the make changes and run it again. Because I am a creature of habit, my outputs for dispcor always of a name of the format dSCIENCE_*, so that's what disp2.cl will remove before doing epar dispcor.

auto_calibrate.cl

Get back to that

toascii_pol.cl and toascii_flux.cl

These will turn your reduced .fits spectra into text files. Before running either of those tasks make sure that you have a folder called 1D_spectra in your working directory. Nothing will catch on fire if you don't, but that's where these tasks put all the "junk" that comes out of turning the fits files into text files.

toascii_pol.cl will use the dSCIENCE*.fits files as input and create 2 files per spectrum: 1 containing the polarised spectrum + 1 containing the errors. Now, each SCIENCE frame contains 2 spectra, and you need at least 4 frames (observed at 0, 22.5, 45, 67.5 degrees) for a complete data set. So at minima you're going to get 16 files per complete spectropolarimetry data set. That's a load of files, but lin_specpol and circ_specpol are made to handle them.

toascii_flux.cl will use the c_dSCIENCE*.fits files (which according to the naming convention I use are the flux calibrated spectra) and output text files. Again, to each spectrum correspond 2 files (one with the spectrum, the other with the errors), so each spectropolarimetric data set will yield 16 files. The function flux_spectrum will handle those.

FUSS.datred

Requirements: os, astropy.io, numpy, math, matplotlib.pyplot, pysynphot The datred sub-module contains the following functions:

datred.sort_red()

Sorts and uncompresses the data files (which MUST end in ”.Z”, which they should if they are FORS2 data files downloaded from the ESO archive). It also renames files using the naming convention required for use with the .cl and PYTHON scripts used for data reduction in IRAF.

datred.info()

Creates a table containing useful information on the images (taken from the headers). Use in the folder containing the uncompressed .fits files.

Output file format:

Filename, ESO label, Retarder Plate Angle, Exposure time, Airmass, Grism, Bin, # of Pixels, 1/Gain, Read-Out Noise, Date.

datred.hwrpangles()

This creates the text files telling lin_specpol and circ_specpol which image corresponds to which retarder plate angle. It must be called in the directory where the SCIENCE_*.fits images are located.

Parameters:

  • sn_name (string, optional): String that is unique to the ESO name of the supernova images. Default is 'CCSN'. If that does not work look in the ESO label columns in the info file created by info and find a suitable string.
  • zeropol_name (string, optional): String that is unique to the ESO name of the zero polarisation standard images. Default is 'Zero_'. If that does not work look in the ESO label columns in the info file created by info and find a suitable string.
  • polstd_name (string, optional): String that is unique to the ESO name of the polarised standard images. Default is 'NGC2024'. This is the most likely to change, so check the ESO label columns in the info file created by info and find a suitable string.

datred.lin_specpol()

This function takes files created by toascii_pol.cl, reads the information in the hwrpangles-files, calculates the linear spectropolarimetric data and outputs it in a text file. It also brings up plots of the degree of polarisaiton, Stokes parameters, polarisation angle, and Δε -- the difference in instrumental signature of q and u (if all is well, λε should be consistently very near 0%). The average λε is written in the terminal, but not returned. You will be prompted in the terminal to give a name to the output file.

Output File format:

    λ,    p,    Δ p,    q,    Δ q,    u,    Δ u,    θ,    Δθ

Parameters

  • oray (string, optional): Aperture corresponding to the ordinary ray. Must be either 'ap1' or 'ap2'. Default is 'ap2'.
  • hwrpafile (string, optional): Name of the file listing image numbers corresponding to sets of HWRP angles. Default is 'hwrpangles.txt'
  • e_min_wl (int/float, optional): Lower Wavelength cut-off for calculation of the λε average. Default 3375A.
  • bayesian_pcorr (boolean, optional): P debiasing method. If False, the step function method described in Wang et al. (1997) (see their equation 3) is used. If True, the Bayesian method described by J. L. Quinn (2012) is used. Default is True.
  • p0_step (float, optional): Step size (and starting point) of the p0 distribution. If the step is larger that an observed value of p then the code will fail, and you should decrease the step size. Also increases the run time significantly. Default is 0.01

Returns

  • 1D-Arrays:   λ,   p,   Δ p,   q,   Δ q,   u,   Δ u,   θ,   Δθ

datred.circ_specpol()

This function takes files created by toascii_pol.cl, reads the information in the hwrpangles-files, calculates the circular spectropolarimetric data and outputs it in a text file. It also brings up plots of the Stoke parameter v and ε -- the instrumental signature of v. You will be prompted in the terminal to give a name to the output file.

Output File format:

    λ,    v,    Δ v

Parameters

  • oray (string, optional): Aperture corresponding to the ordinary ray. Must be either 'ap1' or 'ap2'. Default is 'ap2'.
  • hwrpafile (string, optional): Name of the file listing image numbers corresponding to sets of HWRP angles. Default is 'hwrpangles.txt'
  • e_min_wl (int/float, optional): Lower Wavelength cut-off for calculation of the λε average. Default 3375A.

Returns

  • 1D-Arrays:   λ,  v,  Δ v

datred.lin_vband()

This function takes files created by toascii_pol.cl, reads the information in the hwrpangles-files, and calculates the V-band linear polarimetric data from our spectropolarimetric data set. No file is created, the values are print in terminal and returned by the function.

Parameters

  • oray (string, optional): Aperture corresponding to the ordinary ray. Must be either 'ap1' or 'ap2'. Default is 'ap2'.
  • hwrpafile (string, optional): Name of the file listing image numbers corresponding to sets of HWRP angles. Default is 'hwrpangles.txt'

Returns

  • 1D-Arrays:   λ,   p,   Δ p,   q,   Δ q,   u,   Δ u,   θ,   Δθ

datred.flux_spectrum():

Takes all the files created by toascii_flux.cl (which should contain all the flux calibrated polarised spectra) and combines all the spectra to create the final spectrum which is then written into an output file. You will be prompted in the terminal to give a name to the output file.

Output File format:

    λ,     flux,    Δ flux