Schema validation with LXML on Ubuntu Hardy

LXML is an amazing Python module that picks up where the standard xml.dom(.minidom) left off.

It’s basically a set of wrapper code around the libxml2 and libxslt libraries, and provides functionality missing in Python’s standard library, including XML validation and XPaths.

On a project I’m currently working on I needed a good XML library for Python and ended up trying out lxml. But I simply could not get the schema validation to work, and after several wasted hours I understood that the default lxml that ships with Ubuntu Hardy (the distro I’m using) used the relatively old 1.3.6 python-lxml package.

I’m usually very reluctant to install anything as root that does not come from the “official” repository, but for lxml I made an exception and installed the python-lxml package from the upcoming Intrepid distribution.

Add the following line to your /etc/apt/sources.list file:

deb http://ch.archive.ubuntu.com/ubuntu intrepid main

Then run Synaptic as usual and install python-lxml version 2.1.1. To verify that it works fine, you can test schema validation thus:

>>>> from lxml import etree
>>>> schema_tree = etree.parse('path_to_schema.xsd')
>>>> schema = etree.XMLSchema(schema_tree)
>>>> doc = etree.parse('path_to_some_document')
>>>> schema.validate(doc)

That last command returns as a boolean the result of the validation.

Trends in Smart Buildings Meeting, October 2008

After a two-month hiatus, we resumed our monthly meetings at LESO-PB to discuss recent developments in building automation and simulation. Frédéric Haldi, David Daum and yours truly attended. We had a smaller group this time, but that turned out to be a good opportunity for going into more detail about some of the research that’s currently being done at LESO-PB.

20081006_2217

I had not been on Adhoco’s website for a while and I was recently surprised to see that their range of products had greatly increased in the past months. My opinion is of course completely biased, having contributed some source code to their main product, but I still wanted to mention it.

There was a paper recently in Building and Environment describing how the simulation program IDA had been coupled to a Genetic Algorithm optimization program in order to derive optimal parameters for a family house. Building parameter optimization is, of course, a key area of research for LESO-PB, but during my time there I’ve always felt they were a bit weak on the simulation end. So it will be very interesting to see if some of the current research tries to remedy this situation.

20081006_2218

David Daum pointed out (quite rightly, in my humble opinion) that there are few if any universally accepted guidelines on how the assessment of a building control algorithm should be carried out. All too often, researchers bury their readers under tons of equations and models and conclude by quoting a single number, such as “Our super-duper algorithm yielded 20% energy savings compared with the ultra-realistic user model that keeps all the heating turned on throughout the year in southern Greece.” We seldom see the assumptions being thoroughly documented, or how the energy demand evolves over time. Does the algorithm help equally well in summer and in winter? If not, why not?

Speaking of new developments at LESO, I don’t know any details, but I’ve heard that they now have a N-cluster of PCs (for a largish N), dedicated to running building simulations. Oh, how I wish I had another PhD to do…

20081006_2219

Much of the meeting was spent discussing Fred’s current research on window opening/closing by the building occupants. Perhaps some background is in order here. For the past five years or so LESO-PB has carried out research on modeling the behaviour of building occupants, in order to have more realistic models than the current ones. Jessen Page did his PhD thesis mostly on modeling the occupancy patterns, and Fred is working on modeling the way people interact with their environment, by opening/closing windows, using appliances, etc.

Fred explained to us that after analyzing the data that had been recorded on the LESO building for the past 7 years he concludes that the majority of window events happen immediately after the user enters the room or immediately before they leave it. And the event probability for these two kinds of events is correlated with the indoor temperature.

For intermediate events, that is, window openings/closings that happen while the user remains in the room, he found that the probability per unit of time correlates well with outdoor temperatures. The problem he’s now trying to solve is the exact relationship between outdoor temperature and window event probability.

We spent some time discussing this relationship, but until more browsers support MathML I won’t go into much detail.

That’s about all I remember from this evening. I’ve setup a mailing list for out meetings, smarrtbuildings-trends, and anyone interested is welcome to join us.

The OpenRemote.org project

Recently I stumbled upon a blog entry by Marc Fleury, whom I believe is one of the lead developers on the JBoss Application Server project. In this post he describes his new pet project, OpenRemote, which has of late bloomed into a full blown affair.

There’s an official website and the project seems to be buzzing with activity. From what I understood, the goal of OpenRemote is to build an open-source universal remote control for your home, including all home automation protocols known to man: X10, KNX/EIB, Lon, etc. They are talking about a reference implementation, apparently targeting the iPhone.

I think a major challenge that’s these guys will face is how to make a truly usable UI for home automation. I’ve quoted Donald Norman before and given his opinions on this thorny issue. But I truly hope the OpenRemote people will eventually solve this problem.

Article watch: Lighting Research and Technology vol 40 nr 3

Lighting Research and Technology vol 40 nr 3 has a couple of articles that sound interesting for anyone involved in visual comfort.

Proportions of direct and indirect indoor lighting — The effect on health, well-being and cognitive performance of office workers, by KI Fostervold and J. Nersveen.

Indirect lighting has been recommended as a way to accommodate lighting needs in offices. To investigate this recommendation, the effect of four ceiling-mounted lighting schemes providing inverse proportions of direct and indirect lighting were studied in ordinary office environments. The study used a 4×3 mixed randomised-repeated design. Dependent variables assessed subjective symptoms, subjective well-being and cognitive performance. Glare, a major contributor to visual strain was physically removed. Photometric measurements showed that proportions of direct and indirect lighting affect the luminous environment. Except for an association between reduced job stress severity and direct lighting, the results indicate that proportions of indirect and direct lighting do not affect the dependent variables. A main effect of the new lighting installation was revealed for subjective symptoms and cognitive performance.

I’m mentioning this one first because visual comfort was, after all, the main topic of my thesis, but also because I heard visual comfort was an active field of research at LESO-PB. One of the research projects that I’m aware of tries to optimize the placement of overhead luminaires in order to jointly optimize the energy consumption and the occupant’s visual comfort.

The other paper that might be worth a trip to the library is

Predicting discomfort glare from outdoor lighting installations, by JD Bullough, PhD, JA Brons, MSc, R. Qi, BEng and MS Rea, PhD.

In addition to sky glow and light trespass, discomfort glare from outdoor lighting installations is a growing concern to the public. A series of experimental investigations was performed to assess the relative impacts of light source photometric characteristics on subjective ratings of discomfort glare. The results converge, demonstrating the influence of light source illuminance, surround illuminance and ambient illuminance on subjective judgements of discomfort glare. A simple model relating these photometric quantities is proposed for making predictions of discomfort glare from outdoor lighting installations. This model can be readily incorporated into existing frameworks for evaluating light pollution as well as into lighting calculation software.

This article addresses apparently an issue that’s often overlooked in studies of visual discomfort, namely the influence of outdoor construction elements.

I only which I had time to read all this stuff…

Article watch: Energy and Buildings vol 40 nr 11

One article in the last issue of Energy and Buildings is of particular relevance to the field of home automation, particularly where daylight control is involved:

Simplified correlations of global, direct and diffuse luminous efficacy on horizontal and vertical surfaces, by A. De Rosaa, V. Ferraroa, D. Kaliakatsosa and V. Marinelli.

A simple calculation method to calculate the mean hourly diffuse illuminance on vertical surfaces for all sky, clear sky, intermediate and overcast sky conditions, developed in Arcavacata di Rende (Italy), was compared with experimental data obtained at Osaka (Japan), Vaulx-en-Velin (France) and Geneva (Switzerland). In spite of its simplicity, the method furnishes reasonably good predictions, in comparison with a more complex reference calculation method and can be proposed as a simplified tool for design purposes.