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

create_ensemble_on with calendar noleap #303

Open
1 task done
juliettelavoie opened this issue Dec 11, 2023 · 2 comments
Open
1 task done

create_ensemble_on with calendar noleap #303

juliettelavoie opened this issue Dec 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@juliettelavoie
Copy link
Contributor

Setup Information

  • xscen version: '0.7.20-beta'
  • Python version: 3.10.6
  • Operating System: linux

Description

I am trying to use create_ensemble_on in to_dataset.
I want to convert calendars to noleap. I get an error to use cftime, but that arg is not available through to_dataset. It is fixed to calendar == "default". Why is cftime only acceptable with default ? Is there a problem with adding a use_cftime_for_calendar arg to to_dataset ?

calendar, use_cftime=(calendar == "default"), align_on="date"

Steps To Reproduce

cat = xs.ProjectCatalog('simulation.json')
cat.search(**dict(
        variable='tasmax', 
        source=['MIROC6', 'CanESM5'],
        processing_level='biasadjusted',
        bias_adjust_project=['ESPO-G6-R2'],
        experiment=['ssp245'],
        member='r1i1p1f1')).to_dataset(create_ensemble_on=["institution", "source"], calendar='noleap')

gives:

ValueError: Calendar 'noleap' is only valid with cftime. Try using `use_cftime=True`.

Additional context

Note that technically these two sources are already noleap in cftime. When I use to_dataset without converting to a calendar, the time axis becomes a numpy datetime (but february 29th are still missing.) This seems like a weird behavior to me.
It leads to issue, because xr.infer_freqdoesn't work anymore (outputs None). This means that default xclim checks on indicators fail.

Contribution

  • I would be willing/able to open a Pull Request to address this bug.
@juliettelavoie juliettelavoie added the bug Something isn't working label Dec 11, 2023
@aulemahal
Copy link
Collaborator

Hum. haha what was I thinking ? Maybe its a typo and I actually meant calendar != 'default' ?

Because "default" is the name xclim (and only xclim) gives to the numpy datetime calendar.

On the other hand, if all datasets are using noleap and you are not getting a noleap calendar output, than that's an issue of catalog.to_dask think. Strange!

@juliettelavoie
Copy link
Contributor Author

calendar != 'default' fixes my problem, I'll make the change in my partition PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants