Skip to content

Commit

Permalink
don't see units for multivariate scen
Browse files Browse the repository at this point in the history
  • Loading branch information
coxipi committed Jul 24, 2024
1 parent 2116c63 commit 02f3c55
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions xclim/sdba/adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def _convert_units_to(inda, dim, target):
inda[{dim: iv}], target[v], context="infer"
)
inda[dim].attrs["_units"][iv] = target[v]
inda.attrs["units"], inda.attrs["standard_name"] = "", ""
inda.attrs["units"] = ""
inda.attrs.pop("standard_name")
return inda

if target is None:
Expand Down Expand Up @@ -284,7 +285,12 @@ def adjust(self, sim: DataArray, *args, **kwargs):
infostr = f"{str(self)}.adjust(sim, {params})"
scen.attrs["history"] = update_history(f"Bias-adjusted with {infostr}", sim)
scen.attrs["bias_adjustment"] = infostr
scen.attrs["units"] = self.train_units

_is_multivariate = any(
[_crd.attrs.get("is_variables") for _crd in sim.coords.values()]
)
if _is_multivariate is False:
scen.attrs["units"] = self.train_units

if OPTIONS[SDBA_EXTRA_OUTPUT]:
return out
Expand Down Expand Up @@ -359,7 +365,12 @@ def adjust(
infostr = f"{cls.__name__}.adjust(ref, hist, sim, {params})"
scen.attrs["history"] = update_history(f"Bias-adjusted with {infostr}", sim)
scen.attrs["bias_adjustment"] = infostr
scen.attrs["units"] = ref.units

_is_multivariate = any(
[_crd.attrs.get("is_variables") for _crd in sim.coords.values()]
)
if _is_multivariate is False:
scen.attrs["units"] = ref.units

if OPTIONS[SDBA_EXTRA_OUTPUT]:
return out
Expand Down

0 comments on commit 02f3c55

Please sign in to comment.