Skip to content

Commit

Permalink
add glacier mask for preserving totals when binning variables (#1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-schmitt committed Nov 9, 2023
1 parent 90aef5e commit 365eef8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/whats-new.rst
Expand Up @@ -3,6 +3,16 @@
Version history
===============

v1.6.2 (unreleased)
-------------------

Bug fixes
~~~~~~~~~
- The binned variables in the elevation band flowlines did not used the
glacier mask when preserving the total values (:pull:`1661`).
By `Patrick Schmitt <https://github.com/pat-schmitt>`_


v1.6.1 (August 27, 2023)
------------------------

Expand Down
9 changes: 8 additions & 1 deletion oggm/core/centerlines.py
Expand Up @@ -2224,7 +2224,14 @@ def elevation_band_flowline(gdir, bin_variables=None, preserve_totals=True):
bin_variables = keep
for var in bin_variables:
data = nc.variables[var][:]
out_totals.append(np.nansum(data) * gdir.grid.dx ** 2)
if var == 'consensus_ice_thickness':
# individual handling for consensus thickness as they use a
# different glacier mask than oggm (which was already applied)
data_sum = np.nansum(data)
else:
# use oggm glacier mask for all other data
data_sum = np.nansum(data[glacier_mask])
out_totals.append(data_sum * gdir.grid.dx ** 2)
out_vars.append(data[glacier_mask])

preserve_totals = utils.tolist(preserve_totals, length=len(bin_variables))
Expand Down
2 changes: 1 addition & 1 deletion oggm/utils/_downloads.py
Expand Up @@ -69,7 +69,7 @@
# The given commit will be downloaded from github and used as source for
# all sample data
SAMPLE_DATA_GH_REPO = 'OGGM/oggm-sample-data'
SAMPLE_DATA_COMMIT = '2ad86c93f9235e40edea506f13f6f489adeee805'
SAMPLE_DATA_COMMIT = '56aa8f23e3b450e6f56a8d4e8a5cdb58e03c9cc1'

CHECKSUM_URL = 'https://cluster.klima.uni-bremen.de/data/downloads.sha256.hdf'
CHECKSUM_VALIDATION_URL = CHECKSUM_URL + '.sha256'
Expand Down

0 comments on commit 365eef8

Please sign in to comment.