<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
--></style><title>Re: "define" values are different.
why?</title></head><body>
<div>Mary Jo,</div>
<div><br></div>
<div>When you define "b" or "c" the defined
variable has 144 points in the x-dimension as you expect because the
x-dimension is set to 1 to 144 (see your 'q dims' output). When
you define "a" the defined variable has 146 points (0 to
145) because the x-dimension is 0.5 to 144.5 (see 'q dims'
output).</div>
<div><br></div>
<div>This is because grads is working with the data it needs to make a
plot. If lon is set from 0 to 360, x is set from 0.5 to 144.5.
In order to make a plot that extends all the way to 0 and 360, grads
needs the data at lon = -1.25 and lon = 361.25 to contour the regions
from 0 to 1.25 and from 358.75 to 360. Otherwise if you set the
plot from 0 to 360 and plotted the data you are using, you would get
data plotted only from 1.25 to 358.75 and there would be a blank strip
on either side.</div>
<div><br></div>
<div>It is a good idea to define your variables like you do below for
"b". By explicitly setting the dimensions (set y too)
to match the dimensions of the data you will get what you expect.
If your input data was from -180 to 180 in lon and you don't 'set x 1
144', you would get data that is shifted by 180 degrees.</div>
<div><br></div>
<div>Mike</div>
<div><br></div>
<div><br></div>
<blockquote type="cite" cite><tt>Hi,<br>
<br>
I wasn't able to find anything on the board regarding this issue.
Maybe someone can explain why do I get different values in the script
(below) for the defined variable "a" & "b" ?
("b" and "c" are the same and correct.) I
would expect a = b = c regardless of how I access the values of those
variables.<br>
<br>
Below is the full script and the results. The data file is attached if
anyone would like to run the script on their machine . If you get
different results, please let me know.<br>
<br>
(I'm using Config: v1.9b4 32-bit little-endian on a Linux workstation.
I get the same results, though, using older versions 1.7beta9 and
1.8SL10.)<br>
<br>
I think this is occurring because of this data's grid, where X=1
is longitude 1.25E instead of 0E. By default GrADS maps "set lon
0 360" into "X = 0.5 to 144.5", so however
"define" works, GrADS returns the proper value for
"a" if "set x 30" is done first, but doesn't
return the expected value if you do<br>
"d a(x=30)". Variables "b" and "c" work
because I explicitly "set x 1 144" or "set lon 1.25
358.75" (which correspond to X=1 and X=144 ). <br>
<br>
When I ran a similar script using NCEP data which starts at Lon = 0.,
I didn't have this problem.<br>
<br>
Thanks,<br>
Mary Jo<br>
<br>
SCRIPT:<br>
<br>
sdfopen model.slp.nc<br>
set lat 0<br>
q dims<br>
define a=slp<br>
set x 1 144<br>
q dims<br>
define b=slp<br>
set lon 1.25 358.75<br>
q dims<br>
define c=slp<br>
set x 30<br>
d a<br>
d b<br>
d c<br>
d a(x=30)<br>
d b(x=30)<br>
d c(x=30)<br>
d a-b<br>
d a(x=30)-b(x=30)<br>
d a-c<br>
d a(x=30)-c(x=30)<br>
d b-c<br>
d b(x=30)-c(x=30)<br>
<br>
<br>
RESULTS:<br>
<br>
<b>sdfopen /net2/mjn/model.slp.nc</b><br>
Scanning self-describing file: /net2/mjn/model.slp.nc<br>
SDF file /net2/mjn/model.slp.nc is open as file 1<br>
LON set to 0 360<br>
LAT set to -89.4944 89.4944<br>
LEV set to 0 0<br>
Time values set: 1870:1:16:12 1870:1:16:12<br>
<b>set lat 0</b><br>
LAT set to 1.01124 1.01124<br>
<b>q dims</b><br>
Default file number is: 1<br>
X is varying Lon = 0 to 360 X = 0.5 to
144.5<br>
Y is fixed Lat = 1.01124 Y = 46<br>
Z is fixed Lev = 0 Z = 1<br>
T is fixed Time = 12Z16JAN1870 T = 1<br>
<b>define a=slp</b><br>
Define memory allocation size = 584 bytes<br>
<b>set x 1 144</b><br>
LON set to 1.25 358.75<br>
<b>q dims</b><br>
Default file number is: 1<br>
X is varying Lon = 1.25 to 358.75 X = 1 to
144<br>
Y is fixed Lat = 1.01124 Y = 46<br>
Z is fixed Lev = 0 Z = 1<br>
T is fixed Time = 12Z16JAN1870 T = 1<br>
<b>define b=slp</b><br>
Define memory allocation size = 576 bytes<br>
<b>set lon 1.25 358.75</b><br>
LON set to 1.25 358.75<br>
<b>q dims</b><br>
Default file number is: 1<br>
X is varying Lon = 1.25 to 358.75 X = 1 to
144<br>
Y is fixed Lat = 1.01124 Y = 46<br>
Z is fixed Lev = 0 Z = 1<br>
T is fixed Time = 12Z16JAN1870 T = 1<br>
<b>define c=slp</b><br>
Define memory allocation size = 576 bytes<br>
<b>set x 30</b><br>
LON set to 73.75 73.75<br>
<b>d a</b><br>
Result value = 1010.45<br>
<b>d b</b><br>
Result value = 1010.45<br>
<b>d c</b><br>
Result value = 1010.45<br>
<b>d a(x=30)</b><br>
Result value = 1010.57 <i> <==== ????</i><br>
<b>d b(x=30)</b><br>
Result value = 1010.45<br>
<b>d c(x=30)</b><br>
Result value = 1010.45<br>
<b>d a-b</b></tt></blockquote>
<blockquote type="cite" cite><tt>Result value = 0<br>
<b>d a(x=30)-b(x=30)</b><br>
Result value = 0.122498 <i> <==== a != b</i><br>
<b>d a-c</b><br>
<b>Result value = 0<br>
d a(x=30)-c(x=30)</b><br>
Result value = 0.122498 <i> <=== a != c</i><br>
<b>d b-c</b><br>
Result value = 0<br>
<b>d b(x=30)-c(x=30</b>)<br>
Result value = 0<br>
EOF EXECuting test_script</tt></blockquote>
<blockquote type="cite" cite><br>
Attachment converted: Macintosh HD:model.slp.nc (
/ ) (001D5A5C)<br>
sdfopen /net2/mjn/model.slp.nc<br>
set lat 0<br>
q dims<br>
define a=slp<br>
set x 1 144<br>
q dims<br>
define b=slp<br>
set lon 1.25 358.75<br>
q dims<br>
define c=slp<br>
set x 30<br>
d a<br>
d b<br>
d c<br>
d a(x=30)<br>
d b(x=30)<br>
d c(x=30)<br>
d a-b<br>
d a(x=30)-b(x=30)<br>
d a-c<br>
d a(x=30)-c(x=30)<br>
d b-c<br>
d b(x=30)-c(x=30)</blockquote>
<div><br></div>
</body>
</html>