This file contains 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
def list_bad_zones(input_file): | |
with open(input_file, 'r') as fr: | |
lines = fr.readlines() | |
lines = [line.rstrip('\n') for line in lines] | |
chk = re.compile('.*([0-9]+\.[0-9]*) Trips for I\=([0-9]+) to J\=([0-9]+), but no path.*') | |
lines = pd.DataFrame({'INPUT': [l for l in lines if chk.match(l)]}) | |
lines['trips'] = lines['INPUT'].apply(lambda x: float(chk.match(x)[1])) | |
lines['i'] = lines['INPUT'].apply(lambda x: chk.match(x)[2]) | |
lines['j'] = lines['INPUT'].apply(lambda x: chk.match(x)[3]) | |
return lines[['i', 'j', 'trips']] |
This file contains 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 pandas as pd | |
import numpy as np | |
import re | |
import geopandas as gpd | |
from shapely.geometry import Point, LineString | |
def read_card(input_file, group_id, key_id, nxy_table): | |
with open(input_file, 'r') as fr: | |
lines = fr.readlines() | |
lines = [line.rstrip('\n') for line in lines] |
This file contains 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
# NOTE: There's a post that will be on siliconcreek.net about this someday soon. | |
import os | |
map_list = [ | |
{'fieldname': 'final_accessibility_auPkRetail', 'Legend Name': 'Peak Auto Accessibility to Retail', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4}, | |
{'fieldname': 'final_accessibility_auPkTotal', 'Legend Name': 'Peak Auto Accessibility to Total Emp.', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4}, | |
{'fieldname': 'final_accessibility_auOpRetail', 'Legend Name': 'Off-Peak Auto Accessibility to Retail', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4}, | |
{'fieldname': 'final_accessibility_auOpTotal', 'Legend Name': 'Off-Peak Auto Accessibility to Total Emp.', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4}, | |
{'fieldname': 'final_accessibility_trPkRetail', 'Legend Name': 'Peak Transit Accessibility to Retail', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4}, |
This file contains 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
def getCentroidFromPoints(self, s): | |
points = s.points | |
p_x = 0 | |
p_y = 0 | |
pp = np.array(s.points) | |
pp = np.append(pp, [pp[0]], axis = 0) | |
area = self.shoelace(pp) | |
for p in range(0, len(pp) - 1): | |
p_x += (pp[p, 0] + pp[p + 1, 0])*(pp[p, 0] * pp[p + 1, 1] - pp[p + 1, 0] * pp[p, 1]) | |
p_y += (pp[p, 1] + pp[p + 1, 1])*(pp[p, 0] * pp[p + 1, 1] - pp[p + 1, 0] * pp[p, 1]) |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sun Aug 2 13:05:58 2020 | |
@author: andrew.rohne | |
""" | |
import socket | |
def setLights(setting): |
This file contains 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
# NeoPixel library strandtest example | |
# Author: Tony DiCola (tony@tonydicola.com) | |
# | |
# Direct port of the Arduino NeoPixel library strandtest example. Showcases | |
# various animations on a strip of NeoPixels. | |
import time | |
from neopixel import * | |
This file contains 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
let tweet = function(){ | |
Twitter.post('statuses/update', { | |
status: 'Random Number: ' + Math.random() | |
}, function(err, data, response){ | |
if(err !== undefined){ | |
console.log('err: ' + err); | |
} | |
}); | |
} |
This file contains 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
library(xkcd) | |
library(ggplot2) | |
# Load the font from https://github.com/shreyankg/xkcd-desktop/blob/master/Humor-Sans.ttf | |
windowsFonts(HS=windowsFont("Humor Sans")) | |
airplaneSeats1 = data.frame(Width = pnorm(seq(0,1,0.025), mean = 0.5, sd = 0.1) * 10) | |
airplaneSeats1$label = "Avg American Width" | |
airplaneSeats1$time = as.integer(row.names(airplaneSeats1)) + 1975 |
This file contains 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
library(openxlsx) | |
library(ggplot2) | |
library(reshape2) | |
library(plyr) | |
# Fix the path! | |
cd = read.xlsx("countdata.xlsx", "Sheet1") | |
# Summarize counts to get average weekdays | |
cntByDay.1 = ddply(cd, .(DayOfWeek, CntTimeTxt), summarize, NB = mean(NB), SB = mean(SB)) |
This file contains 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
# | |
# HBWDCPrep.R | |
# | |
# Prepares Destination choice files for HBW DC | |
library(foreign) | |
source("http://raw.githubusercontent.com/osPlanning/omx/dev/api/r/omx.R") | |
A1201 = read.dbf("C:\\Modelrun\\Model80\\Base\\A1201.DBF") |
NewerOlder