Commit 382b68ba authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle
Browse files

typo

parent af65de2b
...@@ -123,11 +123,13 @@ cat("-- SPO timeseries preparation \n") ...@@ -123,11 +123,13 @@ cat("-- SPO timeseries preparation \n")
# time aggregation # time aggregation
frost <- cbind(frost,frost[,.(data.table::IDateTime(date))]) frost <- cbind(frost,frost[,.(data.table::IDateTime(date))])
frost[,`:=`(diff_s = as.numeric(base::difftime(as.POSIXct(idate,itime,tz="UTC"), as.POSIXct("1970-01-01 00:00:00",tz="UTC"), units = "secs")))]
frost_aggreg <- switch(timeAggregation, frost_aggreg <- switch(timeAggregation,
"hourly" = frost[, .(value = mean(value,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate),month = data.table::month(idate), dom = data.table::mday(idate),hour = data.table::hour(itime))], "hourly" = frost[, .(value = mean(value,na.rm=TRUE),diff_sec = max(diff_s,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate),month = data.table::month(idate), dom = data.table::mday(idate),hour = data.table::hour(itime))],
"daily" = frost[, .(value = mean(value,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate),month = data.table::month(idate), dom = data.table::mday(idate))], "daily" = frost[, .(value = mean(value,na.rm=TRUE),diff_sec = max(diff_s,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate),month = data.table::month(idate), dom = data.table::mday(idate))],
"monthly" = frost[, .(value = mean(value,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate),month = data.table::month(idate))], "monthly" = frost[, .(value = mean(value,na.rm=TRUE),diff_sec = max(diff_s,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate),month = data.table::month(idate))],
"yearly" = frost[, .(value = mean(value,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate))], "yearly" = frost[, .(value = mean(value,na.rm=TRUE),diff_sec = max(diff_s,na.rm=TRUE)), by = list(ID = ID, variable = CO_NAME, year = data.table::year(idate))],
stop("unknown parameter 'timeAggregation'") stop("unknown parameter 'timeAggregation'")
) )
...@@ -158,10 +160,10 @@ if (timeAggregation == "hourly") frost_aggreg[,c("time"):=NULL] ...@@ -158,10 +160,10 @@ if (timeAggregation == "hourly") frost_aggreg[,c("time"):=NULL]
############################################################## ##############################################################
cat("-- format [ID , year , month , dom , dow , hour , ... ,$variable] \n") cat("-- format [ID , year , month , dom , dow , hour , ... ,$variable] \n")
frost_aggreg <- switch(timeAggregation, frost_aggreg <- switch(timeAggregation,
"hourly" = data.table::dcast(frost_aggreg, ID + year + month + dom + hour ~ variable , value.var = "value"), "hourly" = data.table::dcast(frost_aggreg, ID + year + month + dom + hour + diff_sec ~ variable , value.var = "value"),
"daily" = data.table::dcast(frost_aggreg, ID + year + month + dom ~ variable, value.var = "value"), "daily" = data.table::dcast(frost_aggreg, ID + year + month + dom + diff_sec ~ variable, value.var = "value"),
"monthly" = data.table::dcast(frost_aggreg, ID + year + month ~ variable, value.var = "value"), "monthly" = data.table::dcast(frost_aggreg, ID + year + month + diff_sec ~ variable, value.var = "value"),
"yearly" = data.table::dcast(frost_aggreg, ID + year ~ variable, value.var = "value"), "yearly" = data.table::dcast(frost_aggreg, ID + year + diff_sec ~ variable, value.var = "value"),
stop("unknown parameter 'timeAggregation'") stop("unknown parameter 'timeAggregation'")
) )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment