3. added rectangle and marker not shown on the plot (Yonghui Wu)

From: Li, Yongzuo <yongzuo.li_at_nyahnyahspammersnyahnyah>
Date: Wed Feb 09 2011 - 14:46:41 MST

Yonghui,

add frame(wks)

Yongzuo
________________________________________
From: ncl-talk-bounces@ucar.edu [ncl-talk-bounces@ucar.edu] on behalf of ncl-talk-request@ucar.edu [ncl-talk-request@ucar.edu]
Sent: Wednesday, February 09, 2011 1:00 PM
To: ncl-talk@ucar.edu
Subject: ncl-talk Digest, Vol 87, Issue 12

Send ncl-talk mailing list submissions to
        ncl-talk@ucar.edu

To subscribe or unsubscribe via the World Wide Web, visit
        http://mailman.ucar.edu/mailman/listinfo/ncl-talk
or, via email, send a message with subject or body 'help' to
        ncl-talk-request@ucar.edu

You can reach the person managing the list at
        ncl-talk-owner@ucar.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of ncl-talk digest..."

Today's Topics:

   1. Re: dynamic variable names (Jonathan Vigh)
   2. Re: Given a string time stamp need to add hours (Carl Schreck)
   3. added rectangle and marker not shown on the plot (Yonghui Wu)
   4. Re: dynamic variable names (Adam Phillips)
   5. Re: added rectangle and marker not shown on the plot
      (Adam Phillips)
   6. binary file reading (Ioana Colfescu)
   7. Re: binary file reading (Dennis Shea)

----------------------------------------------------------------------

Message: 1
Date: Wed, 09 Feb 2011 10:16:47 -0700
From: Jonathan Vigh <jvigh@ucar.edu>
Subject: Re: dynamic variable names
To: "Nissan, Hannah" <h.nissan10@imperial.ac.uk>, Ncl Talk
        <ncl-talk@ucar.edu>
Message-ID: <4D52CBFF.1080001@ucar.edu>
Content-Type: text/plain; charset="iso-8859-1"

Hi Hannah,
     You can attach a variety of attribute arrays to one data object, in
effect creating dynamic variables:

DATA = True

do i = 0, imax-1
<get time data>
<read in new data or whatever, store it as "newdata">
    array_name = <time>.imax
    DATA@$array_name$ = newdata
end do

So all your dynamic arrays would live on the DATA object and could be
retrieved or destroyed later. They would not all have to have the same
dimensions, types, and can be named whatever you want. Advantages are
that this is a handy quick way to read in lots of data with different
dimensions, and NCL currently doesn't have a way to dynamically create
and work with variables without knowing their names in advance.
Disadvantages of this method are that you can't attach additional
attributes to the attribute arrays, so things like _FillValue might have
to be added explicitly later on. Another disadvantage is that processing
could get exponentially slower for certain operations if the total
number of attached elements becomes too large (maybe a million, or a
hundred million?). And finally, to store all the dynamic variables as a
netCDF file, you'd need to basically unpack the attribute arrays into
real variables, add the dimensions, _FillValues, etc. It's possible
using NCL to write it's own NCL code dynamically, but it's not pretty.
Things would get a lot easier if NCL had an "eval" statement.

Jonathan

On 02/09/2011 10:01 AM, Nissan, Hannah wrote:
>
> Hello,
>
> I am looking for a way to dynamically name an array in NCL. I am
> running a loop through time and creating an array which I need to name
> according to the time period or loop. Can anyone help?
>
> Thanks very much,
>
> Hannah
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

--
------------------------------------------------------
Jonathan Vigh
Postdoctoral Fellow, Advanced Study Program
National Center for Atmospheric Research
Mesoscale&  Microscale Meteorology Division
Foothills Lab 3 - Rm. 3081
Office: 303-497-8205
Cell:   720-347-9337
------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110209/93e7a198/attachment.html
------------------------------
Message: 2
Date: Wed, 09 Feb 2011 12:16:35 -0500
From: Carl Schreck <Carl.Schreck@noaa.gov>
Subject: Re: Given a string time stamp need to add hours
To: donna Cote <d-cote@tamu.edu>
Cc: ncl-talk@ucar.edu
Message-ID:
        <AANLkTikDcFPE25MvARgwxRKDQDDNd2CR5s2jGCbB8wW2@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
There may be a simpler way, but you can do it with ut_inv_calendar and
ut_string.  See the attached example.
Hope you keep the sleet down there.  We've had more than our fair share of
winter here in NC!
   Cheers,
   Carl
