Skip to content

Instantly share code, notes, and snippets.

View fritzvd's full-sized avatar

Fritz van Deventer fritzvd

View GitHub Profile
@fritzvd
fritzvd / colocated_cokriging_r.py
Created November 14, 2012 13:49
Colocated cokriging in python with r
def cokriging_in_r(self, x, y, z):
'''
Cokriging (and ordinary kriging) is quite fast in R.
This would anyway be more pragmatic than rewriting/porting it to Python.
For the moment this will be the 'best' way as R makes it very easy to
use kriging without fitting a variogram model, but using a standard
variogram.
'''
import rpy2
import rpy2.robjects as robj
@fritzvd
fritzvd / gist:1446911
Created December 8, 2011 12:51
example inline
from waterqmap.maps.models import Map,MapDate
from django.contrib import admin
class MapDateInline(admin.TabularInline):
#this is the foreignkey
model = MapDate
class MapAdmin(admin.ModelAdmin):
prepopulated_field = {"slug": ("title",)}
inlines = [MapDateInline]
@fritzvd
fritzvd / twitterforroland.py
Created September 26, 2011 10:22
Get request from twitter search and parse it into a Python object.
import urllib2, simplejson
# Hier de respons van de website als je de query opent.
response = simplejson.dumps(urllib2.urlopen("http://search.twitter.com/search.json?geocode=51.985263,5.663259,5km&q=forum").readline())
# Format de website zo dat python het kan lezen als python objecten ipv JSON
# de 5 en de 1 slaan op de indexing van de response. Het 5e item zijn de tweets zelf in deze request, kan misschien verschillen per search.
loadaspy = simplejson.loads(simplejson.loads(response)).items()[4][1]
@fritzvd
fritzvd / models.py
Created June 6, 2011 09:33
Idea for a model
class Points(models.Model):
routes = models.ForeignKey(Routes)
categories = models.ForeignKey(Categories)
attribution = models.CharField(max_length=255)
title = models.CharField(max_length=65)
lat = models.FloatField()
lon = models.FloatField()
imageURL = models.URLField(verify_exists=True)
line2 = models.CharField(max_length=40)
line3 = models.CharField(max_length=40, blank=True, null=True)
from django.db import models
from django.contrib import admin
from django.contrib.admin import widgets
from django.forms import ModelForm
from django import forms
import datetime
TITLE_CHOICES = (
('Dhr', 'Dhr.'),
('Mw', 'Mw.'),