This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def headway_array(arrivals_array, maxseconds=24*60*60, daysinweek=7): | |
''' | |
Given a numpy.array object with... | |
> the number of rows equal to the number of days in a week, <daysinweek> | |
> the number of rows equal to the number of trips made on a public transport | |
route | |
> the array values equal to the time at which the vehicle arrives at the | |
stop, expressed in seconds since midnight for each day. None values can be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# interpolatedMedian.py | |
# Author: Richard Law | |
# Calculates the interpolated median of a list, | |
# which is a form of median that retains the | |
# important properties of a median (isn't swayed by | |
# unusually large or small values) but gives a better | |
# indication of the ditstribution of values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Full | Abbreviation | |
---|---|---|
Access | Accs | |
Dune | Dune | |
Accessway | Accswy | |
Elm | Elm | |
Alley | Aly | |
End | End | |
Anchorage | Ancg | |
Entrance | Ent | |
Approach | App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: [email protected] | |
# | |
# License: BSD (3-clause) | |
# XXX clafify licensing | |
import numpy as np | |
from collections import namedtuple | |
from scipy.signal import detrend | |
from scipy import stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from osgeo import gdal, osr | |
# Click on your layer in the TOC | |
alayer = qgis.utils.iface.activeLayer() | |
bag = gdal.Open(alayer.source()) | |
bag_gtrn = bag.GetGeoTransform() | |
bag_proj = bag.GetProjectionRef() | |
bag_srs = osr.SpatialReference(bag_proj) | |
geo_srs =bag_srs.CloneGeogCS() | |
transform = osr.CoordinateTransformation( bag_srs, geo_srs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qgis.utils | |
import pycurl | |
import StringIO | |
import json | |
buffer = StringIO.StringIO() | |
c = pycurl.Curl() | |
c.setopt(c.URL, 'http://ipinfo.io/') | |
c.setopt(c.WRITEDATA, buffer) | |
c.perform() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pint | |
ur = pint.UnitRegistry() | |
Q = ur.Quantity | |
def convert(array, source, target): | |
''' | |
Convert a list in one unit to a list in another, using Pint. | |
Simple but saves me from writing this repeatedly in ipython. | |
<source> and <target> must be Pint units, e.g. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pint | |
ureg = pint.UnitRegistry() | |
def is_str_valid_pint_unit(unit): | |
try: | |
ureg(unit) | |
except pint.errors.UndefinedUnitError: | |
return False | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build/ESRI_Census_Based_2013_NZTM.zip: | |
mkdir -p $(dir $@) | |
curl -o $@ http://www3.stats.govt.nz/digitalboundaries/census/$(notdir $@) | |
build/ESRI_Census_Based_2013_NZTM.shp: build/ESRI_Census_Based_2013_NZTM.zip | |
unzip -od $(dir $@) $< | |
touch $@ | |
build/wards.geojson: build/ESRI\ shapefile\ Output/2013\ Digital\ Boundaries\ Generalised\ Clipped/WARD2013_GV_Clipped.shp | |
ogr2ogr -f GeoJSON build/wards.geojson build/ESRI\ shapefile\ Output/2013\ Digital\ Boundaries\ Generalised\ Clipped/WARD2013_GV_Clipped.shp -s_srs EPSG:2193 -t_srs EPSG:2193 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import warnings | |
from functools import wraps | |
def ignore_warnings(f): | |
@wraps(f) | |
def inner(*args, **kwargs): |
OlderNewer