Adding a wrap-around longitude

401 views
Skip to first unread message

Joe Melton

unread,
Jun 13, 2016, 5:46:10 PM6/13/16
to xarray
I am trying to add a wrap-around longitude so I can plot using cartopy. Our projection is gaussian and cartopy seems to think I need a wrap-around longitude but my model output doesn't have one. If you don't have one you get a nice white line down the plot at 0 deg longitude. I am then trying to copy all of the first longitude into a new one longitude I will tack on the end. 

Here is what my xarray dataset looks like:

<xarray.Dataset>
Dimensions:  (lat: 64, lon: 128)
Coordinates:
  * lon      (lon) float64 0.0 2.812 5.625 8.438 11.25 14.06 16.88 19.69 ...
  * lat      (lat) float64 -87.86 -85.1 -82.31 -79.53 -76.74 -73.95 -71.16 ...
Data variables:
    depth    (lat, lon) float64 nan nan nan nan nan nan nan nan nan nan nan ...

I am trying to add a 129th longitude (361.41 deg) using the all the lat values from the first (lon = 0.0). I have tried all sorts of things (like converting to pandas) but can't seem to get it to work. I think some of this is my newbie-ness showing. Is there a simple way to do this?

An example .nc file is attached.

Any help is greatly appreciated.

Thanks,
Joe
example.nc

Daniel Rothenberg

unread,
Jun 14, 2016, 1:04:40 PM6/14/16
to xarray
Hi Joe,

Cartopy has a utility function to do this, add_cyclic_point. For a worked example, see here.

- Daniel

Joe Melton

unread,
Jun 15, 2016, 12:37:27 PM6/15/16
to xarray
Excellent, that is exactly what I was hoping for. 

Thanks very much,

Cheers,
Joe
Reply all
Reply to author
Forward
0 new messages