Skip to contents

This function transforms a character vector of Dates or DateTimes into a character vector of seasons (summer, winter, autumn, spring), depending on the value of type:

When type=default -) winter = DJF: December, January, February
-) spring = MAM: March, April, May
-) summer = JJA: June, July, August
-) autumn = SON: September, October, November

When type=FrenchPolynesia -) winter = DJFM: December, January, February, March
-) spring = AM : April, May
-) summer = JJAS: June, July, August, September
-) autumn = ON : October, November

Usage

time2season(x, out.fmt = "months", type="default")

Arguments

x

vector with the dates that have to be transformed. class(x) must be Date

out.fmt

character, indicating the format of the output seasons. Possible values are:
-) seasons => c("winter", "spring", "summer", autumn")
-) months => c("DJF", "MAM", "JJA", SON") or c("DJFM", "AM", "JJAS", ON")

type

character, indicating which weather seasons will be used for computing the output. Possible values are:
-) default => "winter"= Dec, Jan, Feb; "spring"= Mar, Apr, May; "summer"=Jun, Jul, Aug; "autumn"= Sep, Oct, Nov
-) FrenchPolynesia => "winter"= Dec, Jan, Feb, Mar; "spring"= Apr, May; "summer"=Jun, Jul, Aug, Sep; "autumn"= Oct, Nov

Value

character vector with the weather season to which each date in x belongs

Author

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

Note

Weather seasons corresponding to French Polynesia were defined following a comment from Lydie Sichoix

Examples

## Sequence of daily dates between "1961-01-01" and "1961-12-31"
t <- dip("1961-01-01", "1961-12-31")
time2season(t)

## Sequence of monthly dates between "1961-01-01" and "1961-12-31"
t <- mip("1961-01-01", "1961-12-31")
time2season(t)
time2season(t, out.fmt="seasons")