dane <- read.csv("~/Pobrane/dane.csv")
dane$Data1 <- as.POSIXct(as.character(dane$Data1))
dane <- dane[,-c(3,4)]
colnames(dane)[1] <- "date"
head(dane)
##                  date EW1.prod EW1.ws
## 1 2015-11-02 00:00:46     14.0   3.88
## 2 2015-11-02 00:01:46     14.1   4.03
## 3 2015-11-02 00:02:46     11.5   4.02
## 4 2015-11-02 00:03:46     10.6   4.04
## 5 2015-11-02 00:04:46     10.9   3.89
## 6 2015-11-02 00:05:46     19.8   4.02
library(openair)
## Loading required package: lazyeval
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## 
## Następujące obiekty zostały zakryte z 'package:stats':
## 
##     filter, lag
## 
## Następujące obiekty zostały zakryte z 'package:base':
## 
##     intersect, setdiff, setequal, union
## 
## Loading required package: maps
## 
##  # ATTENTION: maps v3.0 has an updated 'world' map.        #
##  # Many country borders and names have changed since 1990. #
##  # Type '?world' or 'news(package="maps")'. See README_v3. #
timePlot(dane, pollutant = c("EW1.ws","EW1.prod"))
## Warning in checkPrep(mydata, vars, type, remove.calm = FALSE): Detected
## data with Daylight Saving Time, converting to UTC/GMT

head(dane)
##                  date EW1.prod EW1.ws
## 1 2015-11-02 00:00:46     14.0   3.88
## 2 2015-11-02 00:01:46     14.1   4.03
## 3 2015-11-02 00:02:46     11.5   4.02
## 4 2015-11-02 00:03:46     10.6   4.04
## 5 2015-11-02 00:04:46     10.9   3.89
## 6 2015-11-02 00:05:46     19.8   4.02
#scatter.smooth(dane$EW1.ws,dane$EW1.prod)
scatterPlot(dane, y="EW1.prod", x="EW1.ws", statistic = "frequency", method = "hexbin", type = "month", smooth = F, linear = T, layout=c(1,3))
## Warning in checkPrep(mydata, vars, type): Detected data with Daylight
## Saving Time, converting to UTC/GMT

scatterPlot(dane, y="EW1.prod", x="EW1.ws",  type = "month", smooth = T, linear=T, layout=c(1,3))
## Warning in checkPrep(mydata, vars, type): Detected data with Daylight
## Saving Time, converting to UTC/GMT

dane2 <- subset(dane, EW1.prod>1)
summary(dane2)
##       date                        EW1.prod         EW1.ws      
##  Min.   :2015-11-02 00:00:46   Min.   :  1.1   Min.   : 1.030  
##  1st Qu.:2015-11-20 05:06:18   1st Qu.: 28.8   1st Qu.: 4.190  
##  Median :2015-12-10 10:45:49   Median : 68.2   Median : 5.030  
##  Mean   :2015-12-09 19:43:33   Mean   :100.8   Mean   : 5.546  
##  3rd Qu.:2015-12-29 01:41:04   3rd Qu.:141.5   3rd Qu.: 6.420  
##  Max.   :2016-01-15 10:40:12   Max.   :469.2   Max.   :17.930
# jest ewidentny blad w danych dla 14.11.2015. (awaria systemu pomiarowego??)
#subset(dane2,EW1.prod==421.5)
dane2 <-  dane2[-which(dane2[,2]==421.5),]

scatterPlot(dane2, y="EW1.prod", x="EW1.ws",  type = "month", smooth = T, linear=T, layout=c(1,3))
## Warning in checkPrep(mydata, vars, type): Detected data with Daylight
## Saving Time, converting to UTC/GMT

dane_godzinowe <- timeAverage(dane2,avg.time="hour", data.thresh = 10)
## Warning in checkPrep(mydata, vars, type = "default", remove.calm = FALSE, :
## Detected data with Daylight Saving Time, converting to UTC/GMT
scatterPlot(dane_godzinowe, y="EW1.prod", x="EW1.ws",  type = "month", smooth = T, linear=T, layout=c(1,3))

model_prosty <- lm(EW1.prod~EW1.ws,dane_godzinowe)
hist(residuals(model_prosty), freq=F) # dla wartosci godzinowych

head(dane_godzinowe)
##                  date EW1.prod   EW1.ws
## 1 2015-11-01 23:00:00 32.62667 4.254500
## 2 2015-11-02 00:00:00 48.42167 4.588833
## 3 2015-11-02 01:00:00 66.47667 4.887667
## 4 2015-11-02 02:00:00 32.36667 4.241500
## 5 2015-11-02 03:00:00 42.33000 4.451667
## 6 2015-11-02 04:00:00 43.78000 4.488167
dane_godzinowe$model_prod <- predict(object=model_prosty, newdata = dane_godzinowe)
head(dane_godzinowe)
##                  date EW1.prod   EW1.ws model_prod
## 1 2015-11-01 23:00:00 32.62667 4.254500   37.31126
## 2 2015-11-02 00:00:00 48.42167 4.588833   52.44643
## 3 2015-11-02 01:00:00 66.47667 4.887667   65.97454
## 4 2015-11-02 02:00:00 32.36667 4.241500   36.72275
## 5 2015-11-02 03:00:00 42.33000 4.451667   46.23694
## 6 2015-11-02 04:00:00 43.78000 4.488167   47.88928
podsumowanie <- timeAverage(dane_godzinowe, avg.time="day",statistic = "sum")
timePlot(podsumowanie, pollutant=c("EW1.prod","model_prod"))

hist(podsumowanie$EW1.prod-podsumowanie$model_prod, main="roznice prod. dobowej")