Skip to content

Instantly share code, notes, and snippets.

View arthur-e's full-sized avatar

K. Arthur Endsley arthur-e

View GitHub Profile
@arthur-e
arthur-e / temperature.py
Created May 18, 2017 19:10
An example Python script for the Software Carpentry Python lesson (https://github.com/arthur-e/swc-workshop/tree/master/python-climate)
'''
Reports the min and max July temperatures for each file
that matches the given filename pattern.
'''
import csv
import os
import sys
import glob
@arthur-e
arthur-e / raster_learning.py
Created March 10, 2017 21:06
An example Python script of using scikit-learn to learn water from non-water pixels
'''
A module for machine learning on Landsat data; implemented and tested,
specifically, for learning water areas on an image. Performance so far:
Gaussian naive Bayes (where validation data chosen by the hydro mask):
Mean precision: Not water=0.9997, Water=0.3090
Mean recall: Not water=0.9787, Water=0.9763
Gaussian naive Bayes (where validation data inspected in Google Earth):
Mean precision: Not water=0.9675, Water=1.0000
@arthur-e
arthur-e / aggregation.Rmd
Last active August 6, 2016 19:10
A comparison of aggregation methods in R using the Gapminder data from Data Carpentry
---
title: "Aggregation in R"
author: "K. Arthur Endsley"
date: "August 4, 2016"
output: html_document
---
Let's explore multiple ways to aggregate data in R.
We'll do this to answer two questions:
@arthur-e
arthur-e / graham_hull.py
Last active April 7, 2024 17:19 — forked from tixxit/hull.py
Graham's scan convex hull algorithm, updated for Python 3.x
def convex_hull_graham(points):
'''
Returns points on convex hull in CCW order according to Graham's scan algorithm.
By Tom Switzer <thomas.switzer@gmail.com>.
'''
TURN_LEFT, TURN_RIGHT, TURN_NONE = (1, -1, 0)
def cmp(a, b):
return (a > b) - (a < b)
@arthur-e
arthur-e / deaths_malaria.txt
Last active January 12, 2016 20:48
Prevalence of current tobacco use among adults (>=15 years) (%) both sexes, columns are: country name, 2002 prevalence (%), 2005 prevalence (%); all data from GapMinder.org
country 2000 2001 2002 2003 2004 2005 2006
Algeria 0 0 0
Angola 96 66 98 254 80 86 62
Benin 10 6 9 7 11 4 16
Botswana 2 2 1 1 1 1 2
Burkina Faso 23 35 32 37 31 37 56
Burundi 9 6 7 6 9 25 5
Cameroon 5 5
Cape Verde 0 0 0 0 0 1
Central African Republic 14 10 21 16 20
@arthur-e
arthur-e / LEDAPS_build_from_source.sh
Created May 6, 2015 15:57
A walkthrough for building LEDAPS 2.2.0 and its dependencies from source on Ubuntu GNU/Linux 14.04
USERNAME=heyyouguys
# NOTE: Could not determine which jpeg library should be installed; it's probably installed by default
sudo apt-get install libtiff5 libtiff5-dev libgeotiff2 libgeotiff-dev libxml2 libxml2-dev
# http://www.hdfgroup.org/release4/obtainsrc.html
sudo mkdir /usr/local/hdf4 && sudo chown $USERNAME /usr/local/hdf4 && cd /usr/local/hdf4
wget http://www.hdfgroup.org/ftp/HDF/HDF_Current/src/hdf-4.2.11.tar.gz
tar -xzvf hdf-4.2.11.tar.gz
cd hdf-4.2.11
@arthur-e
arthur-e / notes.md
Last active December 7, 2024 09:27
Ubuntu for GIS Installation and Setup

Post-Installation Fixes and Setup

# Install compilers and linking tools; other tools
sudo apt-get install g++ swig curl build-essential python-all-dev

# Install package manager
sudo apt-get install synaptic

# Install Unity customization tool

sudo apt-get install unity-tweak-tool

@arthur-e
arthur-e / colorBrewer.js
Created April 10, 2014 12:21
Generates higher-contrast sequential or diverging color palettes based on Cynthia Brewer's colors; outputs the same format as d3/lib/colorbrewer but colors are higher-contrast.
chroma = require('./node_modules/chroma-js/chroma.min.js');
function generatePalettes (type, reversed) {
var n, m;
var paletteNames;
var palettes = {};
if (type === 'sequential') {
paletteNames = [
'BuGn', 'BuPu', 'GnBu', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'RdPu',
@arthur-e
arthur-e / seedrecovery.py
Last active August 29, 2015 13:57
Tool(s) to recover the Markdown contents from an older Springseed *.note file.
'''
Recover the Markdown content of an older Springseed note (*.note) file. Output
*.md file names will be the name of the Note file prepended by the Notebook
name, if available.
'''
import sys
import os
import re
import json
@arthur-e
arthur-e / Django_CSV_Loader.py
Created February 17, 2014 16:41
An example Django command (through the django-admin.py or manage.py interface) for loading in generic CSV data; a design pattern that should apply well to just about any delimited data.
import csv
from django.core.management.base import BaseCommand, CommandError
from django.core.exceptions import ValidationError, ObjectDoesNotExist
from django.db.models.fields import FieldDoesNotExist
from scour_server.nbi.models import Bridge
class Command(BaseCommand):
args = '<path>'
help = ''