On Wed, Feb 9, 2011 at 11:45 AM, donna Cote <d-cote@tamu.edu> wrote:
> I could use help with this. It's sleeting outside and my brain seems to
> be just about as frozen as my car's windshield!
>
> I have a time stamp, in a string:
>
> Variable: timestring
> Type: string
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> 2010-06-01T00:00
>
> And I have a number of hours, which, in this example = 12
>
> (0)     Variable Name: Time
> (0)     1 Dimensions:
> (0)     0) Time: 1
> (0)     long_name: Elapse Time
> (0)     units: hour
> (0)     FORTRAN_format: i8
> (0)     start: 2010-06-01 00:00:00
> (0)     FORM: YYYY-MM-DD hh:mm:ss
>
> How do I get a timestamp created that will give me
>   2010-06-01T12:00:00 (timestring + Time(0))  ??
>
> Thanks, Donna
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
--
Carl J. Schreck III, PhD
Postdoctoral Research Associate
Cooperative Institute for Climate and Satellites (CICS-NC)
NOAA's National Climatic Data Center
151 Patton Avenue
Asheville, NC 28801
Tel: 828-257-3140
carl.schreck@noaa.gov
http://www.atmos.albany.edu/student/carl/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110209/159ce47c/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timestring.ncl
Type: application/octet-stream
Size: 716 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20110209/159ce47c/attachment.obj
------------------------------
Message: 3
Date: Wed, 09 Feb 2011 10:19:04 -0700
From: Yonghui Wu <yonghuiw@ucar.edu>
Subject: added rectangle and marker not shown on the plot
To: ncl-talk@ucar.edu
Message-ID: <4D52CC88.5050307@ucar.edu>
Content-Type: text/plain; charset=ISO-8859-1
Dear All,
I tried to mark the obs location using gsn_polymarker, and tried to
indicate a subdomain of interest using gsn_polyline. They work if I
don't add contour2 (using filled contour). However, if I add contour2
to the plot, then both the polymarker and the box don't show on the
plot. Please help me to find a solution. THX.
Yonghui
Following is the original code: in the plot I have two choice, one
without contour2, the other with contour2.
;   Example script to produce an OLR plot for a WRF real-data run,
;   with the ARW coordinate dynamics option.
;   In this example we are also going to zoom into an area of interest
load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
; model reference states
 dir0 = "/raid2/yonghui/osse-exp/Result/fcst/True/"
 datem = "10_18:00"
 fname = "wrfout_d01_2008-02-" + datem + ":00.nc"
; obs network dimension
 obsnorth = 34
 obseast  = 29
 obssigma = 36
; gain information
 Ibdy = 13   ;get rid of boundary
 Lskip = 2   ;get Kalman gain every 2 grid
; dimension of each gain matrix 25*25
 Ndim = 25
; obs location in model grid
 Ix = 35     ;model grid in east
 Iy = 77     ;model grid in north
 Ilev = 7    ; vertical level
 Ilev1 = Ilev - 1
; small domain centered by (Ix,Jy) with 2*Ibdy-1 as length for plot
 x_start = Ix - Ibdy
 x_end = Ix + Ibdy -2
 y_start = Iy - Ibdy
 y_end = Iy + Ibdy -2
; transform model grid coordinate of obs location in obs network grid
 Ilon=(Ix-13)/2+1 ;obs network grid in east
 Jlat=(Iy-13)/2+1 ;obs network grid in north
; record number
 krec = ((Jlat-1)*obseast+Ilon-1)*obssigma+Ilev-1 ;since ncl start from
0 so -1
; gain data directory
 pathd = "/raid2/yonghui/Gain/letkf-jump02/polynomial-dart-wholemean/"
; case name
 dateh = "1018Z"
 cases = "test-"+dateh+"-ens93-ndim8-nocenter-cut/"
; variable name
  var="t"
;  var="u"
;  var="v"
;  var="q"
  vfile = "gain-"+var+"_org.bin"
;  vfile = "gain-"+var+"_ret.bin"
; WRF input files  needs to have a ".nc" appended, so just do it.
  f0 = addfile(dir0 + fname,"r")
; read the gain
  gaint = new ((/Ndim,Ndim/),"float",-9999.)
  gaint = fbindirread(pathd+cases+vfile,krec,(/Ndim,Ndim/),"float")
; generate plots, but what kind do we prefer?
   type = "pdf"
;   type = "x11"
;   type = "ps"
;   type = "ncgm"
; output filename
  wks = gsn_open_wks(type,"gain-"+dateh+"-Ix"+Ix+"-Iy"+Iy+"-lev"+Ilev)
; Change color map to something that has a grey scale
;  gsn_define_colormap(wks,"wxpEnIR")
; Set some Basic Plot Information
  res = True
;  res@MainTitle    = "OSSE"   ; name of plot
  res@InitTime     = False       ; do not plot initial time
  res@Footer       = False       ; switch footers off
  res@tiXAxisOn = False
  res@tiYAxisOn = False
  res@tiMainOn  = False
  res@tmXBLabelFontHeightF = 0.04    ; boost the axis value labels even more
  res@tmYLLabelFontHeightF = 0.04
  res@tmYRLabelFontHeightF = 0.04
; Set up two sets of plot and map resources
  pltres             = True
  pltres@PanelPlot   = True  ; if want to put plots on 1 page
  pltres@gsnDraw     = False
  pltres@gsnFrame    = False
  pltres@gsnMaximize = True
  pltres@FramePlot   = False ; donot advance frame automatically
  pltres@lbLabelBarOn      = False  ; turn off label bar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  times  = wrf_user_list_times(f0)  ; get times in the file
  ntimes = dimsizes(times)         ; number of times in the file
