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 numpy as np | |
def low_rank_approx(SVD=None, A=None, r=1): | |
""" | |
Computes an r-rank approximation of a matrix | |
given the component u, s, and v of it's SVD | |
Requires: numpy | |
""" |
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
from numpy.fft import fft, ifft, fft2, ifft2, fftshift | |
import numpy as np | |
def fft_convolve2d(x,y): | |
""" 2D convolution, using FFT""" | |
fr = fft2(x) | |
fr2 = fft2(np.flipud(np.fliplr(y))) | |
m,n = fr.shape | |
cc = np.real(ifft2(fr*fr2)) | |
cc = np.roll(cc, -m/2+1,axis=0) |
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 base64 | |
import time | |
import urllib2 | |
import cv2 | |
import numpy as np | |
""" | |
Examples of objects for image frame aquisition from both IP and |
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 numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib | |
import random | |
import pickle | |
import matplotlib.dates as mdates | |
from matplotlib.ticker import LinearLocator |
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 numpy as np | |
import openmdao.api as om | |
class SIRvec(om.ExplicitComponent): | |
"""Basic epidemiological infection model | |
S (suceptible), I (infected), R (recovered). | |
""" | |
def initialize(self): | |
self.options.declare('num_nodes', types=int) |
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 numpy as np | |
import openmdao.api as om | |
class SIRvec(om.ExplicitComponent): | |
"""Basic epidemiological infection model | |
S (suceptible), I (infected), R (recovered). | |
""" | |
def initialize(self): | |
self.options.declare('num_nodes', types=int) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 pickle | |
import gzip | |
def save(object, filename, protocol = 0): | |
"""Saves a compressed object to disk | |
""" | |
file = gzip.GzipFile(filename, 'wb') | |
file.write(pickle.dumps(object, protocol)) | |
file.close() |
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 time | |
import Image | |
import ImageGrab | |
while True: | |
time.sleep(0.5) | |
t = str(time.time()).replace('.','-') | |
tt = time.time() | |
img=ImageGrab.grab() | |
img = img.resize((800,600)) |
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
4 21 894 | |
419 794 987 | |
424 797 125 | |
651 305 558 | |
655 631 963 | |
2 628 436 | |
736 50 363 | |
657 707 408 | |
252 705 98 | |
532 173 878 |
NewerOlder