Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouper's additional dimensions are non-optional #1739

Open
1 task done
aulemahal opened this issue Apr 30, 2024 · 0 comments
Open
1 task done

Grouper's additional dimensions are non-optional #1739

aulemahal opened this issue Apr 30, 2024 · 0 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed sdba Issues concerning the sdba submodule.

Comments

@aulemahal
Copy link
Collaborator

Generic Issue

  • xclim version: master
  • Python version: all
  • Operating System: all

Description

Related to #1736 and discussion #1735. The Grouper add_dims was intended to allow the training of adjustments across dimensions. For example, train a method by mixing all realizations of a simulation. Of course, in such a case, the extra dimensions doesn't exist on the reference data. But the current code expects them to exist in many places.

What I Did

import xarray as xr
from xclim import sdba
from xclim.testing import open_dataset

sim = open_dataset('sdba/CanESM2_1950-2100.nc')
ref = open_dataset('sdba/ahccd_1950-2013.nc')
hist = sim.pr.sel(time=slice('1980', '2010'))
sim = sim.pr.sel(time=slice('2040', '2070'))
ref = ref.pr.isel(location=0).sel(time=slice('1980', '2010'))
ref = ref.drop_vars(['lon','lat'])

group = sdba.Grouper("time.dayofyear", add_dims=['location'])
loci = sdba.LOCI.train(ref, hist, thresh="1 mm/d", group=group)

What I Received

This specific example fails because:

  • sdba.utils.map_cdf passes the group's dims without filtering them to apply_ufunc
  • group.apply('mean', ref) tries to average the extra dim.

Surely, there are more spots where this happens. But fixing those two fixes the issue for LOCI.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@aulemahal aulemahal added bug Something isn't working sdba Issues concerning the sdba submodule. labels Apr 30, 2024
@aulemahal aulemahal added this to the Summer 2024 milestone Apr 30, 2024
@aulemahal aulemahal self-assigned this Apr 30, 2024
@coxipi coxipi self-assigned this May 14, 2024
@aulemahal aulemahal added the help wanted Extra attention is needed label May 14, 2024
@Zeitsperre Zeitsperre removed this from the Summer 2024 milestone Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed sdba Issues concerning the sdba submodule.
Projects
None yet
Development

No branches or pull requests

3 participants