Skip to content

Instantly share code, notes, and snippets.

@naught101
naught101 / separate_points.py
Created Feb 16, 2018
Separating points on a map
View separate_points.py
def lat_lon_hex_mesh(bounds, d=3):
"""Creates a hexagonal lat/lon mesh within bounds that has a radial separation of d"""
lone, lonw, lats, latn = bounds
# heigt of equilatral triangle from radial distance sqrt(r^2 - (r/2)^2)
h = np.sqrt(0.75) * d
w = d / 2
lat_vals = np.arange(lats, latn, h)
@naught101
naught101 / gist:0f73ca85a9ab6d4be3980cde8da9c0cc
Last active Jun 11, 2017
Picard replace "Various Artists" with compiler, dj-mixer, or record label
View gist:0f73ca85a9ab6d4be3980cde8da9c0cc
$if($and($eq(%compilation%,1), $eq(%albumartist%,Various Artists)),
$set(albumartist, $if2(%compiler%, %djmixer%, %label%)))
$set(albumartistsort, $if2(%compiler%, %djmixer%, %label%))))
@naught101
naught101 / mutual_info.py
Last active May 5, 2020 — forked from GaelVaroquaux/mutual_info.py
Estimating entropy and mutual information with scikit-learn
View mutual_info.py
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
These computations rely on nearest-neighbor statistics
'''
import numpy as np
@naught101
naught101 / modelbycluster.py
Last active Nov 9, 2017 — forked from jnothman/modelbycluster.py
Generic scikit-learn estimator to cluster data and build predictive models for each cluster.
View modelbycluster.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Scikit-Learn Model-by-Cluster wrapper.
Original code by jnorthman: https://gist.github.com/jnothman/566ebde618ec18f2bea6
"""
import numpy as np
@naught101
naught101 / ametsoc.latex
Last active Oct 13, 2017
ametsoc.latex
View ametsoc.latex
%% AMS pandoc template.
%% https://gist.github.com/naught101/f369e9796c36965b0cf6
%% Converts pandoc to a latex file along the lines of the templates from
%% https://www2.ametsoc.org/ams/index.cfm/publications/authors/journal-and-bams-authors/author-resources/latex-author-info/preparing-a-latex-manuscript-for-submission/
%% The results of this template should work with ametsoc.cls and ametsoc2014.bst
%% out of the box.
%% amssamp1.tex is nearly identical to amssamp2.tex, except
%% that amssamp2.tex uses the [twocol] option to produce
View toy_rank_histograms.py
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 26 12:12:37 2015
@author: naught101
"""
import numpy as np
import matplotlib.pyplot as pl
@naught101
naught101 / pop_projections.py
Created Aug 18, 2015
Population projections
View pop_projections.py
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 17 10:53:51 2015
Population projections with low-discrepancy sequence based colour scheme.
http://www.storytellingwithdata.com/blog/2015/8/3/visualization-challenge-world-population-forecast
@author: naught101
"""
@naught101
naught101 / python_rank_benchmarking.py
Last active Aug 29, 2015
Python rank benchmarking
View python_rank_benchmarking.py
"""
Benchmarking the methods at
http://stackoverflow.com/questions/5284646/rank-items-in-an-array-using-python-numpy
"""
import timeit
from scipy.stats import rankdata
import pandas as pd
import numpy as np
View extractannotations.py
#!/usr/bin/env python3
import poppler
import sys
import urllib.request, urllib.parse, urllib.error
import os
def main():
input_filename = sys.argv[1]
# http://blog.hartwork.org/?p=612
@naught101
naught101 / .gitignore
Created Jul 9, 2012 — forked from kogakure/.gitignore
Git: .gitignore file for LaTeX projects
View .gitignore
*-blx.bib
*.acn
*.acr
*.alg
*.aux
*.bbl
*.bcf
*.blg
*.dvi
*.fdb_latexmk
You can’t perform that action at this time.