User's guide for reduction of OSIRIS/MOS spectral data using GTCMOS pipeline
 Divakara Mayya (ydm@inaoep.mx)  
  Summary 
    GTCMOS is an IRAF-based script that works directly on the files in the
    GTC raw data directory. Contains automatic wavelength calibration
    routines that transform the original spectral image into a
    wavelength-calibrated longslit-like 2D image. Even the slanted slitlets
    are aligned parallel to other slitlets. Sky spectra from any
    object-free slitlet (or object-free part of a slitlet) can be used to
    subtract sky from objects in any other slitlet.
    THERE IS NO NECESSITY TO OBSERVE SKY FOR EACH SLITLET, which can save you as
    much as 50% of observing time if planned properly. In less than 2 hours you can get
    wavelength-calibrated sky-subtracted 2D image, with minimum level of interaction.
    This cookbook contains a log of reduction of my own data, which gives users
    an idea of the sequential order of the commands. It also guides users on the 
    command syntax. Each task contains a detailed IRAF-format help, with practical 
    examples. Throughout this cookbook, it is assumed that you are already an IRAF user.
 General information 
-  It is an IRAF-based pipeline. You can download the package at the website:
 http://www.inaoep.mx/~ydm/gtcmos/gtcmos.html. 
You can also find installation instructions there.
Once you are in the IRAF environment
(i.e. with the cl> prompt), load GTCMOS package by typing
 gtcmos . At anytime you can type  phelp gtcmos  for general
guidelines on the package or  phelp taskname  for help on
a particular task.
All  gtcmos  commands start with  om  for the OSIRIS-MOS
spectra.  
 -  The first command that you should use is  omstart . This task joins
    the 2 CCDs into a single mosaic image, directly from the raw data
     directory and stores the resultant file in the working directory.
     A unique output filename is automatically generated by the task.
     This output file is the input for the subsequent tasks of GTCMOS.
     All images in the raw data directory can be processed by a single command.  
 -  The task  omcombine  combines multiple images of flat, bias, object or arclamp,
     which is the logical second  active  task to execute.  
 -  The package contains a few  passive  tasks, to handle the files.
  They are omslits and omunlearn
     ( passive  tasks do not create an output image, whereas an  active 
     task always creates an output image).  
 - 
   The package carries out bias subtraction ( omstart ) and illumination correction ( omreduce ). 
   However, comparison of skylines of illumination corrected and uncorrected images show
   better results without illumination correction. 
 - 
   The task  omidentify  automatically identifies the arc lamp lines for all the slitlets. 
    Users can improve the solution obtained by the
    automatic routine by examining each solution individually using the task  omreidentify . 
    Even when an arclamp is not available (e.g. standard star), an accurate wavelength calibration
    is achieved using the standard dispersion solutions for the corresponding grism. 
 -  The task  omreduce  wavelength calibrates all the slitlet spectra one by one and puts them
     back onto a 2D image at their original position. Corrects for tilts of
     spectral lines, if asked to do so. The resultant 2D image looks similar
     to a longslit image, except that there are gaps in the spatial direction. 
 -  The task  omskysub  subtracts sky from the output of  omreduce .
     Various sky subtraction options are available.
 -  The task  omextract  extracts one 1-D spectrum for each slitlet, even
when the continuum spectrum is weak or absent. Alternatively, you can use the
"apall" task of IRAF, using which you can extract multiple spectra in each slitlet.  
 -  The task  omstd  obtains the sensitivity curve using standard star 
observations, which are always carried out in the LONGSLIT mode. 
 -  Longslit spectra can also be analyzed using this package. This applies to even 
those taken before the MOS commissioning. The reduction procedure is exactly
the same as for MOS spectra. The commands omstart and omcombine can be
used even for images.
 -  Read IRAF  reduction manuals 
if you are new to spectroscopic reductions.
 
 Cookbook 
vocl>  gtcmos 
     +------------------- GTCMOS IRAF Package -------------------+
     |             Version 1.3, MAR 15, 2016                     |
     |            Tested with IRAF v2.16 on Fedora               |
     |    Developed by Divakara Mayya at INAOE, Puebla, Mexico   |
     |                                                           |
     |    Type  help  before using it for the first time         |
     |                                                           |
     | User's guide is available at                              |
     |   file:///iraf/iraf/extern/gtcmos/html/mos_reduction.html |
     |                                                           |
     |Please contact ydm@inaoep.mx if you have questions/comments|
     +-----------------------------------------------------------+
 
      omcombine     omflat        omreidentify  omslits       omunlearn
      omextract     omidentify    omskysub      omstart      
      omfindstd     omreduce      omslice       omstd 
gtcmos> 
 Tips: 
-  Expected already to be an IRAF and ds9 user
 -  Use xgterm for running IRAF
 -  Keep xgterm as wide as possible
 -  Don't include .fits extension, while giving filenames i.e. for
identifying arclines in gtc14aob001_arc_sum.fits, omidentify gtc14aob001_arc_sum
 
Part I:  MOS reduction   |  Part II:  Flux calibration  | Part III:  LONGSLIT reduction 
 OSIRIS/MOS DATA reduction 
gtcmos> lpar omstart
      datadir = "GTC4-14AMEX/OB0001a1/object" Data directory
      (filein = "all")          File Name
      (mosaic = no)             Mosaic the 2 CCDs (no==>list only)
      (verify = no)             Verify each file before mosaic?
      (biasim = "")             Bias image [empty means no Sub Bias]
      (fixpix = no)             Fix bad pixels?
       (mask1 = "DEFAULT")      Bad pixel image for CCD1
       (mask2 = "DEFAULT")      Bad pixel image for CCD2
     (filenam = no)             Print long filename?
        (mode = "ql")           
gtcmos>  omstart ../m81/MOS/GTC4-14AMEX/OB0001/bias 
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652346-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652347-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652348-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652349-20140403-OSIRIS-OsirisBias[1]     7ias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652350-20140403-OSIRIS-OsirisBias[1]     7ias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652351-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652352-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652353-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652354-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652355-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
gtcmos>  omstart ../m81/MOS/GTC4-14AMEX/OB0001/bias mos+ 
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652346-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652346-20140403-OSIRIS-OsirisBias
Output stored as gtc14aob001_bias_346
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652347-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652347-20140403-OSIRIS-OsirisBias
Output stored as gtc14aob001_bias_347
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652348-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652348-20140403-OSIRIS-OsirisBias
Output stored as gtc14aob001_bias_348
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652349-20140403-OSIRIS-OsirisBias[1]     7ias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652349-20140403-OSIRIS-OsirisBias
Output stored as gtc14aob001_bias_349
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652350-20140403-OSIRIS-OsirisBias[1]     7ias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652350-20140403-OSIRIS-OsirisBias
Output stored as gtc14aob001_bias_350
../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652351-20140403-OSIRIS-OsirisBias[1]     Bias    1049    2051    OPEN    fOtelo911/42    OPEN    0.      "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/bias/0000652351-20140403-OSIRIS-OsirisBias
Output stored as gtc14aob001_bias_351
gtcmos> lpar omcomb
       filein = "gtc14bob065_arc_*" Input File Name(s)
     (fileout = "omcombine")    File Name
      (imtype = "obj")          Image type [bias|obj|arc|flat]
     (combine = "median")       Type of combine operation
      (reject = "none")         Type of rejection
     (normsec = "[*,*]")        Image Section to Normalize flat
     (logfile = "omcombine.log") Type of rejection
        (mode = "ql")           
gtcmos>   omcomb gtc14aob001_bias_* imtype=bias 
#               IMAGE      NPIX      MEAN    STDDEV       MIN       MAX     MIDPT
 gtc14aob001_bias_346.fits   4327610     6.705     33.02    -1223.     3328.     7.369
 gtc14aob001_bias_347.fits   4327610     6.732     34.12    -1223.    11968.     7.984
 gtc14aob001_bias_348.fits   4327610      6.86     33.41    -1229.     6447.     8.153
 gtc14aob001_bias_349.fits   4327610     6.918     33.26    -1229.     3141.     8.434
 gtc14aob001_bias_350.fits   4327610     6.907     32.87    -1230.     1280.     7.578
 gtc14aob001_bias_351.fits   4327610     6.934     37.11    -1229.    33230.     8.468
 gtc14aob001_bias_352.fits   4327610     6.909     32.96    -1229.     2703.     7.501
 gtc14aob001_bias_353.fits   4327610     6.944     34.12    -1229.     9904.     8.134
 gtc14aob001_bias_354.fits   4327610     6.916     33.12    -1229.     4884.     8.027
 gtc14aob001_bias_355.fits   4327610     6.929     34.67    -1228.    13979.     8.286
Apr 17 18:35: IMCOMBINE
  combine = median, scale = none, zero = median, weight = none
  blank = 0.
                Images   Median    Zero
  gtc14aob001_bias_346.fits  8.1591      0.
  gtc14aob001_bias_347.fits  8.1569  0.0022
  gtc14aob001_bias_348.fits   8.293 -0.1339
  gtc14aob001_bias_349.fits  8.3533 -0.1942
  gtc14aob001_bias_350.fits  8.3566 -0.1975
  gtc14aob001_bias_351.fits  8.3313 -0.1722
  gtc14aob001_bias_352.fits  8.3415 -0.1824
  gtc14aob001_bias_353.fits  8.3533 -0.1942
  gtc14aob001_bias_354.fits  8.3401  -0.181
  gtc14aob001_bias_355.fits  8.3295 -0.1704
  Output image = omcombine, ncombine = 10
Output is stored in omcombine
gtcmos>   imrename omcombine gtc14aob001_bias_master
gtcmos>  omstart ../m81/MOS/GTC4-14AMEX/OB0001/object 
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652265-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    OPEN    OPEN    Sloan_r OPEN    10.     "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652266-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    OPEN    OPEN    Sloan_r OPEN    60.     "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652267-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652268-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652269-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"   0.
 Note that the first two files are pre-images (GRISM=OPEN and FILTER=Sloan_r), 
while the other 3 are spectral images (GRISM=R1000B). Follow the following steps 
to combine only the spectral images. 
gtcmos>  omstart ../m81/MOS/GTC4-14AMEX/OB0001/object mosaic+ biasim=gtc14aob001_bias_master verify+ 
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652265-20140403-OSIRIS-OsirisMOS[1]    OsirisMOS       1049    2051    OPEN    OPEN    Sloan_r OPEN    10.     "2 2"
Want to mosaic 0000652265-20140403-OSIRIS-OsirisMOS? 
no
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652266-20140403-OSIRIS-OsirisMOS[1]    OsirisMOS       1049    2051    OPEN    OPEN    Sloan_r OPEN    60.     "2 2"
Want to mosaic 0000652266-20140403-OSIRIS-OsirisMOS? 
no
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652267-20140403-OSIRIS-OsirisMOS[1]    OsirisMOS       1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"
Want to mosaic 0000652267-20140403-OSIRIS-OsirisMOS? 
yes
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652267-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/object/0000652267-20140403-OSIRIS-OsirisMOS
Bias subtracted output stored as gtc14aob001_object_267
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652268-20140403-OSIRIS-OsirisMOS[1]    OsirisMOS       1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"
Want to mosaic 0000652268-20140403-OSIRIS-OsirisMOS? 
yes
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652268-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/object/0000652268-20140403-OSIRIS-OsirisMOS
Bias subtracted output stored as gtc14aob001_object_268
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652269-20140403-OSIRIS-OsirisMOS[1]    OsirisMOS       1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"
Want to mosaic 0000652269-20140403-OSIRIS-OsirisMOS? 
yes
../m81/MOS/GTC4-14AMEX/OB0001/object/0000652269-20140403-OSIRIS-OsirisMOS[1]    M81-MOS1        1049    2051    R1000B  OPEN    OPEN    OPEN    1308.   "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/object/0000652269-20140403-OSIRIS-OsirisMOS
Bias subtracted output stored as gtc14aob001_object_269
 Note that the answer is "no" for the first two and "yes" for the last 3. 
gtcmos> 
gtcmos>  omslits gtc14aob001_object_269 
OBSMODE= OsirisMOS
R1000B  3700  7000   2.12  3.569E+03 1.698E+00 1.990E-04    0.02   0.0025
36  slitlets found in gtc14aob001_object_269
##   ix1   ix2    x_cen   y_mos    y_CCD   stype  angle
1 312 392 352.16351348683 960.42809724925 948.39095873527 rectangular  0.4662
2 406 422 413.97124290466 674.67596244812 663.72045919895 circular  0.
3 544 623 583.80621672308 1041.9322213566 1033.9488301492 rectangular  0.325
4 650 690 670.33060135485 1129.2172741342 1122.7480596579 rectangular  0.1953
....................................................................
....................................................................
35 1874 1889 1881.7553126431 1140.20518784 1121.2656933055 rectangular  0.3024
36 1897 1974 1935.7530967888 1091.816709784 1071.6622651062 rectangular  0.3743
##   ix1   ix2    x_cen   y_mos    y_CCD   stype  angle
You man open the pre-image in ds9 and load the slitlets region file gtc14aob001_object_269_slits.reg
Pre-image after joining the CCDs with slitlet numbers overlaid as a ds9 reg file
Raw spectra after joining the CCDs with slitlet numbers overlaid as a ds9 reg file
gtcmos>  hselect gtc14aob001_object_*.fits "$I EXPTIME BIASSUB" expr+ 
gtc14aob001_object_267.fits     1308.   gtc14aob001_bias_master
gtc14aob001_object_268.fits     1308.   gtc14aob001_bias_master
gtc14aob001_object_269.fits     1308.   gtc14aob001_bias_master
 Note the image has a new keyword BIASSUB containing the name of the bias image
 Make sure bias="" when you don't want to subtract bias.
