Skip to content

Instantly share code, notes, and snippets.

View nicoguaro's full-sized avatar

Nicolás Guarín-Zapata nicoguaro

View GitHub Profile
@nicoguaro
nicoguaro / hausdorff.py
Last active August 29, 2015 14:19
Calculate two-side Hausdorff distance between two sets using a brute force approach.
# -*- coding: utf-8 -*-
"""
Calculate two-side Hausdorff distance between two sets using a brute
force approach.
References
[1] http://en.wikipedia.org/wiki/Hausdorff_distance
@author: Nicolas Guarin-Zapata
"""
@nicoguaro
nicoguaro / bilinear_map.ipynb
Last active August 29, 2015 14:19
Bilinear map inversion (analytically)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nicoguaro
nicoguaro / example_layered_elastic.py
Created April 20, 2015 22:40
Dispersion curves for multilayer elastic materials using Trasfer Matrix Method and Bloch theorem.
# -*- coding: utf-8 -*-
"""
Wave propagation in layered elastic media.
@author: Nicolas Guarin-Zapata
@email: nguarin@purdue.edu
"""
import matplotlib.pyplot as plt
from matplotlib import rcParams
from layered_elastic import *
@nicoguaro
nicoguaro / mohr2d.py
Last active July 28, 2022 11:12
Scripts to plot Mohr circles.
"""
Mohr circle in 2D.
@author: Nicolás Guarín-Zapata
@date: May 2020
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams['font.family'] = 'serif'
"""
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)
@nicoguaro
nicoguaro / plot_guy.py
Last active August 29, 2015 14:08
Plot stick men.
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)
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
@nicoguaro
nicoguaro / zoomed_inset_axes_example.py
Created October 7, 2014 05:37
An example of a zoom in a simple plot using `zoomed_inset_axes`.
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()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nicoguaro
nicoguaro / videos.sh
Last active November 6, 2019 21:29
Generate videos from a sequence of images with consecutive numbering
#!/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