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

Please add option for 'weekly' frequency in the SPI family of models #1892

Open
1 of 2 tasks
C15H24 opened this issue Aug 26, 2024 · 2 comments
Open
1 of 2 tasks

Please add option for 'weekly' frequency in the SPI family of models #1892

C15H24 opened this issue Aug 26, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@C15H24
Copy link

C15H24 commented Aug 26, 2024

Addressing a Problem?

No response

Potential Solution

the function standardized_precipitation_index accepts freq = 'W' as signifying the nature of the groupings is weekly - and any downstream adjustments that would need to be made to validate the output

Additional context

Many projects in government are beginning to operate and produce products on a weekly basis

Contribution

  • I would be willing/able to open a Pull Request to contribute this feature.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@C15H24 C15H24 added the enhancement New feature or request label Aug 26, 2024
@coxipi
Copy link
Contributor

coxipi commented Aug 28, 2024

Hi! We can add this indeed. Just a couple caveats:

  1. It will only work with standard calendars, as .resample(time="W") and .groupby("time.week") is not yet compatible with cf-time (how to group `cftime` coordinate by `week`? pydata/xarray#6375)
  2. Since there is not an integer number of weeks in a year, using .resample(time="W").mean() the days included in week1 can vary from year to year, e.g.
# days included in week 1 between 2000 and 2002
2000: [Jan 3, Jan 9]
2001: [Jan 1, Jan 7]
2002: [Dec31 2001, Jan 6]
...

sometimes Jan 1rst is not included, sometimes Week1 includes days from december, etc. I'm curious to know if this is what you envision when you consider weekly groupings.

@C15H24
Copy link
Author

C15H24 commented Sep 9, 2024

Yes, I envision strict adherence to ISO-8601 weeks :)
So, looks like it would need to be implemented upstream (cftime.datetime) first?

Thank you for your response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants