In prparation for upgrading lmap (see lamp_markII) I am reviewing the flow of this code and the modules that support it.
Down to about line 108 most of the code is bookkeeping stuff:
- Establish (with bash script wheredata that the BaseDir and Date files are present to establish the basic path to the data, e.g. /media/sco/DataDisk1/sco/..../20200530/lrs2/lrs20000009/exp01/lrs2/20200530T042121.0_056RL_sci.fits or /hetdata/data/20200530/lrs2/lrs20000009/exp01/lrs2/20200530T042121.0_056RL_sci.fits - Use padded_integer.sh to build observation and exposure values with the proper padded zeroes so that they can fit directly into the file names. lrs2/lrs20000009/exp01/lrs2/20200530T042121.0_056RL_sci.fits ^^^ ^^ - Use bash code to establish the channel name. My synatx is not terribly cealr here. I refer to the IFU by the variable "chano", and I refer to the wavelength channel as "channel". chano = B (for LRS2-B ifu) channel can be: uv , or (ultraviolet, orange) chano = B (for LRS2-B ifu) channel can be: rd , fr (red, far-red)
From 108 to 142 we gather the "Peak" files. These are files that give the locations, in Y position, of the spectrum for each fiber in the Upper and Lower amp images. The Peak files can be read locally (if present) or from a default location which is: $LRS2DAT/peaks/$peakfile, where the $peakfile name is built depending on the amp, channel and column number used. From 144 to 165 we produce the ds9 window (with 4 panels) that shows the LRS2 spectral images and locate the associated acm image.
- we show the lrs2 images with lrs2see4. After that code runs we have the local files Name.Upper and Name.Lower that give the fullpath names to the raw image files. - we use the UT time in the Name.Upper file name to find the associated acm image with acam_nearest_3.
Lines 168 to 199 are the real essance of lmpa where the image processing is performed. We use lrs2_skymap_setup to prepare files for the lrs2 spatial image construction. The signal for each fiber are gathered with lrs2_gather_signals.sh and the spatial image is built with lrs2_signals_map_fits.sh .
lrs2_skymap_setup - the lrs2 images are bias-subtracted with lrs2_bias_sub.sh - If the image is a flat ($imagtype="flat") than the code fibermapX is run to find the Peak locations (the Y positions of spectra in the lrs image). - If the image is a sci ($imagtype="sci") then the already established Peak positions are used to integrate a signal for each fiber using the code clip_fibsigx.sh. lrs2_gather_signals.sh - the integrated signals from clip_fibsigx.sh and sorts them into X,Y positions in the spatial frame of the sky-end of the IFU. It collectes a few other quantities as well as the FIBER number. This is a key component of lmap!!! . lrs2_signals_map_fits.sh - the spatial image for LRS2 is built using the signals gathered for each amp in the above step. The code that builds the image is lrs2_signals_map_fits.sh.You see that if I wanted to trace a (wavelength-calibrated) spectrum I would probably do it in (or in place of) clip_fibsigx.sh .
In lines 201 to 216 we add some header cards to the spatial image map, named "lrs2map.fits". We then display and measure this image.
- lrs2map.fits is displayed in the frame=2 ds9 window using ds9_view . - A centroid is measured for the source in frame=2 (lrs2map.fits) with ds9_id.
In lines 240 to 283 we do the same as above, except for the acm image placed into frame=4.
- the acm image is displayed in frame=4 with ds9_view . - we draw in the B,R LRS2 IFUs with cat acam_ifu. - we measure a centroid for the source in the acm window using ds9_id.
In lines 285 to 345 we predictict the spatial map coordinates of the source in units of arcseconds. We use these to predict the tcs command string needed to offset the telescope so that the source will be centered in the IFU. The sets of centroids and other data are collected and written into a final data file (called "lmap.RESULTS").
- the Xlrs2,Ylrs2 values are converted to arcsecond units and fed to lrs2_offsets (for making the command string that will center the source in the IFU). - some bash formatting lines are used to make a "nice" table of the results.
At the end of this process we have our table of cntroids+ in lmap.RESULTS, and if multiple lmap runs are made, the data are appended to thi file.