Saturday, 18 May 2013

Using python to access netcdf files

I needed to write out some arrays in a binary format from a c program. I decided to use the netcdf libraries to store the files in a more structured format.

I also wanted to use python to do dome additional analysis. So I need a way to read netcdf files from the python scripting language. There are a number of different python libraries which can read netcdf files. After some exploration I decided to use Module netCDF4.

There are some good instructions on how to install the netcdf4 python module on Ubuntu.

First the hdf5 library needs to be installed

 gunzip  hdf5-1.8.11.tar.gz 
 tar xvf hdf5-1.8.11.tar 
 cd hdf5-1.8.11/

 ./configure --prefix=/usr/local --enable-shared --enable-hl
 sudo make install

Next the netcdf library needs to be installed.

 gunzip  netcdf-4.3.0.tar.gz
 tar xvf netcdf-4.3.0.tar 
 cd netcdf-4.3.0/
 LDFLAGS="-L/usr/local/lib CPPFLAGS=-I/usr/local/include"
 ./configure --enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local
 sudo make install

Now finally we can install the python library. However first I needed to install a python library to compile against c code.
sudo apt-get install python-dev
sudo ldconfig
Now we need to install the python library.

gunzip netCDF4-1.0.4.tar.gz

tar xvf netCDF4-1.0.4.tar
cd netCDF4-1.0.4/

cp setup.cfg.template  setup.cfg

Then I needed to edit setup.cfg
python build
sudo python install

Friday, 8 February 2013

Reading physics papers on a kobo ebook reader

So I am on mission to do a way with paper copies of physics papers. Every day there are papers published on the Cornell archive site, but what is the best way to organise and read the papers?

Well my colleague in the next office to me came into my office to show me his new ebook reader. He had purchased a  kobo ebook 7 inch ebook reader, so that he could read physics papers.

You can see from the picture that the paper looks OK on this ereader. When I originally played with papers on my kindle, the plots looked like crap (see also). The reader below is high definition, so the graphs look OK on it. So high definition is the way to go.

There was a web browser on the device which he used to download the papers in pdf format.
The text looked a bit small, but it was readable. The next issue is how easy it is to organize the papers on the ereader. Does it allow tage? Can you annotate the papers? This is possible with books in ebook format.

Wednesday, 6 February 2013

Is there a better way to organize physics papers?

Part of doing physics research involves reading scientific papers. Typically the papers are printed out  to read later. Sometime if I am working on a specific project I will have a bunch of papers. After a while I end up with a big pile of papers in my office and in my flat. I do sometimes file things away. Many papers are printed off multiple times, because I can't always find the paper I need to read.

The most "famous" place with big piles of papers was John Ellis's office in CERN.

I have taken a number of papers with me to conferences for reference. But a big collection of papers is heavy and it is not so easy to read them on a plane.

There are some very good tools to collect papers online. For example I use citeulike.

I can't help feeling that both me and John Ellis need to be able to read and organize physics papers on a tablet or on the kindle. In later posts I will see what can be done with today's tablets.

Saturday, 26 January 2013

Hello world in scala

I am slowly reading Seven Languages in Seven Weeks. The book briefly describes 7 computer languages, with just enough detail to get the flavour of each language. Today I had a little play with scala The point is to learn new techniques that some languages make easier.

New smaller languages seem to be very popular at the moment. For example the software for twitter  was originally written in ruby, but as the site got bigger they rewrote it in scala. I see a lot of adverts for jobs in scala -- perhaps even at the BBC for the Iplayer. Scala is a mixed object oriented and functional language. It runs on the java VM.

I downloaded the scala run time stuff via the standard package manager from Ubuntu.
First off is to print hello world. I just followed the instructions on wikipedia.

So my first program.

ubuntu >cat HelloWorld.scala 
object HelloWorld extends App {
   println("Hello, World!")

Compile and run:

ubuntu >scalac HelloWorld.scala
ubuntu >scala -classpath . HelloWorld
Hello, World!

Sunday, 19 August 2012

Introducing HTML 5

I keep see references to HTML 5, so I thought I should at least know more about it, so I got a copy of introducing HTML 5 by Bruce Lawson and  Remy Sharp.

Like most people I know a little HTML, but I had not followed the new developments. There was something called xhtml that was some bastard hybrid of xml and html. Yeah I know xml and html are both mark up languages. One of the good things about html was that it was so forgiving of bad markup.  Now I mostly use google sites or this blogging site, I hardly ever write pure html, but I use the GUI.

The new HTML5 stuff is:

  • Better  code for forms
  • Improved video and audio support with no more plug in
  • Some database support that is an update on cookies.
  • Support for drawing and drag and drop.
  • Geolocation API

Tuesday, 14 August 2012

The NHS IT project

Now that I begin to think about life beyond lattice QCD, I have to decide on what to do with the rest of my life.  I thought perhaps I would help "sick people." To get some idea of what  the computing issues are in health, I have read The NHS IT project by Sean Bremen.

This was an interesting book about an attempt to introduce new IT infrastructure into the NHS. Bremen  
did a really good job of explaining why having better IT in the NHS was good for patients. It would help GPs communicate better with consultants. I am now a big fan of centralized patients records. Also the use of simplified "expert systems" seemed like a good idea to help with treatment and stop basic mistakes. It was clear from the book, that the reorganization of the NHS was less important than getting the IT correct.

There are many challenges to improving the IT infrastructure in  the NHS. Many GPs and hospitals have their own computer systems, so it will be hard to get all the systems to talk to each other. Even in one hospital there are many different systems

It made me laugh that they were intending to use Microsoft tablets for doctors and nurses on wards. This did seem like an application where a tablet was clearly better than a laptop.

The book was published in 2005, so it would be interesting to find out what progress has been made.
Improving IT in the NHS requires a mixture of technology and "politics" (or keeping the users happy).

Monday, 4 June 2012


It was easy to install Eclipse -- the development environment. I just downloaded  the classic version from this site. I got a zipped folder that I moved and unzipped to a better location.

Next I followed these instructions to get the google addons for Eclipse

Umm, I must now be ready for hello world.