This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
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.