;+
; NAME        : EIT_PA_VIEW
;
; PURPOSE     : No frills display of EIT image
;
; CATEGORY    :
;
; EXPLANATION : 
;
; SYNTAX      : 
;
; EXAMPLES    : none
; 
; CALLED BY   :
;
; CALLS TO    : none
;
; ARGUMENTS   :	none
;
; KEYWORDS    : none
;
; OUTPUTS     : none
;
; COMMON      : none
;
; RESTRICTIONS: none
;
; SIDE EFFECTS: none
;
; PROJECT     : SOHO - EIT
;
; HISTORY     : V1,  Elaine Einfalt (HSTX)
;
; CONTACT     : eit@xanado.nascom.nasa.gov
;-
pro eit_pa_view, cat_text, movie=movie

 lz_data = 0					; most likely raw data

 if not(movie) then begin	; view the single image clicked on by user

    ; Parse the cat string to get the filename
    loc = strpos(cat_text,'EFR')
    if loc eq -1 then begin
       loc = strpos(cat_text,'EFZ')		; must be LZ cat text
       lz_data = 1					; it's LZ data
    endif 
    if loc eq -1 then return			; impossible, but handle it

    ; Cut out the filename
    file = strmid(cat_text, loc, 18) 

    ; What color table should be used
    loc2 = strpos(cat_text,'::')-3		; wavelength is before the "::"
    wave = strmid(cat_text, loc2, 3)		; parse out wavelength

 endif else begin		; viewing a single frame from a restored movie

    ; parse to get movie file name
    loc = strpos(cat_text,'EMS')
    file = strtrim(strmid(cat_text, loc, 99),2)	; the ems movie filename

    ; parse to get wavelength
    loc = strpos(cat_text,'(')+1
    wave = strmid(cat_text, loc, 3)		; the wavelength

    ; parse to get the frame number
    loc = strpos(cat_text,':')
    frame = strmid(cat_text, 0, loc)


 endelse

 case wave of
      '171': i_wave=0
      '195': i_wave=1
      '284': i_wave=2
      '304': i_wave=3
      else : return				; yup, another impossible 
 endcase
 
 loadct, 42 + i_wave, file = getenv('coloreit')
 

 ; Where to find the data


 if (lz_data) then dir = 'LZ_ARCHIVE:' $
 else if (movie) then dir = 'MOVIE_DIR:' $
 else dir = 'REF_DIR:' 

 print, 'Reading file '+dir+file

 if not(movie) then begin	; read in and display individual fits file

    data = readfits(dir+file)
    window, xsiz=(size(data))(1), ysiz=(size(data))(2), $
   	    title=strmid(cat_text, 0, loc2+3)

    tv, bytscl(alog10((data-850)>1.))

 endif else begin		; restore EMS movie and show single frame 

    restore, dir+file
    data = b0(*,*, frame)

    window, xsiz=(size(data))(1), ysiz=(size(data))(2), $
   	    title='Frame '+ strtrim(frame,2) + ' in ' + title

    tv, data    

    data = 0
    b0 = 0
 endelse

return
end
