Skip to content

Instantly share code, notes, and snippets.

@naught101
naught101 / separate_points.py
Created February 16, 2018 04:47
Separating points on a map
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 June 11, 2017 10:39
Picard replace "Various Artists" with compiler, dj-mixer, or record label
$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 June 10, 2024 08:18 — forked from GaelVaroquaux/mutual_info.py
Estimating entropy and mutual information with scikit-learn
'''
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 November 9, 2017 11:20 — forked from jnothman/modelbycluster.py
Generic scikit-learn estimator to cluster data and build predictive models for each cluster.
#!/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 October 13, 2017 10:32
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
@naught101
naught101 / toy_rank_histograms.py
Created August 26, 2015 06:42
Toy rank histograms
# -*- 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 August 18, 2015 23:27
Population projections
# -*- 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 July 25, 2024 01:25
Python rank benchmarking
"""
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
@naught101
naught101 / extractannotations.py
Last active August 29, 2015 14:20 — forked from compleatang/extractannotations.py
update to python 3
#!/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 July 9, 2012 02:17 — forked from kogakure/.gitignore
Git: .gitignore file for LaTeX projects
*-blx.bib
*.acn
*.acr
*.alg
*.aux
*.bbl
*.bcf
*.blg
*.dvi
*.fdb_latexmk