pro pltconimage,cgm=cgm,ps=ps @pltdat.h ; ; Make generic rectangular image and/or contour plot: ; gencon = frame.zz ;xur = .95 & yur = .90 ;xll = .15 & yll = .25 xur = .95 & yur = .88 xll = .15 & yll = .23 if imcon ne 1 then yll = .30 if conimage.log10 gt 0 then log10f,gencon,frame.nx*frame.ny,1.e-20,!spval fminmax,gencon,frame.nx*frame.ny,rmin,rmax,!spval print,'contour: ',frame.hdr(0) print,'min,max=',rmin,rmax ; ; Set up contouring cmin,cmax,cint: ; if imcon gt 0 then begin prntcon = cont.prntcon if keyword_set(cgm) or keyword_set(ps) then prntcon = 0 levels = conspec(gencon,cont.cmin,cont.cmax,cont.cint,cont.nlev,$ prntcon) cont.nlev = n_elements(levels) if cont.nlev le 1 then begin if cont.nlev le 0 then $ print,'>>> pltconimage: no data (array all special value) -- no frame made' if cont.nlev eq 1 then $ print,'>>> pltconimage: only one contour level -- no frame made' return endif ; ; clabels(cont.nlev) (c_labels) = int flag for whether or not to label ; contour line ; clines(cont.nlev) (c_linestyle) = int flag for linestyles ; (0=solid, 2=dashed) ; dashneg = 1 clabels = intarr(cont.nlev) clines = intarr(cont.nlev) ; default to solid lines (all 0's) for i=0,cont.nlev-1 do begin if cont.nthlab le 0 then clabels(i) = 0 else $ if cont.nthlab eq 1 then clabels(i) = 1 else $ if i mod cont.nthlab eq 0 then clabels(i)=1 else clabels(i)=0 if dashneg then begin clines(i) = 0 if levels(i) lt 0. then clines(i) = 2 endif endfor if cont.cint gt 0. then $ contitle = 'CONTOUR ' + $ strcompress(string(levels(0),format="(G9.3)"),/remove_all)+' TO '+$ strcompress(string(levels(cont.nlev-1),format="(G9.3)"),/remove_all)+$ ' BY '+ strcompress(string(levels(1)-levels(0),format="(G9.3)"),$ /remove_all) + ' (MIN,MAX=' + strcompress(string(rmin,format="(G9.3)"),$ /remove_all) + ',' + strcompress(string(rmax,format="(G9.3)"),$ /remove_all) + ')' $ else $ contitle = 'CONTOUR ' + $ strcompress(string(levels(0),format="(G9.3)"),/remove_all)+' TO '+$ strcompress(string(levels(cont.nlev-1),format="(G9.3)"),/remove_all)+$ ' BY '+ strcompress(string(levels(1)-levels(0),format="(G9.3)"),$ /remove_all) endif ; ; Make raster image if necessary: ; if imcon eq 0 or imcon eq 2 then begin ; prepare scaled image if (keyword_set(ps) eq 0 and keyword_set(cgm) eq 0) then begin ; X XYll = convert_coord([xll],[yll],/norm,/to_device) xll_dev = XYll(0,0) & yll_dev = XYll(1,0) XYur = convert_coord([xur],[yur],/norm,/to_device) xur_dev = XYur(0,0) & yur_dev = XYur(1,0) image=congrid(gencon,xur_dev-xll_dev,yur_dev-yll_dev,/interp,$ /minus_one) indx = where(image ge !spval/10., cnt) if cont.cmin ge cont.cmax then $ image= bytscl(image,min=rmin,max=rmax,top=!d.table_size-3)+1 $ else begin print,'Using cont.cmin,cmax=',cont.cmin,cont.cmax,' for image scaling' image= bytscl(image,min=cont.cmin,max=cont.cmax,top=!d.table_size-3)+1 endelse if cnt ne 0 then begin image(indx) = 0 print,'Found ',cnt,' "missing data" points (out of total ',$ n_elements(image),' points)' endif if cont.imapply gt 0 then begin indx = where(gencon gt cont.cmax or gencon lt cont.cmin, cnt) if cnt gt 0 then begin image(indx) = 0 print,' Removed ',cnt,' points outside cmin,cmax' endif endif endif else begin ; ps or cgm image = rebin(gencon(*,*),frame.nx*imscale,frame.ny*imscale) indx = where(image ge !spval/10., cnt) if cont.cmin ge cont.cmax then $ image= bytscl(image,min=rmin,max=rmax,top=!d.table_size-3)+1 $ else begin print,'Using cont.cmin,cmax=',cont.cmin,cont.cmax,' for image scaling' image= bytscl(image,min=cont.rmin,max=cont.rmax,top=!d.table_size-3)+1 endelse if cnt ne 0 then begin image(indx) = 0 print,'Found ',cnt,' "missing data" points' endif if cont.imapply gt 0 then begin indx = where(gencon gt cont.cmax or gencon lt cont.cmin, cnt) if cnt gt 0 then begin image(indx) = 0 print,' Removed ',cnt,' points outside cmin,cmax' endif endif endelse endif ; xmid = .5*(xll+xur) pltpos = [xll,yll,xur,yur] chsize = 1.2 & if keyword_set(cgm) then chsize = 1. chsizetop = 1.5 & if keyword_set(cgm) then chsizetop = 1.3 if imcon ne 1 then begin barw = xur-xll & barh = .03 xbar = xll & ybar = yll-barh-.13 barmin = rmin & barmax = rmax if cont.imapply gt 0 then begin barmin = cont.cmin barmax = cont.cmax endif barlabs = [strcompress(string(barmin,format="(g10.4)"),/remove_all),$ strcompress(string(0.5*(barmin+barmax),format="(g10.4)"),/remove_all),$ strcompress(string(barmax,format="(g10.4)"),/remove_all)] endif ; ; Guess from axis labels if either is latitude or longitude, and ; set tic mark labels accordingly: ; xticlabs = '' if strpos(frame.xlab,'LATITUDE') ne -1 or $ strpos(frame.xlab,'latitude') ne -1 or $ strpos(frame.xlab,'Latitude') ne -1 then $ xticlabs = ['-90','-60','-30','0','30','60','90'] if strpos(frame.xlab,'LONGITUDE') ne -1 or $ strpos(frame.xlab,'longitude') ne -1 or $ strpos(frame.xlab,'Longitude') ne -1 then $ xticlabs = ['-180','-120','-60','0','60','120','180'] xminor = 0 if n_elements(xticlabs) gt 1 then xminor = 3 ; yticlabs = '' if strpos(frame.ylab,'LATITUDE') ne -1 or $ strpos(frame.ylab,'latitude') ne -1 or $ strpos(frame.ylab,'Latitude') ne -1 then $ yticlabs = ['-90','-60','-30','0','30','60','90'] if strpos(frame.ylab,'LONGITUDE') ne -1 or $ strpos(frame.ylab,'longitude') ne -1 or $ strpos(frame.ylab,'Longitude') ne -1 then $ yticlabs = ['-180','-120','-60','0','60','120','180'] yminor = 0 if n_elements(yticlabs) gt 1 then yminor = 3 ; ; Make image: ; case imcon of 0: begin ; image only tv,image,xll,yll,/norm,xsize=xur-xll,ysize=yur-yll clrbar,barw,barh,xbar,ybar,barlabs,botcolor=1,topcolor=!d.table_size-2,$ charsize=chsize contour,gencon,frame.xx,frame.yy,/nodata,/follow,/norm,/noerase,$ pos=pltpos,xstyle=1,ystyle=1,xtitle=frame.xlab,ytitle=frame.ylab,$ title=frame.infolab,c_charsize=chsize,charsize=chsize,$ xticks=n_elements(xticlabs)-1,xtickname=xticlabs,xminor=xminor,$ yticks=n_elements(yticlabs)-1,ytickname=yticlabs,yminor=yminor xyouts,xmid,yur+.07,frame.toplab,align=.5,/norm,charsize=chsizetop xyouts,xmid,yll-.24,frame.botlab,align=.5,/norm,charsize=chsize end 1: begin ; contours only contour,gencon,frame.xx,frame.yy,/follow,/norm,/noerase,pos=pltpos,$ xstyle=1,ystyle=1,xtitle=frame.xlab,ytitle=frame.ylab,$ title=frame.infolab,c_charsize=chsize,c_linestyle=clines,$ c_colors=[cont.conclr],charsize=chsize,$ levels=levels,c_labels=clabels,max_value=!spval/10.,$ xticks=n_elements(xticlabs)-1,xtickname=xticlabs,xminor=xminor,$ yticks=n_elements(yticlabs)-1,ytickname=yticlabs,yminor=yminor xyouts,xmid,yur+.07,frame.toplab,align=.5,/norm,charsize=chsizetop xyouts,xmid,yll-.15,contitle,align=.5,/norm,charsize=chsize xyouts,xmid,yll-.2,frame.botlab,align=.5,/norm,charsize=chsize end 2: begin ; image + contours tv,image,xll,yll,/norm,xsize=xur-xll,ysize=yur-yll clrbar,barw,barh,xbar,ybar,barlabs,botcolor=1,topcolor=!d.table_size-2,$ charsize=chsize contour,gencon,frame.xx,frame.yy,/follow,/norm,/noerase,pos=pltpos,$ xstyle=1,ystyle=1,xtitle=frame.xlab,ytitle=frame.ylab,$ title=frame.infolab,c_charsize=chsize,c_linestyle=clines,$ c_colors=[cont.conclr],charsize=chsize,$ levels=levels,c_labels=clabels,max_value=!spval/10.,$ xticks=n_elements(xticlabs)-1,xtickname=xticlabs,xminor=xminor,$ yticks=n_elements(yticlabs)-1,ytickname=yticlabs,yminor=yminor xyouts,xmid,yur+.07,frame.toplab,align=.5,/norm,charsize=chsizetop xyouts,xmid,yll-.24,contitle,align=.5,/norm,charsize=chsize xyouts,xmid,yll-.28,frame.botlab,align=.5,/norm,charsize=chsize end endcase return end