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.
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](https://github.com/NCAR/ADF/assets/56696811/4be26db1-8516-4521-86b1-8680d0f52c56)
And Sympy derived:![RESTOM_ANN_LatLon_Mean_Sympy](https://github.com/NCAR/ADF/assets/56696811/8c088f7e-9d7e-49fe-a00b-b8747f79b5a7)
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](https://github.com/NCAR/ADF/assets/56696811/207a3969-1d69-490a-bac2-3a6be22f8180)
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: