rvn_apply_wyearly: Apply function for water year

View source: R/rvn_apply_wyearly.R

rvn_apply_wyearlyR Documentation

Apply function for water year

Description

rvn_apply_wyearly calculates a function FUN for the periods defined by the water year, similar to other functions of the form apply.<time period>, for example apply.daily, apply.monthly, etc.

Usage

rvn_apply_wyearly(x, FUN, ..., mm = 9, dd = 30)

Arguments

x

xts vector to calculate FUN for

FUN

the function to be applied

...

optional arguments to FUN

mm

month of water year ending (default 9)

dd

day of water year ending (default 30)

Details

The default water year start is October 1st, but may be adjusted with the mm and dd arguments. The values for mm and dd indicate the end of the water year period (i.e. mm=9 and dd=30 indicates a new water year on Oct 1).

See Also

rvn_wyear_indices for obtaining endpoints in the water year

Examples

# use sample forcing data (or use forcings_read to read in ForcingFunctions.csv)
data(rvn_forcing_data)

# apply mean as FUN to daily average temperature
rvn_apply_wyearly(rvn_forcing_data$forcings$temp_daily_ave,mean,na.rm=TRUE)

# apply mean as FUN to all forcings
rvn_apply_wyearly(rvn_forcing_data$forcings,mean,na.rm=TRUE)

# apply maximum via RavenR::cmax as FUN to all forcings (takes the max in each column)
## note that the base::max will not work properly here
rvn_apply_wyearly(rvn_forcing_data$forcings,cmax,na.rm=TRUE)

# apply to Australian water year (July 1)
rvn_apply_wyearly(rvn_forcing_data$forcings,cmax,na.rm=TRUE, mm=6, dd=30)


rchlumsk/RavenR documentation built on April 19, 2024, 5:15 a.m.