Filmic to linear math?
You can use the OpenColorIO Python library to transform a Filmic log encoded image back to scene referred linear.

The base log is a simple normalized log base 2 format, with ten stops down from middle grey and six and a half stops up.