KAPPA/FIGARO REDUCTION

KAPPA/FIGARO REDUCTION

INTRO: 
======

To activate KAPPA and FIGARO, you must first type, on the command line:

 > kappa
 > figaro

To view an image, use GAIA, e.g.

 > gaia gu20030909_111_mos 
or
 > gaiadisp gu20030909_111_mos (uses previously opened gaia window)

To plot an extracted spectrum, use splot (figaro) or linplot (similar 
kappa command.

 > splot gu20030909_111_dbs
 > linplot gu20030909_111_dbs

Splot will let you set axes, scales, etc.  Hit return if you're not
sure what to use.

Some useful Kappa/figaro

 - gdset   (define the graphics display tool, e.g. xw, ps_p, ps_l, etc.)
 - linplot (kappa version of splot;  better for getting publishable graphs)
 - stats   (statistics from image or spectrum)
 - cadd/cmult/cdiv/csub  (add, subtract, etc. a constant from an image/spectrum)
 - add/sub/div           (add, subtract, etc one image/spectrum from another)
 - maths                 (more complex arithmetic involving images/spectra)
  
To view all the available kappa and figaro routines, type:

 > kaphelp
 > fighelp

If necessary; to convert data to NDF format (.sdf files), use convert, e.g.:

 > convert
 > fits2ndf "gu*" "*"


	........................................................


REDUCTION STEPS - SUMMARY:
==========================

 Subaru 
 ------

 IRCS data - cross-dispersed; (extended sources)
 Suggest 
  1) Flat-field, sky-subtract, remove cosmics, correct S-distortion.
  2) Extract individual orders, wavelength calibrate and divide through 
     by standard star spectral images.


 UKIRT
 -----

 UIST data (single order)
 Suggest
  1) Use the _wce frames, or the group of these (the gu* frame).
     These have already been bp-masked, flat-fielded (and sky-subtracted)
  2) To do:  S-distortion correction, wavelength calibrate and divide
     through by standard.
 

	........................................................


FLAT-FIELD & SKY-SUBTRACT SPECTRAL IMAGES
=========================================

Note: The flux from the Black-body flat obviously has a slope with
wavelength.  However, it may not be necessary to remove this slope
because:

 If observing a POINT source, then the curvature of the continuum (the
 "S-distortion") will be the same for the standard and the science
 target.  Both spectra, after flat-fielding, will inherit the same
 slope from the flat; this slope will divide out provided the standard
 and science target spectra are both optimally extracted in the same
 way.

 For an EXTENDED source, if you're using SDIST/CDIST to remove the
 curvature of the standard and science target spectral images, then
 this ONLY shifts/rescales along columns to remove the curvature.  The
 standard and science target spectral images, flat-fielded with a
 sloping BB curve, will both inherit the same slope.  Optimally
 extracting a standard spectral image and expanding this into a 2-D
 image for calibration of the science target spectral image will
 therefore again lead to cancellation of the black-body slope.

So - in both cases, removing the slope in the black-body flat may not
be necessary.
  

To FLAT-FIELD the data, divide all science target and standard star
frames by the SAME flat-field (FF) frame.

  > idiv 

To SKY-SUBTRACT the data, simply subtract skies from object frames and
average the results for each position.  

  > sub

(SUBARU:  Do a half-dozen flats with the lamp on then the lamp off.  
Average the lamp-on frames and the lamp-off frames.  Subtract the averaged 
lamp-off form the averagde lamped-on [to get rid of bad pixels] and apply 
this flat to ALL the data taken that night.  

Also - sky-subtraction;  echelle data may be taken as
object-sky-object,object-sky-object... rather than the traditional "quad";
so subtract the sky from the objects taken directly before and after the
sky).

	........................................................


REMOVE COSMICS THEN (MEDIAN) AVERAGE SPECTRA
============================================

Its probably a good idea to have a first-pass at removing cosmics
and/or bad pixels from ff/sky-subtracted data before averaging up all
the spectral images taken on each source.  Median averaging may then
be use to zap the last few bad pixels.

