Commit bc874ca7 authored by Clément Haëck's avatar Clément Haëck
Browse files

Compute surface fraction for all masks

parent 58b069c0
......@@ -115,7 +115,7 @@ def variables(name_in='hist', allowconcat=True):
def decorator(func):
def decorated(ds, concat=allowconcat, variables=None):
def decorated(ds, concat=allowconcat, variables=None, **kwargs):
if not allowconcat and concat:
raise ValueError("Cannot concatenate with this function.")
......@@ -135,7 +135,7 @@ def variables(name_in='hist', allowconcat=True):
for var, var_ext in zip(variables, variables_ext):
da = ds[var_ext]
da.attrs['VAR'] = var
out = func(da)
out = func(da, **kwargs)
if concat:
out = out.expand_dims(var=[var])
......@@ -159,9 +159,9 @@ def get_N(hist):
def get_surface_fraction(N):
def get_surface_fraction(N, mask='frt'):
"""Return fraction of surface impacted by fronts."""
frac = N.sel(mask='frt') / N.sum('mask')
frac = N.sel(mask=mask) / N.sum('mask')
return frac.rename('frac')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment