IMACS-IFU Acquisition IDL Software
Adam S. Bolton, CfA



Overview
Preliminary Setup
On-Air Usage
Flat-fielding (for the assiduous)
Final Items


NEW: Comprehensive Commands Reference

Overview

This page documents a set of IDL routines made to facilitate IMACS-IFU target acquisition at the Baade 6.5-m (Magellan I) Telescope at Las Campanas Observatory. They serve the same purpose as the ifu-image task of the COSMOS package. The routines perform the following tasks: NOTE: This software currently supports the f/2 and f/4 nod-and-shuffle configurations. Considering the new LCO "always nod-and-shuffle" policy, this should be sufficient for everyone's needs. If for some strange reason you will be taking data with the dewar in the "normal" orientation, you can either (1) try to hack the software yourself, or (2) contact Adam Bolton at CfA (abolton at cfa dot harvard dot edu) with sufficient lead time, and somehow provide him with an undispersed flat image taken through the IFU in your camera mode. The mode-to-mode differences are in (1) which CCD subregions need to be stitched together to make the IFU slit image and (2) different "initial guess" files for the spot positions.

This software is a spinoff of the nascent kungifu package of IMACS/GMOS IFU reduction software. Stay tuned for more.

Top of page

Preliminary Setup

Obviously you'll need IDL. IDL is currently available on burro.lco.cl, but not on llama.lco.cl. This is a bit of a nuisance, since IMACS data frames are written to llama. Therefore observers must copy IFU acquisition frames from llama to burro (via scp, ftp, or whatever) when using this software. Also make sure that the IDL license is free (i.e. that no one else is running IDL remotely on burro).

You will also need to have the Princeton-SDSS IDL routines installed and accessible. These routines and instructions for their installation are available from David Schlegel's website: http://spectro.princeton.edu/idlspec2d_install.html. You will need the idlutils and idlspec2d packages, and you will need to set paths as described in the install instructions. Hopefully these packages can be installed permanently to the observing computers someday.

You also need the IFU acquisition software itself. The author recommends downloading the demo-data as well, so you can test-drive the software at your leisure: Un-tar these in your working IDL directory.

Finally, you may want to take your own undispersed image, a flat of sorts, through the IFU during the afternoon (ambient daytime dome light works, or you can use the flat lamp). This is so that you can verify that the IFU slit image is indeed falling on the detector as expected, and so that you can start tweaking up the spot positions (although you will almost certainly have to tweak them again during the night for photons coming from infinity). The "afternoon" section of the official LCO IFU observing cookbook has some helpful pointers for taking this type of exposure.

You do not need any of the COSMOS routines.

Top of page

On-Air Usage

The two IFU bundles are to leading order identical (but see below), and their fields of view are rather small: 5x7 arcsec in f/2 and 5x4 in f/4. To get your target in the neighborhood of one of the bundles, you should follow the instructions in the "night" section of the official LCO IFU observing cookbook up to but not including running the COSMOS ifu-image task. Also be sure to do cordinated offsets for all offsets after you have set up with guide stars following the "toifu" IRAF task. Also note that the LCO IFU bundle designations "obj" and "bkg" are flipped relative to the "object" and "background" bundle designations given in the Durham IMACS-IFU Fieldmapping diagram. (The two broken fibers and the interchanged blocks are the keys!) This software currently observes the Durham naming convention. The LCO object a.k.a. Durham background bundle seems to fall more favorably onto the IMACS detector, and is the preferred target bundle of the author.

