pro getscatype, fitsHeader, scatype

      ;; NAME:
      ;;       pro getscatype.pro
      ;;
      ;; PURPOSE:
      ;;       This program searches IDTL FITS headers for the
      ;;       DETNAME keyword, extracts the sca type from the
      ;;       detector name, and returns its value in the string
      ;;       scatype.
      ;;
      ;; CALLING SEQUENCE:
      ;;       IDL> scatype = '' ; Declare an empty string to hold the result
      ;;       IDL> getscatype, fitsHeader, scatype
      ;;
      ;; INPUTS:
      ;;       fitsHeader - A valid fits header.
      ;;
      ;; KEYWORD PARAMETERS:
      ;;       none
      ;;
      ;;
      ;; EXAMPLE
      ;;
      ;;      getscatype, fitsHeader, scatype
      ;;
      ;;
      ;; REFERENCE:
      ;;
      ;;
      ;; MODIFICATION HISTORY:
      ;;       Written by:
      ;;       Modified:    B.J. Rauscher, IDTL, November 7, 2002
      ;;                    Initial release
      ;;-

      ;; get the detector name
      getdetname, fitsHeader, scatype

      ;; Parse the detector name for the SCA type. We assume that
      ;; detector names have the format H[???]-???-?.?mu and SB-???-?.?mu.

      if (strpos(scatype, 'H') eq 0) then begin
          ;; Detector is a Rockwell HAWAII family device
          scatype = strmid(scatype, 0, strpos(scatype, '-')) ; first '-' is field separator
      endif else begin
          if (strpos(scatype, 'SB') eq 0) then begin
              ;; Detector is a Raytheon SB family device.
              ;; Separator is second '-'
              scatype = strmid(scatype, 0, strpos(scatype, '-')) ; first '-' is field separator
          endif else begin
              ;; Detector family is unknown
              stop, 'GETSCATYPE ERROR: SCA Type is unknown'
          endelse
      endelse

end
