-
Notifications
You must be signed in to change notification settings - Fork 12
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
DataArray aware pint.context
#231
Comments
Is there any support for |
Sorry, hgrecco/pint#1559 was actually my issue - trying to convert a flux from particles per area per time to mass per area per time. |
no progress (but it looks like you figured that out already). Mostly because I personally have no need for contexts, but in general someone just needs to figure out what would need to be done (and we'd need to figure out a clean way to integrate that in the API). The context manager should already work, though? |
Yeah, the context manager works with simple transformations defined by the context. So for the da: xr.dataArray
da = da.pint.quantify('particle')
with pint.context('chemistry', mw=16.04 * ureg('g/mol')):
da_mass = da.pint.to('kg') but I am working with emissions inventories (ex: EPA Methane Emissions Inventory) which are often given as netcdfs (perfect for xarray) in units of either |
I remember what exactly I was aiming with this issue. Indeed static context can work, but the difficult part is if we want to use an index name or a With #163 finished, this might be possible |
For example, consider the
spectroscopy
context:There the conversion depends on the variable
n
used. Now, consider aDataArray
/DataSet
wheren
is adimension
/coordinate
. Then when callingDataArray.pint.to("nm")
we would want the variablen
to be dynamically imported from the current context of theDataArray
coordinate.API-wise I am not sure how that would work, maybe by passing a list/dict of context objects (+ variables)? This might also involve upstream
pint
support for more complicated context and decorators.The text was updated successfully, but these errors were encountered: