Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23305

About changing longitude array from 0 - 360 to -180 to 180 with Python xarray

$
0
0

I am a matlab user trying to use Python more for my computations recently. I am using xarray and would like to change my longitude array from 0 - 360 to -180 to 180 of a geophysical field. But when I do that:

df=xr.open_dataset(ecmwf_winds.nc)u10=df['u10']lon=df['longitude']lon = np.where(lon > 180, lon-360, lon)[X,Y]=np.meshgrid(lon,df.latitude)plt.contourf(X,Y,u10)

the contourplot turns out to messy with gaps, which does not make sense. Can anyone please help me with it. I am not sure where I am doing wrong.


Viewing all articles
Browse latest Browse all 23305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>