PROGRAM BSDCAL
                                                      v1.1   December 1992

 BSDCAL is part of a suite of programs written to analyse data produced 
 by the BCS (Bragg Crystal Spectrometer) experiment on board the 
 Japanese satellite, YohKoh.

 This program is designed to 'calibrate' the data in the BSD files. These
 contain spectra which have been corrected for instrumental effects and have
 been integrated for a specified period. The wavelengths of these spectra will
 be offset by an amount WO due to the offset of the flare from the centre 
 of the Sun, and also due to the offset of the spacecraft pointing from 
 Sun centre. BSDCAL determines WO, together with DW, the dispersion,  and also
 provides initial guesses for subsequent fitting of the spectra.

 The BSD file is optionally updated, applying corrections for WO and DW.

 The BCS data may consist of up to four channels, one for each of the 
 four spectra: 
               Fe XXVI - ch 1;
               Fe XXV  - ch 2;
               Ca XIX  - ch 3;
               S XV    - ch 4.

 For each channel, specific lines in the spectrum will be fitted using 
 a Voigt profile, to determine width, intensity and position. WO 
 and DW may be calculated from the positions, knowing the expected 
 wavelengths from atomic theory. Alternatively, they may be calculated 
 using the flare offset (observed by the SXT instrument on Solar-A) and 
 the spacecraft pointing information.

 An option is included to fit the resonance (w) line of the spectra with 
 two components to determine 'blue-shifts', which yield the velocity of
 upflowing plasma associated with the flare.



To run BSDCAL, simply type:

                      BSDCAL



A control file is used to provide all the steering information to the program.
This will be requested by the program. If running in batch mode, provide the
control file name after the call to BSDCAL.

If you do not already have a control file simply press return and you will
enter the "SETUP" mode and will be able to build your control file 
interactively. You do not need a template file because defaults are set
within the program. However if you have a control file that you want to
alter slightly you may do so by using the "r" option to read it in.

There is an interactive help system - just type "h" followed by the code
that you want to know about. Some useful ones to look at at first are
"h o" within the "fm" (fit menu), which will describe what lines or groups 
of lines may be fitted and how to select them. Also "h lm" (the link menu)
will tell you what linking lines means and how to do it. The defaults give
you sensible linkages (e.g. if more than one line is fitted the widths are
linked so that they are always equal) so you dont need to set these usually.


You may run the program from any directory, with the data file in any directory,
and the control file may also be anywhere as long as you specify where when you
give the name of the file. 

Output (other than control files that you create):

   This will be in the directory which you are running from. There will be a 
BSDCAL.MON file which is the monitor file for the job. There will be a
BPC..... file containing the results and a number of VFIT*.PLT files if you
have specified plot o/p. The data file will be modified if you specify .true.
in the update line. There will NOT be a copy of the previous BSD file if you
do this. If you want, copy it first.

   To improve portability the monitor file and BPC... files may also be
overwritten if you repeat a run of BSDCAL so if you want to preserve them
rename them before running again.

The results may be plotted using the idl procedure PLOTBPC. Just type PLOTBPC
and respond to the prompts.

TROUBLE-SHOOTING

If the program does not terminate as expected, have a look at the end of
the BSDCAL.MON file. There may be an error message there. It will also give
some idea of the progress of the fit. If you run with the plot o/p option
specified then you will be able to use the IDL routines PLOTIT and PLOTRES
to monitor the progress of the fit. They show the iterations. If the range
over which the fit is done does not look right you may adjust this in the
control file using the fit-range option. This can make a lot of difference.
It may just be that it is converging slowly and ran out of iterations, so
try increasing the maximum iterations set in the control file.

If all else fails, send me a mail message (RLSAC::BJIB) with a copy of the
control file so that I can try to help.

B.Bromage  6.1.93.