[gradsusr] Regrid Help

Charles Seman Charles.Seman at noaa.gov
Fri Dec 9 15:37:14 EST 2011


Emily,

Try something like the code shown below (note, this code has NOT been 
tested!)... To get a single netCDF time-series file of regridded data, 
it seems you'll have to make a time loop in which netCDF files 
containing regridded data are generated for each time level, and then 
after exiting the time loop, the individual regridded netCDF files for 
all time levels would be concatenated together into a single netCDF 
time-series file (perhaps using "NCO utilities" which is attempted in 
the test code below; ref: 
http://grads.iges.org/grads/gadoc/gradcomdsdfwrite.html).

*
*  DATA TO BE REGRIDDED
*
'sdfopen ecmwfsoilw.nc'

tt = 1
while ( tt <= 248 )
*
* REGRID THE DATA for this time level
*
  'set lat -180 180'
  'set lon -90 90'
  'set t 'tt
  'newgrid = re(swvl1.1,2.5)' ;* <- replace as necessary with desired 
regridding command: http://opengrads.org/doc/udxt/re/re.html
*
* DEFINE OUTPUT FILE (define with three digits for time level 
anticipating using "ncrcat" "-n" feature: 
http://nco.sourceforge.net/nco.html#Specifying-Input-Files)
*
  if ( tt < 10 )
    nc_ofile = 'regrid_ecmwfsoilw_t00'tt'.nc'
  else
    if ( tt < 100 )
      nc_ofile = 'regrid_ecmwfsoilw_t0'tt'.nc'
    else
      nc_ofile = 'regrid_ecmwfsoilw_t'tt'.nc'
    endif
  endif

  'set sdfwrite 'nc_ofile
*
* WRITE OUT THE REGRIDDED DATA
*
  'sdfwrite newgrid 'nc_ofile
*
* MAKE THE TIME DIMENSION A RECORD DIMENSION FOR NCO ncrcat
* (note, need NCO Utilities 4.0.1 or later: 
http://nco.sourceforge.net/#Version)

  '!ncks -O -h --mk_rec_dmn time 'nc_ofile ;* see: 
http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink

  tt=tt+1
endwhile

* CONCATENATE INDIVIDUAL TIME LEVELS TOGETHER INTO A SINGLE netCDF 
TIME-SERIES FILE
* see: http://grads.iges.org/grads/gadoc/gradcomdsdfwrite.html, 
http://nco.sourceforge.net/nco.html#ncrcat-netCDF-Record-Concatenator, 
http://nco.sourceforge.net/nco.html#Specifying-Input-Files

'!ncrcat -O -h -n 248,3,1 regrid_ecmwfsoilw_t001.nc 
regrid_ecmwfsoilw_all.nc'

Note, I haven't tried the "mkd_rec_dmn" and "-n" techniques shown in the 
ncks and ncrcat commands shown above, so please use with caution.

I hope this helps,
Chuck

On 12/09/2011 01:44 PM, Emily Parker Wilson wrote:
> Hello I am trying to regrid in GrADS and i am getting the error message...
> No hardcopy metafile open
> All files closed; all defined objects released;
> All GrADS attributes have been reinitialized
> 73 90 -90
> re(swvl1.1,73,LINEAR,-90,2.5,145,LINEAR,-180,2.5,ba)
> Operation Error:  Error from re function
> Operation Error:  Error from regrid2 function
>    Error ocurred at column 1
> DEFINE error:  Invalid expression.
> Operation Error:  Error from re function
>    Error ocurred at column 1
> DEFINE error:  Invalid expression.
> ga->  quit
> Hardcopy output file is closed
> GX package terminated
>
> the grad script i am using looks like this...
> *  DATA TO BE REGRIDDED
> *
>    'sdfopen ecmwfsoilw.nc'
> *
>    'enable print grads.outfile'
>    'clear'
> *
> * DEFINE OUTPUT FILE
> *
>    'set fwrite ecmwfsoilw.regrid.nc'
> *
> * OUTPUT TO THE FILE
> *
>    'set gxout fwrite'
> *
> * WRITE 228 MONTHS
> *
> *  'set t 1 248'
> *
> * REGRID THE DATA
> *
> *  'd regrid2(swvl1,5.0,5.0,bs_p1,-177.5,-87.5)'
> *
> *
>   'set lat -180 180'
>   'set lon -90 90'
>
> * 'd re(swvl1,144,'linear',-192,2.5,73,'linear',94,2.5,bs)'
>
> * 'd re(swvl1,2.5,2.5,bs)'
>
>    'newgrid=regrid2(swvl1.1,2.5)'
>    'define regrid2=re(swvl1.1,2.5,2.5)'
>
> * 'define newvar=re(swvl1,144,'linear',2.5,192,73,'gaus',1,94)'
> * 'd newvar'
> *
>    'print'
>
> can someone please tell me what i am doing wrong?
> Thanks so much,
> Emily
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

-- 

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
  Charles Seman                                Charles.Seman at noaa.gov
  U.S. Department of Commerce / NOAA / OAR
  Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
  201 Forrestal Road                              fax: (609) 987-5063
  Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect any
official or unofficial position of the United States Federal Government,
the United States Department of Commerce, or NOAA."



More information about the gradsusr mailing list