NCAR / ADF

A unified collection of python scripts used to generate standard plots from CAM outputs.
Creative Commons Attribution 4.0 International
34 stars 29 forks source link

Sympy derived quantities from string equations #278

Open justin-richling opened 7 months ago

justin-richling commented 7 months ago

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: