USGS-R / Rainmaker

Repo being permanently moved to: https://code.usgs.gov/water/analysis-tools/Rainmaker
https://code.usgs.gov/water/analysis-tools/Rainmaker
Other
18 stars 14 forks source link

RMevents_sample #43

Open rbcarvin opened 6 years ago

rbcarvin commented 6 years ago

If the sample dates and times are outside the precip data, it repeats the last known result for the remaining sample observations. In this example it repeated row 18 through row 96, which was the length of dfsamples. image

#' Initial set up
library(Rainmaker)
setwd("H:/Projects/Judy/Initial_Loss")

#' Load and prep rainfall dataframe
fileName <- "../Desktop/test/sca_09a_rdb_"
fileName2 <- "../Desktop/test/sca_09b_rdb_"
precip_raw <- read.csv(file = fileName,sep = "",skip = 2,col.names = c("Date", "Time", "rain", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"))
precip_raw2 <- read.csv(file = fileName2,sep = "",skip = 2,col.names = c("Date", "Time", "rain", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"))
precip_prep <- RMprep(df=precip_raw2,prep.type = 1,date.type = 5)

#' Load and prep dataframe with the beginning and ending dates and times of sampling periods in POSIXct format
fileName_samples <- "../Desktop/test/bio_sites_hydrovol_09_10.csv"
samples_raw <- read.csv(fileName_samples,FALSE,col.names = c("start", "end", "one"))
samples_prep_bdate <- RMprep(samples_raw, dates.in = "start", dates.out = "bdate")
samples_prep_edate <- RMprep(samples_raw, dates.in = "end", dates.out = "edate")
samples_prep <- data.frame("bpdate" = samples_prep_bdate$bdate, "epdate" = samples_prep_edate$edate)

#' Run RMevents_sample
precip_events <- RMevents_sample(df=precip_prep, ieHr = 6, rain = "rain", time = "pdate", dfsamples=samples_prep,
                bdate = "bpdate", edate = "epdate")

precip_event_list <- precip_events$storms2