Skip to content

Instantly share code, notes, and snippets.

@anielsen001
anielsen001 / bspline_change.py
Last active September 9, 2016 11:06
scipy bspline complex interpolation
from numpy import *
from scipy.signal import cubic
def cspline1d_eval(cj, newx, dx=1.0, x0=0):
"""Evaluate a spline at the new set of points.
`dx` is the old sample-spacing while `x0` was the old origin. In
other-words the old-sample points (knot-points) for which the `cj`
represent spline coefficients were at equally-spaced points of:
@anielsen001
anielsen001 / pdsns.py
Created August 21, 2018 10:25
analysis example with pandas and seaborn
import matplotlib.pylab as plt
import seaborn as sns
import pandas as pd
nosoi = pd.read_csv('roc3.txt', names = ['file','name','score'],na_values = ['None','no_persons_found'] )
nosoi.assign(truth=False) # create a column of "false"
soi = pd.read_csv('roc_known.txt', names = ['file','name','score'], na_values = ['None','no_persons_found'] )
soi.assign(truth=True) # create a column of Truth = True
@anielsen001
anielsen001 / ofx-to-ledger.py
Created October 20, 2018 11:58 — forked from code-affinity/ofx-to-ledger.py
Python script for importing OFX files into a ledger-cli file
from __future__ import print_function
from ofxparse import OfxParser
import os
import re
import sys
if len(sys.argv) != 1:
print ('This utility does not take command-line arguments')
exit()
@anielsen001
anielsen001 / opencv-build.org
Last active March 6, 2019 02:09
How I build opencv with python bindings

Building and installing opencv with python bindings

dependencies

sudo apt install ffmpeg
sudo apt install libgtk-3-dev
sudo apt install libv4l-dev
sudo apt install libtiff-dev
sudo apt install libwebp-dev
@anielsen001
anielsen001 / pandas_datetime.py
Created October 29, 2018 10:14
pandas datetime conversion options
try:
# python 3
from io import StringIO
except:
# python 2
from StringIO import StringIO
# some examples from
# https://stackoverflow.com/questions/17978092/combine-date-and-time-columns-using-python-pandas
@anielsen001
anielsen001 / basemap.org
Last active November 15, 2018 01:36
building matplotlib/basemap

Target Ubunutu 16.04

Dependencies

cython

pip3 install cython

proj

@anielsen001
anielsen001 / parser_examples.py
Created June 5, 2019 09:07
example code for parsing android data logger files
# Example code for parsing sensor log files from Andriod apps
import pandas as pd
# SensorDataLogger
# https://play.google.com/store/apps/details?id=es.terrik.SensorLogger
# 'a' and 'b' are empty colums
date_parser = lambda x: pd.datetime.strptime( x, "%Y-%m-%d_%H-%M-%S.%f" )
@anielsen001
anielsen001 / ambiguity.py
Created June 19, 2019 09:22
Python implementation of wideband ambiguity function
# this is a python version of the wideband ambiguity function. A matlab version that it was ported from is below.
# https://dsp.stackexchange.com/questions/51372/how-to-calculate-the-ambiguity-function
import numpy as np
from scipy.interpolate import interp1d
from matplotlib import pylab as plt
tb = -1
tend = 1
dilation = 0.8
@anielsen001
anielsen001 / skin_depth.py
Created August 22, 2019 12:28
Generate skin depths in copper and aluminum as a function of frequency
"""
Permeabilities can be found here:
https://www.engineeringtoolbox.com/permeability-d_1923.html
Resistivity can be found here:
http://hyperphysics.phy-astr.gsu.edu/hbase/Tables/rstiv.html
"""
import numpy as np
@anielsen001
anielsen001 / mp_example.py
Created October 9, 2019 09:15
python multiprocessing example with return values
#!/usr/bin/env python3
import multiprocessing as mp
SENTINEL = None
dat = range(10)
rets = []
def function( *args ):