distributeP: Distributes total precipitation over intervals

View source: R/distributeP.R

distributePR Documentation

Distributes total precipitation over intervals

Description

Distributes total precipitation (often daily) evenly over all of the applicable intervals. The function has 2 uses. The primary use is to distribute total precipitation when the precipitation time step is greater than the time step of the obs dataframe. For example, there may be 3-hour total precipitation within an obs dataframe holding hourly values for all other variables. The secondary use is to disaggregate precipitation to a shorter time step. Normally this can be done inside CRHM by putting the data in a separate obs file. However, if you want to do it in this function, then you must specify the new time step.

Usage

distributeP(obs, p.cols = 0, timestep = 0, quiet = TRUE, logfile = "")

Arguments

obs

Required. The CRHMr data frame of obs values.

p.cols

Optional. The number of the column(s) to be used. If not specified, the column will be guessed from the variable name. Note that the variable name MUST include the letter 'p', even if the number is specified.

timestep

Optional. The new time step in hours. If zero (the default) the time step is not used. The time step is only used when disaggregating precipitation to a shorter time step. Note that the specified time step must be shorter than that used in the original data frame.

quiet

Optional. Suppresses display of messages, except for errors. If you are calling this function in an R script, you will usually leave quiet=TRUE (i.e. the default). If you are working interactively, you will probably want to set quiet=FALSE.

logfile

Optional. Name of the file to be used for logging the action. Normally not used.

Value

If sucessful, returns a modified version of the obs data frame. If no time step is specified, the missing precipitation values in the specified data frame are replaced by average precipitation values. If a time step is specified, a new data frame containing ONLY the datetime and the distributed precipitation will be returned. If unsuccessful, returns an error.

Note

This function is potentially destructive. If you have a missing precipitation total, then the next precipitation total will be distributed over a longer time period. For example, you may have 3-hour precipitation data, normally at 03:00, 06:00, 09:00 etc., to be distributed hourly. If the 06:00 data are missing, then the 09:00 precipitation will be distributed over the interval from 04:00 to 09:00.

Author(s)

Kevin Shook

See Also

impute interpolate distributeInst distributeQli distributeQsi

Examples

## Not run: 
distributed <- distributeP(obs, 3)

## End(Not run)

CentreForHydrology/CRHMr documentation built on April 6, 2024, 5:27 p.m.