gtcmos>  omcombine gtc14aob001_object_*.fits imtype=obj 
#               IMAGE      NPIX      MEAN    STDDEV       MIN       MAX     MIDPT
 gtc14aob001_object_267.fits   4327610     1090.     4966.    -17.35    64465.      404.
 gtc14aob001_object_268.fits   4327610     1082.     5003.    -21.96    64463.      403.
 gtc14aob001_object_269.fits   4327610     1060.     4937.    -19.78    64465.     400.3
Apr 17 18:59: IMCOMBINE
  combine = median, scale = median, zero = none, weight = none
  blank = 0.
                Images   Median  Scale
  gtc14aob001_object_267.fits   274.5  1.000
  gtc14aob001_object_268.fits  269.18  1.020
  gtc14aob001_object_269.fits  268.22  1.023
  Output image = omcombine, ncombine = 3
Output is stored in omcombine
gtcmos>  imrename omcombine gtc14aob001_object_av 
Result of combining 3 spectra with slitlet numbers overlaid as a ds9 reg file
gtcmos> omstart ../m81/MOS/GTC4-14AMEX/OB0001/arc  
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/arc/0000652314-20140403-OSIRIS-OsirisCalibrationLamp[1]   ArcLamp_HgAr    1049    2051    R1000B  OPEN    OPEN    OPEN    3.6     "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/arc/0000652315-20140403-OSIRIS-OsirisCalibrationLamp[1]   ArcLamp_Ne      1049    2051    R1000B  OPEN    OPEN    OPEN    2.1     "2 2"   0.
gtcmos> omstart ../m81/MOS/GTC4-14AMEX/OB0001/arc mosaic+ 
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/arc/0000652314-20140403-OSIRIS-OsirisCalibrationLamp[1]   ArcLamp_HgAr    1049    2051    R1000B  OPEN    OPEN    OPEN    3.6     "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/arc/0000652314-20140403-OSIRIS-OsirisCalibrationLamp
Output stored as gtc14aob001_arc_314
../m81/MOS/GTC4-14AMEX/OB0001/arc/0000652315-20140403-OSIRIS-OsirisCalibrationLamp[1]   ArcLamp_Ne      1049    2051    R1000B  OPEN    OPEN    OPEN    2.1     "2 2"   0.
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/arc/0000652315-20140403-OSIRIS-OsirisCalibrationLamp
Output stored as gtc14aob001_arc_315
gtcmos>  omcomb gtc14aob001_arc_314,gtc14aob001_arc_315 imtype=arc 
#               IMAGE      NPIX      MEAN    STDDEV       MIN       MAX     MIDPT
  gtc14aob001_arc_314   4327610     133.4     1323.    -1208.    45346.     51.31
  gtc14aob001_arc_315   4327610     427.9     2511.    -1210.    61064.    -45.27
Apr 17 19:06: IMCOMBINE
  combine = sum, scale = none, zero = none, weight = none
  blank = 0.
                Images 
    gtc14aob001_arc_314
    gtc14aob001_arc_315
  Output image = omcombine, ncombine = 2
Output is stored in omcombine
gtcmos> imrename omcombine gtc14aob001_arc_sum
Arc spectra after "summing" HgAr and Ne lamps
gtcmos> lpar omidentify
       filarc = "gtc14aob009_arc_sum" Comparison arc file [arcfile]
      coordli = "DEFAULT"       Line id coordinate list
      (cursor = "gtcinputs$identify_spline3_2.cursor") Cursor file for identify
     (display = no)             Display graph showing each identification?
     (lastlis = "gtcinputs$R2000B_HgAr_Ne_Xe.dat") Line id coordinate list
        (mode = "ql")           
gtcmos>  omidentify gtc14aob001_arc_sum coordli=DEFAULT 
Linelist is = gtcinputs$R1000B_HgAr_Ne_Xe.dat
OBSMODE= OsirisMOS
R1000B  3700  7000   2.12  3.569E+03 1.698E+00 1.990E-04    0.02   0.0025
1 948.39095873527 41 [312:392,*]
        units   Angstroms
        features    4 
           219.7655 4046.563 4046.563   4.0 1 1 
           399.1017 4358.328 4358.328   4.0 1 1 
           957.6974 5460.735 5460.735   4.0 1 1 HgI
           1656.272 7032.413 7032.413   4.0 1 1 
identify gtc14aob001_arc_sum_1[41,*]
........................................................
........................................................
36 1071.6622651062 39 [1897:1974,*]
        units   Angstroms
        features    5 
           349.291 4046.563 4046.563   4.0 1 1 
           527.4118 4358.328 4358.328   4.0 1 1 
           1084.179 5460.735 5460.735   4.0 1 1 HgI
           1784.463 7032.413 7032.413   4.0 1 1 
           98.62508 INDEF INDEF   4.0 1 1 
identify gtc14aob001_arc_sum_36[39,*]
##########################################
The solution files are stored in database
The statistics of the rms of the solution is shown below
# identify.rms_stat  c1
# nrows            mean        stddev        median           min           max
   36      0.6473315097      0.411766       0.48177      0.390404        2.0338
   
Use omreidentify to check and improve individual solutions
 With the default "display = no" option, the graphs showing line identifications
and fits are stored in a metacode file that can be visualized using gkiextract.
With "display=yes", these graphs are displayed on the graphic terminal. However, 
the display rate is too fast to note any false identification. 
Result of autoidentification of arc spectral lines of the last slitlet
gtcmos> ls *.rms
identify.rms
gtcmos> page identify.rms
Wed 23:28:25 04-Feb-2015
Features identified in image gtc14aob001_arcs_1.
      Pixel        Fit       User   Residual Fwidth Wt Label
 1   219.77  4046.5704   4046.563 0.00735675   4.00  1 HgI
 2   399.10  4358.2962   4358.328 -0.0317851   4.00  1 HgI
 3   957.70  5461.0573   5460.735 0.32227432   4.00  1 HgI
 4  1110.96  5790.7551   5790.663 0.09208835   4.00  1 HgI
 5  1139.01   5852.159   5852.488 -0.3289591   4.00  1 NeI
 6  1180.96  5944.5444   5944.834 -0.2895656   4.00  1 NeI
