geoschem / integrated_methane_inversion

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

Bugfix/perturbation sfs #251

Closed laestrada closed 1 month ago

laestrada commented 1 month ago

Name and Institution (Required)

Name: Lucas Estrada Institution: Harvard ACMG

Describe the update

This PR fixes multiple bugs:

  1. Misapplication of perturbation simulation scale factors in sensitivity calculation for Kalman Filter inversions.
    • With the addition of variable scale factors being applied to perturb emissions fields. We correctly calculated variable scale factors for perturbing emissions based on the original prior emissions. However, the sensitivity calculations are based on the nudged prior emissions, not the original prior emissions. This requires calculating an additional array of scale factor perturbations based on the nudged prior emissions and using that in the calculation of (pert - base)/ perturbation_sf. This bug only affected KF inversions, but led to incorrect calculation of the Jacobian.
  2. Using negative emissions in the nudged prior for KF inversions.
    • Previously negative emissions were allowed to propagate into the next inversion interval through the nudged emission prior. These emissions are unphysical and should not be allowed to propagate as part of the prior. Here, I prevent this by, in the nudged prior, using only the desired alpha emissions (eg. 10% of the original prior) in areas where there are negative emissions. A high bias is prevented by applying a lambda scaler to the nudged emissions, so that it aligns with the posterior emission total.
  3. Bug in the reported total emissions.
    • This fixes a bug in the reported total emissions. Previously in the get_posterior_emissions() function, the AREA of gridcells were also being multiplied by the posterior ScaleFactors. If the updated areas were used to calculate the sum of total emissions, the result would be incorrect. This is addressed by only applying scale factors to data variables with EmisCH4 in the variable name.
  4. Incorrect printing of total emission. One function used to print the total emissions to the output log was pointing at the incorrect directory for prior emissions. This is now fixed.