dtcenter / MET

Model Evaluation Tools
https://dtcenter.org/community-code/model-evaluation-tools-met
Apache License 2.0
78 stars 24 forks source link

Reimplement python embedding dataplane logic using the Python3_Script class and enhance the logging of Python Errors. #1266

Open JohnHalleyGotway opened 4 years ago

JohnHalleyGotway commented 4 years ago

Python embedding is done in 3 spots in MET: (1) vx_data2d_python library for gridded data (2) ascii2nc for point obs (3) stat_analysis for MPR data

(2) and (3) use the Python3_Script class, while (1), implemented first, does not. This makes the implementation details a bit confusing and more difficult to maintain. This task is to refactor (1) to also use the Python3_Script class.

In addition, enhance the Python3_Script class to check when an error occurred. Call PyErr_Occurred() and PyErr_Fetch() to retrieve the PyObjects containing the error details. Print the results to the mlog output so that the error messages are included in the log files.

honnorat commented 4 years ago

I don't know if it is related, but (2) prevents ascii2nc to compile: https://github.com/NCAR/MET/commit/20fcf4f31bffb5b9393f93de7bf00af7785d9122#r37494338