; NAME:
;
;       getmaskname.pro (version 1.0)
;
; PURPOSE:
;
;  This procedure checks for the existence of a good pixel file in
;  specified directories. If the file exists, it returns the
;  filename. If the file does not exist, it returns an empty string.
;     
;
; CALLING SEQUENCE (all procedures):
;
;  maskName = getmaskname(scaName)
;
; INPUTS (all procedures)
;
;  scaName       - A valid IDTL SCA name. For example, H2RG-002-5.0mu.
;
; KEYWORD PARAMETERS:
;
;  help          - Print a help message and exit
;
; EXAMPLES:
;
;  Get a good pixel mask reference for detector H2RG-002-5.0mu
;  IDL> goodMask = getmaskname('H2RG-002-5.0mu')
;
; REFERENCE:
;
;
; MODIFICATION HISTORY:
;       Written by:  B.J. Rauscher, Evil Empire, 30 April 2003
;-


function getmaskname, scaName, help=help

       ;; Set constants.
       ;; 
       ;; Define the mask path. Remember, you will have to do this for each machine that
       ;; the procedure runs on.
       MASK_PATH = '/data/skunk1/idtl/idl/masks/'
       ;;MASK_PATH = '/carthage/data1/idl/masks/'

       ;; Answer requests for help
       if (keyword_set(help)) then $
         stop, 'Usage: fileName = getmaskname(scaName [, /help])'

       ;; Search for a good pixel mask.This is by definiton the
       ;; scaName plus the suffix .gpx.fits

       fileName = strmid(scaName, 0, strpos(scaName, 'mu', /REVERSE_SEARCH))+'mu.gpx.fits'
       if (file_test(MASK_PATH+fileName)) then begin

           ;; If file exists, return the full name including path
           return, MASK_PATH+fileName

       endif else begin

           ;; If file does not exist, return an empty string
           return, ''

       endelse

end
