Re: vectors + ncgm

From: Wolfgang Langhans <wolfgang.langhans_at_nyahnyahspammersnyahnyah>
Date: Wed Jan 21 2009 - 00:37:25 MST

Hi,
unfortunately the .hluresfile doesn't help in this case. That's why I
sent my script. Thanks for having a look at it:

;************************************************
; commonly loaded
;************************************************
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/csm/contributed.ncl"

begin
;************************************************
; open netCDF file: read in selected variables
    ;************************************************
     dir="/lhome/wolangha/cosmo_out/juni_07/"
     fil="lffd_const_2d.nc"
     f=addfile(dir+fil,"r")
     lat2d=f->lat(:,:)
     lon2d=f->lon(:,:)
     s=dimsizes(lat2d)
     HSURF=f->HSURF(0,:,:)
     HSURF@lat2d=lat2d
     HSURF@lon2d=lon2d
     gil="lffd2007060300_3d_1h.nc"
     g=addfile(dir+gil,"r")
     TIME=g->time
     dims=dimsizes(TIME)
     
     ; --- define constants ---
     R=287.
     cp=1004.
;***********************************************
; open graphic wkstation
;***********************************************
type = "ncgm" ; create variable to hold info
type@wkColorModel = "cmyk"
out_name="windfield"
  wks = gsn_open_wks(type,out_name)

  setvalues wks
   "wkColorMap" : "BlueDarkRed18"
   "wkBackgroundColor" : (/1.,1.,1./)
   "wkForegroundColor" : (/0.,0.,0./)
 end setvalues
; gsn_draw_colormap(wks)
 plot=new(3,graphic)
 a4_height=29.7
 a4_width=21.0
 cm_per_inch=2.54
 
 resm = True ; options desired
 resm@gsnDraw = False
 resm@gsnFrame = False
 resm@gsnAddCyclic = False
 resm@gsnMaximize = False ; maximize size of plot
 resm@gsnPaperWidth =a4_width/cm_per_inch
 resm@gsnPaperHeight =a4_height/cm_per_inch
 resm@gsnPaperMargin =0.5/cm_per_inch
; resm@gsnPaperOrientation ="Portrait"
                         pollon = -170.;
                         pollat = 32.5
 resm@mpProjection = "CylindricalEquidistant"
 resm@tfDoNDCOverlay = True ; Has no influence on mapping here
 resm@mpCenterLonF = 180+pollon
 resm@mpCenterLatF = 90-pollat
 resm@mpLimitMode = "Corners"
 resm@mpLeftCornerLatF = lat2d(0,0)
 resm@mpLeftCornerLonF = lon2d(0,0)
 resm@mpRightCornerLatF = lat2d(s(0)-1,s(1)-1)
 resm@mpRightCornerLonF = lon2d(s(0)-1,s(1)-1)
 
 resm@mpDataBaseVersion = "Ncarg4_1"
 resm@mpDataSetName = "Earth..2"
 resm@mpOutlineBoundarySets = "National"
 resm@mpGeophysicalLineColor = "Black"
 resm@mpGridAndLimbOn = False
 resm@mpLabelsOn = False
 resm@mpFillOn = False
 resm@pmTickMarkDisplayMode = "Never"
 resm@gsnLeftString = ""
 resm@gsnRightString = ""

 resm@cnFillOn = True
 resm@cnFillDrawOrder = "Predraw"
 resm@cnRasterModeOn = False
 resm@cnLinesOn = False
 resm@cnLineLabelsOn = False
 resm@cnInfoLabelOn = False
 resm@gsnSpreadColors = True
 resm@lbLabelBarOn = True
 resm@lbOrientation = "vertical"
 resm@lbLabelFontHeightF = .02
 
 resm@cnLevelSelectionMode ="ManualLevels"
 resm@cnLevelSpacingF = 2.5
 resm@cnMinLevelValF = 0.
 resm@cnMaxLevelValF = 40.

; resm@cnLevels =(/0.1,0.5,0.8,1.0,1.5,3.,5,8,10,15,20,30,40,60,80,100/)
; resm@cnFillColors=(/2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19/)
 resm@vcRefAnnoOn = False
 resm@vcRefAnnoFont=21
 resm@vcRefAnnoFontHeightF=0.013
 resm@vcRefMagnitudeF = 10.0 ; define vector ref mag
 resm@vcRefLengthF = 0.034 ;(0.08+0.05)/2. ; define
length of vec ref
 resm@vcRefAnnoPerimOn=False
 resm@vcRefAnnoOrthogonalPosF = -0.994
 resm@vcRefAnnoParallelPosF = 0.994
 resm@vcRefAnnoArrowLineColor = "black"
 resm@vcRefAnnoString1="10 m/s"
 resm@vcGlyphStyle = "LineArrow"
 resm@vcLineArrowColor = "black"
 resm@vcLineArrowThicknessF = 0.004
 resm@vcVectorDrawOrder = "draw"
 resm@vcLevelSpacingF=2.
 resm@vcMinDistanceF=0.037
 resm@gsnScalarContour=True
 resm@tiMainFontHeightF = .020
 
 do i=16,17;dims(0)-1
  do l=20,22

   ; --- read cosmo data ----
   U=g->U(i,l,:,:)
   V=g->V(i,l,:,:)
   U@lat2d=lat2d
   U@lon2d=lon2d
   V@lat2d=lat2d
   V@lon2d=lon2d

   ; --- calculate wind speed ----
   WS=(U^2+V^2)^(0.5)
   WS@lat2d=lat2d
   WS@lon2d=lon2d
 
   ; --- plot at time i
   resm@tiMainString = "Wind speed (m/s); time = init + " +
TIME(i)/3600. + " h; k = " + l ;
   plot(0)=gsn_csm_vector_scalar_map(wks,U,V,WS,resm)
   draw(plot(0))
   frame(wks)
   delete(U)
   delete(V)
   delete(WS)
  end do ; END LEVEL LOOP
 end do ; END TIME LOOP
 print("Succesfully plotted in file " + out_name + "." + type + "!")
end

Best Regards,
Wolfgang

Mary Haley wrote:
>
> On Tue, 20 Jan 2009, Wolfgang Langhans wrote:
>
>> Hey all,
>> I use gsn_csm_vector_scalar_map for overlaying vectors on contours. This
>> works for wks types .ps an .eps, but when I want to produce a .ncgm no
>> vectors are plotted or overlaid (although I use the same script).
>> There`s no Error message.
>> Do you have any ideas on that?
>> Best regards,
>> Wolfgang
>
> Wolfgang,
>
> One possibility is that you don't have a .hluresfile in your home
> directory. Hence, when you send the output to an NCGM, you are
> getting the default black background and a white foreground that
> is associated with an NCGM file.
>
> This could be a problem if you are explicitly drawing black vectors.
>
> Here's some information on the .hluresfile:
>
> http://www.ncl.ucar.edu/Document/Graphics/hlures.shtml
>
> If you can email me your script, I'll take a look.
>
> --Mary
>
>
Received on Wed Jan 21 00:37:30 2009

This archive was generated by hypermail 2.1.8 : Mon Nov 15 2010 - 12:48:08 MST