geoschem / integrated_methane_inversion

Integrated Methane Inversion workflow repository.
https://imi.readthedocs.org
MIT License
26 stars 22 forks source link

Bugfix: Fix DOFS calculation #140

Closed laestrada closed 1 year ago

laestrada commented 1 year ago

Name and Institution (Required)

Name: Lucas Estrada Institution: Harvard ACMG

Describe the update

We noticed a bug in the visualization notebook DOFS calculation. This only occurs when using clustering. In make_gridded_posterior.py we map the calculated sensitivity values to the corresponding state vector elements. Eg. if element 3 has a sensitivity of .5, and is composed of 10 grid cells, then all 10 grid cells are set to .5. However, in visualization_notebook.ipynb the way we calculate DOFS is np.nansum(avkern_ROI.values) which sums every .25 degree grid cell. Per the example, we are effectively overcounting the sensitivity of element 3 by 10x.

To fix this we simply use the un-gridded inversion result from inversion_result.nc to calculate DOFS.

Credit to Alex Oort Alonso for flagging this bug!

Confirmed that this fix works in the Permian test case (with no clustering).