; map set
  mpres = True
  mpres@ZoomIn = True
  mpres@Xstart = x_start
  mpres@Ystart = y_start
  mpres@Xend = x_end
  mpres@Yend = y_end
  mpres@tmXBLabelFontHeightF = 0.02          ; change lat lon font size
  mpres@tmXBMajorLengthF     = 0.02          ; change the tickmark length
  mpres@mpGridAndLimbOn      = True          ; default is every 15 deg
  mpres@mpGridSpacingF       = 2            ; change to match labels
  mpres@mpGeophysicalLineColor      = "Gray"
  mpres@mpNationalLineColor         = "Gray"
  mpres@mpUSStateLineColor          = "Gray"
  mpres@mpGridLineColor             = "Black"
  mpres@mpLimbLineColor             = "Gray"
  mpres@mpPerimLineColor            = "Gray"
  mpres@mpGeophysicalLineThicknessF = 1.5
  mpres@mpGridLineThicknessF        = 0.5
  mpres@mpLimbLineThicknessF        = 1.5
  mpres@mpNationalLineThicknessF    = 1.5
  mpres@mpUSStateLineThicknessF     = 1.5
  mpres@gsnMaximize          = True               ; maximize image
  t0 = wrf_user_getvar(f0,"tc",-1)              ; get variable
  u0 = wrf_user_getvar(f0,"ua",-1)              ; get variable
  v0 = wrf_user_getvar(f0,"va",-1)              ; get variable
  dimvar = dimsizes(t0)
  print ("dimvar=" + dimvar)
  print ("y_start=" + y_start)
  print ("y_end=" + y_end)
  print ("x_start=" + x_start)
  print ("x_end=" + x_end)
  Ilev1 = Ilev - 1 ;ncl start from 0 so -1
  tzoom1 = t0(:,Ilev1,y_start:y_end,x_start:x_end)  ; zoomed area
  uzoom1 = u0(:,Ilev1,y_start:y_end,x_start:x_end)  ; zoomed area
  vzoom1 = v0(:,Ilev1,y_start:y_end,x_start:x_end)  ; zoomed area
  plot = new (1, graphic)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; loop over time
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 do it = 0,ntimes-1                             ; start at time 2
; contour plot of T
    opts = res
    opts@lbTitleOn = False                   ; remove field name from
label bar
    opts@ContourParameters = (/-30, 30, 2/)
    opts@lbLabelBarOn      = False  ; turn off label bar
    opts@TimeLabel = times(it)                   ; set Valid time on the
plot
    opts@cnLineColor              = "black"
    opts@cnInfoLabelOn            = False    ; no bottom info plotted
    opts@pmLabelBarOrthogonalPosF = -0.1
    opts@gsnContourLineThicknessesScale = 2.5
    opts@cnLineLabelsOn           = True
    opts@gsnDraw                  = False    ; Forces the plot to be drawn
    opts@gsnFrame                 = False    ; Frame advance
    opts@mpGridAndLimbDrawOrder    = "PreDraw"
    opts@cnLabelDrawOrder          = "PreDraw"
    contour1 = wrf_contour(f0,wks,tzoom1(it,:,:),opts)
; replace t with the gain
    dimzoom = dimsizes(tzoom1)
    print ("dim of t0zoom=" + dimzoom)
    tzoom1(it,:,:) = (/gaint(:,:)/)
    optg = res
    optg@cnInfoLabelOn        = False
    optg@UnitLabel            = "C, shaded"
    optg@FieldTitle           = "Tdif"   ; overwrite Field Title
;        opts@gsnStringFontHeightF = 2
    optg@lbLabelBarOn      = True  ; turn off label bar
    optg@cnFillOn          = True
    optg@pmLabelBarOrthogonalPosF = -0.02
    optg@ContourParameters = (/-1.2, 1.8, 0.3/)
    optg@cnFillColors      = (/"Blue3","Blue2","Blue1",\
         "Cyan","SpringGreen","White","White","Yellow","Orange",\
         "Red","Red2", "Red4"/)
    optg@gsnContourLineThicknessesScale = 1.0
    optg@gsnDraw           = False    ; Forces the plot to be drawn
    optg@gsnFrame          = False    ; Frame advance
    optg@lbTitleOn = False                   ; remove field name from
label bar
    optg@TimeLabel = times(it)                   ; set Valid time on the
plot
    optg@cnLineColor              = "black"
    optg@cnInfoLabelOn            = False    ; no bottom info plotted
    optg@pmLabelBarOrthogonalPosF = -0.1
    optg@gsnContourLineThicknessesScale = 2.5
    optg@cnLineLabelsOn           = True
    optg@gsnDraw                  = False    ; Forces the plot to be drawn
    optg@gsnFrame                 = False    ; Frame advance
    contour2 = wrf_contour(f0,wks,tzoom1(it,:,:),optg)
; vector plot of (U,V)
    resu = True
    resu@TimeLabel = times(it)                   ; set Valid time on the
