Archive for the ‘Uncategorized’ Category

Estimating Canadian electricity CO₂ intensities

Sunday, June 18th, 2017

I recently became interested in the Electricity Map project. It uses real-time electricity generation data to estimate real-time CO₂-equivalent emissions and intensity per kilowatt-hour — essentially, how green a region’s electricity generation is.

For instance, Germany routinely varies from over 450 g CO₂eq/kWh (grams CO₂-equivalent per kilowatt-hour) to under 250 g CO₂eq/kWh on windy or sunny days, while Poland varies from over 750 to 600 g/kWh. Other jurisdictions, like France or Ontario, have large baseline low-emission generators (often nuclear and hydro) and might vary from 20 to 50 g/kWh. The idea behind Electricity Map and the related CO₂ Signal API is that energy-storage consumer-level devices like batteries, heaters, or coolers can use electricity when it’s greener, or in case of an electric vehicle crossing a regional border, where it’s greener.

For this we need real-time information, for some definition of real-time. Electricity Map can show changes for every 15 minutes, but hourly updates are also common for some jurisdictions. Daily updates are too coarse. Generally, the availability of real-time data is correlated with privatization or decentralization of electricity systems: when different companies operate power stations, the transmission grid, and consumer billing (or some mix of these), real-time information on supply and demand is normally needed to determine purchasing price and in turn generation mix.

The site currently includes data for a few Canadian provinces: Alberta, Nova Scotia, Ontario, Prince Edward Island, and partial data for New Brunswick. Alberta and Ontario have privatized markets, and Prince Edward Island is showcasing how much wind generation is currently taking place (remainder of PEI’s electricity is imported from New Brunswick). New Brunswick provides interchange data (how much electricity it’s importing and exporting) and their demand — possibly driven by their relatively central location, passing on cheap plentiful hydroelectricity from Québec to Nova Scotia, PEI, and the U.S. I want to give credit to Nova Scotia: despite not being privatized nor particularly green, they report their generation mix hourly (in an attempt to highlight their renewables — but they report their coal faithfully too).

Spurring this particular write-up is Prince Edward Island. They report on-island generation and load, and imports can be inferred from this. However, the imports are from New Brunswick, which doesn’t have real-time information, so Electricity Map doesn’t know their generation CO₂ intensity. In these cases, Electricity Map by default assumes the import is the same intensity as the in-province generation.

This assumption doesn’t hold for PEI: local generation is almost always all wind, which has a much lower CO₂ intensity than the electricity imported from New Brunswick. As a result, the value shown in Electricity Map is often too optimistic and too low.

We don’t know New Brunswick’s real-time generation mix — but we can estimate it based on historical data, to at least get within an order of magnitude and hopefully within a margin of 2.

Statistics Canada has the data. The most interesting source is CANSIM Table 127-0002 (linked from CANSIM Energy consumption and disposition). Use “Add/remove data” to control it:

  1. select the desired province or territory in Step 1;
  2. deselect the subcategories “electric utilities” and “industries” in Step 2 since that’s not useful for us;
  3. select all types of electricity generation in Step 3. (The types in Statistics Canada don’t line up with Electricity Map’s fuel divisions – for instance, StatCan distinguishes “Conventional steam turbine”, “Internal combustion turbine”, and “Combustion turbine”, but won’t tell you if the turbines are heated by coal or gas – but we can estimate this later.)
  4. in step 4, select a date range – Table 127-0002 has monthly data from 2008 until 2015, which while not perfect (2016 data would be nice), is not too bad.

The second useful source is CANSIM Table 127-0008, which gives local supply and use vs imports and exports. Unfortunately, this only provides yearly data, but can be used to get a general sense of how electricity systems in the province are used. In this table, “interprovincial deliveries” are exports from a province, and “interprovincial receipts” are imports to the province.

I have put together a Jupyter notebook showing how to obtain and process the data — the numbers below mostly come from there and straight from the StatCan tables.

Because of a chain of imports within Atlantic and Eastern Canada, a brief overview of a few provincial electricity systems might be helpful.

Newfoundland and Labrador

Newfoundland and Labrador (population 530 thousand, GDP around $30 billion) largely runs on hydroelectricity. There is one particularly large hydroelectric project in Labrador, Churchill Falls, the electricity from which is exported to Québec. Per Table 127-0008, about 70-75% of all generation in the province is exported. Québec is Newfoundland and Labrador’s only current export link; an undersea link to Nova Scotia is under construction and should finish in late 2017 or early 2018.

Per Table 127-0002, in 2014-2015, between 94.1% and 97.6% of NL generation came from hydro. By monthly averages, the ratio was higher in the summer and lower in the winter. Between 0.2% and 0.3% of NL generation came from wind. The remaining generation was turbine generation, which, according to Wikipedia’s list of generating stations, consists of a vast majority of fuel oil/diesel and a tiny bit of biomass.

The monthly CO₂ intensity for electricity generated in Newfoundland and Labrador as a whole is around 30 to 70 g/kWh (higher in winter). The electricity exported to Québec is all hydroelectricity (assigned 24 g/kWh on Electricity Map). I haven’t yet calculated the intensity of the local supply excluding the Québec export.


Québec (population 8.4 million, GDP around $380 billion) mostly runs on hydroelectricity. It imports around 18% of its supply, mostly from Labrador (Labrador’s exports are 15% of Québec’s supply). It exports around 13% of its supply (16% of its generation), 10% of it to the U.S. and 3.3% to other provinces. Its import-export balance ends up fairly neutral, and it essentially acts as a conduit from Labrador to the U.S. (Newfoundlanders and Labradorians aren’t too happy about the economic arrangement.)

Between January 2014 and December 2015, Québec’s generation has been between 98.8% and 99.3% hydroelectricity. Fossil generation varied between 0.5% and 0.7% (for offgrid, peakers, and back-ups), and wind generation varied between 0.2% and 0.6%. The only nuclear plant in Québec (Gentilly) shut down in December 2012.

Estimated CO₂ intensity of Québec’s generation is around 25-30 g/kWh. Imports from Labrador, at 24 g/kWh, keep the supply intensity around the same value; the remaining imports, at 3% of the supply, likely come mostly from the other big Canadian province, Ontario, which has CO₂ intensities below 100 g/kWh and thus will not change the Québec intensity significantly.

New Brunswick

New Brunswick (population 760 thousand, GDP around $33 billion), the subject of the post, has a diverse generation mix. Since restarting their nuclear power plant (Point Lepreau) in late 2013, they have had around a third-each split in generation from nuclear, fossil fuel (coal, gas, and oil), and hydroelectricity; however, this varied a lot month-to-month. The CO₂ intensity of generation has bounced around a lot depending on the mix, but stayed around 300 to 400 g CO₂eq/kWh most of the time.

Between 2011 and 2015, imports constituted between 25% and 40% of the supply. Most of the imports come from Québec, at 25-30 g/kWh, thus reducing the CO₂ intensity of the supply by around a third. Over several years, about 33% of supply is exported — around 10% to other provinces and 23% to the U.S.

I would then suggest, in absence of better data, to assume that Prince Edward Island imports electricity which is around 300 g CO₂eq/kWh.

Prince Edward Island

Prince Edward Island (population 150 thousand, GDP around $6 billion), as mentioned, mostly imports electricity from New Brunswick. Local fossil plants (oil and diesel) serve as back-up and sometimes winter load peakers. There has been an increasing amount of wind turbines, which sometimes — but so far not often — cover the island’s complete load.

The Statistics Canada data for PEI is not terribly accurate. There is a large discrepancy between “Total all types of electricity generation” from Table 127-0002 and “Total generation of electricity” from Table 127-0008, present in StatCan’s source table and visible in the Jupyter notebook charts. Perhaps the system is too small to have accurate data.

Sources and programming

The source data is from Statistics Canada. The programming is in a Jupyter notebook on Github Gist. Further analysis or improvements could start from the notebook.

I hope to write further posts about the other provinces and territories.

When a phone is not a phone

Monday, June 5th, 2017

A brief taxonomy of mobile computing devices.

I have been writing a post about my Nexus 5 phone and came across a theory: the Nexus 5 is not, in fact, a phone.

I suggest that modern mobile computers that are between smartwatches and tablets in size can be roughly split into two categories:

  1. “Phone” – use mainly for text and voice, single-handed, will be dropped, will be used on the go
  2. “Mobile device” – two-handed, used in safe locations, seated or at least securely standing

Size impacts how you use a device. It is difficult to use a device bigger than early smartphones one-handed. The situation isn’t helped by slippery surfaces like glass or metal on both sides of many new phones. If you regularly attempt to pull a large smartphone out of a pocket while walking or cycling, you’ll drop it eventually.

And while phones were designed to be dropped with minimum damage – compact shape, non-structural outer body, rounded plastic corners that take in most of the crash energy, even battery covers that pop off – modern devices might as well be designed to take maximum damage when dropped, with rigid materials throughout and functional edge-to-edge glass on a large front face.

Fragile smartphones that don’t take being dropped well have been a problem for almost a decade now and there’s little to indicate that the situation is getting better. Workarounds include protective or grippy cases, but I would much rather just have a phone that doesn’t need a case in the first place. I understand their value for specialized needs or carrying methods – for couriers or sport – but I just want to send short text messages and check next bus time a couple of times a day.

Here is a small selection of phones and mobile devices released over the past two decades:


Exit Review: Canon S100

Monday, January 30th, 2017

I like bunnie’s exit review idea: a retrospective review at the end of a device’s life can be very useful and insightful, and it’s worth thinking back. Here, my thoughts on three and a half years of using a Canon S100 camera.

Short background: I bought a refurbished Canon SD600 as my first own camera in 2008, got a lot of use out of it, and liked it a lot, but by 2013 it was developing severe spotting in sensor and/or lens. I had bought a Nikon D60 DSLR as my “big camera” in 2010, and wanted a newer pocketable camera to take around and bring into shows. I liked my SD600 and was happy to stick with Canon, and had desired an S-series camera since its reboot with the S90 in 2009.

