"define" values are different. why?
Mary Jo Nath
Mary-Jo.Nath at NOAA.GOV
Thu Jun 14 16:10:29 EDT 2007
Thanks for the explanation, Mike. I normally don't access variables
using grid index values, but by using
"lat=" or "lon=". I see that "d a(lon=73.75)" instead of "d a(x=30)"
gives me the value I intended to retrieve. - MJ
Michael Timlin wrote:
> Mary Jo,
>
> 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).
>
> 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.
>
> 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.
>
> Mike
>
>
>> Hi,
>>
>> 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.
>>
>> 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.
>>
>> (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.)
>>
>> 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
>> "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 ).
>>
>> When I ran a similar script using NCEP data which starts at Lon = 0.,
>> I didn't have this problem.
>>
>> Thanks,
>> Mary Jo
>>
>> SCRIPT:
>>
>> sdfopen model.slp.nc
>> set lat 0
>> q dims
>> define a=slp
>> set x 1 144
>> q dims
>> define b=slp
>> set lon 1.25 358.75
>> q dims
>> define c=slp
>> set x 30
>> d a
>> d b
>> d c
>> d a(x=30)
>> d b(x=30)
>> d c(x=30)
>> d a-b
>> d a(x=30)-b(x=30)
>> d a-c
>> d a(x=30)-c(x=30)
>> d b-c
>> d b(x=30)-c(x=30)
>>
>>
>> RESULTS:
>>
>> *sdfopen /net2/mjn/model.slp.nc*
>> Scanning self-describing file: /net2/mjn/model.slp.nc
>> SDF file /net2/mjn/model.slp.nc is open as file 1
>> LON set to 0 360
>> LAT set to -89.4944 89.4944
>> LEV set to 0 0
>> Time values set: 1870:1:16:12 1870:1:16:12
>> *set lat 0*
>> LAT set to 1.01124 1.01124
>> *q dims*
>> Default file number is: 1
>> X is varying Lon = 0 to 360 X = 0.5 to 144.5
>> Y is fixed Lat = 1.01124 Y = 46
>> Z is fixed Lev = 0 Z = 1
>> T is fixed Time = 12Z16JAN1870 T = 1
>> *define a=slp*
>> Define memory allocation size = 584 bytes
>> *set x 1 144*
>> LON set to 1.25 358.75
>> *q dims*
>> Default file number is: 1
>> X is varying Lon = 1.25 to 358.75 X = 1 to 144
>> Y is fixed Lat = 1.01124 Y = 46
>> Z is fixed Lev = 0 Z = 1
>> T is fixed Time = 12Z16JAN1870 T = 1
>> *define b=slp*
>> Define memory allocation size = 576 bytes
>> *set lon 1.25 358.75*
>> LON set to 1.25 358.75
>> *q dims*
>> Default file number is: 1
>> X is varying Lon = 1.25 to 358.75 X = 1 to 144
>> Y is fixed Lat = 1.01124 Y = 46
>> Z is fixed Lev = 0 Z = 1
>> T is fixed Time = 12Z16JAN1870 T = 1
>> *define c=slp*
>> Define memory allocation size = 576 bytes
>> *set x 30*
>> LON set to 73.75 73.75
>> *d a*
>> Result value = 1010.45
>> *d b*
>> Result value = 1010.45
>> *d c*
>> Result value = 1010.45
>> *d a(x=30)*
>> Result value = 1010.57 / <==== ????/
>> *d b(x=30)*
>> Result value = 1010.45
>> *d c(x=30)*
>> Result value = 1010.45
>> *d a-b*
>> Result value = 0
>> *d a(x=30)-b(x=30)*
>> Result value = 0.122498 / <==== a != b/
>> *d a-c*
>> *Result value = 0
>> d a(x=30)-c(x=30)*
>> Result value = 0.122498 / <=== a != c/
>> *d b-c*
>> Result value = 0
>> *d b(x=30)-c(x=30*)
>> Result value = 0
>> EOF EXECuting test_script
>>
>> Attachment converted: Macintosh HD:model.slp.nc ( / ) (001D5A5C)
>> sdfopen /net2/mjn/model.slp.nc
>> set lat 0
>> q dims
>> define a=slp
>> set x 1 144
>> q dims
>> define b=slp
>> set lon 1.25 358.75
>> q dims
>> define c=slp
>> set x 30
>> d a
>> d b
>> d c
>> d a(x=30)
>> d b(x=30)
>> d c(x=30)
>> d a-b
>> d a(x=30)-b(x=30)
>> d a-c
>> d a(x=30)-c(x=30)
>> d b-c
>> d b(x=30)-c(x=30)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20070614/1053c5b3/attachment.html
More information about the gradsusr
mailing list