Skip to content

Instantly share code, notes, and snippets.

View agmarrugo's full-sized avatar

Andres Marrugo agmarrugo

View GitHub Profile
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)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright INRIA
# Contributors: Nicolas P. Rougier (Nicolas.Rougier@inria.fr)
#
# DANA is a computing framework for the simulation of distributed,
# asynchronous, numerical and adaptive models.
#
# This software is governed by the CeCILL license under French law and abiding
@agmarrugo
agmarrugo / plano_oblicuo.matlab
Last active August 29, 2015 14:05
Script para analizar el cambio de los esfuerzos normal y cortante en un plano oblicuo bajo carga axial
%% Datos iniciales
%
% Script para analizar el cambio de los esfuerzos normal y cortante
% en un plano oblicuo bajo carga axial
A_0 = 1; % Area de la seccion transversal
P = 1; % Fuerza externa
% La variacion en theta desde un corte transversal (0º - 0 rad)
% a un corte longitudinal (90º - pi/2 rad)
theta = 60
beta = 18.02
// Omega en radianes
w = 1500*2*%pi/60
// Analisis de velocidades
//
// V_A = V_B + V_A/B
@agmarrugo
agmarrugo / accept_letter.py
Last active August 29, 2015 14:07
Generate acceptance letters for a list of papers downloaded from Easy Chair
# This Python file uses the following encoding: utf-8
import re, subprocess, os, shlex
from string import Template
class REMatcher(object):
def __init__(self, matchstring):
self.matchstring = matchstring
def match(self,regexp):
@agmarrugo
agmarrugo / duplicate_papers.py
Created October 18, 2014 02:46
A script for detecting unique and duplicate values from a csv file.
import csv
with open('papers.csv','r') as f:
sheet = csv.reader(f)
papers = []
for row in sheet:
# Every row is a list, thus I concatenate all to form a single list
papers = papers + row
# remove blank spaces
papers = filter(None,papers)
@agmarrugo
agmarrugo / ago.py
Created December 8, 2014 02:38
ago.py
#!/usr/bin/python
from datetime import date
import sys
now = date.today()
inputDate= sys.argv[1].split()
day = int(inputDate[0])
month = int(inputDate[1])
"""
This code takes two screenshots from the camera roll combines them into one image and saves the new image to the camera roll.
This is adapted from Federico Viticci's blog post at:
http://www.macstories.net/stories/automating-ios-how-pythonista-changed-my-workflow/
It removes the option to change which picture is where, automatically assigning the first one chosen as the leftmost image.
It also removes the necessity to copy the images to the clipboard outside of Pythonista using the new photos library in version 1.3. Finally, it removes the clipboard output.
"""
import photos
@agmarrugo
agmarrugo / openmotif-log.sh
Created July 1, 2015 19:16
OpenMotif 2.3.4 successful install log on Yosemite OS X 10.10.3
Andress-MacBook-Pro:cv Andre$ brew install https://gist.githubusercontent.com/steakknife/60a39a32ae84e12238a2/raw/openmotif.rb
######################################################################## 100.0%
==> Installing openmotif dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.17.yosemite.bott
######################################################################## 100.0%
==> Pouring libpng-1.6.17.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/libpng/1.6.17: 17 files, 1.2M
==> Installing openmotif
==> Downloading https://downloads.sourceforge.net/project/motif/Motif%202.3.4%20
==> Downloading from http://colocrossing.dl.sourceforge.net/project/motif/Motif%

Python version of the MATLAB code in this Stack Overflow post: http://stackoverflow.com/a/18648210/97160

The example shows how to determine the best-fit plane/surface (1st or higher order polynomial) over a set of three-dimensional points.

Implemented in Python + NumPy + SciPy + matplotlib.

quadratic_surface