Re: g2gsh problem

From: Dennis Shea (shea AT cgd.ucar.edu)
Date: Thu Mar 10 2005 - 17:40:37 MST


>>I am having trouble on making interpolation from a
>>gauusian grid to a higher resolution gaussian grid.
>>When using the command g2gsh for the regriding the ncl
>>script seems to work fine and creates another netcdf
>>file with the right resolution but it returns negative
>>values at the variables.
>>
>>Any help in this regard will be highly appreciated.
===
I got some information off-line.

The problem is the the variable that was being interpolated
was bounded by 0. I reproduce here some documentation
regarding using the spherical harmonic interpolators
and bounded variables.

Caveats on using Spherical Harmonic Regridding:

The spherical harmonic based regridding routines
are reasonably fast and highly accurate. However, they may not
be appropriate for certain applications. In particular,
interpolation of bounded variables. For example,
precipitation is bounded by zero and relative humidity
is bounded by 0 and 100. Use of the spherical harmonic
interpolators *may* produce values which exceed the
variable's bounds. This is due to "spectral ringing".
Generally, the values exceed the bounds by only small amounts.

There are two approaches:

(1) To ensure results that do not exceed the variable's bounds,
    the user should use the bilinear regridding function
    "linint2" or (possibly better) "linint2_Wrap". [LINKS]
    This is the recommended approach.

(2) Use the spherical harmonic based interpolation routines
    an employ NCL's clipping operators ">" and "<". [LINKS]
    For example, consider a variable "x" that is bounded
    by 0 and 100.
    
          x = x < 100 ; any value greater than 100 will be set to 100
          x = x > 0 ; any value less than 0 will be set to 0
    
    Even with this approach users should be aware that spectral
    ringing will still be present where values are near the
    bounds. For example, if the variable being interpolated
    is precipitation (bounded by zero). Then values
    in deserts which were originally zero may have some non-zero
    values even after the clipping operator ">0" is used.

===

>>
>>a sample from the script:
>>
>>;newgrid4d = new((/ntime,nlev,newlat,newlon/),float)
>>;print("writing netcdffile->" + innames(6)) ;; Tmin
>>;;dump4d = infile->$innames(6)$
>>;do i=0, ntime-1
>>;do l = 0, nlev-1
>>; dump2d = dump4d(i,l,:,:)
>>; newgrid = g2gsh(dump2d,(/newlat,newlon/), 0)
>>; newgrid4d(i,l,:,:) = newgrid
>>;end do
>>;end do
>>;filevardef(netcdffile, "Tmin","float",(/"time","lev","lat","lon"/))
>>

The above will get the job done BUT is very inefficient

No looping should be done. The function will loop
'behind the scenes'.

   x = infile->SomeVariable
   xNew = g2gsh_Wrap(x ,(/newlat,newlon/), 0)
   
or, just

   xNew = g2gsh_Wrap(infile->X, (/newlat,newlon/), 0)
   
or, in the case of a linint2 [LAT/LOn are the new grid coords]
   
   x = infile->X
   xNew = linint2_Wrap (x&lon,x&lat, x, Cyclic, LON, LAT, 0)
                                        True
                                        False
good luck
D

_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Fri Mar 11 2005 - 08:46:32 MST