Skip to content

Instantly share code, notes, and snippets.

View alexlib's full-sized avatar
:octocat:
Working

Alex Liberzon alexlib

:octocat:
Working
View GitHub Profile
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))
@rsnemmen
rsnemmen / randomvariate.py
Last active September 15, 2022 05:46
Rejection method for random number generation / Python
def randomvariate(pdf,n=1000,xmin=0,xmax=1):
"""
Rejection method for random number generation
===============================================
Uses the rejection method for generating random numbers derived from an arbitrary
probability distribution. For reference, see Bevington's book, page 84. Based on
rejection*.py.
Usage:
>>> randomvariate(P,N,xmin,xmax)
@jobovy
jobovy / post-commit
Last active October 3, 2016 17:10
Modified version of Andy Casey's (@andycasey) post-commit hook to run latexdiff between different revisions of a latex draft (see http://astrowizici.st/blog/2013/10/04/publishing-with-git); works on Macs and when the paper is in a sub-directory of the main git repository.
#!/bin/sh
# Post-commit hook for revision-awsm-ness
function gettempfilename()
{
tempfilename=$1-$RANDOM$RANDOM.tex
if [ -e $tempfilename ]
then
tempfilename=$(gettempfilename)
@alexlib
alexlib / dynamic_masking_openpiv_python.ipynb
Created June 1, 2014 21:02
Dynamic masking of the large reflections, moving body, organisms in PIV images, for use with OpenPIV-Python and OpenPTV-Python packages
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexlib
alexlib / test_of_iter_trajectories_ptv_is.ipynb
Last active October 12, 2016 16:42
Another example of using `postptv` package from the OpenPTV software repository. This time it demonstrates the use of the generator instead of a list to keep the very long lists of trajectories.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeanpat
jeanpat / MFISH_colorCombination.ipynb
Created March 20, 2014 14:41
An ipython notebook showing how to combine five greyscaled images into one RGB MFISH image using scikit-image
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sloria
sloria / bobp-python.md
Last active April 27, 2025 07:06
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@minrk
minrk / nbstripout
Last active March 12, 2025 18:41
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@audreyfeldroy
audreyfeldroy / pypi-release-checklist.md
Last active March 27, 2025 19:16
My PyPI Release Checklist
  • Update HISTORY.md
  • Commit the changes:
git add HISTORY.md
git commit -m "Changelog for upcoming release 0.1.1."
  • Update version number (can also be minor or major)
bumpversion patch
@rossant
rossant / numpy_tricks
Last active February 17, 2025 16:47
Numpy performance tricks
{
"metadata": {
"name": "numpy_tricks"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{