Note that there are some explanatory texts on larger screens.

plurals
  1. POPlotting currents data on a map : Too many value to unpack error
    primarykey
    data
    text
    <p>So here is my code : </p> <pre><code>from netCDF4 import * import datetime as dt import numpy as np import numpy.ma as ma from datetime import date, datetime, timedelta import matplotlib.pyplot as plt nc=Dataset('datasets/essai.nc') time_var = nc.variables[str('forecast_time0')] wave_var = nc.variables['DIST_GDS0_SFC'] lat = nc.variables['g0_lat_1'][:] lon = nc.variables['g0_lon_2'][:] uin = nc.variables['UOGRD_GDS0_DBSL'][:] vin = nc.variables['VOGRD_GDS0_DBSL'][:] plt.quiver(lon[::5], lat[::5], uin[::5], vin[::5], scale=200) </code></pre> <p>And here is the error I get : </p> <pre><code>Traceback (most recent call last): File "nctry.py", line 37, in &lt;module&gt; plt.quiver(lon[::5], lat[::5], uin[::5], vin[::5], scale=200) File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2877, in quive r ret = ax.quiver(*args, **kw) File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 6627, in quiver q = mquiver.Quiver(self, *args, **kw) File "C:\Python27\lib\site-packages\matplotlib\quiver.py", line 394, in __init __ X, Y, U, V, C = _parse_args(*args) File "C:\Python27\lib\site-packages\matplotlib\quiver.py", line 356, in _parse _args nr, nc = U.shape ValueError: too many values to unpack </code></pre> <p>I think the problem comes from the UOGRD and VOGRD which has many values but don't know how manipulate it?</p> <p>Here is how uogrd looks like : <img src="https://i.stack.imgur.com/JEEVM.jpg" alt="UOGRD "></p> <p>the forecast_time up as far as a number of 4.</p> <p>Ok so I used the np.array and shape functions, here is what i've got : </p> <blockquote> <p>C:\Python27>python nctry.py (321,) //lat (720,) //lon (4, 321, 720) //uogrd (4, 321, 720) //vogrd</p> </blockquote> <p>Then I tried this code :</p> <p><img src="https://i.stack.imgur.com/P2PDM.jpg" alt="code"></p> <p>but it only shows one arrow. Can you tell me why?</p> <p>So now I have some modelling which looks like this : <img src="https://i.stack.imgur.com/NvZ9Q.jpg" alt="currents modelized"></p> <p>But this image doesn't change, for [0, :, :], 1, 2 or 3.. What's wrong? Furthermore, all the arrows are going to the same direction, not really true when we're talking about currents' ocean. I use the deg2rad function. Finally, I can't imagine the coastlines, is that normal? Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload