The cost of electricity in Kenya

Thursday, 4th February 2010

Electricity has been a hot topic in Kenya recently. There has been a long drought and it’s impact on hydro-electric power output caused a severe shortfall in electricity, resulting in widespread rationing across the country. Several media articles claim that electricity bills (domestic and industrial) have risen by over 60% since March 2009, blaming increased fossil fuel imports for the rise. I took to investigating whether this was true.

It isn’t.

But first let’s set out the way electricity is charged in Kenya. Electricity is supplied exclusively by the Kenya Power and Lighting Company (KPLC), on behalf of the Kenya Electricity Generating Company (KenGen), under a range of different monthly tariffs. The tariffs were last adjusted in July 2008. Each tariff has a base rate of electricity per kWh. Additionally, a set of surcharges are applied to all tariffs. These are:

  • A fixed charge equivalent to meter rent, and, for industrial customers, a demand charge based on average power requirement.
  • Fuel Cost Charge (FCS) — based on the cost of fuel purchased by KenGen during the month of billing. Applied per kWh of consumption.
  • Foreign Exchange Rate Fluctuation Adjustment — a somewhat obscure measure based on the “foreign currency costs incurred by KenGen in the calendar month immediately preceding the month of the billing period”. Applied per kWh of consumption.
  • Inflation Adjustment — another obscure measure based on national inflation measures (such as the Consumer Price Index), as well as (for reasons I don’t fully appreciate) inflation measures for the USA. Applied per kWh of consumption.
  • Energy Regulatory Commission (ERC) Levy — fixed at 3 Kenya cents/kWh
  • Rural Electrification Programme (REP) Levy — fixed at 5% of the base rate
  • VAT — applied on the base rate and all previous surcharges at 12% (down from 16% since November 2008).

The base rate for domestic electricity is 2 KES/kWh for the first 50kWh, 8.10 KES/kWh for 50 – 1 500 kWh, and KES 18.57/kWh for usage above 1 500 kWh. I have used the mid-range rate for my calculations. Here is a graph then of how the total cost of electricity for domestic use has changed since October 2008. The fixed charge of KES 120/month is not included, as it is constant and independent of consumption.

Chart showing the variation in cost of electricity for domestic consumers in Kenya
Variation in the total cost of electricity per kWh for the domestic tariff (source data)

The maximum percentage increase in cost over this period was between March 2009 (when the total price was 14.7 KES/kWh) and November 2009 (19.5 KES/kWh): an increase of 33%. The increase between January 2009 and January 2010 was 28%, and over the whole sample period just 6%.

I did the same analysis for the industrial tariff with the lowest base rate (and hence the once subject to the greatest percentage fluctuation):

Chart showing the variation in cost of electricity for one industrial tariff in Kenya
Variation in the total cost of electricity per kWh for one industrial tariff (source data)

The maximum percentage increase in cost was again between March 2009 (10.3 KES/kWh) and November 2009 (15.3 KES/kWh): an increase of 49%. The increase between January 2009 and January 2010 was 40%, and over the whole sample period just 13%.

So, while there has been an overall increase in the price of electricity in 2009, it is quite evident that the price hasn’t changed by “over 60%”. Indeed, the price fell over the first half of the year. I suspect that the media reports have considered only the Fuel Cost Charge (which has varied considerably over the year) in their figure of 60%. It is a pretty liberal use abuse of statistics to extrapolate this to the total cost of electricity.

In the light of new investment in renewable energy projects to meet the energy shortage, the cost of fuel imports should decline over the next few years. With any luck this will translate into lower electricity costs for the consumer. Even though the cost of electricity hasn’t risen exorbitantly this year, it is still far higher than in other countries in the region.

Getting to grips with time in PHP

Wednesday, 2nd December 2009

Working with time-sensitive code in PHP can get a little confusing (for me at least) when you have to deal with calculations in up to three different time zones: the server time zone, GMT or UTC, and the client time zone. Here’s a little table with the most important time functions in PHP, that seeks to help clarify what they do.

The server time zone used for these examples is GMT+1. The Unix epoch is defined as Thu, 01 Jan 1970 00:00:00 GMT (and is therefore a fixed point in time, regardless of local time zone).

FunctionOutputComments
time()
(run on Tue, 01 Dec 2009 00:00:00, server time)
1259622000The number of seconds between the Unix epoch and the run-time of the function.
mktime(0,0,0,12,1,2009)1259622000The number of seconds between the Unix epoch and the input time (specified in the server time zone).
gmmktime(0,0,0,12,1,2009)1259625600The number of seconds between the Unix epoch and the input time (specified in GMT).
strtotime('Tue, 01 Dec 2009 00:00:00')1259622000Without a timezone specified in the input string, the function assumes it is in the server time zone.
strtotime('Tue, 01 Dec 2009 00:00:00 GMT')1259625600With a timezone specified in the input string, the function will use that time zone instead of the server time zone.
date('D, d M Y H:i:s', 1259622000)Tue, 01 Dec 2009 00:00:00Takes a Unix timestamp (by definition in GMT) and returns a formatted date in the server time zone.
gmdate('D, d M Y H:i:s', 1259622000)Mon, 30 Nov 2009 23:00:00Takes a Unix timestamp (by definition in GMT) and returns a formatted date in GMT.