plot
    resu@gsnMaximize          = True    ; Maximize plot in frame
    resu@gsnSpreadColors      = True   ; span full colormap
    resu@vcMonoLineArrowColor = True  ; color arrows based on magnitude
    resu@vcRefLengthF         = 0.03313608
    resu@vcMinFracLengthF     = 0.3
;
; Setting the reference magnitude also affects the length
; of the arrows. In this case it is an inverse relationship.
;
    resu@vcRefMagnitudeF = 50.0
;
; Line-drawn arrowheads are sized proportionally to the arrow length
; unless the resulting size would be outside the limits defined by
; the arrowhead minimum and maximum size resources. Setting the
; minimum and maximum sizes to the same value causes all the
;
    resu@tiMainOn                = False
    resu@tiMainString           = ""
    resu@vcLineArrowHeadMinSizeF = 0.013
    resu@vcLineArrowHeadMaxSizeF = 0.013
    resu@gsnDraw              = False              ; don't draw
    resu@gsnFrame             = False              ; don't advance frame
    resu@vcExplicitLabelBarLabelsOn = False
    resu@vcRefMagnitudeF = 15.                    ; make vectors larger
    resu@vcRefLengthF    = 0.050                 ; reference vector length
    resu@vcGlyphStyle    = "CurlyVector"         ; turn on curly vectors
    resu@vcMinDistanceF  = 0.03                 ; thin the vectors
;     resu@FieldTitle           = "Wind "   ; overwrite Field Title
;     resu@UnitLabel            = "m/s, vector"
;     resu@vcRefAnnoOn          = False         ; show ref vector size value
    resu@vcRefAnnoOn          = True         ; show ref vector size value
    resu@vcMinAnnoOn          = False
;    resu@gsnLeftString   = "Wind      (vector)"
; plot vector every 2 grid point
    jump = 1
    vector =
wrf_vector(f0,wks,uzoom1(it,::jump,::jump),vzoom1(it,::jump,::jump),resu)
; Plot OLR in grey scale for the full domain
;    plot = wrf_map_overlays(f0,wks,(/contour/),pltres,mpres)
; Now zoom into the box area and plot just for this area
    plot  = wrf_map_overlays(f0,wks,(/vector,contour1/),pltres,mpres)
;    plot =
wrf_map_overlays(f0,wks,(/vector,contour1,contour2/),pltres,mpres)
; plot a box on the output
    lats = (/  46.0,  50.0 /)
    lons = (/ -87.0, -83.0 /)
    loc = wrf_user_ll_to_ij(f0, lons, lats, True)
    lnres = True
    lnres@gsLineColor = "NavyBlue"
    lnres@gsLineThicknessF = 3.0
    gsn_polyline(wks,plot,(/lons(0),lons(1)/),(/lats(0),lats(0)/),lnres)
    gsn_polyline(wks,plot,(/lons(0),lons(1)/),(/lats(1),lats(1)/),lnres)
    gsn_polyline(wks,plot,(/lons(0),lons(0)/),(/lats(0),lats(1)/),lnres)
    gsn_polyline(wks,plot,(/lons(1),lons(1)/),(/lats(0),lats(1)/),lnres)
; plot a marker at the obs site
    obsloc = wrf_user_ij_to_ll(f0, Ix, Iy, True) ; find lon and lat
    print("lon/lat location is: " + obsloc)
    lonobs = obsloc(0)
    latobs = obsloc(1)
    print("lon= " + lonobs + " lat= "+latobs)
    gsres                    = True
    gsres@tfPolyDrawOrder    = "PreDraw"
;    gsres@tfPolyDrawOrder    = "PostDraw"
    gsres@gsMarkerIndex      = 16
    gsres@gsMarkerColor      = (/"black"/)
    gsres@gsMarkerThicknessF = 10.7
;    gsn_add_polymarker(wks,plot,lonobs,latobs,gsres)
    gsn_polymarker(wks,plot,lonobs,latobs,gsres)
; put the plots together
  resP                      = True
  resP@gsnDraw              = True              ; draw
  resP@gsnFrame             = True              ; advance frame
  resP@gsnMaximize          = True              ; maximize image
  resP@gsnPanelLabelBar     = True              ; add common colorbar
  resP@gsnPanelTop          = 1.0
  resP@gsnPanelBottom       = 0.1               ; space for label bar
  resP@pmLabelBarWidthF     = 0.95               ; make thinner
  resP@pmLabelBarHeightF    = 0.06
  resP@txString             = "The Gain of T at "+dateh
  resP@lbLabelAutoStride   = True
  resP@gsnPaperOrientation = "portrait"
  resP@pmLabelBarOrthogonalPosF = 0.2          ; move labelbar position
  resP@gsnPanelXWhiteSpacePercent = 3
  resP@gsnPanelYWhiteSpacePercent = 0
  resP@gsnPanelYF = (/-2,-2,0.54,0.54/)
  gsn_panel(wks,plot,(/1,1/), resP)
 end do
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end
------------------------------
Message: 4
Date: Wed, 09 Feb 2011 10:22:45 -0700
From: Adam Phillips <asphilli@ucar.edu>
Subject: Re: dynamic variable names
To: ncl-talk@ucar.edu
Message-ID: <4D52CD65.9050500@ucar.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi Hannah,
Jonathan's idea to write dynamic names as attributes is a great one. One
other possible way to get around this:
You can dynamically name arrays to be written to a netCDF file:
do gg = 0,1
    ......................
    if (gg.eq.0) then
       a = addfile("file."+time+".nc","c")
       a@source = systemfunc("pwd")+"/"+get_script_name()
    end if
    vname = "SLP_"+time
    a->$vname$ = arr
    delete(arr)
end do
On 02/09/2011 10:16 AM, Jonathan Vigh wrote:
> Hi Hannah,
> You can attach a variety of attribute arrays to one data object, in
> effect creating dynamic variables:
>
> DATA = True
>
> do i = 0, imax-1
> <get time data>
> <read in new data or whatever, store it as "newdata">
> array_name = <time>.imax
> DATA@$array_name$ = newdata
> end do
>
> So all your dynamic arrays would live on the DATA object and could be
> retrieved or destroyed later. They would not all have to have the same
> dimensions, types, and can be named whatever you want. Advantages are
> that this is a handy quick way to read in lots of data with different
> dimensions, and NCL currently doesn't have a way to dynamically create
> and work with variables without knowing their names in advance.
> Disadvantages of this method are that you can't attach additional
> attributes to the attribute arrays, so things like _FillValue might have
> to be added explicitly later on. Another disadvantage is that processing
> could get exponentially slower for certain operations if the total
> number of attached elements becomes too large (maybe a million, or a
> hundred million?). And finally, to store all the dynamic variables as a
> netCDF file, you'd need to basically unpack the attribute arrays into
> real variables, add the dimensions, _FillValues, etc. It's possible
> using NCL to write it's own NCL code dynamically, but it's not pretty.
> Things would get a lot easier if NCL had an "eval" statement.
>
> Jonathan
>
>
>
>
>
>
> On 02/09/2011 10:01 AM, Nissan, Hannah wrote:
>>
>> Hello,
>>
>> I am looking for a way to dynamically name an array in NCL. I am
>> running a loop through time and creating an array which I need to name
>> according to the time period or loop. Can anyone help?
>>
>> Thanks very much,
>>
>> Hannah
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> --
> ------------------------------------------------------
> Jonathan Vigh
> Postdoctoral Fellow, Advanced Study Program
> National Center for Atmospheric Research
> Mesoscale&  Microscale Meteorology Division
>
> Foothills Lab 3 - Rm. 3081
> Office: 303-497-8205
> Cell:   720-347-9337
> ------------------------------------------------------
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
__________________________________________________
Adam Phillips
asphilli@ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
Climate and Global Dynamics Division         fax: (303) 497-1333
P.O. Box 3000
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
------------------------------
Message: 5
Date: Wed, 09 Feb 2011 10:49:02 -0700
From: Adam Phillips <asphilli@ucar.edu>
Subject: Re: added rectangle and marker not shown on the
        plot
