Tracing a fiber spectrum.
Updated: Sep12,2020

The original lmap used a small central section of each fiber spectrum to derive an integrated signal that was used to build the spatial map. In lmap_markII I want to have the option of tracing each fiber spectrum. Each trace can be used to extract a full fiber spectrum. Whether we wavelength-calibrate that spectrum or not, we can integrate large portions of it to obtain spatial maps with much imporved SNR over the old lmap versions.

Before moving on with tracer code, I'll review the main fiber-related files that an lmap run produces.

 
Some useful lmap figures: 

/home/sco/scohtm/het+virus/lrs2/lrs2_point/graphics/Big_Kahuna.png
/home/sco/scohtm/het+virus/lrs2/lrs2_point/graphics/LRS2_map.png
/home/sco/scohtm/het+virus/lrs2/lrs2_point/dec2016_lmap/graphics/lmap_new01.png

Directions: 
/home/sco/scohtm/het+virus/fcharts/graphics/HET_directions_zoom1.png
/home/sco/scohtm/het+virus/fcharts/graphics/Important_Figs/HET_directions.png

Concerning the spatial map: 

lrs2_fibers.name.reg  == overplot fiber names on the lrs2 spatail image (lrs2map.fits) 
lrs2_fibers.xy.reg    == overplot circle markers at fiber positions in the spatail image (lrs2map.fits).  

lrs2fibermap.fits     == Like the spatial map (lrs2map.fits) except the pixel value 
                         in each lenslet is the value of the fiber number (not the 
                         integrated flux in the fiber). You can overplot the fiber 
                         names with lrs2_fibers.name.reg

lrs2_fibers_px.xy    == list of lenslet XY in pixel units 
lrs2_fibers_as.xy    == list of lenslet XY in arcsec units
lrs2_fibers.name     == lenslet (fiber) names             

Concerning the associated acm image: 
acam_fibers.name.reg   == overplot the fiber names in the acm image 
acam_fibers.xy.reg     == overplot the fibers as circle markers in the acm image 
acam_ifu_B.reg         == Overplot on acm the outer boundary of the LRS2 IFU (B or R) being mapped 

NOTE:   The file lrs2_signals_map_fits.explain explains (briefly) a lot of the above files. 

PROBABLY THE most important file comed from lrs2_gather_signals.sh
It is named:    Final_Map.signals

The top of this file is: 
# lrs2_gather_signals output:   channel = or
# Col1 = X position of lenslet in IFU (arcsec units)
# Col2 = Y position of lenslet in IFU (arcsec units)
# Col3 = mean intgerated signal in fiber
# Col4 = normalized signal (0 to 1 range)
# Col5 = fiber number (integer 1 to 280)
# Col6 = fiber Y position (pixel units) in spectral image
# Col7 = amplifier for spectral image (U or L)
# data
      6.1950        3.0657       90.586998      0.018600       1     26.0  U
      5.6050        3.0657     4132.586914      0.848553       2     32.0  U
      5.0150        3.0657     3587.729980      0.736676       3     39.0  U
 
If I add these, I can make a pretty complete tbale file: 
    lrs2_fibers_px.xy          == pixel positions of fibers in the spatial image  
    Final_Map.acam.XYNames     == fiber positions in acm pixel units  

I have been playing around with the IZw136 data taken on 20200530 UT, but as is often the case, the LRS2 calibration data was taken near the end of 20200529 UT. I stored this data onto scodat, and hree are some running notes:

 
I have a test run directory in:   /home/sco/Aug2020_lmap/LRS2_cals_2

To run a blue flat:    lmap_markII 20 1 or --cal

Date = 20200529
lvimages lrs2 any any any any RU any any
*** Here are the lrs2 cals from that afternoon
  Qth_R         19     1-5
  ldls_long_B   20     1-3
  Cd-A_B        21     1-3
  FeAr_R        22     1-3
  Hg_R          23     1-3
  Hg_B          24     1-3
*** I have these in:   /media/sco/DataDisk1/sco/AD/HET_work/HET_acm+lrs2/HET_IZw136/20200529/lrs2
    Use BaseDir = /media/sco/DataDisk1/sco/AD/HET_work/HET_acm+lrs2/HET_IZw136


Thu Sep 10 12:05:47 CDT 2020 - Using the "--cal" flag

Here I play around with recognizing cases of calbration images (flats) images (flats)

 
% lmap_markII 20 1 or --cal
For now, the --cal or -c flag will stop operation just prior to the run of lrs2_skymap_setup

The files Name.Lower,Name.Upper are made:
% cat Name.Upper
/media/sco/DataDisk1/sco/AD/HET_work/HET_acm+lrs2/HET_IZw136/20200529/lrs2/lrs20000020/exp01/lrs2/20200529T230817.4_056RU_flt.fits

The command line for the next run is given:     lrs2_skymap_setup or flat Upper

I can make this run in an empty test directory (./T0): 
 % mkdir T0
 % cd T0
 % cp ../Name.Upper . 
 % lrs2_skymap_setup or flat Upper 

**** This works well, and I get a good plot of the detected peaks.       

I make a markII version with better command line options: 
  % lrs2_skymap_setup_markII or flat Upper s2_skymap_setup_markII or flat Upper    -v 

After the run:
20200529T230817.4_056RU_flt.fits  junk.1	   lrs_bsub.fits  Peaks_1000_lrs2_Upper_or  S/
Final.Title			  LRS2.Image_Info  Name.Upper	  RUN			    x_1000.fibsx

The peaks are in:   Peaks_1000_lrs2_Upper_or
What is x_1000.fibsx?   I'm guessing that is the line part of the plot file. 

Whne I run just fibermapX:
  fibermapX lrs_bsub.fits 1000 2000 Y 45000 lrs2

% ls
lrs_bsub.fits
% fibermapX lrs_bsub.fits 1000 2000 Y 45000 lrs2
Info out = ypix, Signal, Signal_normalized
Signal range =       30.444      7142.730
140     (Number_of_peaks)
Current plot title: clip_fibsx at Xo=1000 Image=lrs_bsub   Npeaks=140

% ls
lrs_bsub.fits  Peaks_1000_lrs_bsub  x_1000.fibsx

Note: Whether I make the plot or not, I get the files:   Peaks_1000_lrs_bsub x_1000.fibsx

The Peak file is ths important one: 
% head Peaks_1000_lrs_bsub
   1     30.0     6736.4438    1.13732
   2     37.0     6697.8730    1.13081
   3     44.0     6918.4438    1.16805
....
 137    995.0     5037.8730    0.85055
 138   1002.0     6216.4438    1.04953
 139   1009.0     5864.7300    0.99015
 140   1015.0     6008.8730    1.01448
 **** x_1000.fibsx is made by:      clip_fibsx.sh lrs_bsub.fits 1000 3 none > x_1000.fibsx 

The question I face below is this: are my Y positions in the Peaks files being handled properly by the time I get to the final table file?


Sat Sep 12 15:30:27 CDT 2020

I have added two new routines that are called bu lmap_markII.

 
I have written 
  lmap_final_table  == store the lmap data in a local subdirectory 
  lmap_paint        == paint up the region files. 

The lmap.table file has the Y position of the fiber in the original spectral image. However, when I try to overplot this in the spectral images, the fiber numbers do not seem to line up with the correct locations on the image. I really should resolve this before I proceed with tracing the fiber spectra. Otherwise I'll get even more lost.




Back to calling page