HSTaXe Installation

  • conda create --name hstaxe python=3

  • conda activate hstaxe

  • git clone https://github.com/spacetelescope/hstaxe.git

  • conda install numpy astropy gsl cfitsio wcstools stwcs stsci.imagestats drizzle drizzlepac jupyter

  • cd hstaxe

  • python setup.py install

  • Load a few Python modules

    We save the current working directory

    Preparing the G141 data

    We will create a G141 subdirectory to copy all of the G141 files into. This where we will prepare the G141 data

    Creating the directory, removing any existing one

    Copying the G141 data (which we grab from our cookbook_data directory)

    We move into the G141 directory and check the content of the G141.lis file

    We now create a G141 mosaic using the G141 data

    This mosaic will be used to set up the proper astrometry for each individual FLT files. We can only extract G141 spectra from FLT files which have been used to make this mosaic

    We now prepare the F140W Imaging data

    We already created a mosaic of all the G141 data for astrometric purposes, and we now create an F140W mosaic using the G141 mosaic as the astrometric reference frame. This will ensure that the G141 and F140W mosaics have pixels with the same RA and DEC. The process is similar to what we did with the G141 data and we do this in a F140W sub-directory. The F140W mosaic is generated with the same WCS as the G141 mosaic we already generated.

    Creating the directory, removing any existing one

    Copy the F140W data (which we grab from our cookbook_data directory)

    We move into the F140W directory and check the content of the F140W.lis file

    We create a F140W mosaic using the F140W data and the G141 mosaic as a reference

    The F140W and G141 should be aligned and bright objects should generate bright spectra in the expected position. We should see very liittle offset in the y-direction for WFC3 IR grism data

    We create an object catalog using sextractor

    This is one step that needs to be done carefully as several things can go wrong.

    This catalog, when doing a simple extraction, will be used to compute the SED of each sources. These SEDs will be used to compute our contamination models. In this example, we used a single band, F140W, but we could have added information in other bands such as F125W for example. This requires running Sextractor in matched photometry mode, and the creation of a catalog where magnitudes in multiple bands are properly listed

    For simplicity, here, we copy an already generated catalog:

    We can now run aXe

    We start by setting up some necessary environment variables that point to the various aXe directories.

    Create a directory called CONF and copy the WFC3 G141 IR Calibration files in there.

    Set up some work directories and environment variables required by aXe:

    We define the FOV boundaries for the WFC3 IR observations

    We copy the G141 FLT files and the F140W FLT files in the DATA directory

    You can either use the original data or optionally the FLT files used to create the G141 mosaic earlier, which will have some extra bad pixels flagging

    We use the iolprep aXe task to generate individual F140W catalogs

    This task will create the individual F140W extraction catalogs, one for each of the files listed in the F140W.lis file. We pass the F140W mosaic to it, as it contains all the information about all the individual F140W FLT file.

    We copy the newly create catalog files into the DATA directory

    We are almost ready to extract the spectra. We need to create an file aXe.lis containing the G141 images, expected catalog names and associated F140W direct images

    The G141 mosaic we created earlier is not used directly during the aXe extraction process. However, the F140W mosaic was used to create an object master catalog. This catalog will be processed to generate individual object catalogs for the files used to create the F140W mosaic. The aXe.lis file lists which F140W images are logically associated with a particular G141 image. Ideally, these are images taken in the same HST visit so that we can be sure that the WCS of both files are consistent.

    The aXe.lis file is a simple text file, with a slightly different format than the one above. In this file, each line contains 3 items:

    At this stage, we only have items 1 and 2.

    We run aXeprep. This task will amongst other things take care of background subtracting the G141 data using a single master sky.

    We can now proceed with a simple box extraction of our G141 spectra. This will not combine individual 1D spectra and we create one extracted spectrum per object and get G141 FLT file we are processing. The contamination is estimated using the Gaussian model of each object that is included in the SExtractor object catalog test.cat.

    For each of the G141 input FLT file, this will create the following in the OUTPUT/ directory:

    While running the next notebook cell, please check the main terminal window as the aXe routines will output things in there. It will take a few minutes to run

    Results are in the directory pointed to by os.environ['AXE_OUTPUT_PATH'], i.e. ./OUTPUT 1D and 2D spectra extracted from individual FLT files are available. These are not combined. SPC files contained 1D spectra, opt.SPC files contained optimally extracted spectra (using gaussian profiles), STP files contain 2D stamps. CONT files contain the contamination estimate (gaussian based)

    We can examine individual 2D spectra from the STP files. Note that the STP files are meant for quality control and are not calibrated versions of the 2D spectra.

    We now examine the calibrated 1D spectra of one of the sources:

    Contamination is not automatically removed but has been estimated and we can plot it

    More advanced extraction

    We now use the aXe Fluxcube extraction

    We create a new directory called DRIZZLE that we will need:

    We already have an F140W mosaic and we now create an F125W mosaic with the same final WCS as the G141 mosaic

    We create a directory ./FLX/ to prepare our Fluxcubes:

    Copy the direct imaging and G141 mosaic in the Fluxcube directory:

    We will need access to the G141 FLT files, and copy them here instead of working in the ./DATA directory

    We also need the segmenation file we created earlier. Here we copy one we already prepared.

    Create a cubelist.lis file that contains a description of the mosaics we are using and populates the PHOTPLAM and AB magnitude zeropoints

    We now can create the Flexcube

    This will combined the mosaics and segmentation file into a flexcube that can be used to compute the contamination and perform the extraction. A different one is generated for each G141 FLT file

    At this point, we should have generated 2 master FLX file, one for each input imaging mosaic, and four FLX files, one for each of our G141 FLT file.

    We want to work on the non background subtracted G141 data. The ones in the DATA directory have already been subtracted during our basic extraction, so we copy the original G141 data back into the DATA directory.

    We run aXeprep on the data. This step also substracts the background.

    Checking the background levels that were subtracted from each fo the G141 FLT files

    We run axecore using the flexcube models

    Now we use aXedrizzle to combine the dithered observations into single 2D and 1D spectra. We first run the drzprep routine and then the axedrizzle task. The latter will take several minutes to run.

    Do a basic box extraction

    Do an Optimal extraction

    The extraction results are in the DRIZZLE directory we created, and we can examine a 2D, rectified and wavelength calibrated version of the spectrum we looked at earlier:

    We plot the extracted 1D spectra of our source and the estimate of the contamination:

    The MEF files in the DRIZZLE directory contain the 2D version of the spectrum of a source as well as estimte of the contamination:

    The individually extracted spectra are in the OUTPUT directory and the combined ones in the DRIZZLE directory. We can plot and compare them: