Monday, 29 March 2010

Solar Panel Update

Yesterday was the first anniversary of our photo-voltaic solar panel installation.


We have generated 1951 kWh of electrical energy.

This works out to be 5.34 kWh per day on average. A lot less than the 7.5 kWh per day that we were told to expect. At 7.5 kWh we should have generated 2737 kWh over the year.

They base this on Solar Irradiation Maps such as these. Sydney, for example, should receive 5.5 equivalent peak sun hours (PSH). Our 9 panels have an effective area of about 10 square metres. At 15% efficiency, we should generate 1.5 kW during full sun. At 5.5 PSH we should be getting 8.25 kWh per day on average. This roughly agrees with the companies estimate of 7.5 kWh per day. Perhaps something is wrong.

This variation is disappointing. It works out to be 71% of what should be possible. Now we have had a very wet summer so that would limit our generation capacity.

Our average daily consumption is about 6.23 kWh for the last year - 2274 kWh. The wet summer didn't help here either: we had to use an old clothes dryer on several days.

The system is therefore supplying about 85% of our needs. On the up side, we are now being paid 60c for each kWh generated and it costs us about 20c for each kWh consumed.

Electricity earns us $2.00 per day - excluding service charges.


To heat our water we use natural gas. We consume about 27 MJ per day on average. This is equivalent to 7.5 kWh per day, so our total energy consumption is about 14 kWh per day.

Gas costs us 50c per day - excluding service charges. This is about 7c per kWh.


We have a reasonably efficient wood fire for winter heating. I can only guess that we would use 10 to 20 kg of wood for about 100 days each year.  At 15MJ/kg we consume about 40-80 kWh each day for these 100 days or about 11 to 23 kWh per day on average.

Ignoring the capital cost and fuel for the occasional chain-saw use, the wood costs us nothing.


Our car runs on LPG. We consume about 8L per day. At 27.8 MJ/L this is a massive 62 kWh per day - just to run a car.

This is nearly double what we use in our house.

LPG costs us about $5.60 per day or 9c per kWh.


In total, we generate about 5 kWh per day and consume 75 kWh per day (I have excluded the wood since we only plan to use wood that would otherwise have been chipped at the tip).

We have a long way to go before we are sustainable. The car is by far the biggest problem.

In terms of cost per kWh, electricity is double the cost of LPG and triple the cost of natural gas.

Thursday, 11 March 2010

Directory to XML BASH Script

Ever wanted to get a directory into an XML structure?

Here is a quick, short and easily modifiable BASH script that works well.

To see how it works, you could run it like this:

scriptname dir | xmllint --format - | less

for dir, you can use . .. ./ ../ or / as well as subdirectories and full directory paths.

You might also be interested in this project: xml-dir-listing

How it works

The script first makes special directory specifiers easily useable. It then calls doDir with the directory.

doDir uses ls to get all files in the current directory. If the file is actually a directory and not a sym-link, it calls itself to process the subdirectory. Otherwise it outputs the file name.

Certain special directories (. and ..) are ignored to avoid infinite loops.

The program can use a lot of stack space so I increase it - I just guessed a value. It also can take a long time, so I renice the process so you can do other things.

To stop it, you may need to enter a lot (10-20) of ctrl-c's. I'm not sure why.

Sample Output


The Script

# WARNING: To break this, you need to enter a lot of ctrl-c's

# heavy recursion so allow a bigger stack
ulimit -s 32768

# run with low priority so you can do other stuff while it works
renice -n +19 -p $$

function doDir {
  # directory name may contain illegal XML characters so we won't use attributes 
  #echo "<dir name=\"${1}\">"
  echo "<dir>"
  echo "<dirname><![CDATA[${1}]]></dirname>"
  # get all files and directories
  ls -Ab1 "$1/" | while read file; do
  # recursively process directories but not sym-links
  if [ -d "${1}/${file}" ] && [ ! -h "${1}/${file}" ]; then
    # don't do . and .. either
    if [ "$file" != "." ] && [ "$file" != ".." ]; then
      doDir "${1}/${file}"
    # output the file
    echo "<file><![CDATA[$file]]></file>"
  echo "</dir>"

# normalise initial directories so they all work
if [ "."   == "$DIR" ]; then DIR="$(pwd)" ; fi
if [ ".."  == "$DIR" ]; then DIR=".."     ; fi
if [ "../" == "$DIR" ]; then DIR=".."     ; fi
if [ "./"  == "$DIR" ]; then DIR="$(pwd)" ; fi
if [ "/"   == "$DIR" ]; then DIR=""       ; fi

doDir $DIR