The Unix timestamps used above translate to the following GMT times:

  • 1259622000: Mon, 30 Nov 2009 23:00:00 GMT
  • 1259625600: Tue, 01 Dec 2009 00:00:00 GMT

When dealing with time-related calculations, I strongly recommend doing all the number-crunching in GMT, and translating this to client/server time afterwards, otherwise you seriously risk getting confused (especially if you have things like daylight savings to contend with as well).

The date_default_timezone_set function can be used to specify your own time zone for PHP to use (overriding the server time zone) – I find it is easiest to set this to GMT, thereby eliminating the complexity introduced by the server time zone.

PHP function references: time, mktime, gmmktime, strtotime, date, gmdate, date_default_timezone_set

A pill a day isn’t good for you after all

Wednesday, 4th November 2009

A study recently published in the Lancet suggests that it is not advisable for people to take a daily dose of Aspirin as a preventative measure against heart disease, casting doubt on the widespread guidance to that effect from doctors in the United States and Europe.

This painfully common-sense finding raises a lot of fundamental questions:

  • What is the basis for ever prescribing pharmocologically active compounds as part of a daily diet? By their very nature these substances interfere with the functioning of the body: what justifies doing this on a permanent basis unless absolutely necessary (this applies also to the widespread use of multi-vitamins)? That too when a drug has documented risks and adverse effects.
  • The principle of taking a drug to prevent an illness is itself flawed. Why would you prefer to mitigate the risks of heart disease (while adding other risks) rather than eliminate or avoid the root cause? Why would you not instead promote control of diet and lifestyle?
  • Aspirin is well established as an aid in the treatment of heart disease, but not in its prevention. By what logic can one say that the method for prevention is the same as the method for cure? Would you “prevent” diabetes by taking insulin daily?

The medical community (no doubt cajoled by the pharmaceutical lobby) is responsible for a lot of misinformation thrown at the general public. Unfortunately it is highly respected by many people, who consider medical advice to be sacrosanct. Until we start to question more critically the “wisdom” of the doctors, we will remain prey to the far-from-Hippocratic intentions of the pharmaceutical industry.

Will democracy deal with climate change?

Monday, 19th October 2009

I happened to watch a televised debate at IQ2 Australia entitled Democracy is not for Everyone. The somewhat grandiose introduction to the motion reads:

Given the vast quantities of blood spilled and treasure spent in the name of democracy – who would dare to challenge its legitimacy? After all, isn’t democracy good for all?…

Is the promise of democracy real, or merely a fiction to advance the interests of the few by beguiling the majority with myths of equality, liberty and fraternity?…

It’s time to take the dare and put an intellectual blowtorch to the belly of democracy’s defenders.

The audience (who voted before and after the debate) were quite overwhelmingly convinced by the arguments of the “against” panel, who made a pretty good case. A slow, dithering democracy that gives the people what they want was deemed to be better than the alternatives (among which are dictatorships and monarchies). The possible variations in democracy weren’t discussed nearly enough, in my view (the issue of greater grass-roots involvement and less heirarchy was raised, but not picked up) – it seems silly to assume that democracy is the same wherever it appears.

Not surprisingly a lot of the debate was about environmental issues, with the proponents of the motion arguing that the inevitable short-term thinking of democratically elected parties mean that longer-term issues get sidelined in favour of vote-winning agendas. Which highlighted the fact that until environmental and other ethical concerns become a key issue for the average voter in the democratic world, they will stay sidelined.

This is beginning to happen in countries that are bearing the brunt of climate change – the Maldives and Bangladesh for example – and where the general public are having to face the damage. But in most of the Western world, the majority of people are still pretty well sheltered from these effects and climate change does not significantly impact day-to-day life. So how will it get to the top of the political agenda? Or do we have to wait for it to start seriously affecting everyday life…

Windows Vista hangs on startup, fails to logoff/shutdown

Thursday, 17th September 2009

I’ve had enough pain with this problem, which seems not to be that uncommon, to try and ease it for anyone else who has it.

Symptoms

  • Windows Vista runs extremely slowly upon login, with the CPU running at close to 100%
  • Task manager won’t start: if you try running it the green task icon will appear but no main window
  • If you try to shut down, the computer will hang while trying to log off
  • If you use Process Explorer to see what’s happening, you find that an instance of svchost.exe is responsible for the CPU load. If you look at the services it is hosting, they will include Windows Audio Services, DHCP and, key here, Event Log. The instance of svhost may also be associated with something called audiodg.exe (which is part of the Windows Audio setup). Killing the process stops the CPU load, but breaks a lot of other things as well (like networking, which is dependant on some of those services).

Problem

It seems that many people have experienced similar problems, and many solutions have been targeted at the audio services. I tried all of these with no luck. Eventually I narrowed the problem down to the Event Log service and found this which is for Windows Server 2008 but works for Vista too. The problem was some corrupted event logs that were causing the Event Log service to throw a woopsy every time it was started.

Solution

Here’s what worked for me:
  • Kill the offending process using Process Explorer to give you control of the system
  • Disable the “Windows Event Log” service (Control Panel – Administrative Tools – Services)
  • Reboot – this should work fine, but you may notice that all network functionality is lost
  • Browse to %systemroot%\system32\winevt\logs and move/delete all the *.evtx files that were modified around the time the problem started
  • Set the Event Log service back to back to Automatic, and reboot

Of course, the more permanent solution is to steer well clear of Vista (or, some might say, Windows altogether).