[gradsusr] Problem in loading variables in different files.

Hang hang_hang2004 at yahoo.com.hk
Wed Jan 26 10:38:31 EST 2011


Let me try to regrid the files tomorrow and try calculating the values.

thanks again 

henry



________________________________
From: Hang <hang_hang2004 at yahoo.com.hk>
To: GrADS Users Forum <gradsusr at gradsusr.org>
Sent: Wed, January 26, 2011 11:32:53 PM
Subject: Re: [gradsusr] Problem in loading variables in different files.


Doug,

Oh, about the the error refers to vwnd10m, actually I have also defined it but I 
have forgotten to include that in my script. I wanted to simplify the question 
but I cut the wring part... sorry about that. Actually the define command I 
should put here should be         

      'set lat 'lat1
      'set lon 'lon1' 'lon2
      'set t 'time
      'set lev 'level1 
      'define 
wind=(ave(vwnd.2,lon='lon1',lon='lon2')+ave(vwnd10m,lon='lon1',lon='lon2'))/2'  

   in order to match the error message. ( the idea is more of less the same as 
the last one)

So I think you are right that "Dimension = 1" may correspond  to the difference 
in Xsize (vwnd.2 : Xsize = 144   and   vwnd10m:  Xsize = 192 )

Do you mean that multi level files and single level file cannot be combined 
together as well?

And about fixing the lon value with lat varying (in the script  included in the 
last mail) , because I want to find the flux across a certain vertical plane 
when analyzing  a certain grid box. As I am a new user of GrADS, I do not know 
if this is the right way or the usual way, any better suggestions  ?

Thanks so much for your help 

Cheers,
Henry


________________________________
From: "Clark, Douglas B." <dbcl at ceh.ac.uk>
To: GrADS Users Forum <gradsusr at gradsusr.org>
Sent: Wed, January 26, 2011 5:42:14 PM
Subject: Re: [gradsusr] Problem in loading variables in different  files.

Henry,

Actually...I'm not so sure exactly what your problem is!  It has been a while 
since I tried to use different grids and I have forgotten the details. Some 
further suggestions:

I noticed that your first grid has same x and y sizes as grids 4 onwards, so 
perhaps the horizontal grid isn't the problem. The answer probably lies in the 
dimension bit of the error message "Variable = vwnd10m  Dimension = 1", but I 
don't know how to interpret the dimension number here. Dim1 sounds like a 
horizontal thing, but I'm not sure. Also the error refers to vwnd10m, so it 
doesn't relate to the define command you listed below (I had assumed it did). 
But the later files have multiple levels, so perhaps the problem relates to the 
levels.

Also I notice that you fix the lon value, but have lat varying, and then 
calculate an average over latitude, which looks a bit strange (you could also 
fix lat) but should  work.

No answers here I'm afraid, just some thoughts.

Doug




From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org] On 
Behalf Of Clark, Douglas B.
Sent: 26 January 2011 09:10
To: GrADS Users Forum
Subject: Re: [gradsusr] Problem in loading variables in different files.

Henry,

Yes, I think your problem is that you are trying to use variables that are on 
different grids, as you suggested.
(This would only work if one grid was a subset of the other.)

You can do calculations on these variables separately, but you can't combine 
them (e.g. sum them).

Chances are that you will need to regrid some variables to get everything on the 
same grid. In GrADS, you can regrid using the  regrid UDF (user defined function 
- only available with some versions of GrADS I think) or you could regrid using 
some other package outside of GrADS.

(By the way, I notice your file #1 has different xsize and ysize from files #2 
and 3, which might be fine, but check that this also doesn't give you unexpected 
results.)

Doug


From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org] On 
Behalf Of Hang
Sent: 26 January 2011 08:51
To: gradsusr at gradsusr.org
Subject: [gradsusr] Problem in loading variables in different files.

Hi,
 
I want to do some calculations using the values in different files but an error 
message  was shown :
 
Data Request Error: Invalid grid coordinates
  World coordinates convert to non-integer  grid coordinates
    Variable = vwnd10m  Dimension = 1 
Operation Error:  Error from ave function
  Error ocurred at column 32
DEFINE error:  Invalid expression. 
 
The following are the main components of my script:
 
 
'sdfopen /home2/h08hang/redata/uwnd10m.mon.mean.nc'
'set lat -90 90'
'set lon 0 360'
'set t 1 753'
'define uwnd10m=uwnd'
'close 1'
 
