[gradsusr] evaluation of grads expressions in pygrads (galab.py)

Arlindo da Silva dasilva at alum.mit.edu
Fri Nov 25 12:20:44 EST 2011


On Thu, Nov 24, 2011 at 3:31 AM, Francesco Benincasa <
francesco.benincasa at bsc.es> wrote:

> Hi all,
> I'm using pygrads to draw some maps from netcdf files,


Can you give us some more details here? Is this a global or regional
dataset? Also, which version of pygrasd is this? Platform?


> and I've noticed that
> in some cases the map is drawn correctly only if I use the "transf" option
> set
> to True (the projection is cylindric).
>
>
In principle, you should not have to set the "transf" attribute. This is an
internal parameter to signal the package that a map transformation is
necessary, "under the hood" kind of stuff.


> I've taken a look at the code in _contourf method in the galab.py module:
>
> #       Evaluate GrADS expression
> #       -------------------------
>        if self.transf: self.cmd('set lon -180 180',Quiet=True)
>        Z = self.exp(expr)
>
>        g = Z.grid
>        if self.transf: self.cmd('set x %s %s'%dh.x,Quiet=True)
>
>
> But I don't understand why it does that and why in some models it needs
> that options.
>
> Any idea?
>
>
Here is the main issue that drives this special handling. GrADS is very
flexlible in its addressing of longitudes: [-180,180],  [0,360], [20,380],
all is fair game. The Basemap toolkit (and the proj4 library it relies on)
less so, it wants longitudes in the range [-180,180]. Therefore, anytime a
map transformation is necessary the longitude domain of the input grid get
changed to the range [-180,180], a map transform is applied, and the the
original grid arrangement is restored after the transform.

  I am not exactly clear what your particular problem is. If you send me a
small sample file I can try it out and fix whatever bugs may be in there. I
always work with global files, so it is possible that I may have overlooked
some important detail for regional files (if indeed you have a regional
file).

   Arlindo


-- 
Arlindo da Silva
dasilva at alum.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111125/30dcfdd3/attachment-0003.html 


More information about the gradsusr mailing list