> I am reading a binary data with the following attributes:
>
> Dimensions and sizes: [time | 12] x [lat | 21] x [lon | 33]
>
> For that I used the following piece of script...
>
> do n = 0, 11
> data(n,:,:) = fbindirread("pcomp.grd",n,(/21,33/),"float")
> end do
>
> data!0 = "time"
> data!1 = "lat"
> data!2 = "lon"
> data&lon = fspan(40, 120, 33)
> data&lat = fspan(-20, 30, 21)
>
> But when I try to plot (plot = gsn_csm_contour_map_ce(wks,data(2,:,:),False))
> It just stretches out my data field on to the global map. Also it gives a
> warning message "check_for_y_lat_coord: Warning: Data either does not contain
> a valid latitude coordinate array or doesn't contain one at all."
>
> How do I avoid this and plot the data only in the specified domain?
The gsn_csm_* suite of graphical interfaces are "meta-data-aware".
They look at the data object [array + attributes + coordinates]
for information. You assigned values to the lat/lon coordinate
arrays but you did not assign the units attribute.
Also, good programming practice is to use variables names ... even for constants.
It makes the code clearer and if future nodifications are needed,
they need only be done in one place.
fName= "pcomp.grd"
ntim = 12
nlat = 21
mlon = 33
latS = -20
latN = 30
lonL = 40
lonR = 120
lat = fspan(latS,latN,nlat)
lat@units = "degrees_north"
lon = fspan(lonL,lonR,mlon)
lon@units = "degrees_east"
data = fbindirread(fName,0,(/ntim,nlat,mlon/),"float")
;data@long_name = "..."
;data@units = "..."
data!0 = "time"
data!1 = "lat"
data!2 = "lon"
data&lat = lat
data&lon = lat
month = (/ "Jan",...,"Dec"/)
To plot ... Go to "Applications" page:
Click on "Map projections: Cylindrical Equidistant"
See Example 3
wks = gsn_open_wks("x11" ,"ce") ; open a ps file
gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose colormap
res = True ; plot mods desired
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = False ; turn of contour lines
;;res@cnLevelSpacingF = 0.5 ; contour spacing
res@gsnSpreadColors = True ; use full range of color map
;;res@lbLabelStride = 4
;;res@pmTickMarkDisplayMode = "Always"; use NCL default lat/lon labels
;;res@gsnAddCyclic = False ; data already has cyclic point
; this must also be set for any zoom
res@mpMinLatF = latS
res@mpMaxLatF = latN
res@mpMinLonF = lonL
res@mpMaxLonF = lonR
nmo = 2 ; NCL starts at 0 so this is March
res@gsnCenterString = month(nmo)
plot = gsn_csm_contour_map_ce(wks,data(nmo,:,:), res)
_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2b29 : Fri Nov 04 2005 - 09:36:03 MST