This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import osmnx as ox | |
| import geopandas as gpd | |
| import matplotlib.pyplot as plt | |
| from typing import Tuple | |
| MAJOR = { | |
| "motorway","trunk","primary","secondary", | |
| "motorway_link","trunk_link","primary_link","secondary_link", | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{"current": 86.51745, "time": 298.8232, "fuse": "40T", "curve": "Melting "}, {"current": 86.95113, "time": 278.8996, "fuse": "40T", "curve": "Melting "}, {"current": 87.64952, "time": 252.3587, "fuse": "40T", "curve": "Melting "}, {"current": 88.35352, "time": 226.0716, "fuse": "40T", "curve": "Melting "}, {"current": 89.06317, "time": 203.9452, "fuse": "40T", "curve": "Melting "}, {"current": 90.40918, "time": 167.981, "fuse": "40T", "curve": "Melting "}, {"current": 91.59217, "time": 143.8614, "fuse": "40T", "curve": "Melting "}, {"current": 92.88347, "time": 121.3708, "fuse": "40T", "curve": "Melting "}, {"current": 94.28725, "time": 103.2186, "fuse": "40T", "curve": "Melting "}, {"current": 95.90382, "time": 86.21543, "fuse": "40T", "curve": "Melting "}, {"current": 97.54814, "time": 72.22954, "fuse": "40T", "curve": "Melting "}, {"current": 99.31992, "time": 61.05951, "fuse": "40T", "curve": "Melting "}, {"current": 101.225, "time": 51.15437, "fuse": "40T", "curve": "Melting "}, {"current": 102.8576, "t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var height = 450, | |
| width = 960, | |
| margin = {top: 20, right:20, bottom: 30, left: 50}, | |
| layers = 4; | |
| var parseTime = d3.timeParse("%m/%d/%Y"); | |
| var layerArray = d3.range(1, layers+1); | |
| var x = d3.scaleTime() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var height = 450, | |
| width = 960, | |
| layers = 4; | |
| var layerArray = d3.range(layers); | |
| var values =[ | |
| {"x": 1, "y": 28}, {"x": 2, "y": 55}, | |
| {"x": 3, "y": 43}, {"x": 4, "y": 91}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //From Wide and Short to Narrow and Skinny, | |
| var headers = ["hydro", "thermal"]; | |
| var layer = headers.map(function(header){ | |
| return data.map(d => | |
| ({date: d.date, type: header, value:d[header]}) | |
| ); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //vega-lite example of compile to vega spec and then parse the vega spec. | |
| function parse(spec) { | |
| vg.parse.spec(spec, function(chart) { | |
| chart({el:"#vis"}).update(); }); | |
| } | |
| var vlspec = { | |
| "data": { | |
| "values": [ | |
| {"a":"A", "b":28}, {"a":"B", "b":55}, {"a":"C", "b":43}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Data a dataframe of Confidence Intervals around parameter estimates | |
| params <- bind_rows(lm_for%>% | |
| confint()%>% | |
| as.data.frame(., rownames = rownames(.))%>% | |
| add_rownames(var = "parameter")%>% | |
| mutate(model = "Forecast"), | |
| lm_back%>% | |
| confint()%>% | |
| as.data.frame(., rownames = rownames(.))%>% | |
| add_rownames(var = "parameter")%>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| params <- bind_rows(lm_for%>% | |
| confint()%>% | |
| as.data.frame(., rownames = rownames(.))%>% # convert matrix to dataframe | |
| add_rownames(var = "parameter")%>% # convert rownames to variable | |
| mutate(model = "Forecast"), | |
| lm_back%>% | |
| confint()%>% | |
| as.data.frame(., rownames = rownames(.))%>% | |
| add_rownames(var = "parameter")%>% | |
| mutate(model = "Backcast")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df.int <- df.start.end$start[1]%--%df.start.end$end[1] # define interval | |
| time.points <- int_start(df.int)+minutes(seq(0, df.int%/%minutes(1), by = 5 ))# 5 minutes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Classify workdays and weekends | |
| cs.df<- coldstorage%>% | |
| mutate(dofw = wday(Date.Time, label = TRUE), | |
| day.type = as.factor(ifelse(dofw == "Sun"|dofw == "Sat", "weekend", "workweek")))%>% | |
| dplyr::select(-dofw) | |
| #Train Model | |
| model <- train(day.type ~., data = cs.df, | |
| 'nb', trControl=trainControl(method='cv',number=10)) |
NewerOlder