Last active
May 9, 2026 15:32
-
-
Save oousmane/d0f8a476590de40a6430bbf6b6edeeef to your computer and use it in GitHub Desktop.
This piece of code let you compute season length using definition of onset, cessation valid for sahelian region
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # set up | |
| pak::pak("YODAdam/ClimSeasonR") | |
| library(tidyverse) | |
| library(ClimSeasonR) | |
| # read and clean daily data for multiple stations | |
| data<-readxl::read_excel("~/Downloads/rain.xls",skip = 2) %>% | |
| janitor::clean_names() | |
| # compute season length, for a set of stations | |
| data %>% | |
| group_by(name) %>% | |
| reframe( | |
| onset = dt_start( | |
| x = value, | |
| early = 91, | |
| maxDrySpell_aft = 10 | |
| ), | |
| cessation = end_season( | |
| x=value | |
| ) | |
| ) %>% | |
| mutate(season_length = cessation-onset+1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment