dm2seasonal {hydroTSM}R Documentation

(sub)Daily/Monthly -> Seasonal Values


Generic function for computing a seasonal value for every year of a sub-daily/daily/weekly/monthly time series


dm2seasonal(x, ...)
subdaily2seasonal(x, ...)

## Default S3 method:
dm2seasonal(x, season, FUN, na.rm = TRUE, out.fmt="%Y", ...)

## S3 method for class 'zoo'
dm2seasonal(x, season, FUN, na.rm = TRUE, out.fmt="%Y", ...)

## S3 method for class 'data.frame'
dm2seasonal(x, season, FUN, na.rm = TRUE, dates=1, date.fmt = "%Y-%m-%d", 
        out.type = "data.frame", out.fmt="%Y", ...)
## S3 method for class 'matrix'
dm2seasonal(x, season, FUN, na.rm = TRUE, dates=1, date.fmt = "%Y-%m-%d", 
        out.type = "data.frame", out.fmt="%Y", ...)



zoo, xts, data.frame or matrix object, with sub-daily, daily, weekly or monthly time series.
Measurements at several gauging stations can be stored in a data.frame of matrix object, and in that case, each column of x represent the time series measured in each gauging station, and the column names of x have to correspond to the ID of each station (starting by a letter).


character, indicating the weather season to be used for selecting the data. Valid values are:
-) DJF : December, January, February
-) MAM : March, April, May
-) JJA : June, July, August
-) SON : September, October, November
-) DJFM: December, January, February, March
-) AM : April, May
-) JJAS: June, July, August, September
-) ON : October, November


Function that will be applied to ALL the values of x belonging to the given weather season (e.g., FUN can be some of mean, max, min, sd).
The FUN value for the winter season (DJF or DJFM) is computed considering the consecutive months of December, January and February/March. See 'Note' section.


Logical. Should missing values be removed?
-) TRUE : the seasonal values are computed considering only those values different from NA (very important when FUN=sum)
-) FALSE: if there is AT LEAST one NA within a weather season, the corresponding seasonal values are NA


Character indicating the date format for the output time series. See format in as.Date. Possible values are:
-) %Y : only the year will be used for the time. Default option. (e.g., "1961" "1962"...)
-) %Y-%m-%d: a complete date format will be used for the time. (e.g., "1961-01-01" "1962-01-01"...)


numeric, factor or Date object indicating how to obtain the dates.
If dates is a number (default), it indicates the index of the column in x that stores the dates
If dates is a factor, it is converted into Date class, by using the date format specified by date.fmt
If dates is already of Date class, the code verifies that the number of days on it be equal to the number of elements in x


Character indicating the format in which the dates are stored in dates, e.g. %Y-%m-%d. See format in as.Date.
ONLY required when class(dates)=="factor" or class(dates)=="numeric".


Character that defines the desired type of output. Valid values are:
-) data.frame: a data.frame, with as many columns as stations are included in x, the year corresponding to each seasonal value are used as row names.
-) db : a data.frame, with 4 columns will be produced.
The first column (StationID) stores the ID of the station The second column (Year) stores the year,
The third column (Season) stores the season,
The fourth column (Value) contains the seasonal value corresponding to the values specified in the previous three columns


further arguments passed to or from other methods.


A numeric vector with the seasonal values for all the years in which x is defined.


For any year, the FUN value for the winter season (DJF), is computed considering only January and February, and the value of December is used for computing the winter value of the next year.


FUN is applied to all the values of x belonging to the selected season, so the results of this function depends on the frequency sampling of x and the type of function given by FUN


Mauricio Zambrano-Bigiarini, mzb.devel@gmail

See Also

, hydroplot, seasonalfunction, time2season, extract, daily2monthly, daily2annual, monthly2annual


## Loading the DAILY precipitation data at SanMartino
x <- SanMartinoPPts

## Winter (DJF) values of precipitation for each year of 'x'
dm2seasonal(x, FUN=sum, season="DJF")

## Loading the HOURLY discharge data for the Karamea at Gorge streamgauge station
x <- KarameaAtGorgeQts

## Mean winter (DJF) values of streamflow for each year of 'x'
dm2seasonal(x, FUN=mean, season="DJF")
subdaily2seasonal(x, FUN=mean, season="DJF") # same as above

[Package hydroTSM version 0.5-1 Index]