Skip to content

Instantly share code, notes, and snippets.

View robintw's full-sized avatar

Robin Wilson robintw

View GitHub Profile
### WSGI for Web6S app
WSGIScriptAlias /web6s /usr/local/www/wsgi-scripts/Web6S/web6s.wsgi
<Directory /usr/local/www/wsgi-scripts/Web6S>
WSGIApplicationGroup %{GLOBAL}
AllowOverride None
Require all granted
</Directory>
@robintw
robintw / gist:9713069
Created March 22, 2014 19:38
RIOS code which leads to strange offset
import numpy as np
from rios import applier
import tempfile
import subprocess
# Set up the function to be applied
def doMask(info, inputs, outputs, args):
if np.isnan(args.no_data):
outputs.outimage = np.isfinite(inputs.image)
@robintw
robintw / gist:d0a2ed285da634688682
Last active August 29, 2015 14:01
Comparison of ARCSI code with/without parallelisation
# Simple test of method used in current ARCSI code (old_method)
# and Py6S parallelisation (new_method)
# Results from running it on my (relatively old, dual-core) MacBook Pro:
# old_method: 21.1s
# new_method: 10.6s
#
# We get roughly the 2x speed up that you'd expect with two cores.
#
# Running on my work machine which has 8 cores I get:
Process: Python [13682]
Path: /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.6 (2.7.6)
Code Type: X86-64 (Native)
Parent Process: zsh [2073]
User ID: 501
Date/Time: 2014-06-04 22:21:46.058 +0100
OS Version: Mac OS X 10.8.5 (12F45)
Description Resource Path Location Type
Bookmark cannot be resolved to a type BookmarkTransfer.java /org.integratedmodelling.thinkcap/src/org/integratedmodelling/thinkcap/ui line 40 Java Problem
Bookmark cannot be resolved to a type BookmarkTransfer.java /org.integratedmodelling.thinkcap/src/org/integratedmodelling/thinkcap/ui line 40 Java Problem
Bookmark cannot be resolved to a type BookmarkTransfer.java /org.integratedmodelling.thinkcap/src/org/integratedmodelling/thinkcap/ui line 59 Java Problem
Bookmark cannot be resolved to a type BookmarkTransfer.java /org.integratedmodelling.thinkcap/src/org/integratedmodelling/thinkcap/ui line 63 Java Problem
Bookmark cannot be resolved to a type BookmarkTransfer.java /org.integratedmodelling.thinkcap/src/org/integratedmodelling/thinkcap/ui line 74 Java Problem
Bookmark cannot be resolved to a type BookmarkTransfer.java /org.integratedmodelling.thinkcap/src/org/integratedmodelling/thinkcap/ui line 80 Java Problem
Bookmark cannot be resolved to a type ContextView.java
@robintw
robintw / Build stderr
Created October 21, 2014 15:18
Py6S RtD build notes
html
-----
/var/build/user_builds/py6s/checkouts/stable/doc/source/helpers.rst:59: WARNING: autodoc: failed to import class u'Wavelengths' from module u'Py6S.SixSHelpers'; the following exception was raised:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/py6s/envs/stable/local/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 335, in import_object
__import__(self.modname)
ImportError: No module named Py6S.SixSHelpers
/var/build/user_builds/py6s/checkouts/stable/doc/source/helpers.rst:77: WARNING: autodoc: failed to import class u'Angles' from module u'Py6S.SixSHelpers'; the following exception was raised:
Traceback (most recent call last):
@robintw
robintw / gist:abc9a33d54c1d40c6f01
Created December 31, 2014 20:08
SQL for status duration Stack Overflow question
CREATE TABLE `data` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`set_point` float DEFAULT NULL,
`temp` float DEFAULT NULL,
`on` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `data` (`id`, `timestamp`, `set_point`, `temp`, `on`)
@robintw
robintw / apache2-graphite.conf
Last active August 29, 2015 14:21
Apache2 VirtualHost configuration for Graphite on Port 81
<VirtualHost *:81>
WSGIDaemonProcess _graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=_graphite group=_graphite
WSGIProcessGroup _graphite
WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=_graphite application-group=%{GLOBAL}
WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi
Alias /content/ /usr/share/graphite-web/static/
<Location "/content/">
SetHandler None
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@robintw
robintw / vanHOzone.py
Created September 3, 2015 16:59
Code to calculate atmospheric ozone concentrations based upon the van Heuklon (1979) ozone model. In numpy and without numpy.
import numpy as np
from dateutil.parser import parse
import math
def get_ozone_conc(lat, lon, timestamp):
"""Returns the ozone contents in matm-cm for the given latitude/longitude
and timestamp (provided as either a datetime object or a string in any sensible format
- I strongly recommend using an ISO 8601 format of yyyy-mm-dd) according to van Heuklon's
Ozone model.