..........................................................
..........................................................
..........................................................
The file "identify.rms" contains residual of all lines identified in each of the slitlets.
To improve the fits you may run omreidentify
gtcmos>  omreidentify 
rms file from omidentify (identify.rms): 
######### Summary of Identification errors ############
No of slits with rms > 0.5  = 12 
Additional number of slits with at least 1 badly identified line = 0 
######### Summary of Identification errors ############
 Exit [0], Reidentify all [999], Slit# to identify from the list below : 
Slit#  arcfil    rms
1 gtc14aob001_arc_sum_1 0.67578588
3 gtc14aob001_arc_sum_3 0.64711966
4 gtc14aob001_arc_sum_4 0.71349521
6 gtc14aob001_arc_sum_6 0.6456216
7 gtc14aob001_arc_sum_7 0.62050815
10 gtc14aob001_arc_sum_10 0.52383421
14 gtc14aob001_arc_sum_14 0.50641107
15 gtc14aob001_arc_sum_15 0.50398614
19 gtc14aob001_arc_sum_19 0.64343367
23 gtc14aob001_arc_sum_23 0.56145567
24 gtc14aob001_arc_sum_24 0.50685462
33 gtc14aob001_arc_sum_33 0.50767427
Number to Analyze [0, 999, #] : 
1
identify gtc14aob001_arc_sum_1[41,*]
Exit [0], Reidentify all [999], Slit# to identify from the list below : 
Slit#  arcfil    rms
1 gtc14aob001_arc_sum_1 0.67578588
3 gtc14aob001_arc_sum_3 0.64711966
4 gtc14aob001_arc_sum_4 0.71349521
6 gtc14aob001_arc_sum_6 0.6456216
7 gtc14aob001_arc_sum_7 0.62050815
10 gtc14aob001_arc_sum_10 0.52383421
14 gtc14aob001_arc_sum_14 0.50641107
15 gtc14aob001_arc_sum_15 0.50398614
19 gtc14aob001_arc_sum_19 0.64343367
23 gtc14aob001_arc_sum_23 0.56145567
24 gtc14aob001_arc_sum_24 0.50685462
33 gtc14aob001_arc_sum_33 0.50767427
Number to Analyze [0, 999, #] : 
0
DONE
 Note that "Number to Analyze = 0" exits. 
gtcmos> lpar omreduce
       filnam = "gtc14a_mos1abc" File Name
       filarc = "std"           Comparison arc file [std|arcfile]
     (filflat = "")             Master Flat file [gtc14a_p1_m_flat_b or empty]
     (senscur = "")             Sensitivity curve imagename
        (dlam = INDEF)          Wavelength interval in Ang/pixel
      (pixref = INDEF)          Pixel at which lambda=lamref [INDEF=middle]
      (lamref = INDEF)          Lambda in Ang at pixref
   (tilt_slit = no)             Correct for Slit tilt?
    (fiducial = no)             Retain fiducial stars?
    (checksky = no)             Improve lambda calibration by checking a skyline?
      (lamsky = 5577.339)       Lambda of a sky line in Ang[e.g. 5577.339, 6300.304 etc
     (slitrej = "")             Slitlet numbers to reject
    (cleanlev = 2)              Clean Level [2=del all intermediate fits] [0=retain all]
        (mode = "ql")           
gtcmos>  omreduce gtc14aob001_object_av filarc=gtc14aob001_arc_sum 
OBSMODE= OsirisMOS
R1000B  3700  7000   2.12  3.569E+03 1.698E+00 1.990E-04    0.02   0.0025
Reference Slitlet: i=11 x=1111 ydist=1.1778959717411
1 rectangular gtc14aob001_object_av[312:392,*] 960.42809724925  948.39095873527  352.16351348683 312  392 
3 rectangular gtc14aob001_object_av[544:623,*] 1041.9322213566  1033.9488301492  583.80621672308 544  623 
.........................................................................................................
.........................................................................................................
36 rectangular gtc14aob001_object_av[1897:1974,*] 1091.816709784  1071.6622651062  1935.7530967888 1897  1974 
Wavelength calibrated data are stored in gtc14aob001_object_av_wl
gtcmos> 
gtcmos>  omreduce gtc14aob001_object_av filarc=gtc14aob001_arc_sum tilt_slit+ 
.........................................................................................................
36 rectangular gtc14aob001_object_av[1897:1974,*] 1091.816709784  1071.6622651062  1935.7530967888 1897  1974 
Wavelength calibrated data are stored in gtc14aob001_object_av_wl_tlt
Note that the fiducial spectra are eliminated with fiducial-
Wavelength calibrated and "longslit-like" output 
Skylines of different slitlets are aligned using the values of dlam, pixref and lamref.
Tilt of slanted slitlets (and all other slitlets) can be corrected with tilt_slit+ option.
This option is relatively slower (takes around 10 seconds for each slitlet)
gtcmos>  omreduce gtc14aob001_object_abc filarc=gtc14aob001_arcs tilt_slit+ 
Wavelength calibrated and "longslit-like" output with tilt_slit+ 
Each individual slitlets are cut and stored (without wavelength calibration)
gtcmos>  splot gtc14aob001_object_av_wl_tlt 
Image line/aperture to plot (0:) (1480):
Splot cuts through various slitlets 
 Note the position of skylines (eg. 5577, 6300) which exactly coincide
independent of the original slitlet y-position. Thanks to this feature of the
pipeline, sky slitlets for each object slitlet is needed only in case of variable
backgound (when observing large nearby galaxies). 
gtcmos> lpar omskysub
       filnam = "gtc14aob4_object_sum_wl_tlt" File Name
     (skytype = "same")         Sky type [same, pair, skyslits, bg]
      (method = "median")       Method of obtaining sky spectrum [median, percent]
     (percent = 20.)            Percentile value for sky [1-50]
     (normali = no)             Normalize the sky spectrum before subtration?
     (pairlis = "pair.sky")     Object-Sky pair list
     (skyslit = "1,10,30")      Sky slitlet numbers
     (skyrang = "")             Sky range in pixels 240:260,300:310,1500:1520
        (mode = "ql")           
gtcmos>  omskysub gtc14aob001_object_av_wl_tlt 
OBSMODE= OsirisMOS
R1000B  3700  7000   2.12  3.569E+03 1.698E+00 1.990E-04    0.02   0.0025
Analyzing slitlet no 1  Section = [312:392,*]
Analyzing slitlet no 3  Section = [544:623,*]
.........................................................................................................
.........................................................................................................
Analyzing slitlet no 36  Section = [1897:1974,*]
Sky subtrated 2D spectrum is = gtc14aob001_object_av_wl_tlt_obj
Sky spectrum= gtc14aob001_object_av_wl_tlt_sky and SNR spectrum= gtc14aob001_object_av_wl_tlt_snr are also stored.
Sky subtracted and "longslit-like" output 
gtcmos> 
gtcmos> lpar omextract
       filnam = "gtc14a_mos1abc" File Name
       slitno = "all"           Slit numbers to slice [all, #]
       (nfind = 1)              Number of apertures to be found automatically
     (lamline = INDEF)          Dispersion line
     (referen = "")             List of aperture reference images
     (interac = no)             Run task interactively?
      (extras = yes)            Extract sky, sigma, etc.?
      (llimit = INDEF)          Lower aperture limit relative to center
      (ulimit = INDEF)          Upper aperture limit relative to center
      (ylevel = 0.1)            Fraction of peak or intensity for automatic width
     (t_funct = "legendre")     Trace fitting function
     (t_order = 5)              Trace fitting function order
     (backgro = "none")         Background to subtract
        (mode = "ql")           
gtcmos>  omextract gtc14aob001_object_av_wl_tlt_obj 
Slit numbers to slice [all, #] (all): 
OBSMODE= OsirisMOS
R1000B  3700  7000   2.12  3.569E+03 1.698E+00 1.990E-04    0.02   0.0025
Examining a cut at lambda=INDEF  Ang, line = INDEF 
Extracting slitlet #1  and saving in gtc14aob001_object_av_wl_tlt_obj_1.ms
............................................................................
............................................................................
Extracting slitlet #34  and saving in gtc14aob001_object_av_wl_tlt_obj_34.ms
Extracting slitlet #35  and saving in gtc14aob001_object_av_wl_tlt_obj_35.ms
Extracting slitlet #36  and saving in gtc14aob001_object_av_wl_tlt_obj_36.ms
gtcmos> 
 Flux Calibration using Standard star 
Standard star spectra are taken using longslit. As illustrated in the cookbook for the reduction of longslit spectra, the procedure 
to be followed to analyze longslit spectra is identical to that of MOS spectra.
Flux calibration involves 4 steps:
-  Basic reduction to get a wavelength-calibrated 2D-spectrum (GTCMOS tasks)
 -  Identification of the star and extraction of its 1-D spectrum using the IRAF task "apall"
 -  Obtaining the sensitivity curve using the IRAF flux calibration tasks (standard, sensfunc)
 -  Apply the sensitivity correction to the object spectra using the IRAF task "calibrate"
 
 The first 3 steps are combined in a single task called omstd. 
gtcmos> lpar omstd
       filstd = "gtc12bob003_stds_316" Stadard star file
     star_nam = "Feige34"       Star name in calibration list
     (filflat = "DEFAULT")      Master Flat file
      (lamsky = "DEFAULT")      Lambda of a sky line in Ang
    (checksky = no)             Improve lambda calibration by checking a skyline?
     (interac = no)             Run apall interactively?
        (line = INDEF)          Line number to plot to search stars
       (nfind = 1)              Number of stars to find
      (extras = yes)            Extract sky, sigma, etc.?
      (llimit = INDEF)          Lower aperture limit relative to center
      (ulimit = INDEF)          Upper aperture limit relative to center
      (ylevel = 0.1)            Fraction of peak or intensity for automatic width
     (b_sampl = "-50:-40,40:50") Background sample regions
     (t_funct = "legendre")     Trace fitting function
     (t_order = 5)              Trace fitting function order
     (backgro = "median")       Background to subtract
     (stdflux = "gtc_flux.std") Output flux file (used by SENSFUNC)
     (extinct = "gtcinputs$tn_ext_curve.dat") Extinction curve file
      (caldir = "find")         Directory containing calibration data
    (sensfunc = yes)            Run sensfunc?
     (senscur = "gtc_sense_curve") Sensitivity function imagename
        (mode = "ql")           
gtcmos> omstart ../GTC5-12BMEX/OB0003/stds mos+ biasim=gtc12bob003_bias_av
gtcmos> imhead gtc12bob003_stds_315
gtc12bob003_stds_315[2110,2051][real]: SpectStand_Feige34
gtcmos>  omstd gtc12bob003_stds_315 Feige34 
gtcmos> splot gtc_sense_curve
Sensfunc graph | Typical sensitivity Curve
You can alternatively follow the steps 1 to 3.
  Step 1 
gtcmos>  omstart ../m81/MOS/GTC4-14AMEX/OB0001/stds mos- 
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652303-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     Ross640 1049    2051    OPEN    OPEN      Sloan_r OPEN    1.      "2 2"   0.
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652304-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     Ross640 1049    2051    OPEN    OPEN      Sloan_r OPEN    1.      "2 2"   2.52
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652305-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     Ross640 1049    2051    R1000B  OPEN      OPEN    OPEN    10.     "2 2"   2.52
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652306-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     Ross640 1049    2051    R1000B  OPEN      OPEN    OPEN    100.    "2 2"   2.52
gtcmos>  omstart ../m81/MOS/GTC4-14AMEX/OB0001/stds mos+ biasim=gtc14aob001_bias_master verify+ 
Analyzing the following files
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652303-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     OsirisLongSlitSpectroscopy      1049      2051    OPEN    OPEN    Sloan_r OPEN    1.      "2 2"
Want to mosaic 0000652303-20140403-OSIRIS-OsirisLongSlitSpectroscopy?
no 
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652304-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     OsirisLongSlitSpectroscopy      1049      2051    OPEN    OPEN    Sloan_r OPEN    1.      "2 2"
Want to mosaic 0000652304-20140403-OSIRIS-OsirisLongSlitSpectroscopy?
no
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652305-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     OsirisLongSlitSpectroscopy      1049      2051    R1000B  OPEN    OPEN    OPEN    10.     "2 2"
Want to mosaic 0000652305-20140403-OSIRIS-OsirisLongSlitSpectroscopy?
yes 
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652305-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     Ross640 1049    2051    R1000B  OPEN      OPEN    OPEN    10.     "2 2"   2.52
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652305-20140403-OSIRIS-OsirisLongSlitSpectroscopy
Bias subtracted output stored as gtc14aob001_stds_305
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652306-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     OsirisLongSlitSpectroscopy      1049      2051    R1000B  OPEN    OPEN    OPEN    100.    "2 2"
Want to mosaic 0000652306-20140403-OSIRIS-OsirisLongSlitSpectroscopy?
yes 
../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652306-20140403-OSIRIS-OsirisLongSlitSpectroscopy[1]     Ross640 1049    2051    R1000B  OPEN      OPEN    OPEN    100.    "2 2"   2.52
Running mosaic_2x2_v2 ../m81/MOS/GTC4-14AMEX/OB0001/stds/0000652306-20140403-OSIRIS-OsirisLongSlitSpectroscopy
Bias subtracted output stored as gtc14aob001_stds_306
gtcmos> 
 Note that the first two spectra are pre-images (answer to the question is no), and the last two are spectra of standard star Ross640
gtcmos>  omcomb gtc14aob001_stds_305,gtc14aob001_stds_306 fileout=gtc14aob001_stds_av imtype=obj 
gtcmos>  omreduce gtc14aob001_stds_av filarc=std checksky+ 
1 rectangular gtc14aob001_stds_av[160:179,*] 994.966  993.566  170. 160  179 
2 rectangular gtc14aob001_stds_av[180:199,*] 994.966  993.916  190. 180  199 
............................................................................
............................................................................
90 rectangular gtc14aob001_stds_av[1990:2009,*] 994.966  987.191  2000. 1990  2009 
91 rectangular gtc14aob001_stds_av[2010:2030,*] 994.966  986.741  2020. 2010  2030 
Wavelength calibrated data are stored in gtc14aob001_stds_av_wl
 Note that there is no "arc" lamps observed for longslit spectrum in the MOS mode.
However, longslit is always placed at the same Y-direction, and hence the standard 
dispersion solution is used in the above example using the option filarc=std. 
The checksky = yes option corrects for any zeropoint offset in wavelength calibration.  
   Step 2 
gtcmos>  apall gtc14aob001_stds_av_wl interac+ extras+ resi- lower=-20 upper=20 b_sampl="-50:-40,40:50" t_funct=legendre t_order=5 backgro=median  
 Read apall help to interactively choose the critical extraction parameters. 
  Step 3 
gtcmos>  standard gtc14aob001_stds_av_wl.ms gtc14aob001_stds_flux.std extinct=gtcinputs$tn_ext_curve.dat caldir=onedstds$/redcal/ star_nam=ross640 
 Boxes for evaluating Sensitivity function  
 Note that the boxes at the position of the absorption features have been already deleted 
 In the above example the standard spectrum of star "Ross640" is available in the
IRAF directory "onedstds$/redcal/" with name ross640.dat.
You should delete boxes near absorption lines. If you have more than one star or
the same star observed several times, repete the command standard for each 
observation, but give the same output file (e.g. gtc14aob001_stds_flux.std). 
Flux and count rate values for each observation are appended to the already existing
output text file.  
gtcmos>  sensfunc gtc14aob001_stds_flux.std gtc14aob001_stds_flux.sens extinct=gtcinputs$tn_ext_curve.dat inter+ 
Sensitivity function for aperture 1:
Fitting function is spline3 of order 6 with 18 points and RMS of 0.0338.
                    Image  Airmass  Points Shift    RMS     Fit    Dev 1   Dev 2   Dev 3
gtc14aob001_stds_av_wl.ms   1.033      18  0.0000  0.0328 -0.0027  0.0016  0.0012
 Read sensfunc help to interactively change the fitting parameters. In this example the rms of the fit is 0.0328 
 Sensitivity function and the rms error at each wavelength  
 Comparsion of Sensitivity functions from 2012 and 2014 runs 
  Step 4 
 
gtcmos> calibrate gtc14aob001_object_av_wl_tlt gtc14aob001_object_av_wl_tlt_cal extinct+ flux+ extinct=home$tn_ext_curve.dat sensiti=gtc12bob001_stds_flux.sens.0001
gtcmos>  omskysub gtc14aob001_object_av_wl_tlt_cal 
gtcmos>  omextract gtc14aob001_object_av_wl_tlt_cal_obj 
gtcmos>  splot gtc14aob001_object_av_wl_tlt_cal_obj_8.ms 
Note that you can run omskysub and omextract before or after flux calibration.
 Final calibrated and extracted spectrum of one of the slitlets 
 Reduction of Longslit spectra using GTCMOS package
GTCMOS tasks interpret longslit as a series of contiguous slitlets (i.e zero-pixel space between 
successive slitlets). Hence, the procedure to be followed to analyze longslit spectra are 
identical to that of MOS spectra.
gtcmos>  omstart "../m81/GTC5-12BMEX/OB0001/arc"  
Analyzing the following files
../m81/GTC5-12BMEX/OB0001/arc/0000290984-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_HgAr    1049    2051    R1000B       OPEN    OPEN    OPEN    5.      "2 2"   1.23
../m81/GTC5-12BMEX/OB0001/arc/0000290985-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_HgAr    1049    2051    R1000B       OPEN    OPEN    OPEN    3.      "2 2"   1.23
../m81/GTC5-12BMEX/OB0001/arc/0000290986-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_Ne      1049    2051    R1000B       OPEN    OPEN    OPEN    3.      "2 2"   1.23
../m81/GTC5-12BMEX/OB0001/arc/0000290987-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_Ne      1049    2051    R1000B       OPEN    OPEN    OPEN    1.4     "2 2"   1.23
gtcmos>  omstart "../m81/GTC5-12BMEX/OB0001/arc" mos+  
Analyzing the following files
../m81/GTC5-12BMEX/OB0001/arc/0000290984-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_HgAr    1049    2051    R1000B       OPEN    OPEN    OPEN    5.      "2 2"   1.23
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/arc/0000290984-20130111-OSIRIS-OsirisCalibrationLamp
Output stored as gtc12bob001_arc_984
../m81/GTC5-12BMEX/OB0001/arc/0000290985-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_HgAr    1049    2051    R1000B       OPEN    OPEN    OPEN    3.      "2 2"   1.23
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/arc/0000290985-20130111-OSIRIS-OsirisCalibrationLamp
Output stored as gtc12bob001_arc_985
../m81/GTC5-12BMEX/OB0001/arc/0000290986-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_Ne      1049    2051    R1000B       OPEN    OPEN    OPEN    3.      "2 2"   1.23
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/arc/0000290986-20130111-OSIRIS-OsirisCalibrationLamp
Output stored as gtc12bob001_arc_986
../m81/GTC5-12BMEX/OB0001/arc/0000290987-20130111-OSIRIS-OsirisCalibrationLamp[1]       ArcLamp_Ne      1049    2051    R1000B       OPEN    OPEN    OPEN    1.4     "2 2"   1.23
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/arc/0000290987-20130111-OSIRIS-OsirisCalibrationLamp
Output stored as gtc12bob001_arc_987
gtcmos>  omcombi gtc12bob001_arc_*.fits fileout=gtc12bob001_arc_sum imtype=arc 
#               IMAGE      NPIX      MEAN    STDDEV       MIN       MAX     MIDPT
 gtc12bob001_arc_984.fits   4327610     203.6     1665.    -1005.    51723.     81.21
 gtc12bob001_arc_985.fits   4327610     111.6     1098.    -1005.    36176.     41.37
 gtc12bob001_arc_986.fits   4327610     877.5     4200.    -1005.    64509.     69.37
 gtc12bob001_arc_987.fits   4327610     415.4     2003.    -1004.    38691.     107.6
Apr 22 11:30: IMCOMBINE
  combine = sum, scale = none, zero = none, weight = none
  blank = 0.
                Images 
  gtc12bob001_arc_984.fits
  gtc12bob001_arc_985.fits
  gtc12bob001_arc_986.fits
  gtc12bob001_arc_987.fits
  Output image = gtc12bob001_arc_sum, ncombine = 4
Output is stored in gtc12bob001_arc_sum
gtcmos>  omidentify gtc12bob001_arc_sum  
.................................................
.................................................
identify gtc12bob001_arc_sum_90[10,*]
91 986.741 11 [2010:2030,*]
        units   Angstroms
        features    4 
           251.0527 4046.563 4046.563   4.0 1 1 
           418.3986 4358.328 4358.328   4.0 1 1 
           984.2291 5460.735 5460.735   4.0 1 1 HgI
           1691.874 7032.413 7032.413   4.0 1 1 
identify gtc12bob001_arc_sum_91[11,*]
##########################################
The solution files are stored in database
The statistics of the rms of the solution is shown below
# identify.rms_stat  c1
# nrows            mean        stddev        median           min           max
   91       0.174976417      0.272068      0.135168   3.31810E-11       2.68449
   
Use omreidentify to check and improve individual solutions
gtcmos>  omreidentify  
rms file from omidentify (identify.rms): 
######### Summary of Identification errors ############
No of slits with rms > 0.5  = 1 
Additional number of slits with at least 1 badly identified line = 1 
######### Summary of Identification errors ############
Exit [0], Reidentify all [999], Slit# to identify from the list below : 
Slit#  arcfil    rms
87 gtc12bob001_arc_sum_87 2.6844871
91 gtc12bob001_arc_sum_91 3.3180979000000E-11
Number to Analyze [0, 999, #] : 
87
identify gtc12bob001_arc_sum_87[10,*]
Write feature data to the database (yes)? 
Exit [0], Reidentify all [999], Slit# to identify from the list below : 
Slit#  arcfil    rms
87 gtc12bob001_arc_sum_87 2.6844871
91 gtc12bob001_arc_sum_91 3.3180979000000E-11
Number to Analyze [0, 999, #] : 
91
identify gtc12bob001_arc_sum_91[11,*]
Write feature data to the database (yes)? 
Exit [0], Reidentify all [999], Slit# to identify from the list below : 
Slit#  arcfil    rms
87 gtc12bob001_arc_sum_87 2.6844871
91 gtc12bob001_arc_sum_91 3.3180979000000E-11
Number to Analyze [0, 999, #] : 
0
DONE
gtcmos> 
gtcmos>  omstart "../m81/GTC5-12BMEX/OB0001/bias" mos+ 
gtcmos>  omcomb gtc12bob001_bias_*.fits imtype=bias 
#               IMAGE      NPIX      MEAN    STDDEV       MIN       MAX     MIDPT
 gtc12bob001_bias_966.fits   4327610     2.607     26.44    -1002.     8706.     3.757
 gtc12bob001_bias_967.fits   4327610     2.636     27.77    -1003.     8328.     3.703
 gtc12bob001_bias_968.fits   4327610     2.578     26.09    -1003.     3621.      3.23
 gtc12bob001_bias_969.fits   4327610     2.617     28.59    -1002.    10481.     3.537
 gtc12bob001_bias_970.fits   4327610     2.596     26.37    -1003.     6691.     3.608
 gtc12bob001_bias_971.fits   4327610     2.589     26.52    -1003.     5697.     3.545
 gtc12bob001_bias_972.fits   4327610     2.569     26.04    -1002.     3853.     3.529
 gtc12bob001_bias_973.fits   4327610     2.562     25.76    -1003.     2187.     2.995
 gtc12bob001_bias_974.fits   4327610     2.571     26.82    -1002.     6649.     3.334
 gtc12bob001_bias_975.fits   4327610     2.578      27.3    -1002.    10756.      3.48
Apr 22 12:12: IMCOMBINE
  combine = median, scale = none, zero = median, weight = none
  blank = 0.
                Images   Median    Zero
  gtc12bob001_bias_966.fits  3.6793      0.
  gtc12bob001_bias_967.fits  3.6655 0.01387
  gtc12bob001_bias_968.fits  3.6473 0.03205
  gtc12bob001_bias_969.fits  3.6582  0.0211
  gtc12bob001_bias_970.fits  3.6817 -0.0023
  gtc12bob001_bias_971.fits  3.6342 0.04515
  gtc12bob001_bias_972.fits  3.6381 0.04119
  gtc12bob001_bias_973.fits  3.6538 0.02557
  gtc12bob001_bias_974.fits  3.6307 0.04864
  gtc12bob001_bias_975.fits  3.6283 0.05103
  Output image = omcombine, ncombine = 10
gtcmos>  imrename omcombine gtc12bob001_bias_av 
 
gtcmos>  omstart "../m81/GTC5-12BMEX/OB0001/object" mos+ biasim=gtc12bob001_bias_av 
gtcmos>  omcomb gtc12bob001_object_927,gtc12bob001_object_928,gtc12bob001_object_929  
#               IMAGE      NPIX      MEAN    STDDEV       MIN       MAX     MIDPT
 gtc12bob001_object_927   4327610     516.4      645.    -1011.    29537.     363.5
 gtc12bob001_object_928   4327610     533.8     676.8    -1010.    27737.     370.1
 gtc12bob001_object_929   4327610     542.4     693.6    -1010.    63482.      376.
Apr 22 12:17: IMCOMBINE
  combine = median, scale = median, zero = none, weight = none
  blank = 0.
                Images   Median  Scale
  gtc12bob001_object_927   364.7  1.000
  gtc12bob001_object_928  372.89  0.978
  gtc12bob001_object_929  375.67  0.971
  Output image = omcombine, ncombine = 3
Output is stored in omcombine
gtcmos>  imrename omcombine gtc12bob001_object_av 
gtcmos> 
gtcmos>  omreduce gtc12bob001_object_av filarc=gtc12bob001_arc_sum checksky+ lamsky = 5577.838 
Reference Slitlet: i=1 x=170 ydist=0.033999999999764
1 rectangular gtc12bob001_object_av[160:179,*] 994.966  993.566  170. 160  179 
..............................................................................
91 rectangular gtc12bob001_object_av[2010:2030,*] 994.966  986.741  2020. 2010  2030 
Wavelength calibrated data are stored in gtc12bob001_object_av_wl
gtcmos> omskysub gtc12bob001_object_av_wl
Analyzing slitlet no 1  Section = [160:179,*]
..............................................................................
Analyzing slitlet no 91  Section = [2010:2030,*]
Sky subtrated 2D spectrum is = gtc12bob001_object_av_wl_obj
Sky spectrum= gtc12bob001_object_av_wl_sky and SNR spectrum= gtc12bob001_object_av_wl_snr are also stored.
gtcmos> 
gtcmos>  omstart "../m81/GTC5-12BMEX/OB0001/stds" mos-  
Analyzing the following files
../m81/GTC5-12BMEX/OB0001/stds/0000290947-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051OPEN     OPEN    Sloan_g OPEN    1.      "2 2"   0.
../m81/GTC5-12BMEX/OB0001/stds/0000290948-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051OPEN     OPEN    Sloan_g OPEN    1.      "2 2"   2.52
../m81/GTC5-12BMEX/OB0001/stds/0000290949-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051R1000B   OPEN    OPEN    OPEN    20.     "2 2"   2.52
../m81/GTC5-12BMEX/OB0001/stds/0000290950-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051R1000B   OPEN    OPEN    OPEN    30.     "2 2"   2.52
gtcmos>  omstart "../m81/GTC5-12BMEX/OB0001/stds" mos+ biasim=gtc12bob001_bias_av 
Analyzing the following files
../m81/GTC5-12BMEX/OB0001/stds/0000290947-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051OPEN     OPEN    Sloan_g OPEN    1.      "2 2"   0.
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/stds/0000290947-20130111-OSIRIS-OsirisLongSlitSpectroscopy
Bias subtracted output stored as gtc12bob001_stds_947
../m81/GTC5-12BMEX/OB0001/stds/0000290948-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051OPEN     OPEN    Sloan_g OPEN    1.      "2 2"   2.52
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/stds/0000290948-20130111-OSIRIS-OsirisLongSlitSpectroscopy
Bias subtracted output stored as gtc12bob001_stds_948
../m81/GTC5-12BMEX/OB0001/stds/0000290949-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051R1000B   OPEN    OPEN    OPEN    20.     "2 2"   2.52
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/stds/0000290949-20130111-OSIRIS-OsirisLongSlitSpectroscopy
Bias subtracted output stored as gtc12bob001_stds_949
../m81/GTC5-12BMEX/OB0001/stds/0000290950-20130111-OSIRIS-OsirisLongSlitSpectroscopy[1] SpectStand_GD140        1049    2051R1000B   OPEN    OPEN    OPEN    30.     "2 2"   2.52
Running mosaic_2x2_v2 ../m81/GTC5-12BMEX/OB0001/stds/0000290950-20130111-OSIRIS-OsirisLongSlitSpectroscopy
Bias subtracted output stored as gtc12bob001_stds_950
There are 4 files in the "stds" directory, two pre-images and other two spectral images. The pre-image gtc12bob001_stds_949 looks like  this. 
Note that the spectral images are of exposures 20 and 30 seconds, and hence if they are averaged, the EXPTIME keyword 
should be set as 25 sec (using hedit). Here we will reduce the two spectra idependently.
gtcmos> omreduce gtc12bob001_stds_949
gtcmos> omreduce gtc12bob001_stds_950
2-D Spectrum of standard star  before  and  after  wavelength calibration. Note how the "curvature" of skylines gets corrected on wavelength calibration.
gtcmos>  apall gtc12bob001_stds_949_wl interac+ extras+ resi- lower=-20 upper=20 b_sampl="-50:-40,40:50" t_funct=legendre t_order=5 backgro=median 
Recenter apertures for gtc12bob001_stds_949_wl?  (yes): 
Edit apertures for gtc12bob001_stds_949_wl?  (yes): 
 Tracing the spectrum for extraction 
gtcmos>  apall gtc12bob001_stds_950_wl interac+ extras+ resi- lower=-20 upper=20 b_sampl="-50:-40,40:50" t_funct=legendre t_order=5 backgro=median 
 Name of the standard star is GD140, which is in the onedstds$/spec50cal/ directory of IRAF.  
gtcmos>  standard gtc12bob001_stds_949_wl.ms gtc12bob001_stds_flux.std extinct=gtcinputs$tn_ext_curve.dat caldir=onedstds$/spec50cal/ star_nam=gd140 
gtcmos>  standard gtc12bob001_stds_950_wl.ms gtc12bob001_stds_flux.std extinct=gtcinputs$tn_ext_curve.dat caldir=onedstds$/spec50cal/ star_nam=gd140 
 Boxes for evaluating Sensitivity function   Note that the boxes at the position of the absorption features have been already deleted 
gtcmos>  sensfunc gtc12bob001_stds_flux.std gtc12bob001_stds_flux.sens extinct=gtcinputs$tn_ext_curve.dat inter+ 
Sensitivity function for aperture 1:
Fitting function is spline3 of order 6 with 124 points and RMS of 0.0328.
       Image Airmass  Points   Shift RMS Fit   Dev 1   Dev 2   Dev 3
gtc12bob001_stds_949_wl.ms   1.087      60  0.0502  0.0326 -0.0024 -0.0021  0.0041
gtc12bob001_stds_950_wl.ms   1.091      64  0.0000  0.0328 -0.0001 -0.0017  0.0021
 Sensitivity function and the rms error at each wavelength 
Calibrate the 2-D or 1-D spectra of objects using the sensitivity function as in the floowing 2 examples.
gtcmos>  calibrate gtc12bob001_object_av_wl gtc12bob001_object_av_wl_cal extinct+ flux+ extinct=home$tn_ext_curve.dat sensiti=gtc12bob001_stds_flux.sens 
gtcmos>  calibrate gtc12b_p1abc_ccd1tbf_wl.ms gtc12b_p1abc_ccd1tbf_wl.ms_cal extinct+ flux+ extinct=home$tn_ext_curve.dat sensiti=sens_gtc12b_p1GD140_ccd2tbf.std 
 
 Comments by the author 
 
1. All the examples in this cookbook are from the data obtained for the projects by the Author. 
2. The tasks are tested only on Ubuntu and Fedora systems for the IRAF V2.14 version.
3. If you find this pipeline/cookbook useful, please acknowledge its use in the publication. 
4. Author acknowledges the GTC/OSIRIS staff, especially Antonio Cabrera for providing useful calibration tables figures in the corresponding webpage. Thanks to these data files, 
it was possible to keep the interaction level to the minimum.
5. The author acknowledges the contribution of Victor Mauricio Gomez Gonzalez, a Ph.D. student at INAOE who has helped extensively in doing the tedious job of identifying the arc lamp lines in several MOS 
images that formed the basis for various emperical relations that the script uses. He also contributed in testing all the tasks in this package.
6. The pipeline couldn't have been realized without the enthusiastic support from friends and colleagues at INAOE and IAC.
 Last updated on 15 Mar 2016  ydm@inaoep.mx