To: ncl-talk@ucar.edu
Message-ID: <4D52D38E.8030609@ucar.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi Yonghui,
As you are using gsn_panel, you should use gsn_add_polymarker and
gsn_add_polyline. Note that they are functions, and thus their output
needs to be kept in an array of type graphic:
dum = new(4,graphic)
dum(0)=gsn_add_polyline(wks,plot,(/lons(0),lons(1)/),(/lats(0),lats(0)/),lnres)
....
dum(3)=gsn_polyline(wks,plot,(/lons(1),lons(1)/),(/lats(0),lats(1)/),lnres)
dum2 = gsn_add_polymarker(wks,plot,lonobs,latobs,gsres)
You will also want to have tfPolyDrawOrder = "PostDraw" for both your
lnres and gsres resource lists...
Good luck,
Adam
On 02/09/2011 10:19 AM, Yonghui Wu wrote:
> Dear All,
>
> I tried to mark the obs location using gsn_polymarker, and tried to
> indicate a subdomain of interest using gsn_polyline. They work if I
> don't add contour2 (using filled contour). However, if I add contour2
> to the plot, then both the polymarker and the box don't show on the
> plot. Please help me to find a solution. THX.
>
> Yonghui
>
> Following is the original code: in the plot I have two choice, one
> without contour2, the other with contour2.
>
> ;   Example script to produce an OLR plot for a WRF real-data run,
> ;   with the ARW coordinate dynamics option.
> ;   In this example we are also going to zoom into an area of interest
>
> load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
> load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> ; model reference states
>   dir0 = "/raid2/yonghui/osse-exp/Result/fcst/True/"
>   datem = "10_18:00"
>   fname = "wrfout_d01_2008-02-" + datem + ":00.nc"
>
> ; obs network dimension
>   obsnorth = 34
>   obseast  = 29
>   obssigma = 36
>
> ; gain information
>   Ibdy = 13   ;get rid of boundary
>   Lskip = 2   ;get Kalman gain every 2 grid
>
> ; dimension of each gain matrix 25*25
>   Ndim = 25
>
> ; obs location in model grid
>   Ix = 35     ;model grid in east
>   Iy = 77     ;model grid in north
>   Ilev = 7    ; vertical level
>   Ilev1 = Ilev - 1
>
> ; small domain centered by (Ix,Jy) with 2*Ibdy-1 as length for plot
>   x_start = Ix - Ibdy
>   x_end = Ix + Ibdy -2
>   y_start = Iy - Ibdy
>   y_end = Iy + Ibdy -2
>
> ; transform model grid coordinate of obs location in obs network grid
>   Ilon=(Ix-13)/2+1 ;obs network grid in east
>   Jlat=(Iy-13)/2+1 ;obs network grid in north
>
> ; record number
>   krec = ((Jlat-1)*obseast+Ilon-1)*obssigma+Ilev-1 ;since ncl start from
> 0 so -1
>
> ; gain data directory
>   pathd = "/raid2/yonghui/Gain/letkf-jump02/polynomial-dart-wholemean/"
>
> ; case name
>   dateh = "1018Z"
>   cases = "test-"+dateh+"-ens93-ndim8-nocenter-cut/"
>
> ; variable name
>
>    var="t"
> ;  var="u"
> ;  var="v"
> ;  var="q"
>    vfile = "gain-"+var+"_org.bin"
> ;  vfile = "gain-"+var+"_ret.bin"
>
> ; WRF input files  needs to have a ".nc" appended, so just do it.
>    f0 = addfile(dir0 + fname,"r")
>
> ; read the gain
>
>    gaint = new ((/Ndim,Ndim/),"float",-9999.)
>    gaint = fbindirread(pathd+cases+vfile,krec,(/Ndim,Ndim/),"float")
>
> ; generate plots, but what kind do we prefer?
>     type = "pdf"
> ;   type = "x11"
> ;   type = "ps"
> ;   type = "ncgm"
>
> ; output filename
>    wks = gsn_open_wks(type,"gain-"+dateh+"-Ix"+Ix+"-Iy"+Iy+"-lev"+Ilev)
>
>
> ; Change color map to something that has a grey scale
> ;  gsn_define_colormap(wks,"wxpEnIR")
>
> ; Set some Basic Plot Information
>    res = True
> ;  res@MainTitle    = "OSSE"   ; name of plot
>    res@InitTime     = False       ; do not plot initial time
>    res@Footer       = False    ; switch footers off
>    res@tiXAxisOn = False
>    res@tiYAxisOn = False
>    res@tiMainOn  = False
>    res@tmXBLabelFontHeightF = 0.04    ; boost the axis value labels even more
>    res@tmYLLabelFontHeightF = 0.04
>    res@tmYRLabelFontHeightF = 0.04
>
> ; Set up two sets of plot and map resources
>
>    pltres             = True
>    pltres@PanelPlot   = True  ; if want to put plots on 1 page
>    pltres@gsnDraw     = False
>    pltres@gsnFrame    = False
>    pltres@gsnMaximize = True
>    pltres@FramePlot   = False ; donot advance frame automatically
>    pltres@lbLabelBarOn      = False  ; turn off label bar
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>    times  = wrf_user_list_times(f0)  ; get times in the file
>    ntimes = dimsizes(times)         ; number of times in the file
>
> ; map set
>    mpres = True
>    mpres@ZoomIn = True
>    mpres@Xstart = x_start
>    mpres@Ystart = y_start
>    mpres@Xend = x_end
>    mpres@Yend = y_end
>    mpres@tmXBLabelFontHeightF = 0.02          ; change lat lon font size
>    mpres@tmXBMajorLengthF     = 0.02          ; change the tickmark length
>    mpres@mpGridAndLimbOn      = True          ; default is every 15 deg
>    mpres@mpGridSpacingF       = 2            ; change to match labels
>    mpres@mpGeophysicalLineColor      = "Gray"
>    mpres@mpNationalLineColor         = "Gray"
>    mpres@mpUSStateLineColor          = "Gray"
>    mpres@mpGridLineColor             = "Black"
>    mpres@mpLimbLineColor             = "Gray"
>    mpres@mpPerimLineColor            = "Gray"
>    mpres@mpGeophysicalLineThicknessF = 1.5
>    mpres@mpGridLineThicknessF        = 0.5
>    mpres@mpLimbLineThicknessF        = 1.5
>    mpres@mpNationalLineThicknessF    = 1.5
>    mpres@mpUSStateLineThicknessF     = 1.5
>    mpres@gsnMaximize          = True               ; maximize image
>
>    t0 = wrf_user_getvar(f0,"tc",-1)              ; get variable
>    u0 = wrf_user_getvar(f0,"ua",-1)              ; get variable
>    v0 = wrf_user_getvar(f0,"va",-1)              ; get variable
>
>    dimvar = dimsizes(t0)
>    print ("dimvar=" + dimvar)
>    print ("y_start=" + y_start)
>    print ("y_end=" + y_end)
>    print ("x_start=" + x_start)
>    print ("x_end=" + x_end)
>
>    Ilev1 = Ilev - 1 ;ncl start from 0 so -1
>    tzoom1 = t0(:,Ilev1,y_start:y_end,x_start:x_end)  ; zoomed area
>    uzoom1 = u0(:,Ilev1,y_start:y_end,x_start:x_end)  ; zoomed area
>    vzoom1 = v0(:,Ilev1,y_start:y_end,x_start:x_end)  ; zoomed area
>
>    plot = new (1, graphic)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;; loop over time
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>   do it = 0,ntimes-1                             ; start at time 2
>
> ; contour plot of T
>      opts = res
>      opts@lbTitleOn = False                   ; remove field name from
> label bar
>      opts@ContourParameters = (/-30, 30, 2/)
>      opts@lbLabelBarOn      = False  ; turn off label bar
>      opts@TimeLabel = times(it)                   ; set Valid time on the
> plot
>      opts@cnLineColor              = "black"
>      opts@cnInfoLabelOn            = False    ; no bottom info plotted
>      opts@pmLabelBarOrthogonalPosF = -0.1
>      opts@gsnContourLineThicknessesScale = 2.5
>      opts@cnLineLabelsOn           = True
>      opts@gsnDraw                  = False    ; Forces the plot to be drawn
>      opts@gsnFrame                 = False    ; Frame advance
>      opts@mpGridAndLimbDrawOrder    = "PreDraw"
>      opts@cnLabelDrawOrder          = "PreDraw"
>      contour1 = wrf_contour(f0,wks,tzoom1(it,:,:),opts)
>
> ; replace t with the gain
>      dimzoom = dimsizes(tzoom1)
>      print ("dim of t0zoom=" + dimzoom)
>      tzoom1(it,:,:) = (/gaint(:,:)/)
>
>      optg = res
>      optg@cnInfoLabelOn        = False
>      optg@UnitLabel            = "C, shaded"
>      optg@FieldTitle           = "Tdif"   ; overwrite Field Title
> ;        opts@gsnStringFontHeightF = 2
>      optg@lbLabelBarOn      = True  ; turn off label bar
>      optg@cnFillOn          = True
>      optg@pmLabelBarOrthogonalPosF = -0.02
>      optg@ContourParameters = (/-1.2, 1.8, 0.3/)
>      optg@cnFillColors      = (/"Blue3","Blue2","Blue1",\
>           "Cyan","SpringGreen","White","White","Yellow","Orange",\
>           "Red","Red2", "Red4"/)
>      optg@gsnContourLineThicknessesScale = 1.0
>      optg@gsnDraw           = False    ; Forces the plot to be drawn
>      optg@gsnFrame          = False    ; Frame advance
>      optg@lbTitleOn = False                   ; remove field name from
> label bar
>      optg@TimeLabel = times(it)                   ; set Valid time on the
> plot
>      optg@cnLineColor              = "black"
>      optg@cnInfoLabelOn            = False    ; no bottom info plotted
>      optg@pmLabelBarOrthogonalPosF = -0.1
>      optg@gsnContourLineThicknessesScale = 2.5
>      optg@cnLineLabelsOn           = True
>      optg@gsnDraw                  = False    ; Forces the plot to be drawn
>      optg@gsnFrame                 = False    ; Frame advance
>      contour2 = wrf_contour(f0,wks,tzoom1(it,:,:),optg)
>
> ; vector plot of (U,V)
>      resu = True
>      resu@TimeLabel = times(it)                   ; set Valid time on the
> plot
>      resu@gsnMaximize          = True    ; Maximize plot in frame
>      resu@gsnSpreadColors      = True   ; span full colormap
>      resu@vcMonoLineArrowColor = True  ; color arrows based on magnitude
>      resu@vcRefLengthF         = 0.03313608
>      resu@vcMinFracLengthF     = 0.3
> ;
> ; Setting the reference magnitude also affects the length
> ; of the arrows. In this case it is an inverse relationship.
> ;
>      resu@vcRefMagnitudeF = 50.0
> ;
> ; Line-drawn arrowheads are sized proportionally to the arrow length
> ; unless the resulting size would be outside the limits defined by
> ; the arrowhead minimum and maximum size resources. Setting the
> ; minimum and maximum sizes to the same value causes all the
> ;
>      resu@tiMainOn                = False
>      resu@tiMainString           = ""
>      resu@vcLineArrowHeadMinSizeF = 0.013
>      resu@vcLineArrowHeadMaxSizeF = 0.013
>      resu@gsnDraw              = False              ; don't draw
>      resu@gsnFrame             = False              ; don't advance frame
>      resu@vcExplicitLabelBarLabelsOn = False
>      resu@vcRefMagnitudeF = 15.                    ; make vectors larger
>      resu@vcRefLengthF    = 0.050                 ; reference vector length
>      resu@vcGlyphStyle    = "CurlyVector"         ; turn on curly vectors
>      resu@vcMinDistanceF  = 0.03                 ; thin the vectors
> ;     resu@FieldTitle           = "Wind "   ; overwrite Field Title
> ;     resu@UnitLabel            = "m/s, vector"
> ;     resu@vcRefAnnoOn          = False         ; show ref vector size value
>      resu@vcRefAnnoOn          = True         ; show ref vector size value
>      resu@vcMinAnnoOn          = False
> ;    resu@gsnLeftString   = "Wind      (vector)"
> ; plot vector every 2 grid point
>      jump = 1
>      vector =
> wrf_vector(f0,wks,uzoom1(it,::jump,::jump),vzoom1(it,::jump,::jump),resu)
>
> ; Plot OLR in grey scale for the full domain
> ;    plot = wrf_map_overlays(f0,wks,(/contour/),pltres,mpres)
>
>
>
>
> ; Now zoom into the box area and plot just for this area
>      plot  = wrf_map_overlays(f0,wks,(/vector,contour1/),pltres,mpres)
> ;    plot =
> wrf_map_overlays(f0,wks,(/vector,contour1,contour2/),pltres,mpres)
>
>
> ; plot a box on the output
>      lats = (/  46.0,  50.0 /)
>      lons = (/ -87.0, -83.0 /)
>      loc = wrf_user_ll_to_ij(f0, lons, lats, True)
>      lnres = True
>      lnres@gsLineColor = "NavyBlue"
>      lnres@gsLineThicknessF = 3.0
>      gsn_polyline(wks,plot,(/lons(0),lons(1)/),(/lats(0),lats(0)/),lnres)
>      gsn_polyline(wks,plot,(/lons(0),lons(1)/),(/lats(1),lats(1)/),lnres)
>      gsn_polyline(wks,plot,(/lons(0),lons(0)/),(/lats(0),lats(1)/),lnres)
>      gsn_polyline(wks,plot,(/lons(1),lons(1)/),(/lats(0),lats(1)/),lnres)
>
>
> ; plot a marker at the obs site
>      obsloc = wrf_user_ij_to_ll(f0, Ix, Iy, True) ; find lon and lat
>      print("lon/lat location is: " + obsloc)
>      lonobs = obsloc(0)
>      latobs = obsloc(1)
>      print("lon= " + lonobs + " lat= "+latobs)
>
>      gsres                    = True
>      gsres@tfPolyDrawOrder    = "PreDraw"
> ;    gsres@tfPolyDrawOrder    = "PostDraw"
>      gsres@gsMarkerIndex      = 16
>      gsres@gsMarkerColor      = (/"black"/)
>      gsres@gsMarkerThicknessF = 10.7
> ;    gsn_add_polymarker(wks,plot,lonobs,latobs,gsres)
>      gsn_polymarker(wks,plot,lonobs,latobs,gsres)
>
> ; put the plots together
>    resP                      = True
>    resP@gsnDraw              = True              ; draw
>    resP@gsnFrame             = True              ; advance frame
>    resP@gsnMaximize          = True              ; maximize image
>    resP@gsnPanelLabelBar     = True              ; add common colorbar
>    resP@gsnPanelTop          = 1.0
>    resP@gsnPanelBottom       = 0.1               ; space for label bar
>    resP@pmLabelBarWidthF     = 0.95               ; make thinner
>    resP@pmLabelBarHeightF    = 0.06
>    resP@txString             = "The Gain of T at "+dateh
>    resP@lbLabelAutoStride   = True
>    resP@gsnPaperOrientation = "portrait"
>    resP@pmLabelBarOrthogonalPosF = 0.2          ; move labelbar position
>    resP@gsnPanelXWhiteSpacePercent = 3
>    resP@gsnPanelYWhiteSpacePercent = 0
>    resP@gsnPanelYF = (/-2,-2,0.54,0.54/)
>    gsn_panel(wks,plot,(/1,1/), resP)
>
>   end do
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> end
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
__________________________________________________
Adam Phillips
asphilli@ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
Climate and Global Dynamics Division         fax: (303) 497-1333
P.O. Box 3000
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
------------------------------
Message: 6
Date: Wed, 9 Feb 2011 12:54:26 -0500 (EST)
From: Ioana Colfescu <colfescu@cola.iges.org>
Subject: binary file reading
To: ncl-talk@ucar.edu
Message-ID:
        <1986165137.21046.1297274066337.JavaMail.root@mail.iges.org>
Content-Type: text/plain; charset=utf-8
Hi,
Can NCL read binary files that contain more than a single record but are not written using Fortran ?
Thanks,
Ioana
------------------------------
Message: 7
Date: Wed, 09 Feb 2011 11:02:42 -0700
From: Dennis Shea <shea@ucar.edu>
Subject: Re: binary file reading
To: Ioana Colfescu <colfescu@cola.iges.org>
Cc: ncl-talk@ucar.edu
Message-ID: <4D52D6C2.9090303@ucar.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Although the documentation states
"records written by a Fortran direct access write"
the function 'fbindirread' can be used to read
a 'flat' binary file written by any language.
Ideally, the file contains records of the same type.
http://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirread.shtml
On 02/09/2011 10:54 AM, Ioana Colfescu wrote:
> Hi,
>
> Can NCL read binary files that contain more than a single record but are not written using Fortran ?
>
> Thanks,
>
> Ioana
------------------------------
_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
End of ncl-talk Digest, Vol 87, Issue 12
****************************************
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Feb 9 14:46:50 2011

This archive was generated by hypermail 2.1.8 : Fri Feb 11 2011 - 16:11:42 MST