pro plot_gsn, infil, hc=hc, gsn_head=gsn_head, tit=tit, gif_file=gif_file
;+
;NAME:
;	plot_gsn
;PURPOSE:
;	To plot the active region information in the SOON observing log files
;SAMPLE CALLING SEQUENCE:
;	plot_gsn,'/ydb/gsn/sth940517.cat'
;	plot_gsn,'/ydb/gsn/sth940517.cat', /hc
;       plot_gsn,'/ydb/gsn/sth940517.cat',gif_file="soon_out.gif"
;INPUT:
;	infil	- the input file
;OPTIONAL KEYWORD INPUT:
;	hc	 - If set, send the output to the printer
;       gif_file - plot results to named gif file
; 
;HISTORY:
;	Written 28-Jul-94 by M.Morrison
;	 5-Aug-94 (MDM) - Allow header to be passed in
;       14-jul-95 (SLF) - add gif_file keyword
;-
;
progver = 'PLOT_GSN  Ver 2.0'
;
lun = -1
gif=data_chk(gif_file,/string)		; gif file name supplied?

if (keyword_set(hc)) then begin
    save_dev = !d.name
    set_plot, 'ps
    device, /land
end
;
if gif then begin
   save_dev=!d.name
   wdef,zz,420,420,/zbuffer		; plot to zbuffer
endif
;
rad = 15.75	;arcminute diameter
xcir = cos(2*!pi*findgen(400)/399)
ycir = sin(2*!pi*findgen(400)/399)

if (not keyword_set(gsn_head)) then begin
    nfil = n_elements(infil)
    rd_gsn, infil, head, obs, imap
    rd_fheader, infil, fheader

    sttim = fmt_tim(anytim2ints([fheader(0).first_time, fheader(0).first_day]))
    entim = fmt_tim(anytim2ints([fheader(nfil-1).last_time, fheader(nfil-1).last_day]))
  
    if (nfil eq 1) then tit = 'SOON/SPOT data for ' + infil + '!c' + sttim + ' to ' + entim $
		else tit = 'SOON/SPOT data for ' + strtrim(nfil,2) + ' files !c' + sttim + ' to ' + entim
end else begin
    head = gsn_head
    if (n_elements(tit) eq 0) then tit = 'SOON/SPOT Data'
end
;
xtitle = 'Arcminutes from Sun Center'

if (!d.name eq 'X') and (!d.window eq -1) then window	;have to create window first
dev = !d.name
set_plot, 'null
plot, xcir*rad, ycir*rad, xrange=[-25,25], yrange=[-25,25], xstyle=1, ystyle=1, xtitle=xtitle, tit=tit
set_plot, dev
mk_square2
plot, xcir*rad, ycir*rad, xrange=[-25,25], yrange=[-25,25], xstyle=1, ystyle=1, xtitle=xtitle, tit=tit
if (!d.name eq 'X') then wshow
;
for i=0,n_elements(head)-1 do begin
    p = head(i)
    xc = p.location(0)/10./60.
    yc = p.location(1)/10./60.
    xsiz = (float(p.image_shape(0)) * p.pix_siz(0)/1000.)/60.
    ysiz = (float(p.image_shape(1)) * p.pix_siz(1)/1000.)/60.
    draw_boxcensiz, xc, yc, xsiz, ysiz, /data
    ;print, xc, yc, xsiz, ysiz
    x0 = xc - xsiz/2
    y0 = yc - ysiz/2
    object = string(p.st$object)
    if (strmid(object, 0, 4) ne '9999') then xyouts, x0, y0, object
end
;
plottime, 0, 0, progver
plottime
if (!d.name eq 'PS') then pprint

if gif then begin
   loadct,0      
   tvlct,r,g,b,/get
   plotimg=tvrd()
   write_gif,gif_file,plotimg,r,g,b
endif

if (keyword_set(save_dev)) then set_plot, save_dev
end
