[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #PHR-160601]: MetPy Help



Greetings!

My first (and right now only) guess is that you need to convert your u/v 
collections from lists to arrays. Easiest way is probably to change the lines 
that attach units to:

    u = np.array(u) * units('m/s')
    v = np.array(v) * units('m/s')

If that doesn't help, can you post a sample input grib file somewhere I can 
grab it?

Cheers,

Ryan

> Hi Ryan,
> 
> I made some of the changes you suggested. When testing, I ran into the
> following error:
> 
> Traceback (most recent call last):
> >   File "gfs_pv_fcst_metpy.py", line 69, in <module>
> >     data = pv(input_file) #Call function to calculate PV
> >   File "gfs_pv_fcst_metpy.py", line 57, in pv
> >     pv = mc.potential_vorticity_baroclinic(pot_temp, levs, u, v, dx=dx,
> > dy=dy, latitude=lats)
> >   File "/d1/Lindsay_SBU/lib/python3.6/site-packages/metpy/xarray.py", line
> > 1493, in wrapper
> >     return func(*bound_args.args, **bound_args.kwargs)
> >   File "/d1/Lindsay_SBU/lib/python3.6/site-packages/metpy/xarray.py", line
> > 1206, in wrapper
> >     result = func(*bound_args.args, **bound_args.kwargs)
> >   File "/d1/Lindsay_SBU/lib/python3.6/site-packages/metpy/units.py", line
> > 246, in wrapper
> >     return func(*args, **kwargs)
> >   File
> > "/d1/Lindsay_SBU/lib/python3.6/site-packages/metpy/calc/kinematics.py",
> > line 779, in potential_vorticity_baroclinic
> >     or np.shape(pressure)[vertical_dim] < 3
> > IndexError: tuple index out of range
> >
> 
> I've attached the program to this email. Could you please take a look and
> let me know what I'm doing wrong when you get a chance?


Ticket Details
===================
Ticket ID: PHR-160601
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.