[Matplotlib-users] Need clarification on shiftgrid and addcylic
ashwinD12 .
winash12 at gmail.com
Fri Jun 24 12:51:36 EDT 2016
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 -
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap, addcyclic, shiftgrid
Traceback (most recent call last):
File "display.py", line 89, in <module>
hgt, lons = shiftgrid(180, hgt, lons, start = False)
File
"/usr/local/lib/python3.4/dist-packages/mpl_toolkits/basemap/__init__.py",
line 5020, in shiftgrid
raise ValueError('lon0 outside of range of lonsin')
ValueError: lon0 outside of range of lonsin
Here is my code -
<code>
nc_f = './hgt_500_2014_12_5_00Z.nc' # Your filename
nc_fid = Dataset(nc_f, 'r') # Dataset is the class behavior to open the
file
# and create an instance of the ncCDF4 class
# Extract data from NetCDF file
lats = nc_fid.variables['lat'][:]
lons = nc_fid.variables['lon'][:]
time = nc_fid.variables['time'][:]
hgt = nc_fid.variables['hgt'][:]
nc_fid.close()
hgt, lons = shiftgrid(180, hgt, lons, start = False)
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
</code>
On Wed, Jun 22, 2016 at 8:15 PM, Paul Hobson <pmhobson at gmail.com> wrote:
> Can you show your imports? Where did shiftgrid come from?
>
> On Tue, Jun 21, 2016 at 4:51 AM, ashwinD12 . <winash12 at gmail.com> wrote:
>
>> Hello,
>> 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.
>>
>> My dataset is between latitude 5 N to 40 N and 65 E and 100 E.
>> I am trying to plot geopotential height from NCEP reanalysis data. Here
>> is my code -
>>
>> <code>
>> level = 5
>> time = 0
>>
>> meters_per_grid = 277830
>>
>> d = Dataset("hgt_500_2014_12_5_00Z.nc")
>> hgt = d.get_variables_by_attributes(axis="hgt")
>> lon = d.get_variables_by_attributes(axis="lon")
>> lat =d.get_variables_by_attributes(axis="lat")
>> hgt = hgt[::-1]
>> hgt, lon = shiftgrid(180, hgt, lon, start = False
>> </code>
>>
>> Why do I get an IndexError: index out of range on shiftgrid call ?
>>
>> BR,
>> Ashwin.
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users at python.org
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160624/8151924c/attachment.html>
More information about the Matplotlib-users
mailing list