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
#!/bin/bash | |
set -e | |
function get_instance_storage_nvme() { | |
for nvme_device_name in `lsblk | cut --delimiter=" " --fields=1 | grep ^nvme | sort -n`; do | |
local nvme_device="/dev/${nvme_device_name}" | |
if ( nvme id-ctrl "${nvme_device}" | grep --quiet "^mn\\s*:\\s*Amazon EC2 NVMe Instance Storage\\s*$" ); then | |
echo "${nvme_device}" | |
fi | |
done |
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
""" | |
Reads a fastq file directly from the 1000genomes AWS public dataset | |
into a Bio.SeqRecord set | |
Requires an AWS Account | |
""" | |
from smart_open import open | |
from Bio import SeqIO |
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
SP = sin(0.5*tt) + cos(.8*tt) + 5 |
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
SP = rep(10, length(tt)) | |
SP[which(tt >= 30)] = 5 | |
SP[which(tt >= 60)] = 20 |
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
for (k in 2:length(tt)) { | |
PV[k] = pv(PV[k-1], U[k-1], tt[k]) | |
E[k] = PV[k] - SP[k] | |
EI[k] = EI[k-1] + E[k]*dt # integral | |
ED[k] = (E[k] - E[k-1])/dt # derivative | |
U[k] = Kp*(E[k] + (1/Ti)*sum(E*dt) + Td*ED[k]) | |
if (U[k] < 0) U[k] = 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
MultiSetFun = function(fun, x) { | |
# performs a set function (e.g. intersect, setdiff) on x | |
# where x is a list of vectors of the same type but not necessarily the same length | |
fun = tolower(fun) | |
this.intersect = function(M, v) { | |
return(names(which(rowSums(M) == sum(v)))) | |
} | |
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
# controller parameters | |
Kp = 10 # proportional gain | |
Ti = 1 # integral time | |
Td = 0.01 # derivative time | |
# simulation parameters | |
dt = .1 # time step | |
tt = seq(0, 100, by=dt) # time vector | |
# initialize the following to a vector of zeros |
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
# assuming --pylab ipython | |
import numpy as np | |
from lmfit import minimize, Parameters | |
s = np.float_(np.array(range(0,1201,1200/8))) | |
v = np.round(120*s/(171+s) + np.random.uniform(size=9), 2) | |
def residual(p, x, data): | |
vmax = p['vmax'].value | |
km = p['km'].value |
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
pv = function(pv.prev, u, tt) { | |
out = pv.prev*1.1 + .5 # exponential growth + linear growth | |
out = out - 0.1*u # the control response | |
out = out + .5*runif(length(tt)) # a little noise, just for fun | |
if (out < 0) out = 0 # keep values positive | |
return(out) | |
} |
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
function cmap = colorRamp(colors, varargin) | |
% colorRamp produces a color ramp for use in figure colormaps | |
% cmap = colorRamp(colors) | |
% cmap = colorRamp(colors, nlevels) | |
% | |
% Interpolates between color stops specified in the m-by-3 matrix colors. | |
% Each row represents one color stop. | |
% Assumes color stops are equally spaced. | |
% | |
% By default, produces a cmap with 32-levels, unless the nlevels argument |
NewerOlder