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 numpy as np | |
def circmean(alpha,axis=None): | |
mean_angle = np.arctan2(np.mean(np.sin(alpha),axis),np.mean(np.cos(alpha),axis)) | |
return mean_angle | |
def circvar(alpha,axis=None): | |
if np.ma.isMaskedArray(alpha) and alpha.mask.shape!=(): | |
N = np.sum(~alpha.mask,axis) | |
else: |
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
def binMeanPlot(X,Y,ax=None,numBins=8,xmin=None,xmax=None): | |
if xmin is None: | |
xmin = X.min() | |
if xmax is None: | |
xmax = X.max() | |
if ax is None: | |
fig = pylab.figure() | |
ax = fig.add_subplot(111) | |
bins = np.linspace(xmin,xmax,numBins+1) | |
XX = np.array([np.mean((bins[binInd], bins[binInd+1])) for binInd in range(numBins)]) |
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
def selectRectangle(fig): | |
pts = fig.ginput(2) | |
pts = np.array(pts) | |
pts.sort(axis=0) | |
pts = np.round(pts).astype(int) | |
return pts | |
""" | |
#example usage: | |
axROI.imshow(frames.mean(2),cmap='gray',origin='lower') |
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
def findClosestSampleTimes(denseSamples,sparseSamples,debug=False): | |
"""inds, samples = findClosestSampleTimes(denseSamples,sparseSamples) | |
NOTE: SHOULD CLEAN ADC SIGNAL BEFORE DOWNSAMPLING""" | |
inds = np.empty(sparseSamples.shape) | |
for sparseInd, sparseSample in enumerate(sparseSamples): | |
inds[sparseInd] = np.argmin(abs(denseSamples - sparseSample)) | |
if debug: | |
f = pylab.figure() | |
ax = f.add_subplot(111) | |
ax.plot(denseSamples,denseSamples*0,'.b') |
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
// polarization rotator experiment | |
int incomingByte = 1; // for incoming serial data | |
int pwmPin = 9; // white wire | |
int dirPin = 11; // green wire | |
int statusLED = 13; | |
int delaymsec = 100; | |
void setup() { | |
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps |
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
// control intensity of LED using serial communication | |
int incomingByte = 0; // for incoming serial data | |
int outVal = 0; // for signal out | |
int pwmPin = 6; // white wire (pin 5 and 6 have pwm frequency ~1000 Hz, faster than pin 9) | |
int statusLED = 13; | |
int delaymsec = 100; | |
void setup() { | |
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps |
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
function [data, h] = import_edr(file) | |
% function [data, h] = import_edr(file) | |
% | |
% Imports .edr file to matrix | |
% for use with files output by WinEDR, | |
% http://spider.science.strath.ac.uk/sipbs/page.php?show=software_ses | |
% but created independently | |
% | |
% ---------------inputs------------------------------ | |
% file .edr file name ( e.g. 'File_001.EDR') |
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 sys, os | |
import numpy as np | |
import roslib | |
roslib.load_manifest('rosbag') | |
import rosbag | |
def loadBag(inFileName): | |
""" | |
Script to import strokelitude bag file | |
usage: outDict = loadBag(inFileName) |
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 argparse # need to install argparse: sudo apt-get install python-argparse | |
import os, ast | |
import numpy as np | |
import motmot.FlyMovieFormat.FlyMovieFormat as FMF | |
import pylab | |
pylab.ion() | |
import roslib | |
roslib.load_manifest('rosbag') | |
import rosbag |
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 numpy as np | |
import matplotlib.pyplot as plt | |
plt.ion() | |
import scipy.interpolate | |
def interpolate_to_common_samplerate(Y, X=None, t=None): | |
if t is None: | |
if X is None: | |
t = np.arange(len(Y[0]),dtype='float') | |
else: |
OlderNewer