[gradsusr] Ploting Cross/X at specific grid box
James T. Potemra
jimp at hawaii.edu
Fri Aug 5 14:06:20 EDT 2011
Dan:
You can do this with two loops, one over X (lon) and the other over Y
(lat).
First open the data and plot something in order to plot scaling dimensions
(if you don't want to display anything just set the maximum clev
appropriately).
Next, loop over all lat/lon and "set X" / "set Y" each step of the way,
store the
result in two variables. Then, display your variable, and if equal to a
valid
point, draw a character.
As an example, let's say you have a variable called "temp", with 360
longitudes
and 180 latitudes, with missing values equal to -999.
*--------
* open data set and display some variable
'sdfopen dansdata.nc'
'set cmax -10000'
'd temp'
* loop over all lon/lat
i = 1
while ( i <= 360 )
j = 1
while ( j <= 180 )
* set location to (i,j) and store lon/lat response
'set x 'i
xlon = subwrd(result,4)
'set y 'j
ylat = subwrd(result,4)
* convert lon/lat to inches on the page
'q w2xy 'xlon' 'ylat
x1 = subwrd(result,3)
y1 = subwrd(result,6)
* display variable at this (i,j) point
'd temp'
val = subwrd(result,4)
* if value is not "missing", draw an "X" centered in the grid box
if ( val != -999 )
'set string 2 c'
'draw string 'x1' 'y1' X'
endif
j = j + 1
endwhile
i = i + 1
endwhile
*------
Jim
On 8/4/11 11:14 PM, Dan Zhang wrote:
> Dear all,
>
> I have a global NetCDF file (resolution T31) with constant value of 1 and 1000
> missing values. I would like to plot a cross/X at each grid box, except the
> box with missing value.
>
> Questions:
> Is it possible to do it by a loop of 'draw string x-position y-position X'?
> Since x-position and y-position are related to the latitudes and longitudes
> of the boxes. But then how to exclude the boxes with missing value?
> Or is there another easier way?
>
> Please help me out. Thanks a lot.
> sincerely,
>
> Dan
>
>
> ----------------------------------------------------------------------------------------------
> Dan ZHANG
>
> Max Planck Institute for Meteorology
> Meteorological Insititute, University Hamburg
> KlimaCampus
> Room 407, Grindelberg 5
> D-20144, Hamburg
> Germany
>
> Tel(office):+49 (0)40 42838 5067
> Fax:+49 (0)40 42838 5066
>
> ----------------------------------------------------------------------------------------------
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
More information about the gradsusr
mailing list