Skip to content

Instantly share code, notes, and snippets.

View moorepants's full-sized avatar

Jason K. Moore moorepants

View GitHub Profile
@moorepants
moorepants / trip.csv
Created September 3, 2012 15:46
Northwest US, Canada, Euro Roadtrip Costs
Description Category Who Paid Amount Currency Jason Charlie Robbie Quenby Yumi
2nd Nachos Food Charlie 26 C TRUE TRUE TRUE
Beer in Vancouver Food Charlie 7.5 C TRUE
groceries in Portland Food Charlie 65 D TRUE TRUE TRUE
concert ticket Entertainment Charlie 30 C TRUE
Taxi in Vancouver Transportation Jason 18 C TRUE TRUE TRUE
Tacos in Vancouver Food Jason 39 C TRUE TRUE
Loan MIsc Jason 50 E TRUE
Euro Map Transportation Jason 10 E TRUE TRUE TRUE TRUE
Loan for car payment Misc Jason 400 D TRUE
@moorepants
moorepants / peak_steer_rate.py
Created September 11, 2012 19:45
Generates a histogram showing the peak steer rates in my the UCD biycle id data.
from canonicalbicycleid.canonical_bicycle_id import select_runs
import bicycledataprocessor as bdp
import matplotlib.pyplot as plt
riders = ['Charlie', 'Jason', 'Luke']
maneuvers = ['Balance',
'Track Straight Line',
'Balance With Disturbance',
'Track Straight Line With Disturbance']
environments = ['Horse Treadmill', 'Pavillion Floor']
@moorepants
moorepants / gilbert_whipple.py
Created September 11, 2012 19:49
Gilbert's method of generating the bicycle equations of motion.
from sympy import *
from sympy.physics.mechanics import *
print('Calculation of Linearized Bicycle \"A\" Matrix, with States: Roll, Steer, Roll Rate, Steer Rate')
Vector.simp = False
mechanics_printing()
q1, q2, q4, q5 = dynamicsymbols('q1 q2 q4 q5')
q1d, q2d, q4d, q5d = dynamicsymbols('q1 q2 q4 q5', 1)
@moorepants
moorepants / sum_cols.R
Created September 12, 2012 18:56
Simple example of conditinal sum over columns of R
d <- as.data.frame(replicate(10, rnorm(20)))
# sum colums method 1
colSums(d)
# method 2
apply(d, 2, sum)
# now sum the columns only if the first column has values greater than 2
colSums(subset(d, V1 > 2))
# now sum if any column is greater than 0 on a per column basis
condSum <- function(x){
sum(x[x > 0])
@moorepants
moorepants / BodyFixed.all
Created October 10, 2012 05:05
Calculate the yaw, roll, pitch of the bicycle frame from the Vector Nav
(1) % this code calculates the equations for the yaw, roll and pitch rates of the
(2) % bicycle frame as functions of the body fixed rates measured by the VN-100
(3) newtonian n
(4) % y : yaw frame
(5) % r : roll frame
(6) % p : pitch frame
(7) % v : vn-100 frame
(8) frames y, r, p, v
(9) motionvariables yaw', roll', pitch'
(10) simprot(n, y, 3, yaw)
@moorepants
moorepants / col.py
Created December 3, 2012 07:25
Combine two gene files
#!/usr/bin/env python
# first open the two files and read their lines into lists
f1 = open('file1.txt', 'r')
f2 = open('file2.txt', 'r')
lines1 = f1.readlines()
lines2 = f2.readlines()
f1.close()
f2.close()
@moorepants
moorepants / jason-bicycle-parameters.ipynb
Created December 18, 2012 17:25
Computes the benchmark bicycle parameters for Jason sitting on the Davis rigid rider instrumented bicycle.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moorepants
moorepants / kalman-filter-test.ipynb
Created February 19, 2013 16:47
An attempt to make some sense of Tai's data.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moorepants
moorepants / tab-delimited.py
Last active September 1, 2020 16:41
Basic loading of tab delimited text files.
# This section just builds a sample tab delimited file to work with, don't
# worry too much about this code yet. Just have a look at the `test.txt` file
# that it creates and checkout the following sections.
x = range(10)
funcs = [lambda x: x**2, lambda x: x / 5.0, lambda x: x**3, lambda x: x + 3]
lines = 'x\tx^2\tx/5\tx^3\tx+3\n'
for row in x:
lines += str(row)
for col in funcs:
@moorepants
moorepants / walking_least_squares
Last active December 21, 2015 01:18
Maths for transforming time series data of walking into a linear least squares form: Ax=b that can solve for the gains.
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{