Basemap.shiftgrid without cyclic point

I'm using basemap to plot a dataset* that has longitude values like so:

lon = [0, 2, 4, ..., 356, 358]

I'd like to use Basemap.shiftgrid to transform the longitudes and data
to the -180, 180 interval, but I get 'ValueError, cyclic point not
included' since 360 isn't among the longitudes.

Attached is a version of shiftgrid that attempts to handle the
non-cyclic case. There are pseudo-unit-tests that demonstrate the
cyclic and non-cyclic case for a 180 degree shift.

Thanks,
Eric

*SST anomalies from http://nomads.ncdc.noaa.gov/thredds/dodsC/ersstv3Agg

shiftgrid.py (3.5 KB)

Eric Bruning wrote:

I'm using basemap to plot a dataset* that has longitude values like so:

lon = [0, 2, 4, ..., 356, 358]

I'd like to use Basemap.shiftgrid to transform the longitudes and data
to the -180, 180 interval, but I get 'ValueError, cyclic point not
included' since 360 isn't among the longitudes.

Attached is a version of shiftgrid that attempts to handle the
non-cyclic case. There are pseudo-unit-tests that demonstrate the
cyclic and non-cyclic case for a 180 degree shift.

Thanks,
Eric
  

Eric: Thanks - I've updated the shiftgrid function in SVN with your changes, and added your tests to test.py.

-Jeff