[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[python #OAQ-273853]: Q-vector divergence, and "too many positional arguments"
- Subject: [python #OAQ-273853]: Q-vector divergence, and "too many positional arguments"
- Date: Mon, 11 Oct 2021 14:24:31 -0600
Hello, and thanks for reaching out!
The Q-vector example on the python-training website is currently out-of-date
and will be updated for MetPy 1.1 soon. Your code adaptation for MetPy>=1.0 is
close! For this to work:
1.) `dx` and `dy` are now "keyword-only" arguments, not "positional" arguments.
This means you need to specify the name of the keyword. For example,
q_div = mpcalc.divergence(uqvect, vqvect, dx=dx, dy=dy, ...)
2.) `x_dim` and `y_dim` are to specify the positional number of the axis for
each, NOT the total length of those. For example,
q_div = mpcalc.divergence(uqvect, vqvect, dx=dx, dy=dy, x_dim=1, y_dim=0)
where I'm telling the function that my x-dimension is the SECOND of my
dimensions of the array (note Python 0-indexing rules), and my y-dimension is
the first dimension of the array.
Some notes: If you work with parsed Xarray data [1] in these calculations, you
can get by without specifying any of these at all! Also, MetPy's default
`x_dim` and `y_dim` ordering will end up working for many datasets, especially
in our examples. You may not have to set these at all, depending on the data
you're working with. I hope this helps, and don't hesitate to follow up if I
can offer any more clarification. Thanks!
[1]: https://unidata.github.io/MetPy/latest/tutorials/xarray_tutorial.html
All the best,
Drew
> Last fall, I used the wonderful Q-vector example from the MetPy webpage,
> modified to plot user-specified current data. My students and I found it
> very useful.
>
> This fall, the same code fails at the point where it goes to compute the
> Q-vector divergence. I've tried to modify the code to be consistent with
> MetPy1.0, but when I run that line, even when configured exactly as in the
> docs, I get the error "TypeError: too many positional arguments".
>
> The code I am using (one of many attempted variations) is here:
> q_div = mpcalc.divergence(uqvect, vqvect, dx, dy, x_dim=260, y_dim=87)
>
Ticket Details
===================
Ticket ID: OAQ-273853
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.