Re: Plotting stretched grids in NCL Contours

From: Dave Brown (dbrown AT XXXXXX)
Date: Wed Jun 26 2002 - 10:08:06 MDT

  • Next message: Heiko Klein: "Own Logo"

    Hi Mary,

    I think you left out one thing that is necessary for overlaying on
    the LogLinPlot using "straight NCL": the data coordinate extents of the
    LogLinPlot needs to match the actual data extents. The easy way to do this
    is analogous to setting the viewport; just retrieve and set the
    tr[X|Y][Min|Max]F resources:

       getvalues contour
         "vpXF" : vpx
         "vpYF" : vpy
         "vpWidthF" : vpw
         "vpHeightF" : vph
         "trXMinF" : xmin
         "trXMaxF" : xmax
         "trYMinF" : ymin
         "trYMaxF" : ymax
       end getvalues
     ;
     ; Create a loglin plot object.
     ;
       loglin = create "LogLin" logLinPlotClass wks
         "vpXF" : vpx
         "vpYF" : vpy
         "vpWidthF" : vpw
         "vpHeightF" : vph
         "trXMinF" : xmin
         "trXMaxF" : xmax
         "trYMinF" : ymin
         "trYMaxF" : ymax
       end create

    Also a nitpick: I assume you mean in your example code to set the
    data in the ScalarField, i.e:

       dataid = create "data" scalarFieldClass defaultapp
         "sfDataArray" : contour_data
         "sfXArray" : xg
         "sfYArray" : yg
       end create

    On Tue, 25 Jun 2002, Mary Haley wrote:

    .....
    >
    > There's a good example of how to do this in frame 4 of the the NCL
    > example "cn03n". To generate this example, type:
    >
    > ng4ex cn03n
    >
    > Then, edit the file and search for "logLinPlotClass", and you'll see
    > how the overlay is done. Below is a similar example of how this might
    > work.
    >
    > contour_data = (/some 2D array/)
    > ;
    > ; Open an X11 workstation.
    > ;
    > wks = create "x11" xWorkstationClass defaultapp end create
    > ;
    > ; Create a data object.
    > ;
    > dataid = create "data" scalarFieldClass defaultapp
    > "sfXArray" : xg
    > "sfYArray" : yg
    > end create
    > ;
    > ; Create a contour plot object.
    > ;
    > contour = create "plot" contourPlotClass wks
    > "cnScalarFieldData" : dataid
    > end create
    > ;
    > ; Retrieve the viewport coordinates so we can use them to
    > ; specify the exact same coordinates for the loglin plot.
    > ;
    > getvalues contour
    > "vpXF" : vpx
    > "vpYF" : vpy
    > "vpWidthF" : vpw
    > "vpHeightF" : vph
    > end getvalues
    > ;
    > ; Create a loglin plot object.
    > ;
    > loglin = create "LogLin" logLinPlotClass wks
    > "vpXF" : vpx
    > "vpYF" : vpy
    > "vpWidthF" : vpw
    > "vpHeightF" : vph
    > end create
    > ;
    > ; Overlay the contour plot on the loglin plot.
    > ;
    > overlay(loglin,contour)
    > ;
    > ; The loglin plot becomes the base plot that contains the
    > ; contour plot, so to draw the contour plot, you must draw
    > ; the loglin plot.
    > ;
    > draw(loglin)
    > ;
    > ; Advance the frame.
    > ;
    > frame(wks)
    >
    > >
    > > When I try and use the gsn_contour routine and set the attributes, I
    > > also get the correct cooridinate values plotted but no change in the plot.
    > >
    > >
    > > Lou Wicker
    > >
    >
    > This whole process is a little easier if you are using gsn_contour.
    > You can set the special "gsn" resource "gsnYAxisIrregular2Linear" to
    > True, and the creating/overlaying of the logLinPlotClass will take
    > place behind the scenes.
    >
    > Your GSUN script might look something like this:
    >
    >
    > contour_data = (/some 2D array/)
    > wks = gsn_open_wks("x11","example") ; Open an X11 workstation.
    >
    > res = True
    > res@sfXArray = xg
    > res@sfYArray = yg
    > res@gsnYAxisIrregular2Linear = True
    >
    > contour = gsn_contour(wks,contour_data,res) ; Draw plot and advance frame.
    >
    > --Mary
    >
    > >
    > > ================================================
    > > Dr. Louis J. Wicker
    > > Research Scientist, National Severe Storms Lab
    > > 1313 Halley Cir, Norman, OK 73069
    > > E-mail: Louis.Wicker@nssl.noaa.gov
    > > Phone: (405) 366-0416 / Fax: (405) 579-0808
    > > Norman's Little River Zoo on SE 120th off Rt. 9:
    > > Your zoo for life!
    > > ===============================================
    > _______________________________________________
    > ncl-talk mailing list
    > ncl-talk@ucar.edu
    > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    >



    This archive was generated by hypermail 2b29 : Wed Jun 26 2002 - 10:01:53 MDT