-
Notifications
You must be signed in to change notification settings - Fork 445
Description
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 xarray apply_ufunc(), but I don't think I am advanced enough of a user to get it to broadcast the precipitable_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.