-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support calculation of indices (e.g. precipitable water) using gridded data #1533
Comments
I know this doesn't isn't reusable for other calculations, but if 'P' is a 1D dimension of 'TD', maybe you could do: |
@DanielAdriaansen Thanks for opening. This is definitely something we want to enable now that we have a fairly large set of useful calculations. Not sure on a schedule for that, though... |
Agreed, thanks for opening! #1490 does not resolve this, as of that PR (and the current state of the master branch), |
I guess another way is to use map blocks (must be chunked with dask) and then perform your loop inside so that it's kind of parallelized.
Executed in 2 mins 6 seconds (tested on my personal machine with 4 cores) Compared to the absolute serial case
Executed in 2 mins 35 seconds Entire script:
|
I have an Xarray Dataset object and it has 3D variables of atmospheric data stored in it. Essentially, a collection of nx X ny columns of data. I am attempting to compute precipitable water using this 3D grid, but have been unsuccessful doing it any other way besides looping in nx and ny, storing the result from
precipitable_water()
in an np ndarray, and then adding it to my Xarray Dataset object. I tried various flavors of xarrayapply_ufunc()
, but I don't think I am advanced enough of a user to get it to broadcast theprecipitable_water()
function across my Dataset correctly. Or maybe it's not even possible.In MetPy, It would be nice to be able to pass these variables in and get back a 2D nx X ny grid of precipitable_water back into my Dataset, or as a separate DataArray object since the dimensions are reduced from 3D to 2D in this calculation.
Something like:
pw_da = mpcalc.precipitable_water(ds['P'],ds['TD'],bottom=pbot,top=ptop)
where pw_da would be a DataArray object since two Dataset objects were passed into the function.
I made the issue generic, since there may be other indices, or calculations that fit this model in MetPy that I haven't thought about where the user would want to distill 3D data into a 2D field of some sort.
After perusing current issues and PR's, I found #1490 , and this may help me but I am not entirely sure.
I originally posted a question on SO awhile back here: https://stackoverflow.com/questions/61255329/pythonic-way-to-compute-precipitable-water, where @dopplershift alluded to some assumed 1D behavior at least in
precipitable_water()
, so in addition to Xarray-type enhancements there is probably also some 1D to 3D changes needed to achieve this.The text was updated successfully, but these errors were encountered: