<div dir="ltr"><div><div><div>Thanks for your response. There was a problem with my data which made removed that error. I still have another error with shiftgrid. As per your request here are my import statements - <br><br>import matplotlib.pyplot as plt<br>from mpl_toolkits.basemap import Basemap, addcyclic, shiftgrid<br><br>Traceback (most recent call last):<br>  File "display.py", line 89, in <module><br>    hgt, lons = shiftgrid(180, hgt, lons, start = False)<br>  File "/usr/local/lib/python3.4/dist-packages/mpl_toolkits/basemap/__init__.py", line 5020, in shiftgrid<br>    raise ValueError('lon0 outside of range of lonsin')<br>ValueError: lon0 outside of range of lonsin<br><br></div>Here is my code -<br></div><code><br>nc_f = './hgt_500_2014_12_5_00Z.nc'  # Your filename<br>nc_fid = Dataset(nc_f, 'r')  # Dataset is the class behavior to open the file<br>                             # and create an instance of the ncCDF4 class<br># Extract data from NetCDF file<br>lats = nc_fid.variables['lat'][:]<br>lons = nc_fid.variables['lon'][:]<br>time = nc_fid.variables['time'][:]<br>hgt = nc_fid.variables['hgt'][:]  <br>nc_fid.close()<br>hgt, lons = shiftgrid(180, hgt, lons, start = False)<br>fig = plt.figure()<br>ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])<br></div></code><br><div><div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 22, 2016 at 8:15 PM, Paul Hobson <span dir="ltr"><<a href="mailto:pmhobson@gmail.com" target="_blank">pmhobson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Can you show  your imports? Where did shiftgrid come from?</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Jun 21, 2016 at 4:51 AM, ashwinD12 . <span dir="ltr"><<a href="mailto:winash12@gmail.com" target="_blank">winash12@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div><div>Hello,<br></div>          I am just starting to 
learn how to plot NCEP reanalysis data using Python3 and matplotlib and 
basemap. I have some clarifications on how to go about doing it.<br><br></div>My dataset is between latitude 5 N to 40 N and 65 E and 100 E. <br></div>I am trying to plot geopotential height from NCEP reanalysis data. Here is my code - <br><br></div><code><br><div>level = 5<br>time = 0<br><br>meters_per_grid = 277830<br><br>d = Dataset("hgt_500_2014_12_5_00Z.nc")<br>hgt =  d.get_variables_by_attributes(axis="hgt") <br>lon =  d.get_variables_by_attributes(axis="lon")<br>lat =d.get_variables_by_attributes(axis="lat")  <br>hgt = hgt[::-1]<br>hgt, lon = shiftgrid(180, hgt, lon, start = False<br></div><div></code><br><br></div><div>Why do I get an IndexError: index out of range on shiftgrid call ?<br><br></div><div>BR,<br></div>Ashwin. </div>
<br></div></div>_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>