Robin's Blog

Archive for the ‘How To’ Category

How to: get nice vector graphics in your exported PDF ipython notebooks

(This is really Part 2 of IPython tips, tricks & notes – Part 1, but I thought I’d give it a more self-explanatory title) IPython (sorry, Jupyter!) notebooks are really great for interactively exploring data, and then turning your analyses into something which can easily be sent to a non-technical colleague (by adding some Markdown and […]

How to: load the Google Maps Places library through Google API Loader

Google have recently introduced a new way of loading their javascript APIs: their Google API Loader. To use it, all you do is add a script tag in your HTML: <script src=””></script> You can then load whatever Google APIs you want using code like this: google.load(‘visualization’, ‘1.0’); google.load(‘jquery’, ‘1’); google.load(‘maps’, ‘3’); google.setOnLoadCallback(function() { console.log(‘Callback’) }); […]

How to: Log electricity usage from a CurrentCost EnviR – Part 1

After borrowing a CurrentCost electricity usage meter from my local library (if you’re in the area, then Eastleigh library will loan you one for free!), I decided to buy one, as I’d found it very useful in trying to reduce my electricity usage. The benefit of buying one as opposed to borrowing one was that […]

How to: Fix weird ENVI startup file issues

This post is more a note to myself than anything else – but it might prove useful for someone sometime. In the dim and distant mists of time, I set up a startup file for ENVI which automatically loaded a specific image every time you opened ENVI. I have no idea why I did that […]

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 […]