[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[python #PHR-160601]: MetPy Help
- Subject: [python #PHR-160601]: MetPy Help
- Date: Wed, 03 Mar 2021 11:37:16 -0700
Greetings!
Getting my hands on the data made this much easier to track down. The problem
is an issue with numpy broadcasting--how it matches up arrays of different
dimensions to do calculations. The solution, in addition to making sure you've
included np.array() when creating levs, u, v, is to change the call to
`mc.potential_vorticity_baroclinic` to:
pv = mc.potential_vorticity_baroclinic(pot_temp, levs[:, None, None], u, v,
dx=dx[None], dy=dy[None], latitude=lats)
What the additional indexing in that line does is add dummy dimensions in the
correct spot to make all of the arrays 3-dimensional, so that everything lines
up properly. For more information on broadcasting in NumPy, checkout these
pages:
https://numpy.org/doc/stable/user/basics.broadcasting.html
https://numpy.org/doc/stable/user/theory.broadcasting.html#array-broadcasting-in-numpy
Cheers!
Ryan
> Hi Ryan,
>
> Great! Here is the location of the file on
> cheyenne: . Please let me know if you
> run into any issues.
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.