How to Use the Spectroscopic Quick Tool

1). Open a MIDAS session in the wg5off machine :
                > inmidas

2). Create a catalogue of images you want to reduce.
Go to the directory where the data are.
                midas> cd /data/raw/YYYY-MM-DD
Create an image catalogue with the frames you want to reduce:
                midas> cre/icat target ONTT*.fits
Edit this catalogue using emacs or vi or whatever, and select only the files you needs, the object frames of one target.

3). Arc:  
If you have an arc corresponding to your data, good. For a simplier use you can rename it (ex: arc_B.fits). This file will be use for the
reduction, to do the wavelength calibration of the spectra.
If you don't have arcs, the procedure will go to look for one in the sofi database

4). Flats:
** If you don't have flat files: the procedure will go to find some in the sofi database.
** If you have reduced flats, you just have to use the name of the normalized flat (ex: flat_spectro.fits or flat_spectro.bdf).
** If you have the flat frames :
        - you can use the SOFI_spectroflat procedure to reduce them.
       - you can just create an image catalogue with the names of the frames,
                midas> cre/icat flat ONTT*.fits
Edit this catalogue and select the 4 frames corresponding to your set up.  This catalogue will be used as input for the spectroscopy reduction procedure.

5).  Standard star:
If you want to divide your data by a standard star, and if you have data of a standard star:
Reduce the standard star with the SOFI_spec_redu.prg procedure putting the last parameter equal to n (for none).
You will have output files corresponding to your reduced standard star : final_spectrum.tfits and final_spectrum.fits.
Rename them standard_spectrum.tfits and standard_spectrum.fits, and use the tfits file as input to the spectroscopy reduction procedure.

If you don't want to divide by a standard star, just use "n" as input.

6). Run the procedure :

               midas> @@ sofi_spec_redu  arc.fits  standard_spectrum.tfits
or           midas> SOFIRE/NTT arc.fits standard_spectrum.tfits

                midas> @@ sofi_spec_redu  arc.fits  flat_spectro.fits  standard_spectrum.tfits

If you don't want to divide by the standard star :
                midas> @@ sofi_spec_redu  arc.fits  n
If you don't have flat :
                midas> @@ sofi_spec_redu  arc.fits  n  n
If you don't have arc:
                midas> @@ sofi_spec_redu  n  n  n

Of course, you can combine any of these solutions.
At the end, you will have:

* final_sepctrum.fits and final_spectrum.bdf : the image of the final spectrum
* final_spectrum.tfits : the table of the final spectrum. That the useful file. This table can be read inside midas using the
command :
                midas> read/tab final_spectrum.tfits
You have 3 columns :
-- X_coordinate : wavelength
-- Extracted_spectr : Spectrum of your object
-- Sky_spectrum  : spectrum of the sky

You can plot the results using the plot/tab command:
                midas> plot/tab final_spectrum.tfits :X_coordinate :Extracted_spectr

[ In fact the result is automatically plotted inside the graphic window. ]

* final_spectrum_status.ascii : an ascii file with the log of the procedure.
* final_spectrum_aver_i : the images of the recombinations
* final_spectrum_diff_i : the images of the differences

In summary, the quick tool to reduce SOFI data does :

- prepare the frame to be treated by isaacp (some keywords are added, some are changed to be understandable by isaacp).
- calibration in wavelenght using isaacp wavecal over the arcs.
- division of the science images by the flat.
- run isaacp sw_spjitter to simply do the reduction ! for more information have a look onto the help of isaacp sw_spjitter.
- plot the final spectrum for verification.