;+
; NAME:
;  inms_list_cal_species - lists species contained in calibration data structure
;
pro inms_list_cal_species,  axCal, debug=debug
;
; PURPOSE:
;   list the species for which calibration data is available
;
; USAGE:
;   inms_list_cal_species, axCal
;
; ARGUMENTS: 
;  axCal  - a calibration structure returned by inms_read_cal
;
; KEYWORDS:
;   debug       if set, diagnostic information is produced
;
; CHANGES
; 08-FEB-2005  DAG  Initial Coding
; 17-AUG-2005  DAG  Add molecular mass to output
; 20-Sep-2006  DAG  Use error handler and inms_post_message
;
;-
;==================================================================
;
  ;; establish error handler
  bDebugSw = keyword_set(debug)
  nError = 0
  catch, nError
  if nError ne 0 then begin
     catch, /cancel
     inms_post_message, traceback=bDebugSw, console=inms_is_image() or bDebugSW
     if bDebugSw then stop
     return
  endif 

  if inms_validate_cal_data(axCal) eq 1 then begin
     ;; argument is a valid calibration data structure

     asSpecies = sprl_create_list(axCal.sFormula)
     asSpecies = asSpecies[sort(asSpecies)]

     print,  'identifier', 'mass', 'species name', 'source', $
             format='(A, 2x, A, 2x, A, T45, A)'

     for nI=0, n_elements(asSpecies)-1 do begin
        anIdx = where(axCal.sFormula eq asSpecies[nI])
        asSource = sprl_create_list(axCal[anIdx].sSource)
        asName = axCal[anIdx[0]].sGas
        nMolWt = axCal[anidx[0]].nMolWT
        print, asSpecies[nI], nMolWt, asName, strjoin(asSource, ','), $
               format='(A10, 3x,I3,2x, A, T45, A)'
     endfor 
  endif else begin
     ;; argument is not a calibration structure
     message, 'input argument does not appear to be a calibration structure'
  endelse 
end
