After reading the title for this post - I know what you may be thinking - “Hey, whoa, wait a second. I’m an engineer. The learning curve for programming is too steep. There’s no way I can become proficient without a huge time investment.”
I used to be the same way; fighting my way through excel spreadsheets and even dabbling in a few visual basic macros to help process the data going into and coming out of energy simulation programs. The reality is that there is a better way. Through discussions with a few prominent energy modelers at the Building Simulation 2011 conference in Sydney in November, I decided there just isn’t a ‘nudge’ out there to push more engineers and energy analysts towards basic proficiency in high level programming languages such as Python and Ruby. This post will be the first in a series which will help the average engineer get started with scripting languages, build a few practical skills which are directly applicable to pre and post processing of data for modeling purposes, and go through a couple of these scenarios from start to finish. I have engaged the assistance of energy modeling extraordinaire Marcus Jones to help out with future posts on the simulation scenarios which this stuff can be useful for.
For this first post, I want to just break energy modelers out of their shell when it comes to modern, high level scripting languages. There are many intuitive, ‘batteries included’ languages out there with a massive amount of documentation and training online. My favorite (so far) is Python. I have found that going from a complete beginner to understanding basic data/text manipulation skills within Python can take as little as a lazy Sunday afternoon’s worth of effort. It has been said that starting out with Python is like ‘falling in love’ – I agree its fun if you’re into it. In the developer world, there are a few other choices such as Ruby, Haskall, or Lisp and many associated fanboy groups which promote each one. In experimenting with the various options, Python’s syntax and ease of just getting things done quickly stood out to me.
I’m going to assume that the average reader of this post is technical and understands the ins and outs of energy modeling but is completely new to programming. This post is meant to get your bearings with respect to Python and I won’t go into details of modeling use. I think it will take an afternoon or two to get through installation and some of the tutorials listed but I think most good modelers will already recognize possible use cases. The hardest part is getting over the fear of trying something new but I assure that it will be worth it.
Python comes installed in brand new macs and installation on PC’s is a straightforward process. Here’s a good video if you get stuck
Don’t listen your ‘hacker’ friends who may say you’re a poser if you use anything but the command line. Who has time to memorize all the commands and options when you’re a pragmatic programmer (command line can be quicker though if you become very proficient) I’m a Mac user and have really come to enjoy using PyCharm. It’s not a free but I appreciate the functionality, especially as I’ve gotten into dabbling in some web development. Other notable editors to check out are the free Notepad++ and TextMate (not free).
Learning the Basics
Python is one of the primary languages used by Google, in fact, the creator of the language, Guido van Rossum, has been working there for many years. Google has posted a short series of Python training sessions that they give to their internal staff which I found very helpful for just getting started. It was through completing and succeeding at these webcasts which gave me the confidence to starting really getting into Python.
Upcoming Part 2 post will look at a practical use of Python for an energy modeler.