function display_ovsamap,ovsa,index,refmap=refmap,color=color,offset=offset,no_offset=no_offset,_extra=_extra
  if valid_map(ovsa) then goto, validmap
  if file_exist(ovsa) then goto, validfile
  ovsa = dialog_pickfile(filter='*.f*')
  if (ovsa eq '') then return,0
  validfile:
  ovsa = wimagr_fits2map(ovsa,header,_extra=_extra)
  ; Create the map object from the file, and also get header
  validmap:
  if keyword_set(offset) then begin
     if tag_exist(ovsa,'offset') and tag_exist(ovsa,'off') then begin
       if ovsa.off eq 1 then begin
         ovsa.xc=ovsa.xc-ovsa.offset[0]
         ovsa.yc=ovsa.yc-ovsa.offset[1]
         ovsa.off=0b
       endif
        ovsa.offset=offset
        ovsa.xc=ovsa.xc+ovsa.offset[0]
        ovsa.yc=ovsa.yc+ovsa.offset[1]
        ovsa.off=1b   
     endif
  endif
  if keyword_set(no_offset) then begin
    if tag_exist(ovsa,'offset') and tag_exist(ovsa,'off') then begin
     if ovsa.off eq 1 then begin
      ovsa.xc=ovsa.xc-ovsa.offset[0]
      ovsa.yc=ovsa.yc-ovsa.offset[1]
      ovsa.off=0b
     endif
    endif
    if valid_map(refmap) then begin
      if tag_exist(refmap,'offset') and tag_exist(refmap,'off') then begin
        if refmap.off eq 1 then begin
          refmap.xc=refmap.xc-refmap.offset[0]
          refmap.yc=refmap.yc-refmap.offset[1]
          refmap.off=0b
        endif
      endif
    end
  endif
  if ~keyword_set(_extra) then _extra={grid:10,levels:[10,30,50,70,90,99],percent:1}
  if ~tag_exist(_extra,'grid') then _extra=create_struct(_extra,'grid',10)
  if ~tag_exist(_extra,'levels') then _extra=create_struct(_extra,'levels',[30,50,70,90,99])
  if ~tag_exist(_extra,'percent') then _extra=create_struct(_extra,'percent',1)
  
  
  if n_elements(color) eq 0 then color=255
  if (valid_map(refmap)) then begin
     plot_map,refmap,_extra=_extra
     ;plot_map,drot_map(ovsa,time=refmap.time,/keep_limb),/over,color=color,_extra=_extra
     plot_map,ovsa,index,/over,color=color,_extra=_extra
  endif else begin
     ; Plot the map and solar grid lines
     plot_map,ovsa,index,_extra=_extra
  endelse

;  ; Read info from the header to display the 1/2 power beamsize
;  a = sxpar(header,'BMAJ')*sqrt(alog(2.))  ; Semi-major half-power axis
;  b = sxpar(header,'BMIN')*sqrt(alog(2.))  ; Semi-minor half-power axis
;  phi = sxpar(header,'BPOS')               ; Position angle of major axis
;  solp = sxpar(header,'SOLP')              ; Solar P angle
;  ; Correct angle for solar P angle (since image is rotated by P angle)
;  phi = (phi - solp)*!dtor

;The beam information is now added to ovsa structue by ovsa2map, so no need to recalculate it 
  a=ovsa.a
  b=ovsa.b
  phi=ovsa.phi

  ; Make an array from 0 to 2pi, in 1 degree increments
  th = findgen(361)*!dtor

  ; Create x and y values for unrotated ellipse
  x = a*cos(th)
  y = b*sin(th)
  ; Rotate ellipse to correct angle
  xp = x*cos(phi) - y*sin(phi)
  yp = x*sin(phi) + y*cos(phi)

  ; Draw beam ellipse in upper-left corner
  oplot,!x.crange[0]+xp+2*max(xp),!y.crange[1]+yp-2*max(yp),color=255,linesty=2

return,ovsa
en