Re: Image resize problem

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 17 2010 - 09:26:25 MDT

Sahidul,

Are the text strings showing up on the very last page of your PS file by any chance?

I think what may be happening is that when you call wrf_map_overlays, it is calling a frame advance for you.
This means that anything you draw after this call will be drawn on a new page.

If this is what's happening, then before you call this function, try setting:

  pltres@gsnFrame = False

You also mentioned a problem with resizing the image. I'm not sure what you mean.

Note that if you want the text to appear on the map, you'd be better off using "gsn_add_text",
because this allows you to attach the text to the plot. This means if you resize the plot, the text
will be resized automatically.

In order to do this, however, you need to use data coordinates of your plot, rather than NDC
coordinates. This would be lat/lon coordinates, since "plot" is a map.

Also, the text won't get drawn until the plot gets drawn.

Here's what your code changes might look like:

  . . .
   pltres = True
  . . .
  pltres@gsnDraw = False ; don't draw plot
  pltres@gsnFrame = False ; don't advance frame

  . . .
  contour_tot2 = wrf_contour(wrf_out,wks2,rain_tot2,opts)
  plot = wrf_map_overlays(wrf_out,wks2,(/contour_tot2/),pltres,mpres) ; plot will not get drawn at this point

;*********************plot1**************************************************
  txres@txFontHeightF = 0.013 ; font smaller. default big
  txres@txFont = "text-symbols"
  dumid1 = gsn_add_text(wks2,plot,"S",xlon1,xlat,txres) ; need to replace xlon1 and xlat with appropriate lon/lat values
; page coordinates are normalized. go from 0->1 not 0->8" etc.
  txres@txFontHeightF = 0.015 ; font smaller. default big
  txres@txFont = "courier-bold"
  dumid2 = gsn_add_text(wks2,plot,"CDAC",xlon2,xlat,txres) ; need to replace xlon2 and xlat with appropriate lon/lat values
  txres@txFontHeightF = 0.01 ; font smaller. default big
  txres@txFont = "courier"
  dumid3 = gsn_add_text(wks2,plot,"(Continent Boundary may differ from Political boundary) ",xlon3,xlat1,txres) ; need to replace xlon3 and xlat with appropriate lon/lat values

  draw(plot) ; This will draw plot and the three text strings.
  frame(wks2) ; now advance frame

--Mary

On Jun 17, 2010, at 6:29 AM, Sahidul wrote:

> Dear NCL users forum,
>
> I am facing problem to resize the image created by following script:
>
> We are not able to print the "text" using this following script i.e., required text is not writing in image file. Kindly help me to sort out this problem
>
> =================================
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> datadir = "/WRF/output/2010061600/"
> date1="2010-06-16_00"
> date2="2010-06-16_23"
> date3="2010-06-17_23"
> date4="2010-06-18_23"
>
> FILES1 = systemfunc ("ls -1 " + datadir + "wrfout_d02_"+date1)
> FILES2 = systemfunc ("ls -1 " + datadir + "wrfout_d02_"+date2)
> FILES3 = systemfunc ("ls -1 " + datadir + "wrfout_d02_"+date3)
> FILES4 = systemfunc ("ls -1 " + datadir + "wrfout_d02_"+date4)
>
> wrf_out = addfile(FILES1+".nc","r")
>
> res = True
> opts = res
> opts@InitTime = False
> opts@Footer = False
>
> ; Total Rainfall calculation
> ;***********************************************************************
> rainc1 = wrf_user_getvar(wrf_out,"RAINC",0)
> rainnc1 = wrf_user_getvar(wrf_out,"RAINNC",0)
>
> wrf_out2 = addfile(FILES2+".nc","r")
>
> ; Total Rainfall calculation
> ;***********************************************************************
> rainc2 = wrf_user_getvar(wrf_out2,"RAINC",0)
> rainnc2 = wrf_user_getvar(wrf_out2,"RAINNC",0)
> rain_tot2=((rainc2+rainnc2)-(rainnc1+rainc1))/10.
> ;***********************************************************************
> wrf_out3 = addfile(FILES3+".nc","r")
>
> ; Total Rainfall calculation
> ;***********************************************************************
> rainc3 = wrf_user_getvar(wrf_out3,"RAINC",0)
> rainnc3 = wrf_user_getvar(wrf_out3,"RAINNC",0)
> rain_tot3=((rainc3+rainnc3)-(rainnc2+rainc2))/10.
> ;***********************************************************************
> wrf_out4 = addfile(FILES4+".nc","r")
>
> ; Total Rainfall calculation
> ;***********************************************************************
> rainc4 = wrf_user_getvar(wrf_out4,"RAINC",0)
> rainnc4 = wrf_user_getvar(wrf_out4,"RAINNC",0)
> rain_tot4=((rainc4+rainnc4)-(rainnc3+rainc3))/10.
>
> rain_tot2@description = ""
> rain_tot3@description = ""
> rain_tot4@description = ""
> ;***********************************************************************
> ;Open Workstation ps,eps,X11,pdf,ncgm
> ;***********************************************************************
> wks2 = gsn_open_wks("ps","precip_surf_day1")
>
> res@InitTime = False
> res@Footer = False
> res@gsnMaximize = True
> res@MainTitle = "Total Precipitation"
>
> opts@cnLinesOn = False
> opts@cnFillOn = True
> opts@cnLevelSelectionMode = "ExplicitLevels"
> ;opts@UnitLabel = "cm"
> ; opts@description = "Precipitation Rate"
>
> opts@cnLevels = (/ 1., 2., 5., 10., 15., 20., 25., 30., 35., 40., 50./)
> opts@cnFillColors = (/"white","seagreen1","green4","greenyellow","yellow","goldenrod1","goldenrod2","tomato","orangered",\
> "red","red2","red4"/)
> opts@cnInfoLabelOn = False
> opts@cnConstFLabelOn = False
> res@gsnMaximize = True ; must include w/ Paper Orientation
> res@gsnPanelBottom = 0.2 ; save space at bottom
>
> txres = True ; text mods desired
>
> pltres = True
> mpres = True
> mpres@mpOutlineBoundarySets = "National"
> mpres@mpNationalLineThicknessF = 1.5
> mpres@mpNationalLineColor = "Black"
> mpres@mpGeophysicalLineColor = "Black"
> mpres@mpGeophysicalLineThicknessF = 1.5
> ;***********************************************************************
> contour_tot2 = wrf_contour(wrf_out,wks2,rain_tot2,opts)
> plot = wrf_map_overlays(wrf_out,wks2,(/contour_tot2/),pltres,mpres)
>
> ;*********************plot1**************************************************
> txres@txFontHeightF = 0.013 ; font smaller. default big
> txres@txFont = "text-symbols"
> gsn_text_ndc(wks2,"S",0.12,.19,txres)
> ; page coordinates are normalized. go from 0->1 not 0->8" etc.
> txres@txFontHeightF = 0.015 ; font smaller. default big
> txres@txFont = "courier-bold"
> gsn_text_ndc(wks2,"CDAC",0.17,.19,txres)
> txres@txFontHeightF = 0.01 ; font smaller. default big
> txres@txFont = "courier"
> gsn_text_ndc(wks2,"(Continent Boundary may differ from Political boundary) ",0.6,.19,txres)
> frame(wks2) ; now advance frame
> end
> =================================
>
> Thanking you in advance
>
> Sahidul
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 17 09:26:31 2010

This archive was generated by hypermail 2.1.8 : Thu Jun 24 2010 - 14:10:27 MDT