OMS-NetZero / FAIR

Finite-amplitude Impulse Response simple climate model
https://docs.fairmodel.net
Apache License 2.0
120 stars 61 forks source link

scipy 1.10 failure #119

Closed chrisroadmap closed 1 year ago

chrisroadmap commented 1 year ago

ValueError: The input matrix must be symmetric positive semidefinite is raised with scipy 1.10.0, and did not occur with scipy 1.9.3.

See https://scipy.github.io/devdocs/release.1.10.0.html under "Other changes".

chrisroadmap commented 1 year ago

After a little more digging, this is only triggered with certain combinations of stochastic parameters in the energy balance model. Prior to scipy 1.10, it was only a warning, and now it is an error. It seems to be tricky with non-annual time steps and stochastic, this should be treated with care.

Another point is that the calibration (up until now) is done in R, and the model run in Python. It seems like R's linear algebra routines are a little closer to Python's (specifically, scipy's) sparse linear algebra rather than the full linear algebra package. The CMIP6 calibration done in R will sometimes throw these not positive semi-definite errors with the full linear algebra, but the calibrations seem to work OK with the sparse algebra. So for now I'm retaining the sparse algebra in the energy balance model, but at some point it should be replaced. This will require a recalibration and will give different results, so it is a target for a minor version release.

In the calibration: need a pre-filter to eliminate combinations of non-positive semidefinite. Could be a lot of combinations filtered out.

chrisroadmap commented 1 year ago

Fixed in #120