Skip to content

Instantly share code, notes, and snippets.

import itertools as itt
from collections import deque
# Each element of a sequence can have these values
possible_elements = [0, 1, 2, 3, 4, 5, 6, 7]
element_count = len(possible_elements)
# A sequence contains this many elements
sequence_length = 4
@GrantTrebbin
GrantTrebbin / orderGraph.py
Created February 28, 2016 14:18
Visualizing Periodic Order Schedules
import random
import math
import sqlite3
import numpy
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
def order_trajectory(base, colours, trajectory):
scale = 500
day_trajectory = trajectory / 24
@GrantTrebbin
GrantTrebbin / MagField.py
Created November 3, 2015 13:18
A quick demonstration of the magnetic field of a circular current loop
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
a = 1.55
current = 1
mu = 4 * np.pi / 10000000
# equal to sqrt(4ra(z^2 + (a+r)^2)^(-1))
def k_val (R, Z):
@GrantTrebbin
GrantTrebbin / imCompress.py
Created May 21, 2015 13:16
Compressing Similar PNG Images
#!/usr/bin/python
from PIL import Image
import numpy
import argparse
import os
import sys
#Configure argument parser to take input arguments
@GrantTrebbin
GrantTrebbin / si470x_log_processor.py
Created May 10, 2015 09:20
Create a series of images to demonstrate weather related events using python and matplotlib
#!/usr/bin/python
import csv
import sys
from datetime import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.image as image
import matplotlib.lines as mlines
import os.path