'sdfopen /home2/h08hang/redata/vwnd10m.mon.mean.nc'
'set lat -90 90'
'set lon 0 360'
'set t 1 753'
'define vwnd10m=vwnd'
'close 1'
 
'sdfopen /home2/h08hang/redata/shum2m.mon.mean.nc'
'set lat -90 90'
'set lon 0 360'
'set t 1 753'
'define shum2m=shum'
'close 1'

'sdfopen  /home2/h08hang/redata/uwnd.mon.mean.nc'

'sdfopen /home2/h08hang/redata/vwnd.mon.mean.nc'
 
'sdfopen /home2/h08hang/redata/shum.mon.mean.nc'
 
....
   
   lon1=112.5
   lon2=115
   lat1=22.5
   lat2=25
 
   'set lat 'lat1' 'lat2
   'set lon 'lon1
   'set t 'time
   'set lev 'level1
 
   'define 
wind=(ave(uwnd.1,lat='lat1',lat='lat2')+ave(uwnd10m,lat='lat1',lat='lat2'))/2'
 
 
 
 
 
For the first three files I opened (uwnd10m,vwnd10m,shum2m), the variables are 
uwnd,vwnd and shum respectively.  I define three new variables to store them as 
their varable name crash with the next three file I am going to open. I close 
the each file after I have defined the new variables (for the first three files)
 
For the next three files I  opened, they have a different Grids as shown below. 
Is this the reason why I cannot run my script, or something else?
But what I want is to use the values from different files (those with different 
Grids to do my calculation)  How can I solve this? 

 
Can anyone give me some help? Thanks a lot (and sorry for the lengthy question)
 
 
File 1 : NCEP Reanalysis monthly ltm surface pressure
  Descriptor: /home2/h08hang/redata/pres.mon.mean.nc
  Binary: /home2/h08hang/redata/pres.mon.mean.nc
  Type = Gridded
  Xsize = 144  Ysize = 73  Zsize = 1  Tsize = 756  Esize = 1
  Number of Variables = 1
    pres 0 -103 Monthly Mean of Surface Pressure
File 2 : monthly mean u wind
  Descriptor: /home2/h08hang/redata/uwnd10m.mon.mean.nc
  Binary: /home2/h08hang/redata/uwnd10m.mon.mean.nc
  Type = Gridded
   Xsize = 192  Ysize = 94  Zsize = 1  Tsize = 756  Esize = 1
  Number of Variables = 1
    uwnd 0 -103 Monthly Mean of U-Wind
File 3 : monthly mean u wind
  Descriptor: /home2/h08hang/redata/vwnd10m.mon.mean.nc
  Binary: /home2/h08hang/redata/vwnd10m.mon.mean.nc
  Type = Gridded
  Xsize = 192  Ysize = 94  Zsize = 1  Tsize = 756  Esize = 1
  Number of Variables = 1
    vwnd 0 -103 Monthly Mean V wind at 10 m
 
File 4 : monthly mean u wind from the NCEP Reanalysis
  Descriptor: /home2/h08hang/redata/uwnd.mon.mean.nc
  Binary: /home2/h08hang/redata/uwnd.mon.mean.nc
  Type = Gridded
  Xsize = 144  Ysize = 73  Zsize = 17  Tsize = 751  Esize = 1
  Number of Variables = 1
    uwnd 17 -103 Monthly mean u wind
File 5 : monthly mean v wind from the  NCEP Reanalysis
  Descriptor: /home2/h08hang/redata/vwnd.mon.mean.nc
  Binary: /home2/h08hang/redata/vwnd.mon.mean.nc
  Type = Gridded
  Xsize = 144  Ysize = 73  Zsize = 17  Tsize = 751  Esize = 1
  Number of Variables = 1
    vwnd 17 -103 Monthly mean v wind
File 6 : 4x daily NMC reanalysis
  Descriptor: /home2/h08hang/redata/shum.mon.mean.nc
  Binary: /home2/h08hang/redata/shum.mon.mean.nc
  Type = Gridded
  Xsize = 144  Ysize = 73  Zsize = 8  Tsize = 752  Esize = 1
  Number of Variables = 1
    shum 8 -103 Monthly Mean of Specific Humidity
 
Best,
Henry


-- 
This message (and any attachments) is for the recipient only. NERC 
is subject to the Freedom of Information Act 2000 and the contents 
of this email and any reply you make may be disclosed by NERC unless 
it is exempt from release under the Act. Any material supplied to 
NERC may be stored in an electronic records management system.

_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110126/6f8d90fa/attachment-0003.html 


More information about the gradsusr mailing list