Do this for the science target AND the associated standard star.

 > GLITCH (kappa)  - just replaces by average of surrounding pixels
 > FILLBAD  ( " )  - may be better, fits a surcae to surrounding
                     pixels and replaces that way. 
 > BCLEAN (figaro) - another option
 > FFCLEAN         - can use this on 1-D spectra, though emission lines
                     have to be at least a few pixels wide, otherwise 
                     it'll think a line is a cosmic!


	........................................................


CORRECT FOR S-DISTORTION
========================

You should now have one spectral image for the standard star and one
for the science target.

Use SDIST to determine the curvature along a continuum spectrum (the
standard, say).  Then use CDIST to remove this curvature from both
spectral images (also do the arc - to be used later).  

You should display the spectral image of the star in the xw window, so
that you can use ICUR to identify the positions of bright continuum
spectra (can do multiple orders!).

 > idev xw
 > colour grey
 > image star autoscale ystart=min yend=max xstart=min xend=max accept

 > icur

Hit space-bar with mouse positioned over centre of continuum in xw display.

 > sdist image=star columns=5 trace=E width=6 maxdeg=2 softd=yes softd=yes soft=xw
 Spectrum traced from 1 to 1021
 Spectrum fitted to polynomial of degree 2
 Analysis results written to sdist.dat

If sdist fails, try starting from a brighter/higher-S/N part of spectrum with icur.
Or try a different fit (G for gaussian works well with Subaru - but E worked best 
with UIST..??)

CDIST will now use the parameters in "sdist.dat" to correct the
curvature.  N.B.  If you want to redo sdist, you MUST delete sdist.dat
first.  It won't over-write the file.

 > cdist IMAGE - (IMage) Image to be corrected for S-distortion /@star/ 
 YSTART - (YStart) First Y value in range to be corrected /0.5/ > 
 YEND - (YEnd) Last Y value in range to be corrected /1023.5/ > 
 OUTPUT - (OUTput) Name of resulting image /@done/ > star_cdist
 Correction is based on analysis of a single spectrum

(Must also do this to science target and arc spectrum; may need to use
a different sdist.dat file, i.e. one derived from the science data
rather than from the standard star - though strictly speaking these
should be the same...)

 > cdist
 IMAGE - (IMage) Image to be corrected for S-distortion /@star/ > arc 
 YSTART - (YStart) First Y value in range to be corrected /0.5/ > 
 YEND - (YEnd) Last Y value in range to be corrected /1023.5/ > 
 OUTPUT - (OUTput) Name of resulting image /@star_cdist/ > arc_cdist

Now, to check the results of the distortion correction,. extract
(YSTRACT) a cut along a few columns at the left, centre and right-hand
edges of the continuum and use FITGAUSS to precisely measure the
position of the continuum; does the continuum have any curvature?
Compare cuts from the pre- and post-distortion-correction data (in
this case, the spectral images star.sdf and star_cdist.sdf).

 > ystract
 IMAGE - (IMage) name of image to extract data from /@star/ > 
 XSTART - (XStart) first x-value to be used /0.5/ > 10
 XEND - (XEnd) last x-value to be used /1023.5/ > 20
 SPECTRUM - (SPectrum) name of spectrum to be generated /@stdbb/ > yleft

 > ystract
 IMAGE - (IMage) name of image to extract data from /@star/ > 
 XSTART - (XStart) first x-value to be used /10/ > 1000
 XEND - (XEnd) last x-value to be used /20/ > 1010
 SPECTRUM - (SPectrum) name of spectrum to be generated /@yleft/ > yright

Here's an example run with fitgauss; just answer the questions...  The
region to be used, and the gaussian fit, should be displayed on the xw
display. (TIP: the MASK interval is the range over which the gaussian is
fitted. i.e. gaussian peak at 550, FWHM=10, so mask1=500 and
mask2=600.)

 > fitgauss
 IN - Input NDF /@test/ > yleft
 DEVICE - Graphics device /!/ > xw
 MASK1 - Mask interval lower bound(s) /[0.4999999,0,-1.998481,-1.998484,0,-1.998479]/ > 500
 MASK2 - Mask interval upper bound(s) 
 /[1023.5,4.3240165E-34,-1.998484,-1.998479,1.4012985E-45,1.4012985E-45]/ > 600

 Input NDF:  /export/data/cdavis/UistSpecDemo/yleft
 Varuse parameter:             F
 No. of data points:        1024
 No. of mask intervals:        1
 No. of valid data points:   100
 Mask:
    500.0000       600.0000
 Actual abscissa range:
    500.5000       599.5000

 REMASK - Improve mask intervals /NO/ > 
 NCOMP - Number of components /1/ > 
 CONT - Continuum level /0/ > 
 CENTRE - Gauss positions /545/ > 
 PEAK - Gauss heights /800/ > 
 FWHM - Gauss widths (FWHM) /10/ > 6
 CF - Fit flags for line centres /[0,0,0,0,0,0]/ > 
 PF - Fit flags for line peaks /[0,0,0,0,0,0]/ > 
 WF - Fit flags for line widths /[0,0,0,0,0,0]/ > 

 Input NDF:  /export/data/cdavis/UistSpecDemo/yleft
 Varuse parameter:             F
 No. of data points:        1024
 No. of mask intervals:        1
 No. of valid data points:   100
 Mask:
    500.0000       600.0000
 Actual abscissa range:
    500.5000       599.5000
 Accepted continuum:          0.000000
 No. of Gauss components:      1
 Fit flags:
 #   centre    peak    FWHM
 1       0       0       0
 List of free parameters:
  1 Centre #1
  2   Peak #1
  3   FWHM #1
 Gauss components:
  #   centre pos.    peak height       FWHM       line integral
  1     545.0000       800.0000       6.000000       5109.441
 +/-    0.000000       0.000000       0.000000       0.000000
 Degrees of freedom:          97
 rms:                         41.97770

 REGUESS - Improve component guesses /NO/ > 
 REMASK - Improve mask intervals /NO/ > 
 FITGOOD - Fit acceptable /YES/ > 
 COMP - Component numbers for storage /[1,2,3,4,5,6]/ > 
 Used component # 1 to store results.
 !! DAT_PUT: Error writing value(s) to an HDS primitive.
 !  Application exit status DAT__DIMIN, Dimensions invalid



**
**
**  You know have arc, standard and source spectral images
**  that have been corrected for s-distortion.
**
**


	........................................................


CORRECT DISTORTION ALONG ARC LINES AND WAVELENGTH CALIBRATE 
===========================================================

If you have cross-dispersed data, you probably have to "cut out"
the different orders, so that you have a "mini spectral image" for 
each order.  To do this, use

 > ndfcopy 

For non-cross-dispersed data, the above won't be necessary...

To correct for sloping arc/sky lines and wavelength calibrate the
grouped spectral images (after sdist/cdist), firstly extract a 1-D
spectrum from the arc image (or from a raw image if using sky lines,
though make sure the raw image has been sdist/cdist like the science
data and standard star spec image - using the same sdist.dat file):

 > extract
 IMAGE - (IMage) name of image to extract data from /@iras20000/ > arc_cdist
 YSTART - (YStart) first y-value to be used /113/ > 91
 YEND - (YEnd) last y-value to be used /119/ > 93
 SPECTRUM - (SPectrum) name of spec to be generated /@iras20000_cal/ > argspec

Next use the "arc" routine to identify the arc lines.  Click on each line
and enter the wavelength (in microns) followed by an "e".  Move
spectrum along with "n"; use "q" once all lines are labeled.  The fit
to these lines will be written to an ascii file, "arclines.lis".
Also, an output file (a 1-D spectrum) will be plotted (in this
case, called "argcal") that can be viewed with splot.  Note; if you've
just done a similar arc, set PREVIOUS to true and it will pick up
identifications from these data.  Otherwise, for a new arc, PREVIOUS =
FALSE.

 > arc
 SPECTRUM - (SPectrum) Arc spectrum to be fitted /@argarc/ > argspec
 ARCTYPE - (ARctype) Type of arc /'argon'/ > 
 Reading lines from /star/etc/figaro/argon.arc
 PREVIOUS - (PREvious) Use arc lines from previous fit? /FALSE/ > true
 ARFILE - (ARFile) Name of file giving previous fit /'arlines.lis'/ > 
 ORDER - (ORder) Polynomial order for 1st fit /3/ > 
 SIGMA - (SIgma) Arc line half width in pixels /3/ > 
 Use cursor to select an arc line
 ...
 WAVELEN - Wavelength, blank to cancel line /''/ > 2.38515 e
 Wavelength is 2.38515 OK?
 LINEOK - Correct? /YES/ > 
 RMS now =  2.25E-4 Order of fit = 2
 Use cursor to select an arc line
 Line at pixel 428.9 (fit:  2.396955) (interp:  2.396725)
 WAVELEN - Wavelength, blank to cancel line /''/ > 2.39713 e
 Wavelength is 2.39713 OK?
 LINEOK - Correct? /YES/ > 
 RMS now =  2.17E-4 Order of fit = 2
 Use cursor to select an arc line
 QUITSEL - Quit line selection /YES/ > 
 CMD - Fit,Order,Disp,Help,Edit,Reselect,Quit,Print,Auto,Xauto,Modify /''/ > d

  2nd order polynomial fit

Coefficients of fit are -

 -1.82364E-09  1.25096E-03  1.86088E+00

Mean dispersion    =    0.00 microns/channel
Start wavelength   =    1.86 microns
End wavelength     =    2.50 microns
Central wavelength =    2.18 microns
           Line    Wavelength  Calculated Discrepancy    RMS if
                               Wavelength                omitted

   1      96.914       1.982       1.982       0.000     0.000
   2     108.868       1.997       1.997       0.000     0.000
   3     137.106       2.032       2.032       0.000     0.000
   4     161.116       2.062       2.062       0.000     0.000
   5     190.721       2.099       2.099       0.000     0.000
   6     234.567       2.154       2.154       0.000     0.000
   7     277.485       2.208       2.208       0.000     0.000
   8     362.282       2.314       2.314       0.000     0.000
   9     419.560       2.385       2.385       0.000     0.000
  10     428.871       2.397       2.397       0.000     0.000

RMS error:      0.000

 CMD - Fit,Order,Disp,Help,Edit,Reselect,Quit,Print,Auto,Xauto,Modify /''/ > d

 CMD - Fit,Order,Disp,Help,Edit,Reselect,Quit,Print,Auto,Xauto,Modify /''/ > o
 ORDER - (ORder) Polynomial order for 1st fit /2/ > 3

 CMD - Fit,Order,Disp,Help,Edit,Reselect,Quit,Print,Auto,Xauto,Modify /''/ > d

 CMD - Fit,Order,Disp,Help,Edit,Reselect,Quit,Print,Auto,Xauto,Modify /''/ > q
 WRITEARC - Create and output file using this fit /YES/ > 
 OUTPUT - (OUtput) Resulting arc file with wavelength fit /@argcal/ > argcal
 HARDARC - Do a hard plot of the arc /NO/ > 
 HARDISP - Do a hard plot of the dispersion curve /NO/ > 

 Details of fit output to /home/guest04/data/19990718/rgdir/arlines.lis


Now use "iarc" to fit arc lines to the other rows in the arc image
"arc_cdist".  The routine works from the central row outward; 92 is the
centre row in this case.  The results are written to a text file,
"argarc.iar" which is later used by "iscrunch" to correct the
science target and standard star spectral images.

 > iarc
 IMAGE - (IMage) Image containing 2D arc to be fitted /@argarc/ > arc_cdist
 RSTART - (RSTart) Central row at which to start fit /92/ > 
 RWIDTH - (RWidth) Number of rows to sum for each fit /1/ > 
 FILE - (FIle) Text file used for results /'argarc.iar'/ > 
 LOCK - (LOck) Automatic search for lines to help lock fit? /FALSE/ > 
 XCORR - (XCorr) Analyse successive spectra for shifts? /FALSE/ > 

...
Row 46 Lines fitted:   9, Order of fit:  3 RMS:      0.00
Row 45 Lines fitted:   9, Order of fit:  3 RMS:      0.00
...

Now use HDSTRACE on the 1-D spectrum produced by "arc" to get the
wavelength value of the first and last x-axis bin (column) to be used
in "iscrunch".  Also note the data size:


 > hdstrace argcal

    DATA(514)      <_REAL>         1.874811,1.87601,1.877208,
                                        ... 2.487228,2.488426,2.489625

Run iscrunch on the arc spectral image to see how good a job it does.
Are the arc lines straight?  Are their wavelengths correct?

 > iscrunch
 IMAGE - (IMage) Image to be scrunched /@argarc/ > arc_cdist
 FILE - (FIle) File containing results of 2D arc fit /' '/> argarc.iar
 BINS - (BIns) Number of bins for scrunched image /514/ > 
 LOG - (LOg) Bin into logarithmic wavelength bins? /FALSE/ > 
 WSTART - (WStart) Wavelength of center of first bin /1.8/ > 1.874811
 WEND - (WEnd) Wavelength of center of last bin (or increment) /2.5/ > 2.489625

 Data is in units of A/D numbers per exposure

 DENSITY - (DENsity) Treat data as flux per unit wavelength? /FALSE/ > 
 QUAD - (Quad) Use quadratic interpolation for data? /TRUE/ > 
 OUTPUT - (OUtput) Name of resulting scrunched image /@rg289_scr/ > arc_scr

You can view the scrunched arc spectral image with Gaia, or use
xstract (like ystract above) with fitgauss to look at horitontal cuts
made across the top, middle and bottom of the arc's spectral image.
Are the wavelengths of the arc lines in the scrunched spectral images
good?.

Finally, if the scrunching is working ok, "iscrunch" the standard star
and science target spectral images using the same argarc.iar as the
reference.

 > iscrunch
 IMAGE - (IMage) Image to be scrunched /@argarc/ > std_cdist
 FILE - (FIle) File containing results of 2D arc fit /' '/> argarc.iar
 ...
 OUTPUT - (OUtput) Name of resulting scrunched image /@rg289_scr/ > std_scr 

Or, because everything remains the same for each file, the following
which uses the previous input values can be used:

 > iscrunch IMAGE=star_cdist OUTPUT=star_scr \\



 *** You now have a flat-fielded, wavelength-calibrated, sky-subtracted
 *** spectral image for the target AND for the standard star.  
 *** All that's left to do now is correct for atmospheric
 *** absorption and (simultaneously) flux-calibrate by dividing
 *** the later into the former.  You can do this either for 
 *** an extracted spectrum or for the whole spectral image of
 *** the science target.


	........................................................


PREPARING THE STANDARD SPECTRA
==============================

If you just want to extract a single spectrum from the reduced/group
spectral image, and flux calibrate and correct this for telluric
absorption, then follow the steps below, under "Extracting Standard
Star Spectrum", then "Extracting the Target spectrum".  However, if
you want to produce a flux-calibrated spectral image (for, e.g. a
publishable P-V diagram), look under "Flux Calibrating a Spectral
Image".


Extracting Standard Star Spectrum
---------------------------------

For a compact/point source, optimal extraction is often preferable
over simply adding up 3 or 4 rows from the spectral image. Optimal
extraction is used for the standard star:

Use "profile/optextract" to fit and extract the +ve and -ve beams of
the standard (assuming you slid it up and down the slit) and combine
these:

 > profile
 IMAGE - (IMage) The input 2D data /@P/ > rg121_scr
 YSTART - (YStart) Y start for window /124/ > 95
 YEND - (YEnd) Y end for window /128/ > 97
 DEGREE - (DEGree) Degree of polynomial /5/ > 
 NREJECT - (NREJect) Number of points to reject /5/ > 
 PROFILE - (PROFile) Name of resulting profile image /@neg/ > pos
 RESIDUAL - (RESIDual) Name of image containing residuals /@junk/ > 

 > profile
 IMAGE - (IMage) The input 2D data /@rg121_scr/ > rg121_scr
 YSTART - (YStart) Y start for window /95/ > 125
 YEND - (YEnd) Y end for window /97/ > 127
 DEGREE - (DEGree) Degree of polynomial /5/ > 
 NREJECT - (NREJect) Number of points to reject /5/ > 
 PROFILE - (PROFile) Name of resulting profile image /@pos/ > neg
 RESIDUAL - (RESIDual) Name of image containing residuals /@junk/ >

 > optextract
 IMAGE - (IMage) The 2D data to be reduced to a spectrum /@rg121_scr/ > 
 PROFILE - (PROFile) The normalized spatial profile /@neg/ > pos
 SPECTRUM - (SPectrum) Name of resulting spectrum /@crl_jet_sw_cal3/ > P

 > optextract
 IMAGE - (IMage) The 2D data to be reduced to a spectrum /@rg121_scr/ > 
 PROFILE - (PROFile) The normalized spatial profile /@pos/ > neg
 SPECTRUM - (SPectrum) Name of resulting spectrum /@P/ > N

Combine the extracted spectra by subtracting the -ve (N) beam from +ve (P):

 > isub
 IMAGE - (IMage) Name of first image /@rg121_scr/ > P
 IMAGE1 - (IMAGE1) Name of second image /@N/ > N
 OUTPUT - (OUTput) Name of resulting image /@crl_jet_sw3/ > bs8170_121

Display on xw or graphics display

 > soft xw   (may not ne needed)
 > splot
 SPECTRUM - (SPectrum) Spectrum to be plotted /@N/ > bs8170_121
 WHOLE - (WHole) Plot all of spectrum? /TRUE/ > 
 AUTOSCALE - (AUtoscale) Scale so all of spectrum fits? /TRUE/ > 
 LABEL - (LABel) Label for plot /'CRL2688 Jet SW3'/ > Standard
 HARDCOPY - (HArdcopy) Produce plot as a hard copy? /TRUE/ > false

You can deriple (irflat) and remove BrGamma spike (isedit) from the standard
if necessary.

 > irflat
 SPECTRUM - (SPectrum) Spectrum containing  data /@bs8170_121/ > 
 !! DSA_SPECIFIC_STRUCTURE: Error trying to access the specific structure
 !     SPECT.MORE.FIGARO.MORE. The structure does not exist.
 PERIOD - (PERiod) Period of Ripple (pixels) /2/ > 
 OUTPUT - (OUTput) Name of resulting ripple spectrum /@RIP/ > RIP
 Input spectrum name is /home/guest04/data/19990717/rgdir/bs8170_121
 Output will be written to /home/guest04/data/19990717/rgdir/RIP
 Select Regions to be used to generate flat field spectrum
 XSTART - (XStart) Start X value of region /1.9/ > 1.9 
 XEND - (XEnd) End X value of region /2.5/ > 2.5
 MORE - (MORE) Include additional ranges? /FALSE/ > 
 1            1.000269
 2            0.9997311

 > idiv bs8170_121 RIP test
 > splot test \\

 > isedit
 IMAGE - (IMage) The 1D or 2D data /@bs8170_121/ > test
 OUTPUT - (OUTput) Name of resulting edited data /@bs8170_211e/ > bs8170_121e
 WHOLE - (WHole) Plot all of spectrum? /TRUE/ > 
 D - Delete Point
 H - Type this list of commands
 I - Interpolate Between Two Data Points
 J - Interpolate Between Two Indicated Points
 M - Move Point
 R - Redraw Plot
 S - Delete This Scan
 Q - Quit
 Y - Plot a different Y value
 Indicate Second Point and Hit any Key

Click on the spectrum; use "I" twice to mark left and right side of
the BrG line, then "Q" and the line will be masked out.

Now you can use "bs8170_121e", the reduced standard star spectrum, to
flux calibrated extracted target spectra (or the whole spectral image
if need be - see later)


Extracting the Target spectrum:
-------------------------------

You have two choices; either 1) optimal extraction as above, or, if an
extended object 2) extract and average rows over a given range.  For
the former, the spectrum must be confined to a few rows, i.e. like a
point-source spectrum (like the standard).  The example below assumes
an extended source, though one which is nevertheless slid up and down
the slit (so positive and negative beams appear on the group spectral
image).


 > extract
 IMAGE - (IMage) name of image to extract data from /@P/ > rg169_scr
 YSTART - (YStart) first y-value to be used /132/ > 83
 YEND - (YEnd) last y-value to be used /137/ > 89
 SPECTRUM - (SPectrum) name of spectrum to be generated /@crl_disk_e_cal/ > P

 > extract
 IMAGE - (IMage) name of image to extract data from /@rg169_scr/ > 
 YSTART - (YStart) first y-value to be used /83/ > 113
 YEND - (YEnd) last y-value to be used /89/ > 119
 SPECTRUM - (SPectrum) name of spectrum to be generated /@P/ > N

 > isub
 IMAGE - (IMage) Name of first image /@rg169_scr/ > P
 IMAGE1 - (IMAGE1) Name of second image /@N/ > N
 OUTPUT - (OUTput) Name of resulting image /@crl_disk_e/ > crl_disk_w


Now flux calibrate and divide out atmospheric effects using IRFLUX:

 > irflux
 SPECTRUM - (SPectrum) Name of Source spectrum /@N/ > crl_disk_w
 STANDARD - (STandard) Name of Standard spectrum /@bs8170_211e/ > 
 TEMP - (TEMP) Temperature of standard /6200/ > 
 Standard name given as bs8170
 Unable to find an entry for BS8170
 in file /star/etc/figaro/kmags.dat
 CALTYPE - (CALtype) Type of calibration data /'K'/ > 
 MAG - (MAG) magnitude of standard star /5.05/ > 
 OUTPUT - (OUTput) Name of resulting spectrum /@crl_disk_e_cal/> crl_disk_w_cal

The resulting, reduced spectrum can again be displayed with splot, and
a hardcopy (postscript file) saved to disk, e.g.:
 
 > splot
 SPECTRUM - (SPectrum) Spectrum to be plotted /@crl_disk_w_cal/ > 
 WHOLE - (WHole) Plot all of spectrum? /TRUE/ > 
 AUTOSCALE - (AUtoscale) Scale so all of spectrum fits? /FALSE/ > 
 HIGH - (HIgh) Maximum data value to be plotted /500/ > 
 LOW - (LOw) Minimum data value to be plotted /0/ > 
 BIAS - (BIas) Bias value to be added to data /0/ > 
 LABEL - (LABel) Label for plot /'crl2688 disk W'/ > 
 HARDCOPY - (HArdcopy) Produce plot as a hard copy? /FALSE/ > true
 HARD /''/ > ps_l

 > mv gks74.ps crl_disk_w.ps
 > lp -dhp2 crl_disk_w.ps


Flux Calibrating a Spectral Image
---------------------------------

To flux calibrate a whole spectral image, optimally extract the standard star
spectrum as described above, divide this by a blackbody (that has been
normalised at a reference wavelength), and "grow" this into a 2-D image.  This
can then be used for flux calibration and telluric correction for the whole
image.  Basically, you must divide the group spectral image of the target by
the spectral image "grown" out of the standard Star spectrum.

Here we assume that the optimally extracted standard spectrum is called
"bs8170spec"

First, create a blackbody spectrum with "bbdoy" for the same temperature as the
standard.  bs8170 is a G2V star (mag 6.7) so its temp is 6500K

 > bbody -> bbspec...

normalise this bb function so that the counts are 1 at a reference wavelength,
say 2.2 microns.  Splot "bbspec" and use ICUR to measure the flux at
2.2microns.  Say the counts are 2000...

 > idiv bbspec 2000 bbspec_norm

Now divide out the BB function associated with the standard star spectrum:

 > idiv bs8170spec bbspec_norm bs8170spec_bb

Next, make an "image" from this spectrum.  The image MUST be the same size as
the image of the target (probably 1024 rows).

 > growx
 SPECTRUM - (SPectrum) Spectrum to be "grown" into image /@starspec/ > bs8170spec_bb
 NEW - (NEw) Force creation of a new image? /TRUE/ > 
 IMAGE - (IMage) Image to grow spectrum into /@hh72/ > bs8170im
 YSTART - (YStart) First cross-section to copy spectrum into /1/ > 
 YEND - (YEnd) Last cross-section to copy spectrum into /178/ > 1024
 YSIZE - (YSIze) Y-dimension of new image /178/ > 1024

Finally, you can divide the "image" of the standard into the "image" of the
source and - viola - you've corrected for telluric absorption.  If, before you
do this, you scale the counts so that both the standard star spectrum and the
target image are in counts/second (i.e. divide by the exposure time), you can
use the known flux density of the standard (W/m2/micron, say, or mJy) to give a
meaningful flux scale across the corrected spectral image of the science
target.

The command "fwconv" can also be used to convert the flux to ergs, or Watts, if
need be...

Last updated Sep 2003.