# Re: clipped raster plot

From: David Ian Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 27 Feb 2007 15:01:16 -0700

Hi Andrea,

When there are the same number of grid elements as coordinate elements,
then NCL treats the grid values as being centered on the cell.
The edge cells (whether drawn using the CellFill or the RasterFill
technique)
are half size because NCL does not extrapolate beyond the given
coordinate
values.
To specify the same grid as you have below using cell edges is
straightforward
in this case because the cell sizes are uniformly spaced in lat and lon.
The size of each cell is:
lat: (55 - 25) / (13 - 1) => 2.5
lon: (50 - 20) / (13 -1) => 2.5

That means that half a cell is 1.25 in both lat and lon.
Therefore the edge cell boundaries are 1.25 degrees beyond the cell
edges in
each direction. Also, as Mary suggested, there is one more edge than
center.
So you get the coordinates of the edges as follows:

lat_edges = fspan(23.75,56.25,14)
lon_edges = fspan(18.75,51.25,14)

Since the coordinate arrays that attach to NCL variables always
represent centers
rather than edges (the variable coordinates must correspond 1 for 1
with the elements
along that dimension), you must explicitly set sfXArray and sfYArray
with the edge array values
to communicate them to the plotting code. That is:

res_at_sfXArray = lon_edges
res_at_sfYArray = lat_edges
plot = gsn_csm_contour_map(wks,ncycl,res)

-dave

On Feb 26, 2007, at 5:09 PM, Andrea Hahmann wrote:

> Hi!
>
> I am trying to draw a raster plot of cyclone counts defined on a
> uniform
> lat/lon grid on a map on a Lambert projection. The uniform cyclone
> count grid is plotted in the right place, but only half of the
> "squares"
> at the edge of the domain are drawn. Is there a resource parameter I
> can use to disable this behavior?
>
> The documentation states that "If the data grid is defined using cell
> edges, the cell boundaries are obtained explicitly from the coordinate
> arrays. " I think this is how I might solve my problem... But, how do I
> define the data array using the cell edge?
>
> I have attached my resulting image and a snip of the code is below.
> Any help will be greatly appreciated!
> Thanks,
>
> Andrea
>
> lat1dg = fspan(25.,55.,13)
> lat1dg_at_long_name = "latitude"
> lat1dg_at_units = "degrees north"
>
> lon1dg = fspan(20.,50.,13)
> lon1dg_at_long_name = "longitude"
> lon1dg_at_units = "degrees east"
>
> ncycl = new((/13,13/),"float")
> ncycl = 0.
> ncycl!0 = "lat"
> ncycl&lat = lat1dg
> ncycl!1 = "lon"
> ncycl&lon = lon1dg
>
> ...
>
> res_at_cnFillOn = True ; turn on color fill
> res_at_cnFillMode = "CellFill"
> res_at_cnCellFillEdgeColor = 1
> res_at_gsnSpreadColors = True ; use full range of
> colors
> res_at_cnLinesOn = False
> res_at_cnLineLabelsOn = False
> res_at_gsnMaximize = True
>
> res_at_tiMainString = "Cyclone count - January "+YearRes
> plot = gsn_csm_contour_map(wks,ncycl,res)
>
> --
> ----------------------------------------------------------------
> Andrea N. Hahmann, Ph.D.
> Research Applications Laboratory
> Natl. Center for Atmospheric Research Phone: 1-303-497-8383
> PO BOX 3000 Fax: 1-303-497-8401
> Boulder, CO 80301 hahmann_at_ucar.edu
> ----------------------------------------------------------------
>
>
> <count.2006.05.gif>_______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 27 2007 - 15:01:16 MST

This archive was generated by hypermail 2.2.0 : Thu Mar 01 2007 - 18:02:36 MST