Skip to content
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

Sympy derived quantities from string equations #278

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

justin-richling
Copy link
Collaborator

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:
RESTOM_ANN_LatLon_Mean_ADF

And Sympy derived:
RESTOM_ANN_LatLon_Mean_Sympy

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.
MADEUPVAR_ANN_LatLon_Mean

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:

  • sympy
  • gmpy2
  • mpc
  • mpfr
  • mpmath

@justin-richling justin-richling marked this pull request as draft January 11, 2024 22:49
@justin-richling justin-richling changed the title Sympy derived qunatity draft Sympy derived quantity draft Jan 22, 2024
@justin-richling justin-richling changed the title Sympy derived quantity draft Sympy derived quantities from string equations Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant