geoschem / integrated_methane_inversion

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

Hardcoding vertical levels in write_boundary.py #155

Closed eastjames closed 10 months ago

eastjames commented 1 year ago

In src/write_BCs/write_boundary.py, a previously calculated bias correction is applied to GEOS-Chem BoundaryCondition files. The same correction in units of ppb is applied to all model levels. However, in src/write_BCs/write_boundary.py, the number of vertical model levels is hardcoded to be 47. I know this is the IMI standard configuration, but the option is given for a user to write boundary conditions from their own GEOS-Chem runs which could have a different configuration than standard IMI, which opens up the possibility that the bias correction would not be applied to all the model levels if a 47 level configuration wasn't used.

Here is the original code: https://github.com/geoschem/integrated_methane_inversion/blob/b49ce2ffe5cd72ff6ce094b26c62671c88ddc8fe/src/write_BCs/write_boundary.py#L47C1-L49C77

I think a simple fix would be to changes lines 47-49 from:

for t in range(orig_data.shape[0]):
    for lev in range(47):
        orig_data[t, lev, :, :] = orig_data[t, lev, :, :] - Bias

to

orig_data = orig_data - Bias
nicholasbalasus commented 1 year ago

Thanks, @eastjames! I'm going to open a draft PR later today for the many boundary condition changes and will include this.

nicholasbalasus commented 10 months ago

Closed by #156