The Canon S100 was announced in 2011; I bought a black one as an “open box” from Black’s in May 2013 for 291 CAD including taxes. The choice came down to the S100 or a white S110 that Henry’s was selling. Ultimately I thought the additional features in the S110 (slightly better ISO, wifi, touchscreen) were not worth the extra price. I had it until December 2016, when I lost or was helped to lose it.

The S100 was my main camera from June to December 2014 when the D60 had a mirror-sticking problem (magically self-resolved) and from August 2015 until September 2016 when the only lens I had for the D60 was getting unsharp due to too many bumps. After September 2016, it was my wider-than-50mm-equiv-lens camera when I wanted that. It was also my portable camera and video recorder at other times.



Saturday, December 31st, 2016
  • I moved to Berlin in April and spent the year eating ice cream and not doing much else.
  • There was a river and canals and parks. I missed the mountains and the sea though.
  • I didn’t work, and that got boring after a while, and I didn’t end up doing all that much programming either.
  • I got to a very weak conversational level in German. I became keenly aware of privileges of knowing English – I can’t imagine how difficult it would be to move to e.g. Canada while knowing as much English as I know German. It’s definitely reinforced how difficult immigrating, integrating, and learning a language is.
  • I travelled the Trójmiasto—Warszawa—Kraków north-south line in January, and visited Gdynia again in June to see family. I visited Ontario, including the biennial visit to Kitchener-Waterloo in September. On the return flight stopover I took a two-week trip around Iceland, including four days of Westfjords and seals and many geothermal hot pools and it was great seeing the glaciers again. I also went to Nürnberg (for the the Christmas market) and Hamburg (for CCC) for a few days in early and late December respectively. I felt like I should have travelled more around the region.
  • I failed many of the goals I had set out in 2015, including financial, but I can’t bring myself to be really bothered. It’s OK.
  • I read a lot of books, including in particular fiction by Brandon Sanderson and Charles Stross, a series of short simple books for German learners by André Klein, and, earlier in the year, non-fiction about industrial revolution (I have a 4500-word draft sitting since April waiting to be finished up). Many of the books were fairly short, but I still read more pages than last year overall.
  • I didn’t listen to much music at all, both recorded ( and live ( I went to fewest concerts since 2012, again meeting the trend of even-numbered years being slower. I scrobbled less than ever since signing up in 2006, though what I did scrobble was slightly more varied than in 2015 – the result of a few “shuffle all” days. There were a number of reasons – storing music on an external hard drive mostly not plugged in, doing a different kind of work not as suited to background music, lack of good loudspeakers — but I will be trying to change that trend and get back to some of the music I’ve enjoyed in the past.
  • I started keeping a journal, on paper, and late in the year started writing with a fountain pen. How very hipster.
  • Hardware changes: I bought a new lens for my DSLR — a 35 mm f/1.8 — ahead of the Iceland trip as the kit lens was showing its 8 years of being bumped. Unfortunately it was a year of losing things, as I left behind a USB charger in Waterloo (I felt a bit sad, I’ve had it for five years and it worked well) and I lost or was helped to lose the Canon S100 on the last day of the Nürnberg trip (breaking a good trend of 8 years without a camera loss). I then broke the Nexus 5 touchscreen four days later. The screen on my X220 is becoming increasingly wonky and I might need to do something about it next year.
  • The planned data organization and clean-up went meh. I digitized a bit, but there’s still a lot to do. I started using a password manager with stronger passwords, deleted some online accounts and started a Google cleanout – yay to that.
  • I felt not as interested in photography. I still took pictures but I didn’t really care about processing or sharing them. Changing hobbies is a weird feeling.
  • I feel kind of bad about this, but the year wasn’t bad for me. It was quite good.
  • Treasure hiding.

Rescuing data from an Android phone with broken touchscreen and disabled USB debugging

Friday, December 16th, 2016

Last week I dropped my Nexus 5 once again, this time for good. I had cracked and broken the top glass before, but the display and the touchscreen kept on working. This time, the touchscreen no longer registers touches, though luckily the display still works somewhat. On a device with no trackball, touchpad, or keyboard, a broken touchscreen is problematic.

Unfortunately, I had been lazy about keeping my phone properly backed up. There wasn’t that much unique stuff on it, but I always meant to backup apps and app data, and to eventually root and reflash someday — but never got around to it. Consequently I didn’t have USB debugging turned on, or a computer cleared for debugging.

Generally, the way to control and back up Android devices is from your desktop computer, using a USB connection and software called adb (Android Debug Bridge, see adb docs). However, USB debugging must be first turned on in Android settings, and since Android 4.2.2, the phone asks to confirm debugging access from each computer that attempts to connect. Normally the confirmation is done using the phone touchscreen. Oops.

Here are my notes on what I did to eventually gain USB debugging access. I did not require root or fastboot. I needed a computer to act as the adb host and a few accessories: a USB OTG cable, a USB mouse, and a Bluetooth keyboard.

Learning from my trouble, I recommend people running Android 4.4.3 or higher and interested in maintaining access to their device to enable USB debugging ahead of time.