The last stage from the cookbook is to take an undispersed image of your target through the IFU fibers. When you take this image, make sure you use 1x1 binning. Also be sure to use a broadband filter of some sort (at least until the atmospheric dispersion corrector is atmospheric dispersion correctin'), or your target image will be made oblong by differential refraction. Once you have taken this image (and transferred it to burro), you can use the IDL software to have a look at a focal-plane reconstruction of it to see if you are lined up properly, and apply offsets to the telescope if needed.

Here's how you do it. You can play along with the 'ccd0305' fits files from the demo data, or with your own acquisition image (the name of which should be substituted in, of course):

Once during your IDL session, you will need to initialize the IFU "state information", which you do by executing
  IDL> ifu_set, camera='f2nods'
  IDL> ; ** OR **
  IDL> ifu_set, camera='f4nods'
The choice of "camera=" depends upon whether you are using f/2 or f/4. (If you are using f/2, you can skip this step, since it is the default and will be initialized automatically when you display your first slit image.) ifu_set can take other optional keywords to control the details of slit-image creation and spot extraction; see its internal comments for details.

The first acquisition step is to display a slit image:
  IDL> ifu_slit, frame='ccd0305'
That should throw up a horizontally-oriented slit image created from bias-subtracted images. A 50-fiber block containing flux from a well-centered target looks like this (in f/2):
One target shows up as two peaks within the block because each 50-fiber block runs down and back across the FOV.

Now look at where the routine thinks the fiber spots are along the slit:
  IDL> ifu_spot
This overplots points where the assumed spot positions are. Check both the left end and right end of the slit image. The originally plotted positions are read from a "first-guess" file by the name of "spot_f2nods.txt" (for the f/2 nod-and-shuffle setup), which must be present in the working directory. If the points are off, then you will need to tweak the positions. For instance, our demo-data slit image with positions overplotted looks like this on the very leftmost block:
and like this on the very rightmost:
So we need to adjust the positions before we extract spot fluxes and reconstruct an image. We need to specify, for two well-separated x-positions, what x-shifts and y-shifts need to be applied to the assumed spot positions at thos x-values in order to line things up. This specifies a unique stretch, tilt, and shift that is calculated and applied by the ifu_tweak routine. Calling ifu_tweak with no arguments gives details of how to tweak it:
  IDL> ifu_tweak

   ifu_tweak usage:

     IDL> ifu_tweak, [x1, dx1, dy1, x2, dx2, dy2]

   where x1 and x2 are x-pixel locations along the
   pseudo-slit image where shifts are specified,
   and dx1, dy1, dx2, dy2 are the x- and y-shifts
   that need to be applied to the assumed IFU spot
   positions at those locations in order to bring
   assumed positions to the correct positions.
Figuring out the needed shifts is non-tivial, because the 50-fiber block ends are what you really need to line up on, but many blocks have bad-to-dead fibers on the end. In many fibers only sky flux will be detected, but this is good enough for spot positioning if you have counts. When you think you have a feel for how the spots need to move, call ifu_tweak with the proper values. For our demo data, the following seems approximately correct:
  IDL> ifu_tweak, [1290., 5., 0.7, 6770., -5., 0.5]
Now check the new spot positions:
  IDL> ifu_spot
If the points are falling on the spots all along the slit, you are in good shape. If not, you can iterate, or reset to the previous spot positions using the ifu_set routine -- see its internal comments for more details. (Why not do all this automatically with some sort of optimization routine? Because I haven't written it, and because I think you would still need to get within one fiber along the whole slit manually before turning it loose.) If you are observing in f/4 mode, you will probably find it necessary to adjust the spot positions again for new targets more so than you would with f/2 observing. This is presumably because the position of the f/4 imaging mirror changes a bit with removal and replacement.

Finally, to display the focal-plane image that results from extracting apertures about the spot positions, execute the following:
  IDL> ifu_im      ; (if target in Durham "object" bundle)
  IDL> ; -- OR --
  IDL> ifu_im, /bg ; (if target in Durham "background" bundle)
Your atv window should now show a reconstructed image of your target, along with (new for 2005!) a compass to show the orientation and parity of the IFU FOV. Apply coordinated telescope offsets and repeat as needed. A well-aligned target would look like the following unassuming SDSS LRG:
You might want to verify how the cardinal directions map onto this reconstructed image. Last I checked, for images north of zenith and the nominal slit position angle, the reconstruction has east up and north left. Note that f/4 images will be smaller (5 by 4 arcsec instead of 5 by 7), but will have the same parity despite the extra reflection in the optical path. This is because the 2D info is encoded in one dimension along the pseudoslit and is invariant under reflection of the slit image.

Also, if you need to re-display the active slit image after displaying a reconstructed focal-plane image, you can do that with the command
  IDL> ifu_slit, /replot

Top of page

Flat-fielding (for the assiduous)

It's easy to apply a flat corrrection to these acquisition images, if you are so inclined. Assuming you checked the spot alignment in the afternoon, you already have a flatfield exposure to use. In the demo data, 'ccd0215' is a daytime flat, and is actually the data that the f2 nod-and-shuffle spot positions were measured from. For a real application, substitute your own flat-name, and tweak as necessary. For the demo data, we can restore the originally-assumed spot positions using ifu_set (again, see its internal docs for details):
  IDL> ifu_set, count=0
Now initialize the slit image:
  IDL> ifu_slit, frame='ccd0215'
(Check positions with ifu_spot and tweak with ifu_tweak, etc.) Now, when you extract the spot fluxes and make the IFU image of the flat frame, you can save the extracted data as follows:
  IDL> ifu_im, savename='flat'
(You don't have to call it 'flat'. Call it whatever you want. Also, you don't need to save separately for the object and background fields: both are saved to the same file with the single call to ifu_im.) This writes the flat spot-flux data to 'flat.fits'. Then when you make your actual acquisition image (after you have set the spot positions appropriate to the acquisition image), you can apply a flatfield correction by calling ifu_im as follows:
  IDL> ifu_im, /bg, flatname='flat'  ; (for background bundle)
where 'flat' is whatever you named the flatfield fits file. It's a subtle difference, but worth it if you save the flat during the day. It particularly helps with acquiring extended targets, and doesn't really requre any more effort at night. Here's non-flatfielded on the left and flatfielded on the right:


Top of page

Final Items

This page is not an exhaustive documentation of the software. See the internal routine comments for more info regarding additional options, common variables, spot-position history saving, etc.

For your edification, here are some failure modes of image reconstruction, so that you might recognize them if they occur. From left to right, we have: (1) Good (but not flatfielded) reconstruction, (2) Spots off by 1 fiber along slit direction, (3) Spots off by 2 fibers along slit direction, (4) Spots tilted w.r.t slit, lined up at bottom but off by about 1 fiber at top.
Note the sawtooth shear of (2) and (3). That's a consequence of the down-and-back fieldmapping within each block.

The author welcomes any communication regarding this software (abolton at cfa dot harvard dot edu). Happy observing!

Last update 11 March 2005