Question is: when is optimal time fo using electricity produced by
fotovoltaic system. Problem: outdated utility grid causing inverter
shutdown. I use dataset which contain observations from 1.04.2022 to
31.03.2023. This observations have made every hour, throut year.
Dataset setup
fotovolt<-read_csv('energia2022_2023.csv', col_names=TRUE)
## Rows: 9480 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (3): In_kWh", ECO_kWh, Out_kWh
## dttm (1): Time
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(fotovolt,5)
## # A tibble: 5 × 4
## Time `In_kWh"` ECO_kWh Out_kWh
## <dttm> <dbl> <dbl> <dbl>
## 1 2022-04-01 01:00:00 1.08 0 1.08
## 2 2022-04-01 02:00:00 0.94 0 0.94
## 3 2022-04-01 03:00:00 0.99 0 0.99
## 4 2022-04-01 04:00:00 1.08 0 1.08
## 5 2022-04-01 05:00:00 1.2 0 1.2
# There are mistakes in names of two columns: 2 and 4. It's my fault. Now I need to change this:
colnames(fotovolt)[2]<-'In_kWh'
colnames(fotovolt)[4]<-'total_kWh'
colnames(fotovolt)
## [1] "Time" "In_kWh" "ECO_kWh" "total_kWh"
options(repr.plot.width =15, repr.plot.height =10)
glimpse(fotovolt)
## Rows: 9,480
## Columns: 4
## $ Time <dttm> 2022-04-01 01:00:00, 2022-04-01 02:00:00, 2022-04-01 03:00:…
## $ In_kWh <dbl> 1.08, 0.94, 0.99, 1.08, 1.20, 1.11, 1.06, 1.10, 1.17, 1.10, …
## $ ECO_kWh <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.08, …
## $ total_kWh <dbl> 1.08, 0.94, 0.99, 1.08, 1.20, 1.11, 1.06, 1.10, 1.17, 1.02, …
fotovolt_date<-fotovolt %>%
mutate(new_date=as.POSIXlt(Time))
# -----------------------------------------------------------------------
fotovolt_new_date<-fotovolt_date%>%
mutate(year=new_date$year+1900, month=new_date$mon+1, week=strftime(Time,format="%W"), day=new_date$mday, hour=new_date$hour)%>%
mutate(week=as.numeric(week)+1)
head(fotovolt_new_date)
## # A tibble: 6 × 10
## Time In_kWh ECO_kWh total_kWh new_date year month
## <dttm> <dbl> <dbl> <dbl> <dttm> <dbl> <dbl>
## 1 2022-04-01 01:00:00 1.08 0 1.08 2022-04-01 01:00:00 2022 4
## 2 2022-04-01 02:00:00 0.94 0 0.94 2022-04-01 02:00:00 2022 4
## 3 2022-04-01 03:00:00 0.99 0 0.99 2022-04-01 03:00:00 2022 4
## 4 2022-04-01 04:00:00 1.08 0 1.08 2022-04-01 04:00:00 2022 4
## 5 2022-04-01 05:00:00 1.2 0 1.2 2022-04-01 05:00:00 2022 4
## 6 2022-04-01 06:00:00 1.11 0 1.11 2022-04-01 06:00:00 2022 4
## # ℹ 3 more variables: week <dbl>, day <int>, hour <int>
glimpse(fotovolt_new_date)
## Rows: 9,480
## Columns: 10
## $ Time <dttm> 2022-04-01 01:00:00, 2022-04-01 02:00:00, 2022-04-01 03:00:…
## $ In_kWh <dbl> 1.08, 0.94, 0.99, 1.08, 1.20, 1.11, 1.06, 1.10, 1.17, 1.10, …
## $ ECO_kWh <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.08, …
## $ total_kWh <dbl> 1.08, 0.94, 0.99, 1.08, 1.20, 1.11, 1.06, 1.10, 1.17, 1.02, …
## $ new_date <dttm> 2022-04-01 01:00:00, 2022-04-01 02:00:00, 2022-04-01 03:00:…
## $ year <dbl> 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, …
## $ month <dbl> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, …
## $ week <dbl> 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, …
## $ day <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ hour <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1…