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

dm2seasonal: allow flexible definition of seasons #3

Open
hzambran opened this issue May 20, 2016 · 2 comments
Open

dm2seasonal: allow flexible definition of seasons #3

hzambran opened this issue May 20, 2016 · 2 comments
Assignees
Milestone

Comments

@hzambran
Copy link
Owner

Original question from 'Bernard Okoński UP ':

I think it would be great that the values for the argument season should be maximum flexible that everyone can chose any month sequence or a period that suits ones research end geographic region e.g. hydrologic year in Atlantic Europe starts November 1st of one year and October 30th of the next, in the US October 1st of one year and September 30th of the next, Vegetation period (mean temp. above 5C) is roughly from the beginning of April to the end of October.

The problem will be with months starting with the same letter with JFMAMJJASOND but the same issue was solved in treeclim package by Christian Zang. There is dcc function with that functionality for calculating correlation/multiple correlation with arguments:

selection=.range(-4:-9)+.range(4:9) indicating the season April to September previous year and April to September the next year as an explanatory data for calculation of linear correlation

@hzambran hzambran added this to the v0.5 milestone May 20, 2016
@hzambran hzambran self-assigned this May 20, 2016
@maxmarumbwa
Copy link

It will be nice to have a flexible season . In my case it will be October to September the following year. The best would be to start time and number of months to sum.

@ajpelu
Copy link

ajpelu commented Jan 9, 2024

hi, I think is better to allow to the user to define the season, and change the month-approach by a day-approach. I mean, I would like to define the season based on a specific date, for instante the start of spring is in 21-march. So, what if you get the day of the year and then do the classification of the dates?

In a very customized approach I use the following code, that requires lubridate:

date2season <- function(x) { 
  
  day_of_year <- lubridate::yday(x) 
  winter <- which(day_of_year %in% c(1:80,356:366))
  spring <- which(day_of_year %in% 81:172)
  summer <- which(day_of_year %in% 173:264)
  autumm <- which(day_of_year %in% 265:355)
  
  seasons <- rep(NA, length(x))
  seasons[winter] <- "winter"
  seasons[spring] <- "spring"
  seasons[summer] <- "summer"
  seasons[autumm] <- "autumm"
  
  return(seasons)
  
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants