View least_sq_fit.py
from scipy import zeros, dot, linspace, linalg, array, sqrt, loadtxt, meshgrid | |
from scipy import shape, mean | |
from numpy.linalg import norm | |
from scipy.optimize import minimize | |
x = loadtxt('x.txt') | |
t = loadtxt('t.txt') | |
S = loadtxt('Syy.txt') | |
X, T = meshgrid(x,t) |
View poly_lsq.py
""" | |
Computes the least squares fitting for a polynomial of order k. | |
The condition k< n should be satisfied. | |
""" | |
from scipy import zeros, dot, array, loadtxt | |
from scipy import shape, mean | |
from numpy.linalg import norm, solve |
View ode.py
from numpy import * | |
from scipy import integrate | |
def ode(f, t0, tf, n_steps, X0): | |
""" | |
Solve an ODE in the time interval [t0, tf] using a number of steps given | |
by nsteps, with initial conditions X0. The differential equation is | |
written as a system of linear equations | |
x'_i = f(x_j) |
View plotdf.py
import numpy as np | |
from matplotlib import pyplot as plt | |
def plotdf(f, xran=[-5, 5], yran=[-5, 5], grid=[21, 21], color='k'): | |
""" | |
Plot the direction field for an ODE written in the form | |
x' = F(x,y) | |
y' = G(x,y) | |
The functions F,G are defined in the list of strings f. |
View videos.sh
#!/bin/bash | |
# | |
# Generate an animation (.avi, .gif) from a sequence of image with | |
# the same name and a sequence of numbers. | |
# | |
mencoder "mf://*.png" -mf type=png:fps=5 -ovc lavc -o vid.avi | |
convert img*.png -delay 20 -loop 0 -channel Alpha vid.gif | |
rm img*.png |
View superquads.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View zoomed_inset_axes_example.py
import matplotlib.pyplot as plt | |
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes | |
from mpl_toolkits.axes_grid1.inset_locator import mark_inset | |
import numpy as np | |
fig, ax = plt.subplots() |
View circular_membrane.py
from __future__ import division | |
from numpy import pi, sin, cos, mgrid | |
from scipy.special import jn, jn_zeros | |
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
from matplotlib import rcParams | |
# In Windows the next line should provide the full path to convert.exe |
View plot_guy.py
import matplotlib.pyplot as plt | |
import numpy as np | |
def plot_guy(x, y, frown=False, **plot_args): | |
"""Plot a stick man of 2 units wide and 6 units tall. | |
http://nbviewer.ipython.org/gist/theandygross/4544012 | |
""" | |
an = np.array(np.linspace(0,2*np.pi,100)) | |
head, = plt.plot(np.cos(an)+x, np.sin(an)+y + 5, **plot_args) |
View butterfly_curves.py
""" | |
Plot multiple butterfly curves. | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def curve(turns, npts): | |
t = np.linspace(0, 2*turns*np.pi, npts) | |
x = np.sin(t)*(np.exp(np.cos(t))- 2*np.cos(4*t) - np.sin(t/12)**5) |
OlderNewer