Robin's Blog

Archive for the ‘Python’ Category

Simple parameter files for Python class-based algorithms

As part of my PhD I’ve developed a number of algorithms which are implemented as a class in Python code. An example would be something like this: class Algorithm: def __init__(self, input_filename, output_basename, thresh, n_iter=10): self.input_filename = input_filename self.output_basename = output_basename self.thresh = thresh self.n_iter = n_iter def run(self): self.preprocess() self.do_iterations() self.postprocess() def preprocess(self): # […]

How to: Find out what modules a Python script requires

I do a lot of my academic programming in Python, and – even though I often write about the importance of reproducible research – I don’t always document my code very well. This sometimes leads to problems where I have some code running fine, but I don’t know which modules it requires. These could be […]

How to: Convert OSM waypoints defining polygons into Shapefile

Today I got sent a file by a colleague in OSM format. I’d never come across the format before, but I did a quick check and found that OGR could read it (like pretty much every vector GIS format under the sun). So, I ran a quick OGR command: ogr2ogr -f “ESRI Shapefile” Villages.shp Villages.osm […]

Py6S now has Continuous Integration & better tests

As a Fellow of the Software Sustainability Institute I’m always trying to make my software more sustainable – and one element of this is ensuring that my software works correctly. Although crashes might annoy users (which generally isn’t a good plan if you want your software to be well-used), a far worse problem is your […]

Encouraging citation of software – introducing CITATION files

Summary: Put a plaintext file named CITATION in the root directory of your code, and put information in it about how to cite your software. Go on, do it now – it’ll only take two minutes! Software is very important in science – but good software takes time and effort that could be used to do […]

van Heuklon Ozone model implementation in Python

As part of my PhD I wanted to use a simple model which would give me an estimation of the atmospheric ozone amount given a location and time of year. A simple model to do this was created by van Heuklon in 1979, and was described in a delightfully simple paper (unfortunately not freely available […]

John Snow’s Cholera data in more formats

In honour of the bicentenary of John Snow’s birth – and because I was asked to by someone via email – I have now released my digitisation of John Snow’s Cholera data in a few other formats: KML and as Google Fusion Tables. To save you reading my previous blog posts on the subject, I’ll […]

Converting latitude/longitude co-ordinates to Landsat WRS-2 paths/rows

As part of some work I was doing for my PhD, I needed to automatically find what Landsat scene path and row would contain a pixel with a certain latitude/longitude co-ordinate (this was basically so I could automatically download the relevant Landsat image and do some processing on it). There is an online converter (provided by […]

Can I atmospherically-correct my images with Py6S?

I’m a big fan of Matt Might’s blog, and thought I’d implement one of his tips for blogging as an academic – namely Reply to Public. I’ve had a number of emails from Py6S users asking me questions about how to atmospherically-correct entire satellite images with Py6S – so I thought ‘d respond online, so that […]