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

Version for cooperator #12

Closed rbcarvin closed 6 years ago

rbcarvin commented 7 years ago

Rainmaker's RMIntense function is failing and I can't figure out why. "rain.test.csv" is available in the r-data file on my fork.

Raw.test <- (read.csv("D:/RCode/Rainmaker/data/rain.test.csv"))
PrecipPrep <- RMprep(df = Raw.test,prep.type = 3,date.type = 1,dates.in = "date",cnames.in = "gage01")
PrecipEvents <- RMevents_sko(df = PrecipPrep,ieHr = 2,rainthresh = 0,rain = "rain",time = "pdate")
PrecipEventList <- PrecipEvents$storms2
StormSummary <- RMIntense(df = PrecipPrep,date = "pdate",rain = "rain",df.events = PrecipEventList,
                          sdate = "StartDate",edate = "EndDate",depth = "rain")

When I run the above lines I get:

Error in [.data.frame(df, , date) : undefined columns selected

rbcarvin commented 7 years ago

The same exercise does work with the "test_data_ones.1.csv" file, also in the data folder on my fork.

test_data_ones <- read.csv("M:/NonPoint Evaluation/GLRI Edge-of-field/R/Rainmaker/R_package_course/test_data_ones.1.CSV",sep = ",")
RDB3 <- RMprep(df=test_data_ones,prep.type = 3,date.type = 4,cnames.in = "rain")
RMevent_sko.list_RDB3 <- RMevents_sko(df=RDB3,rainthresh = 0.0,ieHr = 2)
RMevent_sko.0.2_RDB3 <- RMevent_sko.list_RDB3$storms2
StormSummary <- RMIntense(df=RDB3,date="pdate",rain="rain",
                          df.events=RMevent_sko.0.2_RDB3,sdate="StartDate",edate="EndDate",depth="rain",xmin=c(5,10,15,30,60))
limnoliver commented 7 years ago

@rbcarvin Turns out to be an easy fix. Because we were telling RMprop that the logger was in central with dst, we got an error when the time switched. Instead, use the following:

RMprep(..., tz = 'Etc/GMT-6')

This is telling the function that we're using UTC minus six hours. The times get exported as the same times as the logger. I tried this with the cooperators data, and it allowed me to run RMprep and RMevents_sko

rbcarvin commented 6 years ago

This is related to issue #11 and the solution (set tz='Etc/GMT-6') needs to be spelled out in the vignette.

rbcarvin commented 6 years ago

This issue has been resolved, save for the suggestion to include info about timezones in the vignette.