;+
; Project     : SOHO - CDS     
;                   
; Name        : SAVE_WAVECAL()
;               
; Purpose     : Returns wavecal from common block for temporary storage
;               
; Explanation : In some circumstances a routine may wish to temporarily load
;               a wavecal into the wavecal common block and to restore the
;               original calibration when it has finished.  This function
;               retrieves the common block entries.  Use LOAD_WAVECAL with
;               the cal_struct keyword for the reverse process.
;               
; Use         : IDL> wcal = save_wavecal(detector)
;    
; Inputs      : detector  - either 'NIS' or 'GIS' (can be abbreviated)
;              
;               
; Opt. Inputs : None
;               
; Outputs     : Function returns either NIS or GIS wavecal structure from
;               common block.
;               
; Opt. Outputs: None
;               
; Keywords    : None
;
; Calls       : None
;
; Common      : CDS_WAVECAL
;               
; Restrictions: None
;               
; Side effects: None
;               
; Category    : Data analysis, wavelength calibration
;               
; Prev. Hist. : None
;
; Written     : C D Pike, RAL, 14-Mar-96
;               
; Modified    : 
;
; Version     : Version 1, 14-Mar-96
;-            

function save_wavecal, detector

common cds_wavecal, ncoff, gcoff


;
;  check input
;
if n_params() eq 0 then begin
   print,'Use:  IDL> wcal = save_wavecal(detector)
   return,-1
endif

;
;  check detector 
;
det = strupcase(strmid(detector,0,1))
case det of
     'G': if datatype(gcoff) eq 'STC' then return,gcoff else return,-1
     'N': if datatype(ncoff) eq 'STC' then return,ncoff else return,-1
    else: begin
             print,'Error in detector specification'
             return,-1
          end
endcase
end
