Re: Shift global data

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 11 2011 - 15:28:15 MST

Hi Alexandra,

Maybe something like this, using numpy's "where" and "roll" functions:

import numpy

lon = numpy.array([ 0, 7, 15, 22, 30, 37, 45, 52, 60, 67, 75, 82, 90, 97, 105, 112, 120, 127, \
                   135, 142, 150, 157, 165, 172, 179, 181, 188, 195, 203, 210, 218, 225, 233, 240, 248, 255, \
                   263, 270, 278, 285, 293, 300, 308, 315, 323, 330, 338, 345, 353])

itemindex = numpy.where(lon > 180)
lon_shift = numpy.roll(lon,itemindex[0][0]-1)
lon_shift = numpy.where(lon_shift > 180, lon_shift - 360 ,lon_shift)

print "original lon",lon
print " shifted lon",lon_shift

--Mary

On Feb 9, 2011, at 4:26 PM, Alexandra Valentim wrote:

> Hi,
>
> Is there a good way to shift global GFS data so that the raster data corresponds to a longitudes from [-180,180[ instead [0, 360[?
>
> I'm interested in cut a region over Europe using the following convention:
>
> smallArea = globaArea['lat_0|X1:X2 lon|Y1:Y2']
>
> but since my region crosses the 0 long, I dont know how to use it...
>
> any ideias?
>
> Tks !!
> _______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Fri Feb 11 15:28:28 2011

This archive was generated by hypermail 2.1.8 : Fri Feb 11 2011 - 16:11:13 MST