Sympy derived quantities from string equations #278
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a test to see if we can/should use
sympy
to parse equations to derive quantities.The idea is the user can put an equation and constituents (already in) in the variable defaults file and sympy will parse the string equation and then xarray will do the calculations.
For quick comparison, here is the current ADF generated RESTOM lat/lon plot:
And Sympy derived:
This is a small test case so far, but it seems pretty flexible in how it parses equations. For example, I created a fake var called MADEUPVAR with a derived equation: PRECC-(0.5*PRECL)+PRECSC and it seemed to handle the parenthesis.
If it makes sense, we can move this to discussions so we can chat about it. If you want to add some stress testing, checkout my branch and give it a try: https://github.com/justin-richling/ADF/tree/sympy-derived-qunatity-draft
The only python packages sympy would add to the npl environment are: