Identifier   dark
 
 Purpose      subtract dark current from data 
 
 Synopsis     out_spd = dark( in_spd [,darktable=darktable] 
                              [, CAL21_1=cal21_1] [, CAL21_2=cal21_2]
                              [, CAL21_4=cal21_4] [, CAL21_8=cal21_8]
                              [, /noclearbuffer]  [,/fortran] )
 
 Arguments    Name    I/O   Type:    Description:
              --------------------------------------------------------
              out_spd   O    struct   Name of output SPD in IDL format.
              in_spd    I    struct   Name of input SPD in IDL format
              darktable I    string   Name of dark current TA file
              cal21_x   I    string   Selected calfile 21_x, where x=1,2,4,8
                                      If this is not supplied calfile 21_x from
                                      the default calfile directory is used.
              /noclearbuffer
                        I     --      Do not clear the calfile buffer
                                      before setting any optional
                                      alternative calibration calfile
              /fortran  I    keyword  use fortran version

 Returns      an SPD struct.

 Description  This procedure calculates dark currents and subtracts them from
              the data, like it is done in the pipeline. The resulting SPD
              is returned.

              If the /noclearbuffer option is not given, the calfile
              buffer will be cleared upon entering DARK thus ensuring
              that the default set of calibration files will be used
              even in those cases where no calxx parameter is used.
 
 Comment      TA part not yet activated
 
 Example      spd2 = dark(spd1)
 
 Category     AA
 
 Filename     dark.pro (module: ias_dark)
 
 Author       K. Leech
 
 Version      2.1

 History      1.0 25-05-94 -->KL   First written
              1.1 07-07-94 -->GB   Changed into function; implemented.
              1.2 11-07-94 -->GB   Added optional keyword CAL21
              1.3 23-09-94 -->DRB  Flexible calfile access implemented
              1.4 03-10-94 -->DRB  Always clear the calbuffer unless
                                      told otherwise with /noclearbuffer
              1.5 10-03-95 --> HB  Unified Arguments
                  07-04-95 --> HB  Unified header
              1.6 13-09-95 --> FL  Added seperate keywords for CAL21_X
                                   typo in call to setup_cal removed
              1.7 21-11-96  --> BV   Timedependent calfile access
              2.0 03-12-97 --> EkW call IDL program
              2.1 20-01-98 --> EkW activate TA (SPR_S0314)
              2.2 21-01-98 --> EkW activate keywords spec by keyword S0319