<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Planetmarshall</title>
	<atom:link href="http://www.planetmarshall.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.planetmarshall.co.uk</link>
	<description>Andrew Marshall&#039;s blog</description>
	<lastBuildDate>Sat, 13 Apr 2013 20:20:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>My First Full Scottish Winter Season</title>
		<link>http://www.planetmarshall.co.uk/2013/04/my-first-full-scottish-winter-season/</link>
		<comments>http://www.planetmarshall.co.uk/2013/04/my-first-full-scottish-winter-season/#comments</comments>
		<pubDate>Mon, 01 Apr 2013 14:00:31 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Climbing]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=1678</guid>
		<description><![CDATA[As I write this, the Scottish winter is not just hanging in there, it&#8217;s colder now than it was in any of the Winter months and it&#8217;s likely I could yet get some more winter routes in the bag before<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2013/04/my-first-full-scottish-winter-season/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0060.jpg" title="'The Curtain' (IV,5), Ben Nevis. © John Harrison. Climber : Andy Owen" class="thickbox" rel="singlepic183" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/183__200x_IMG_0060.jpg" alt="The Curtain, Bein Nevis (IV,5)" title="The Curtain, Bein Nevis (IV,5)" />
</a>
As I write this, the Scottish winter is not just hanging in there, it&#8217;s colder now than it was in any of the Winter months and it&#8217;s likely I could yet get some more winter routes in the bag before the season is over, however I wanted to write this up while the memories were still fresh.</p>
<p>A couple of caveats &#8211; I&#8217;ve been in the Scottish Hills in Winter before, and as is often said there&#8217;s no such thing as Scottish Winter Hillwalking, only Mountaineering. That said, prior to this Winter my only experience of Scottish Winter Climbing was being guided up the Grade II North Gully on Ben Nevis at the end of a particularly foul week, weatherwise, in February 2012. So this is pretty much my first full season of Scottish Winter Climbing.</p>
<p>Probably one of the best ways to get out into the mountains as much as possible is to join a local mountaineering club. I&#8217;m a member of the <a title="Jacobites Mountaineering Club" href="https://sites.google.com/site/newjacobitesmountaineeringclub/" target="_blank">Jacobites Mountaineering Club</a> based in Edinburgh, a motley bunch of Munro and Corbett baggers, climbers, alpinists and ski mountaineers. In addition, I took a couple of weeks out to do some guided climbing with <a title="Moran Mountain" href="http://www.moran-mountain.co.uk/" target="_blank">Martin Moran</a>, based in Strathcarron in the North West, and also with <a title="Jagged Globe" href="http://www.jagged-globe.co.uk/" target="_blank">Jagged Globe</a>, based out of Ballachulish.</p>
<p><span id="more-1678"></span></p>
<h3>The A&#8217;Chioch Ridge (II,***)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/031_stitch.jpg" title="My consolation prize, a traverse of the A'Chioch Ridge (II), Beinn Bhan." class="thickbox" rel="singlepic185" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/185__200x_031_stitch.jpg" alt="A'Chioch Ridge (II), Beinn Bhan" title="A'Chioch Ridge (II), Beinn Bhan" />
</a>
 After a couple of days on some lower grade objectives, the plan was for a route on Beinn Bhan &#8211; the <a title="Cold Climbs by Ken Wilson" href="http://www.amazon.co.uk/Cold-Climbs-Great-British-Yourself/dp/0906371163" target="_blank">Cold Climbs</a> classic &#8216;March Hare&#8217;s Gully&#8217; (IV,4,***), but the initial steep ice pitch was to prove a bit much too soon, and remains something I hope to return to now that I&#8217;ve had more practice. The consolation prize was a traverse of the A&#8217;Chioch ridge. Not technically difficult, but stunning scenery along the entire route.</p>
<h3>Turquoise Gully (III,*)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/020.jpg" title="The first pitch of 'Turquoise Gully' (III), Meall Gorm." class="thickbox" rel="singlepic192" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/192__150x_020.jpg" alt="Turquoise Gully (III), Meall Gorm." title="Turquoise Gully (III), Meall Gorm." />
</a>
I was feeling a bit dejected after failing on March Hare&#8217;s gully, so the next day we headed to Meall Gorm, and Turquoise Gully. A great climb that merits more than its single star in the SMC selected Winter Climbs book. Although, that may be coloured by the fact that the base of the climb lies barely 15 minutes walk from the car park. After practicing some skills on a top rope in the car park, we left our rucksacks by the car and walked to the base of the route. The initial pitch, led by <a title="Alpha Mountaineering" href="http://www.alphamountaineering.co.uk/" target="_blank">Nick Carter</a>, had an imposing &#8216;ice mushroom&#8217; feature, or shroud, caused by high winds in the direction of the gully. I was a bit nervous of this feature having considered the initially steep ice of March Hare’s to be less difficult – however I passed it without any problems. I left the route feeling satisfied, and keen to get back to Beinn Bhan to have another go at March Hare’s Gully, though perhaps that will now have to wait for next winter.</p>
<h3>Tower Ridge (IV,3,****)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/013_stitch.jpg" title="Awaiting our turn to cross Tower Gap on a busy day ( but not the busiest this year )." class="thickbox" rel="singlepic188" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/188__x150_013_stitch.jpg" alt="Tower Gap, on Tower Ridge (IV,3)" title="Tower Gap, on Tower Ridge (IV,3)" />
</a>
Having had some instruction in leading winter routes, I was keen to put it to good use and my opportunity would come at the inaugural <a title="Scottish Winter Climbing Meet" href="http://www.scottishwinterclimbing.co.uk/" target="_blank">Scottish Winter Climbing Meet</a>, organised by <a title="Mountain Motion" href="http://www.mountainmotion.co.uk/" target="_blank">Richard Bentley</a>. My partner for the weekend would be fellow Jacobite, Victor Manazares. On the Friday night before climbing we got some local info from <a title="Abacus Moutaineering" href="http://www.abacusmountaineering.com/" target="_blank">Mike Pescod</a> on which routes were in condition, but I had heard the phrase &#8216;Tower Ridge&#8217; and could think of little else. Victor took some persuading, but he relented and the climb was on for the following morning. Arriving at the CIC hut, we saw that the path to the ridge had been well trod and visibility excellent &#8211; both signs which bode well for what would be my first winter lead without the assistance of a guide. We saw that most parties had opted to skip the initial gully that separates the ridge from the Douglas Boulder, and we took this as a sign that we should do the same. The route was busy and required waiting at some of the trickier points, but visibility remained excellent. I led the slightly hairy Eastern Traverse and Tower Gap, involving a short but intimidating down climb but I resisted the temptation to use the in-situ sling for aid. We topped out on a clear summit at about 5pm.</p>
<p>Postscript – Victor’s car had some difficulty escaping from the top car park and as a result we had to leave it and walk back down to the main road. I stuck out a thumb and flagged down a passing Range Rover, driven by none other than Tom, the owner of the Ben Nevis Inn, where we happened to be staying and the base for the meet that evening.</p>
<h3>The Curtain (IV,5,***)</h3>
<p>On the inside page of the current SMC Winter Climbs guidebook, there&#8217;s a picture of a climber on a steeply inclined icefall with the Ben Nevis cliffs in the background. This is &#8216;The Curtain&#8217;, and it is spectacular. This would be my first Grade IV ice climb since my failing at Beinn Bhan, and was in fact a degree harder in technical difficulty. There were to be no problems here, however – the ice was solid and had seen so much traffic that it often felt like a ladder to the top. Two excellent pitches finishing on Ledge Route above made the perfect introduction to ice climbing on Ben Nevis.</p>
<h3>Point Five Gully (V,5,****)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/p5.jpg" title="The Rogue Pitch on 'Point Five Gully' (V,5), Ben Nevis. Climber : Andy Owen." class="thickbox" rel="singlepic201" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/201__x200_p5.jpg" alt="The Rogue Pitch" title="The Rogue Pitch" />
</a>
After the previous day’s success on The Curtain I was buzzing, and when it came to discussing objectives for the next day, I tentatively suggested Point 5. I fully expected to be told it would be too much of a step up and was somewhat surprised to be told it would be an entirely appropriate choice, and wondered what I had gotten myself into.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0125.jpg" title="The author, pulling himself up a steep pitch on 'Point Five Gully' (V,5), Ben Nevis." class="thickbox" rel="singlepic197" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/197__150x_IMG_0125.jpg" alt="The author on Point 5 Gully." title="The author on Point 5 Gully." />
</a>
Another of Ken Wilson&#8217;s &#8216;Cold Climbs&#8217;, Point 5 was the undisputed highlight of my winter. Andy Owen of Jagged Globe took on all the leading here, but even seconding would prove to be a challenge. The pitches were steep, sustained and strenuous and would prove to be a test of how I would be able to ice climb as efficiently as possible. The entire route was armour-plated in solid ice, forcing Andy to be a bit ‘creative’ at times with belays.Leading a route like this is beyond my abilities for the moment, though it remains a tentative goal for next season.</p>
<h3>Ice Crew (III,**)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0196.jpg" title="The author, getting a cold shower on 'Ice Crew' (III), Beinn Udlaidh." class="thickbox" rel="singlepic198" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/198__x150_IMG_0196.jpg" alt="Ice Crew (III), Beinn Udlaidh" title="Ice Crew (III), Beinn Udlaidh" />
</a>
With a change in the weather we went for the lower lying Beinn Udlaidh, a great ice climbing venue in cold conditions but we were to see it, or rather not see it, in a day of thaw and poor visibility. With the noise of falling ice all around I would not have gone near the place without a guide of Andy’s experience, and he concurred that that would have been a sensible decision. However we would not be deterred, and climbed the fine, though wet, ‘Ice Crew’. In more benign conditions I would have led this as Andy could have soloed ( He would later solo Orion Direct during two weeks of stunning alpine conditions in late February ) but on this occasion I was more than happy to let Andy go up first. Ice cold water poured down from every icicle, but it’s a fine climb, and I would be happy to return to this venue. The neighbouring ‘Quartzvein Scoop’ (IV,4) is a reputed classic.</p>
<h3>Raeburn&#8217;s Route (IV,4,***)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0255.jpg" title="The author, on 'Raeburn's Route' (IV,4), Stob Coire Nan Lochan, Glencoe." class="thickbox" rel="singlepic199" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/199__150x_IMG_0255.jpg" alt="Raeburn's Route (IV,4), Stob Coire Nan Lochan, Glencoe" title="Raeburn's Route (IV,4), Stob Coire Nan Lochan, Glencoe" />
</a>
Harold Raeburn was a prolific climber, and so there are a plethora of routes that bear his name. Confusingly, there are two on Stob Corrie Nan Lochan. Known as &#8216;Raeburn&#8217;s Route&#8217; in the SMC guide, this is also known as &#8216;Raeburn&#8217;s Ordinary Route&#8217;, not to be confused with &#8216;Ordinary Route&#8217; on the same crag. With ice climbing being the theme for the week so far, I was keen to try some mixed climbing. I found myself to be far more comfortable with this style of climbing than with pure ice, but nonetheless I was to take a fall near the top of the route. I console myself that I had gone the wrong way and had taken a harder technical variation than was standard.</p>
<h3>George (III,4,**)</h3>
<p>My first lead of a Scottish Winter gully climb. For me, this is what it&#8217;s all been leading up to. I don&#8217;t want to continue my climbing career being guided up things, far better to experience both the physical and psychological stress of climbing &#8216;at the sharp end&#8217;. Although I had led on Tower Ridge, that climb earns its grade from its length rather than its difficulty. I was expecting George to be a typical, though excellent, example of a Scottish Winter gully climb, more serious and technical, and I was not to be disappointed.</p>
<p>The Jacobites have a hut, <a href="https://sites.google.com/site/newjacobitesmountaineeringclub/club-hut" target="_blank">Inver Croft</a>, near Achnasheen in the North West highlands. It is perfectly located for climbs in the Torridion area, and that is where I and two friends headed on a weekend in early March that would also host the club’s Whisky tasting event. It wasn’t the finest of weather, and I would have liked to have better visibility, but ‘George’ is undeniably a fantastic climb. Nick and I shared leads to the top, we took the standard route rather than the harder ‘Sinister Prong’ variation, but nonetheless found the characteristic cave feature to be buried. During a slightly tricky manoeuvre I dropped one of Nick’s ice screws, and was delighted to receive it in the post a few weeks later after I contacted a climber on <a href="http://www.ukclimbing.com/" target="_blank">UKC</a> who had climbed the route the following day.</p>
<p><span style="font-size: 13px;"> </span></p>
<h2>An Teallach</h2>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/016_stitch.jpg" title="Toll an Lochain, An Teallach." class="thickbox" rel="singlepic189" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/189__x150_016_stitch.jpg" alt="Toll an Lochain, An Teallach." title="Toll an Lochain, An Teallach." />
</a>
 Despite a return to cold weather in late March, I was unable to get out for further climbing until the Easter weekend. I arranged with another Jacobite, Pete, to head back up to Inver with the aim of doing one of the major ridges. I suggested An Teallach, as I hadn’t been there before. Pete’s not a climber, but nonetheless it wasn’t difficult to persuade him to try an ascent of ‘Chockstone Gully’ (I), which would allow us to approach via Toll an Lochain, which is a sight to behold.</p>
<h3><span style="font-size: 1.17em;">Chockstone Gully (I,*)</span></h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/038.jpg" title="'Chockstone Gully' (I), An Teallach. Climber : Pete Edwards." class="thickbox" rel="singlepic193" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/193__x175_038.jpg" alt="Chockstone Gully (I), An Teallach." title="Chockstone Gully (I), An Teallach." />
</a>
After fighting through the Rhodedendrons opposite Dundonell House, we began the long (2 hours) walk to Toll an Lochain. The ascent up the gully was solid, so we didn’t bother to rope up and made good time to the ridge. The view from the ridge is hidden while ascending until the very last moment, when it is a spectacular reveal, with Beinn Dearg figuring prominently to the south.</p>
<h3>Ridge Traverse (II,****)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/047_stitch.jpg" title="On a good day, topping out on Chockstone Gully will present you with this view." class="thickbox" rel="singlepic202" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/202__x150_047_stitch.jpg" alt="Beinn Dearg, from An Teallach" title="Beinn Dearg, from An Teallach" />
</a>
The views from the ridge are spectacular, however the normally Grade II pinnacles were not really in appropriate condition for winter climbing, having been stripped dry by the spring sun. In addition the turf was unfrozen and the snow soft and powdery. As it was we avoided much of the difficulty, though made it back up to the crest where possible to take in more of the scenery.</p>
<p>With time pressing, and neither of us being munro baggers we opted to skip the final munro and descend from the col at the head of Glas Tholl. Although suggested by the guide book, this seemed excessively steep and corniced to me, so we continued along the ridge until we reached a more forgiving gradient. I wasn’t aware of the descent via ‘Hayfork Gully’, which I have noted for future reference.</p>
<h2>Epilogue</h2>
<p>As I hoped, I was able to get one more winter route done before packing up the axes and crampons, and what a route it was.</p>
<h3>Crowberry Gully (IV,4,****)</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/048.jpg" title="Rob on 'Crowberry Gully (IV,4)'" class="thickbox" rel="singlepic204" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/204__200x_048.jpg" alt="Rob on 'Crowberry Gully (IV,4)'" title="Rob on 'Crowberry Gully (IV,4)'" />
</a>
Rob and I headed out at 5am from Edinburgh for a day trip to Glencoe to bag one more Cold Climbs classic, and my first (IV,4) lead. From following the <a title="#scotwinter" href="https://twitter.com/search?q=%23scotwinter&amp;src=typd" target="_blank">#scotwinter</a> feed on twitter I was aware that it had seen lots of traffic this week. We were at the base of the route by 8am but even so there was a party already ahead, and several behind. The ice was thin in places, and we considered the thin traverse before the cave pitch to be tougher than the usual crux, the cave pitch itself, which Rob generously let me lead.</p>
<p>The descent was almost as much fun as the climb itself, a smooth glissade down almost the entirety of Great Gully, bringing us from the summit of Buachaille Etive Mor to the car in under an hour.</p>
<h2>What Next?</h2>
<p>Climbing amongst the dry Torridonian sandstone in the spring sunshine last week and my thoughts were already turning to rock rather than ice, but next years goals are really just to increase the mileage on grade IV routes, though if I could up my game to leading a grade V that would be a great achievement for me. I&#8217;d also like to try some more mixed climbs, and I haven&#8217;t yet paid a visit to Coire Mhic Fhearchair on Beinn Eighe, though that goal remains tantalisingly within reach for this winter while the temperatures are still low.</p>
<p>For the full image gallery, see my <a title="Scottish Winter" href="https://plus.google.com/photos/111007392474500551607/albums/5837889864696248273?authkey=CPjYlIPc_9S6cw" target="_blank">gallery on Google+</a><br />

<div class="ngg-galleryoverview" id="ngg-gallery-20-1678">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.planetmarshall.co.uk/2013/04/my-first-full-scottish-winter-season/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-183" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0060.jpg" title="'The Curtain' (IV,5), Ben Nevis. © John Harrison. Climber : Andy Owen" class="thickbox" rel="set_20" >
								<img title="The Curtain, Bein Nevis (IV,5)" alt="The Curtain, Bein Nevis (IV,5)" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_IMG_0060.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-184" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/026.jpg" title=" " class="thickbox" rel="set_20" >
								<img title="'March Hare's Gully' (IV,4), Beinn Bhan" alt="'March Hare's Gully' (IV,4), Beinn Bhan" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_026.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-185" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/031_stitch.jpg" title="My consolation prize, a traverse of the A'Chioch Ridge (II), Beinn Bhan." class="thickbox" rel="set_20" >
								<img title="A'Chioch Ridge (II), Beinn Bhan" alt="A'Chioch Ridge (II), Beinn Bhan" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_031_stitch.jpg" width="100" height="51" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-186" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/007.jpg" title="Victor belays on Tower Ridge (IV,3), Ben Nevis." class="thickbox" rel="set_20" >
								<img title="Tower Ridge (IV,3), Ben Nevis." alt="Tower Ridge (IV,3), Ben Nevis." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_007.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-187" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/009_stitch.jpg" title="Looking back over the Forcan Ridge (II), The Saddle." class="thickbox" rel="set_20" >
								<img title="The Forcan Ridge (II), The Saddle." alt="The Forcan Ridge (II), The Saddle." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_009_stitch.jpg" width="100" height="35" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-188" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/013_stitch.jpg" title="Awaiting our turn to cross Tower Gap on a busy day ( but not the busiest this year )." class="thickbox" rel="set_20" >
								<img title="Tower Gap, on Tower Ridge (IV,3)" alt="Tower Gap, on Tower Ridge (IV,3)" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_013_stitch.jpg" width="86" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-189" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/016_stitch.jpg" title=" " class="thickbox" rel="set_20" >
								<img title="Toll an Lochain, An Teallach." alt="Toll an Lochain, An Teallach." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_016_stitch.jpg" width="100" height="59" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-190" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/017.jpg" title="Belaying Victor as he crosses The Gap." class="thickbox" rel="set_20" >
								<img title="Tower Gap, on Tower Ridge (IV,3)" alt="Tower Gap, on Tower Ridge (IV,3)" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_017.jpg" width="52" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-191" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/018.jpg" title="Car Park Ice, Meall Gorm." class="thickbox" rel="set_20" >
								<img title="Car Park Ice" alt="Car Park Ice" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_018.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-192" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/020.jpg" title="The first pitch of 'Turquoise Gully' (III), Meall Gorm." class="thickbox" rel="set_20" >
								<img title="Turquoise Gully (III), Meall Gorm." alt="Turquoise Gully (III), Meall Gorm." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_020.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-193" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/038.jpg" title="'Chockstone Gully' (I), An Teallach. Climber : Pete Edwards." class="thickbox" rel="set_20" >
								<img title="Chockstone Gully (I), An Teallach." alt="Chockstone Gully (I), An Teallach." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_038.jpg" width="52" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-194" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/050.jpg" title=" " class="thickbox" rel="set_20" >
								<img title="Pete nearing the top of Chockstone Gully." alt="Pete nearing the top of Chockstone Gully." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_050.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-196" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0110.jpg" title=" " class="thickbox" rel="set_20" >
								<img title="'Point 5 Gully' (V,5), Ben Nevis." alt="'Point 5 Gully' (V,5), Ben Nevis." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_IMG_0110.jpg" width="63" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-197" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0125.jpg" title="The author, pulling himself up a steep pitch on 'Point Five Gully' (V,5), Ben Nevis." class="thickbox" rel="set_20" >
								<img title="The author on Point 5 Gully." alt="The author on Point 5 Gully." src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_IMG_0125.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-198" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0196.jpg" title="The author, getting a cold shower on 'Ice Crew' (III), Beinn Udlaidh." class="thickbox" rel="set_20" >
								<img title="Ice Crew (III), Beinn Udlaidh" alt="Ice Crew (III), Beinn Udlaidh" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_IMG_0196.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-199" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0255.jpg" title="The author, on 'Raeburn's Route' (IV,4), Stob Coire Nan Lochan, Glencoe." class="thickbox" rel="set_20" >
								<img title="Raeburn's Route (IV,4), Stob Coire Nan Lochan, Glencoe" alt="Raeburn's Route (IV,4), Stob Coire Nan Lochan, Glencoe" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_IMG_0255.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-200" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/IMG_0278.jpg" title="The author about to go the wrong way,  'Raeburn's Route' (IV,4), Stob Coire Nan Lochan, Glencoe." class="thickbox" rel="set_20" >
								<img title="Raeburn's Route (IV,4), Stob Coire Nan Lochan, Glencoe" alt="Raeburn's Route (IV,4), Stob Coire Nan Lochan, Glencoe" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_IMG_0278.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-201" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/p5.jpg" title="The Rogue Pitch on 'Point Five Gully' (V,5), Ben Nevis. Climber : Andy Owen." class="thickbox" rel="set_20" >
								<img title="The Rogue Pitch" alt="The Rogue Pitch" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_p5.jpg" width="57" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-202" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/047_stitch.jpg" title="On a good day, topping out on Chockstone Gully will present you with this view." class="thickbox" rel="set_20" >
								<img title="Beinn Dearg, from An Teallach" alt="Beinn Dearg, from An Teallach" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_047_stitch.jpg" width="100" height="42" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-203" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/039.jpg" title="The Cave Pitch on Crowberry Gully, Gencoe" class="thickbox" rel="set_20" >
								<img title="The Cave Pitch on Crowberry Gully, Gencoe" alt="The Cave Pitch on Crowberry Gully, Gencoe" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_039.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-204" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/048.jpg" title=" " class="thickbox" rel="set_20" >
								<img title="Rob on 'Crowberry Gully (IV,4)'" alt="Rob on 'Crowberry Gully (IV,4)'" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_048.jpg" width="56" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-205" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/080.jpg" title=" " class="thickbox" rel="set_20" >
								<img title="Glissade" alt="Glissade" src="http://www.planetmarshall.co.uk/wp-content/gallery/scottish_winter_2013/thumbs/thumbs_080.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>

</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2013/04/my-first-full-scottish-winter-season/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving Listener Crossword 4151 with Mathematica</title>
		<link>http://www.planetmarshall.co.uk/2011/10/solving-listener-crossword-4151-with-mathematica/</link>
		<comments>http://www.planetmarshall.co.uk/2011/10/solving-listener-crossword-4151-with-mathematica/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 09:29:25 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[Mathematica]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=1126</guid>
		<description><![CDATA[MathsJam is a monthly meeting for people interested in recreational mathematics, and drinking of beer. At the Edinburgh meeting in August, we were presented with this Listener Crossword, from The Times Crossword Club. At the time of writing, there are<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2011/10/solving-listener-crossword-4151-with-mathematica/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/crossword/puzzle.png" title="Listener Crossword 4151" class="thickbox" rel="singlepic181" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/181__150x_puzzle.png" alt="Listener Crossword 4151" title="Listener Crossword 4151" />
</a>

<p class="pm_first"><a href="http://mathsjam.com/" target="_blank" title="MathsJam">MathsJam </a>is a monthly meeting for people interested in recreational mathematics, and drinking of beer. At the <a href="http://mathsjam.com/index.php?content=edinburgh" title="MathsJam Edinburgh" target="_blank">Edinburgh meeting</a> in August, we were presented with this <a href="http://www.listenercrossword.com/" title="The Listener Crossword" target="_blank">Listener Crossword</a>, from <a href="https://www.crosswordclub.co.uk/" title="The Times Crossword Club" target="_blank">The Times Crossword Club</a>. At the time of writing, there are plenty of solutions on the web from those who tackled the puzzle in the traditional manner of brain, pen and paper. I opted to cheat.<br />
<span id="more-1126"></span><br />
The description of the puzzle itself is quite complex, but in a nutshell the task is to substitute each of the given letters for one of the first ten prime numbers ( with no duplication ). The expression for each clue will then give a numerical solution. Substitute each digit in the solution with the first letter of its name and write the result in the crossword. There are two ways of substituting digits for letters, either in English or in German, but a solution to a given clue must be consistently one language or the other.</p>
<h2>An Algorithmic Solution</h2>
<p>I have decided to use <a href="http://www.wolfram.com/mathematica/" title="Wolfram Mathematica" target="_blank">Mathematica</a> due to its built in symbolic evaluation capabilities, but in principle any sufficiently powerful programming language would do. If you wish you can <a href="#Download">download</a> a copy of the mathematica notebook.</p>
<p>The goal of the algorithm will be to find two sets of rules that map the first 10 primes to the given letters, which give valid solutions. One straightforward way to achieve this is to enumerate every single possibility until we find two such sets. So how many possibilities are there?</p>
<p>There are <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/a466372541e515c191b8f1f549969e84.png"> possible sets of rules to examine. However, for each of the 27 clues, the solution generated by each rule set can be one of two options: English or German. That means that the total number of candidate solutions is<br />
<img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/44a695f6b2ea985a651430e5605b725c.png"></p>
<p>This is what&#8217;s called the &#8216;solution space&#8217;, and at a rate of 1000 candidates per second, it would take over 15,000 years to examine them all. Clearly this kind of brute force enumeration is impractical.</p>
<p>However, most of these solutions will be invalid in some way. In fact, if we trust the crossword compilers, all but two of them will be invalid. Some rules will produce solutions of the wrong size, others may conflict with other solutions in the crossword, and some may be invalid from a mathematical point of view ( such as a division that does not produce a whole number ). If instead of trying to solve the puzzle in one go, we construct &#8216;partial&#8217; solutions in some systematic fashion, we could avoid exploring parts of the solution space that cannot possibly lead to a correct solution. This is the principle behind the <a href="http://en.wikipedia.org/wiki/Backtracking" title="Wikipedia article on Backtracking" target="_blank">backtracking search</a>, one of the cornerstones of artificial intelligence. </p>
<h2>Implementation of a Backtracking Search</h2>
<p>The notion of a partial solution comes quite easily when considering a crossword puzzle, as it is simply a puzzle that is incomplete &#8211; ie, the solutions to at least one clue has been filled in. As an example, consider clue 19 Down : <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/372c8c0974114a670f97d71577e77b98.png">.</p>
<p>There are ten ways of mapping the single letter in 19 down to each prime</p>
<pre class="brush: mathematica; title: ; notranslate">
In[1]  := rules = {{a -&gt; 2}, {a -&gt; 3}, {a -&gt; 5}, {a -&gt; 7}, {a -&gt; 11}, {a -&gt; 13}, {a -&gt; 
   17}, {a -&gt; 19}, {a -&gt; 23}, {a -&gt; 29}}

In[2]  := a^2/.rules
Out[2] = {4, 9, 25, 49, 121, 169, 289, 361, 529, 841}
</pre>
<p>Since we know 19 Down must be three letters long, immediately we can discard the first four candidates. The remainder are all possibilities, since at this point we have no more information. Lets take the first matching possibility, <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/129e6f0f7e0fd7ed8bd23d9eee7930c6.png"> given by the rule <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/ce5e35c9cebf11ae5974aa56145381cb.png">.</p>
<p>In English, this gives</p>
<pre class="brush: mathematica; title: ; notranslate">
In[3]  := IntegerDigits[121] /. {1 -&gt; &quot;O&quot;, 2 -&gt; &quot;T&quot;}
Out[3] = {&quot;O&quot;, &quot;T&quot;, &quot;O&quot;}
</pre>
<p>If we now look at 21 Across &#8211; <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/8cdcc93f429c0e2dbee6d8a1b257f8b1.png"> &#8211; There are 2 symbols to map to the remaining 9 primes ( &#8220;A&#8221; has already been mapped to 11 by 19 Down ). The number of <em>ordered</em> k-subsets of n is given by,<br />
<img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/6d7a125c468b365be35d6b8195f692f0.png"></p>
<p>So we have <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/0949100eaa2bca627621bb76f08199cd.png"> new sets of rules to examine</p>
<pre class="brush: mathematica; title: ; notranslate">
In[4] := rules = {a -&gt; 11, b -&gt; #[[1]], i -&gt; #[[2]]} &amp; /@ 
 Permutations[{2, 3, 5, 7, 13, 17, 19, 23, 29}, {2}] 
Out[4] = {{a -&gt; 11, b -&gt; 2, i -&gt; 3}, {a -&gt; 11, b -&gt; 2, i -&gt; 5},...

In[5] := a b i/. rules
Out[5] = {66, 110, 154, 286, 374, 418, 506, 638, 66,...
</pre>
<p>Again, many of the partial solutions produced by these rules are invalid. Only 36 are the required 4 digits long, and we also now have information about the form of this solution. We know that the first letter is &#8220;T&#8221;, given to us by the puzzle setter, and also that the last letter is &#8220;T&#8221;, because of our solution to 19 Down : &#8220;OTO&#8221;.</p>
<pre class="brush: mathematica; title: ; notranslate">
In[6] := candidates = Select[a b i /. rules, Length[IntegerDigits[#]] == 4 &amp;]
Out[6] = {1045, 1265, 1595, 1001, 1309, 1463, 1771, 2233,...

In[7] := englishRules = {0 -&gt; &quot;Z&quot;, 1 -&gt; &quot;O&quot;, 2 -&gt; &quot;T&quot;, 3 -&gt; &quot;T&quot;,...
In[8] := germanRules = {0 -&gt; &quot;N&quot;, 1 -&gt; &quot;E&quot;, 2 -&gt; &quot;Z&quot;, 3 -&gt; &quot;D&quot;,...
In[9] := candidates = StringJoin @@@ ((IntegerDigits /@ candidates)
   /. Join[english, german])
Out[9] = {&quot;OZFF&quot;, &quot;OTSF&quot;, &quot;OFNF&quot;, &quot;OZZO&quot;, &quot;OTZN&quot;, &quot;OFST&quot;,...

In[10] := Select[candidates, StringMatchQ[#, RegularExpression[&quot;T..T&quot;]] &amp;]
Out[10] = {&quot;TTTT&quot;, &quot;TFFT&quot;, &quot;TTTT&quot;, &quot;TFFT&quot;}
</pre>
<p>Note the duplicates. This is because <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/234da07d44fe9b1f1a2d23844f177e16.png">, but we cannot eliminate them because the rules used to produce them are different, and so will lead to different partial solutions. By applying the constraints systematically, we have reduced the number of potential solutions for 21 Across from 90 to just 4.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/crossword/alg.png" title="A portion of the backtracking search algorithm." class="thickbox" rel="singlepic178" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/178__256x_alg.png" alt="Algorithm" title="Algorithm" />
</a>
We then repeat this process in a recursive manner, using one of the valid solutions to 21 across, and the rules that  were used to generate it, to examine the next clue. We continue in this fashion until either the crossword is filled, or we reach a dead end ( which is more likely ). If we reach a dead end, we backtrack ( hence the name ) to one of the possibilities we haven&#8217;t tried yet. </p>
<p>Why is this approach any more efficient than the brute force enumeration described above? The key is the generation of partial solutions in a tree like fashion, and the ability to eliminate them when we know that they could not possibly form part of a full solution. When we eliminate such a partial solution because it didn&#8217;t satisfy the constraints, we eliminate all the possible solutions leading from that branch. For example, when we eliminated the rule <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/1e1a0e85efabbd0e97200a1aada32fa1.png"> because it produced a solution to 19 Down that was too short, it eliminates not just one solution but all <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/a28fcb488e01635362c81adeeb069a7f.png"> solutions incorporating that rule. Not bad for a single calculation.</p>
<h2>The Solution</h2>
<p>In abbreviated form, the algorithm looks something like this.</p>
<pre class="brush: mathematica; title: ; notranslate">
ExamineNextCandidate[{solved_, unsolved_}, 
  rules_] := {solved, rules} /; Length[unsolved] == 0

ExamineNextCandidate[{solved_, unsolved_}, rules_] := Module[{...},
   {clueIdx, cluePattern} = First[unsolved];
  nextRuleSet = 
   GenerateRules[GetSymbolsInClue[ClueExpression[clueIdx]], rules];
  solution = Null;
  While[Length[nextRuleSet] &gt; 0 &amp;&amp; solution == Null,
   nextRule = First[nextRuleSet];
   nextRuleSet = Rest[nextRuleSet];
   candidates = 
    StringJoin @@@ (IntegerDigits[
        ClueExpression[clueIdx] /. nextRule] /. {english, german});
   candidates = FilterCandidatesByConstraints[candidates];
   If[Length[candidates] &gt; 0,
     nextPatterns = 
      GenerateNewPatterns[unsolved, {#, clueIdx}] &amp; /@ candidates;
     nextArgs = {Append[solved, First[#]], Rest[#]} &amp; /@ nextPatterns;
     While[solution == Null &amp;&amp; Length[nextArgs] &gt; 0,
      solution = ExamineNextCandidate[First[nextArgs], nextRule];
      nextArgs = Rest[nextArgs]
      ];
     ]
    ];
  solution
</pre>
<p>Note that the function <code>ExamineNextCandidate</code> calls itself until the pattern on the list of unsolved solutions is met, ie the list is empty. We call this function using an initially empty rules list, and the patterns provided by the puzzle setter.</p>
<pre class="brush: mathematica; title: ; notranslate">
In[1]:=ExamineNextCandidate[{{}, {...,{20, &quot;..&quot;}, {21, &quot;T...&quot;}, {23, &quot;....&quot;},...}, {}]
Out[1]={...,{20, &quot;FE&quot;}, {21, &quot;TTTT&quot;}, {23, &quot;FZFO&quot;},...}
</pre>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/crossword/clue1.png" title="The solution for the first grid" class="thickbox" rel="singlepic179" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/179__256x_clue1.png" alt="Solution 1" title="Solution 1" />
</a>
 On my dual core netbook ( A 2010 Alienware M11xR2 ), this took just over 2 seconds to find a solution.</p>
<p>For the second puzzle, we alter the pattern to specify that the first letter of 21 Across ( and last of 9 Down ) can be any letter <em>except</em> &#8216;T&#8217;, using the regular expression <code>"[^T]..."</code>. In the code snippets, I have abbreviated the output somewhat. See the attached Mathematica notebook file for full details.</p>
<pre class="brush: mathematica; title: ; notranslate">
In[2]:=ExamineNextCandidate[{{}, {...,{20, &quot;..&quot;}, {21, &quot;[^T]...&quot;}, {23, &quot;....&quot;},...}, {}]
Out[2]={...,{20, &quot;EE&quot;}, {21, &quot;FFTT&quot;}, {23, &quot;FZFO&quot;},...}
</pre>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/crossword/clue2.png" title="The solution for the second grid" class="thickbox" rel="singlepic180" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/180__256x_clue2.png" alt="Solution 2" title="Solution 2" />
</a>
 Finally, the last part of the puzzle is to complete the following task:</p>
<blockquote><p>&#8220;Solvers must identify the English transcriptions of the answers entered using German in one of the grids, which, in clue order, form two words of equal length that are to be entered below the grids, one on each side of the colon; this will relate to a claim made above.&#8221;
</p></blockquote>
<p>To identify the answers entered in German, we apply the rules returned by the solver to the original expressions and use the German digit replacement rules. We then compare these to the completed grid.</p>
<pre class="brush: mathematica; title: ; notranslate">
In[1]:={solution,rules}=ExamineNextCandidate[{{}, {...,{20, &quot;..&quot;}, {21, &quot;T...&quot;}, {23, &quot;....&quot;},...}, {}]
Out[1]={...,{a -&gt; 11, b -&gt; 17, d -&gt; 19, e -&gt; 7,...}}

In[2]:=Intersection[(clues /. rules1) /. {a_, b_} :&gt; {a, 
    IntegerDigits[b] /. german}, solution][[;;,1]]
Out[2]={10, 11, 13, 16, 25, 29, 30}

In[3]:=(Select[clues, MemberQ[%2, First[#]] &amp;] /. rules) /. {a_, b_} :&gt; {a,
    StringJoin @@ (IntegerDigits[b] /. english)}
Out[3]={{10, &quot;SF&quot;}, {11, &quot;NF&quot;}, {13, &quot;FOO&quot;}, {16, &quot;TNOTE&quot;}, {25, &quot;NON&quot;}, {29,
   &quot;SENSE&quot;}, {30, &quot;SSF&quot;}}
</pre>
<p>Having identified those clues, we reevaluate the expressions this time using the English rules. There are 4 clues that are the same in both German and English, but it is pretty clear that the required words are &#8220;<strong>Footnote</strong>&#8221; and &#8220;<strong>Nonsense</strong>&#8221;</p>
<h2>Download</h2>
<p><a name="Download"/><a href="http://www.planetmarshall.co.uk/code/xword/xword.nb" title="Mathematica Notebook" target="_blank">Mathematica Notebook (111K)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2011/10/solving-listener-crossword-4151-with-mathematica/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vancouver</title>
		<link>http://www.planetmarshall.co.uk/2011/10/vancouver/</link>
		<comments>http://www.planetmarshall.co.uk/2011/10/vancouver/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 18:36:38 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Hiking]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=1147</guid>
		<description><![CDATA[One of the advantages of my job is the ocassional opportunity to visit Vancouver. This is the first time I’d visited the city ( or Canada, in fact, though I have been to the US a few times ) and<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2011/10/vancouver/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
	<div class="bing-map-left" ><img id="map_519c1b4001c5c" style="position: relative; width:400px; height: 400px;" src="http://www.planetmarshall.co.uk/maps/vancouver.png"/></div>			<content:encoded><![CDATA[<p class="pm_first">One of the advantages of my job is the ocassional opportunity to visit Vancouver. This is the first time I’d visited the city ( or Canada, in fact, though I have been to the US a few times ) and I wanted to make the most of the free time I had.</p>
<p><br />
Having decided do go for a hike in the surrounding mountains, I only really had one full day free, limiting my options to what was easily accessible and returnable from in a day. Some of my colleagues had previously been to Grouse Mountain and mentioned it as a possible destination, but having never been higher than Ben Nevis ( at 1344m, 4409 ft, the highest mountain in the UK ) I wanted to use this opportunity to improve on that. Further to the west than Grouse, <a href="http://www.env.gov.bc.ca/bcparks/explore/parkpgs/cypress/" title="Cypress Provincial Park" target="_blank">Cypress Provincial Park</a> offers a number of peaks starting at around 1350m and steadily increasing in height as you go further north. These peaks form part of the popular <a href="http://www.env.gov.bc.ca/bcparks/explore/parkpgs/cypress" target="_blank">Howe Sound Crest Trail</a>, the full length of which is around 30km but I would only be doing the portion as far as <a href="http://en.wikipedia.org/wiki/The_Lions_(peaks)" title="The Lions ( Wikipedia )" target="_blank">The Lions</a> &#8211; two 1600m peaks visible from Vancouver that are not entirely dissimilar from Garbh Chioch Mhòr and Sgùrr Na Cìche in <a href="http://www.planetmarshall.co.uk/2011/09/adventures-in-knoydart/" title="Adventures in Knoydart" target="_blank">Knoydart</a>. From what I can ascertain, ascending The Lions themselves requires scrambling ( class 4 according to Wikipedia, though I have no idea what that is in UK terms ), however strange peaks in strange countries merit appropriate safety gear, so this time at least I would content myself to the summit of Unnecessary Mountain, which at 1530m fulfilled my &quot;higher than Nevis&quot; criterion well enough. </p>
<p><span id="more-1147"></span></p>
<h2>Cypress Mountain to Lions Bay</h2>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1048_stitch.jpg" title="View of Howe Sound from St Marks' Summit" class="thickbox" rel="singlepic172" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/172__150x_IMG_1048_stitch.jpg" alt="Howe Sound" title="Howe Sound" />
</a>

<p>I dislike retracing my steps, so I prefer circular routes where possible, or failing that a destination served by public transport back to my starting point. With that in mind I perused the useful <a href="http://www.vancouvertrails.com/" title="Vancouver Trails" target="_blank">Vancouver Trails</a> website for a suitable route. I opted for a portion of the Howe Sound Crest Trail, taking me over St Mark&#8217;s Summit and Unnecessary Mountain to The Lions, and then a sharp descent to Lions Bay from where a regular bus service goes back to Vancouver. </p>
<p>Vancouver Trails rates its routes as Easy/Intermediate/Difficult, but this means little if you have no basis for comparison. The portion as far as St Mark&#8217;s Summit ( intermediate ) is virtually a gravel track for most of the way, with a few sections of clambering over fallen trees near the top. Compared to hiking in the UK it’s a luxurious highway. Between St Mark&#8217;s Summit and Mount Unnecessary a sign indicates that the improvements that have been done to the trail by the local authorities come to an end, after which the ground is rough and going is hard and a map is all but useless &#8211; but there are orange tags and other such markers hanging from branches, nailed to trees and sprayed on rocks for the entire route making it difficult to miss. </p>
<p> 
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1071_stitch.jpg" title="Panorama of The Lions" class="thickbox" rel="singlepic173" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/173__150x_IMG_1071_stitch.jpg" alt="Panorama of The Lions" title="Panorama of The Lions" />
</a>
The portion on the ridge itself is the most rewarding, with its spectacular views. At this time ( late September ) there was a little snow but most of it avoidable, and even where not avoidable it wasn&#8217;t anything that would necessitate crampons, the worst consequences of a slip being embarrassment and a wet arse. There are some fixed ropes left in some areas to ease clambering off the rocks but personally I prefer not to trust my wellbeing to ropes when I have no idea who put them there. In any case they aren&#8217;t really necessary to progress.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1081_stitch.jpg" title="Lions Bay" class="thickbox" rel="singlepic177" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/177__150x_IMG_1081_stitch.jpg" alt="Lions Bay" title="Lions Bay" />
</a>
The ascent and descent from Lions Bay is described as &#8216;difficult&#8217; by Vancouver Trails, and though I would only be doing the descent it&#8217;s a bit of a slog and I would say that although being both longer and higher than Ben Nevis via the Pony Trail, it&#8217;s a route of similar character. The last section however, where the track widens and zig-zags down the hill is tedious beyond belief, and what I wouldn&#8217;t have given for a mountain bike at that stage.</p>
<p>One major difference between hiking in Scotland and Canada is the presence of bears. Hikers are advised to carry various forms of protection as an emergency measure, such as a pepper spray variant available from outdoor shops in the area. Bears, I am told, tend to avoid the smell and noise of people anyway, which I imagine is true since I didn’t see a single one. I did buy the pepper spray, however, though I was unable to take it on the plane back to the UK.</p>
<h2>The interactive map</h2>
<p>A quick word on the interactive map above for those interested ( if you&#8217;re viewing this as a Facebook note or RSS feed, you&#8217;ll need to view the original post to see it ). The basic service is provided by Microsoft, the reason I don&#8217;t use Google Maps is that Microsoft provide access to the UK&#8217;s Ordnance Survey topographical mapping. I have customised it somewhat for this specific post, using the Canadian Government&#8217;s <a title="Geogratis" href="http://geogratis.gc.ca/geogratis/en/product/search.do" target="_blank">Geogratis</a> service to download a local topographic map in pdf format, and then used <a href="http://research.microsoft.com/en-us/um/redmond/projects/mapcruncher/" title="MapCruncher from Microsoft Research" target="_blank">MapCruncher</a> from Microsoft Research to prepare it in a format so that it can be used with Bing. The details on how to do this are available from <a href="http://msdn.microsoft.com/en-us/library/gg427610.aspx" title="Bing Maps v7.0 API" target="_blank">MSDN</a> for interested web geeks, but it&#8217;s probably not of any interest to anyone else.</p>
<h2>Gallery</h2>
<p>High resolution images are available from <a href="http://www.flickr.com/photos/planetmarshall/sets/72157627766646674/" title="Flickr : Vancouver" target="_blank">Flickr</a>.<br />

<div class="ngg-galleryoverview" id="ngg-gallery-16-1147">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.planetmarshall.co.uk/2011/10/vancouver/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-171" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1041.jpg" title="Vancouver harbour" class="thickbox" rel="set_16" >
								<img title="Vancouver harbour" alt="Vancouver harbour" src="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/thumbs/thumbs_IMG_1041.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-172" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1048_stitch.jpg" title="View of Howe Sound from St Marks' Summit" class="thickbox" rel="set_16" >
								<img title="Howe Sound" alt="Howe Sound" src="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/thumbs/thumbs_IMG_1048_stitch.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-173" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1071_stitch.jpg" title="Panorama of The Lions" class="thickbox" rel="set_16" >
								<img title="Panorama of The Lions" alt="Panorama of The Lions" src="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/thumbs/thumbs_IMG_1071_stitch.jpg" width="100" height="74" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-174" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1074_stitch.jpg" title="The Lions" class="thickbox" rel="set_16" >
								<img title="The Lions" alt="The Lions" src="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/thumbs/thumbs_IMG_1074_stitch.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-175" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1076_stitch.jpg" title="Vancouver, from the Howe Sound Crest Trail" class="thickbox" rel="set_16" >
								<img title="Vancouver" alt="Vancouver" src="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/thumbs/thumbs_IMG_1076_stitch.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-176" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1080.jpg" title="Unnecessary Mountain" class="thickbox" rel="set_16" >
								<img title="Unnecessary Mountain" alt="Unnecessary Mountain" src="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/thumbs/thumbs_IMG_1080.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-177" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/IMG_1081_stitch.jpg" title="Lions Bay" class="thickbox" rel="set_16" >
								<img title="Lions Bay" alt="Lions Bay" src="http://www.planetmarshall.co.uk/wp-content/gallery/vancouver/thumbs/thumbs_IMG_1081_stitch.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>

</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2011/10/vancouver/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adventures in Knoydart</title>
		<link>http://www.planetmarshall.co.uk/2011/09/adventures-in-knoydart/</link>
		<comments>http://www.planetmarshall.co.uk/2011/09/adventures-in-knoydart/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 09:20:57 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Sport]]></category>
		<category><![CDATA[Hiking]]></category>

		<guid isPermaLink="false">http://97.107.139.84/?p=1042</guid>
		<description><![CDATA[Despite having been born and brought up for the first half of my life in Scotland, and having recently returned there, I have seen and explored little of it. Until recently I believed Fort William to be in the reasonably<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2011/09/adventures-in-knoydart/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
	<div class="bing-map-right" ><img id="map_519c1b4028ac9" style="position: relative; width:400px; height: 400px;" src="http://www.planetmarshall.co.uk/maps/knoydart.png"/></div>			<content:encoded><![CDATA[
<p class="pm_first">
Despite having been born and brought up for the first half of my life in Scotland, and having recently returned there, I have seen and explored little of it. Until recently I believed Fort William to be in the reasonably far north, despite the fact that the most cursory glance of a map reveals it to be only about halfway between Carlisle and Thurso. As part of what I hope will be a series of adventures to explore the rest of the land of my birth, I decided to venture into Knoydart, the region between Lochs Nevis and Hourn, at least partly inspired by the initial stages of the <a href="http://en.wikipedia.org/wiki/Cape_Wrath_Trail" title="The Cape Wrath Trail (Wikipedia)" target="_blank">Cape Wrath Trail</a>. The aim would be to reach Inverie, and its pub <a href="http://www.theoldforge.co.uk/" title="The Old Forge" target="_blank"><em>The Old Forge</em></a>, the most remote pub in mainland Britain. Also, being of modest mountaineering ambitions, I would try to prefer high level routes where possible.</p>
<p><span id="more-1042"></span></p>
<h2>Day 1 : Glenfinnan to Strathan</h2>
<p>I don&#8217;t drive, and so am subject to the vagaries of public transport, which in the less densely populated areas of Scotland are more vague than most. I was however able to arrive at Fort William station at a reasonable hour, making the obligatory stop at Nevisport to pick up anything I&#8217;d forgotten, including a hat, but not insect repellent, something I was to regret several times over the course of the next few days. </p>
<p>

<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/glenfinnan.jpg" title="The Glenfinnan Monument" class="thickbox" rel="singlepic151" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/151__100x_glenfinnan.jpg" alt="The Glenfinnan Monument" title="The Glenfinnan Monument" />
</a>
Rather than start my journey from Fort William, I opted to get the train to Glenfinnan and start from there. I had last been in my childhood or early teens and had taken a photograph of the monument during some appalling weather, which has since become an oil painting and present for some recently married friends. I couldn&#8217;t resist the opportunity to make a quick stop to take another picture of what is probably one of the most beautiful places in Scotland.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/streap.jpg" title="Looking back to the bealach at the head of Gleann Cuìrnean. The huddles of stones strewn through this valley suggests there was once a settlement here. A victim of the clearances? The prominent hill to the left is Streap." class="thickbox" rel="singlepic153" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/153__100x_streap.jpg" alt="Streap" title="Streap" />
</a>
Here my journey began in earnest, walking from the monument under the famous Glenfinnan Viaduct. Since its appearance in the Harry Potter films, this location has brought in tourists from far and wide, these were the last people I was to see for some time, however at the time of writing there was a lot of work going on as part of a hydroelectric project and so I didn&#8217;t really begin to feel the isolation I&#8217;d been anticipating until I was well past the Glenfinnan Lodge. Here a track diverges to go up over Sgùrr nan Coireachan ( marked with a red dotted line on the map ), which I would have taken had circumstances permitted. I did consider the detour, but it was late ( about 3pm ), and the weather was less than ideal so I opted for the low level route. A little later the skies opened, and I knew that I had made the right decision.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/arkaig.jpg" title="Strathan and Loch Arkaig. The ground here was a nightmare 'Bog of Eternal Stench'. I recommend trying your luck in the forest." class="thickbox" rel="singlepic147" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/147__100x_arkaig.jpg" alt="Strathan and Loch Arkaig" title="Strathan and Loch Arkaig" />
</a>
Once out of Gleann Cuìrnean,  the route crosses over the river Pean and <a href="http://www.amazon.co.uk/North-Cape-William-Wrath-Cicerone/dp/1852842857/ref=sr_1_1?ie=UTF8&#038;qid=1315185066&#038;sr=8-1" title="North to the Cape ( Amazon UK )" target="_blank">Brook and Hinchliffe&#8217;s guide</a> suggests avoiding the conifer forest and making your way around the edge toward Strathan. However, I found the ground here to be extremely boggy and eventually, in order to make further progress, I had to succumb to getting my feet wet and wade through about 2 feet of marsh water. To anyone attempting this route, I recommend fighting through the conifers to find the track through the forest, or perhaps going along the riverbank where the ground may be firmer.</p>
<p>It was by this point getting dark, and I was tired, so I decided to camp on the first bit of acceptable ground rather than continue on toward Glendassary. Unfortunately I discovered that I had neglected to bring anything with which to light my stove, and so a well needed brew was not an option. In addition, the considerable weight of the stove was now largely redundant and not for the first time I thought about how in future I might save some weight.</p>
<h2>Day 2 : Strathan to Sourlies</h2>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/strathan.jpg" title="Strathan in the morning after the first night's camping." class="thickbox" rel="singlepic152" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/152__100x_strathan.jpg" alt="Strathan in the morning" title="Strathan in the morning" />
</a>
I woke to find that the predicted foul weather had not yet arrived, and resolved to make an early start. I was packed up and ready to go by 8.00 am, and despite lacking a hot breakfast I was feeling pretty good and made good time along the solid track through Glendassary. I noticed that some fellow wild campers had made good use of the fact that the ground here was much nicer than at Strathan, the first people I&#8217;d seen since Glenfinnan. I made a mental note to camp here if I came this way again.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/munroes.jpg" title="Boobies. ( I kid you not, that's Garbh Chioch Mhòr and Sgùrr Na Cìche, or 'Big Rough Place of the Breast' and 'Peak of the Breast', respectively. )" class="thickbox" rel="singlepic162" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/162__100x_munroes.jpg" alt="Boobies" title="Boobies" />
</a>
At this point I had to make the first real decision affecting my route, it was early enough that I could opt to traverse the Glendassary ridge all the way to Sourlies, however I was suspicious of the weather, both the <a href="http://www.metoffice.gov.uk/loutdoor/mountainsafety/westhighland/westhighland_latest_weather.html" title="MET office mountain forecast for the West Highlands" target="_blank">MET</a> office and <a href="http://www.mwis.org.uk/nw.php" title="Mountain Weather Information Service for the Northwest Highlands" target="_blank">MWIS</a> had forecast rain and high winds on the summits, and so I opted for the valley rather than the ridge. It was a decision I still regret, but at the time it was the sensible one.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/cairn1.jpg" title="Summit Cairn of Garbh Chioch Mhòr,  looking back over the whole ridge." class="thickbox" rel="singlepic154" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/154__100x_cairn1.jpg" alt="Summit Cairn of Garbh Chioch Mhòr" title="Summit Cairn of Garbh Chioch Mhòr" />
</a>
As the day went on, the rain and winds failed to materialize. In fact the weather was glorious, and the dreaded midgies took maximum advantage of the still weather and my bare arms. By about 11.00am I made the decision to try to get up onto the ridge and make the most of the conditions while they held. The OS 50,000 map indicates a path from the valley up to the ridge but I failed to find it, and instead improvised my way along sheep tracks and up gullies. While letting my mind wander it occurred to me that Sheep Track Optimization could be an unexplored avenue for heuristic optimization techniques, but I digress ( see <a href="http://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms" title="Ant Colony Optimization ( Wikipedia )" target="_blank">Ant Colony Optimization</a> in case you think I&#8217;ve gone barking mad ). Eventually I found the crest of the ridge, where there was a clearly well trodden path and a wall, over which was a dramatic view toward Loch Quoich.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/ridge.jpg" title="Descending the West Glendassary Ridge, toward Loch Nevis.  The islands of the Inner Hebrides can be seen in the distance, Eigg is particularly distinctive dominated by a plateau with a single peak toward its southern end. Further out is Rum, and nearest is the Sleat peninsula on Skye. The bay at Inverie is to the right." class="thickbox" rel="singlepic165" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/165__100x_ridge.jpg" alt="The West Glendassary Ridge" title="The West Glendassary Ridge" />
</a>
It was a glorious day for walking the ridge, with a good path and plenty of opportunities for easy and totally unnecessary scrambling. The huge peaks of Garbh Chioch Mhòr and Sgùrr Na Cìche ( which rather amusingly translate as &#8216;Big Rough Place of the Breast&#8217; and &#8216;Peak of the Breast&#8217; respectively ) command awesome views of Knoydart and beyond. </p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/camp2.jpg" title="Sunset over the Inner Hebrides, and a night's camp on the ridge above Loch Nevis, south west of  Sgùrr Na Cìche." class="thickbox" rel="singlepic156" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/156__100x_camp2.jpg" alt="Wild camping on the ridge" title="Wild camping on the ridge" />
</a>
Descending the ridge from Sgùrr Na Cìche it gradually became obvious that the gusts of wind were increasing in strength and in frequency, and that the long heralded foul weather had been merely delayed. The path had long since disappeared to give way to some fairly nondescript peatbogs, and it became clear I was not going to get off the ridge before nightfall. There was a lochan at about 400m that would have been an idyllic spot but for the fact it offered no shelter from the, by now, impressive wind blowing from the direction that I had come. I found a reasonably sheltered spot on the south side of the ridge, set up the tent and perched on a rock  to watch the sun set. </p>
<h2>Day 3 : Sourlies to Inverie</h2>
<p>The weather arrived sometime during the night. The tent however performed admirably, staying rock solid in the face of every blast of gale force wind and every torrent of rain. Lighter tents are available, but for once I was glad to carry a bit of extra weight for something solidly constructed ( The tent is a <a href="http://hilleberg.se/product/akto" title="Hilleberg Akto" target="_blank">Hilleberg Akto</a> for those interested ). I remember listening to the noise of rain and wind and wishing I could get to sleep, only to drift off and the next thing I knew it was morning.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/river.jpg" title="The River Carnach. The effect of the night's heavy rain is in evidence. The footbridge in the next picture can just be seen at the narrowest point of the river." class="thickbox" rel="singlepic166" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/166__100x_river.jpg" alt="The River Carnach" title="The River Carnach" />
</a>
I woke to find that the trickle of water I had heard from a nearby stream now sounded like a full blown waterfall, though thankfully it was nowhere near the tent. It was a miserable morning, and I took my time about packing up. The rain was easing off, but I nonetheless decided to get off the ridge as quickly as possible rather than take the longer route toward the beach at Loch Nevis. Visibility gradually improved, but the going was difficult and it was the best part of an hour before I made the footbridge.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/footbridge.jpg" title="The 'footbridge' over the river Carnach ( although I've seen worse ). Taken by a couple of friendly walkers who had stayed in the relative luxury of Sourlies Bothy." class="thickbox" rel="singlepic159" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/159__100x_footbridge.jpg" alt="The 'footbridge' over the river Carnach" title="The 'footbridge' over the river Carnach" />
</a>
Here I was somewhat surprised to meet a couple of walkers who had spent the night at Sourlies Bothy ( &#8216;Luxury&#8217;, apparently, though they wouldn&#8217;t have had my views ). They had already crossed the bridge, conveniently demonstrating that it wasn&#8217;t quite the death trap it looked. Actually it was pretty solid, though it swings disconcertingly if you try to cross at speed. From here a good stalkers path climbs to the bealach at the head of Gleann Meadail.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/pub.jpg" title="&lt;a href=&quot;http://www.theoldforge.co.uk/&quot; target=&quot;_new&quot;&gt;The Old Forge&lt;/a&gt; at Inverie, and the most remote pub in mainland Britain. Pretty damn good seafood, too." class="thickbox" rel="singlepic163" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/163__100x_pub.jpg" alt="The Old Forge at Inverie" title="The Old Forge at Inverie" />
</a>
By this time I could practically taste the beer at The Old Forge, and struck up a pace that would make a mockery of Naismith&#8217;s rule. I noted on the map that I could have taken another high level diversion here over Meall Buidhe, but again I was thwarted by the weather. As I approached Inverie, signs of civillization began to appear: the odd outbuilding, landrover tracks, highland cattle. I made it to Inverie by 4pm, and went straight to the pub where I met a walker who had come south over Ladhar Bheinn, immediately making me feel like a wimp.</p>
<h2>Inverie, and home.</h2>
<p>There is a perfectly good campsite at Inverie, and a bunkhouse, but I felt that I&#8217;d earned a small amount of luxury and decided to try my luck at the B&#038;B, <a href="http://www.knoydartlodge.co.uk/" title="Knoydart Lodge" target="_blank">Knoydart Lodge</a>. I popped my head round and managed to disturb  the owners, Bob and Morag, and their guests having dinner. Luckily there was a room available. </p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/inverie.jpg" title="Inverie." class="thickbox" rel="singlepic160" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/160__100x_inverie.jpg" alt="Inverie" title="Inverie" />
</a>
Knoydart Lodge puts many of the hotels I have stayed in to shame, the bedroom had a huge double bed and breakfast the following morning was fresh and cooked to order. That evening I had dinner at the pub and returned to Knoydart Lodge to while away the evening chatting to Bob, Morag and their guests, who had brought guitars, a mandolin and an accordion to have &#8216;a wee tune&#8217;. My version ( actually Travis&#8217; version ) of the Britney Spears hit &#8216;<em>Hit me baby one more time</em>&#8216; caused some hilarity but was, sadly, not really up to scratch. I was able to redeem myself with a few bars of Rachmaninoff on the piano until I reached a mental block probably caused by too much whisky.</p>
<p>The following morning, while well rested, I decided to expedite my route home by taking the local ferry to Mallaig, and thence the train back to Edinburgh via Fort William. Unfortunately there was a considerable gap between connections at Fort William and so I was forced to spend a few hours in <em><a href="http://www.grogandgruel.co.uk/" title="The Grog and Gruel, Fort William" target="_blank">The Grog and Gruel</a></em>. Life is hard, sometimes.</p>

<div class="ngg-galleryoverview" id="ngg-gallery-15-1042">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.planetmarshall.co.uk/2011/09/adventures-in-knoydart/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-151" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/glenfinnan.jpg" title="The Glenfinnan Monument" class="thickbox" rel="set_15" >
								<img title="The Glenfinnan Monument" alt="The Glenfinnan Monument" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_glenfinnan.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-153" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/streap.jpg" title="Looking back to the bealach at the head of Gleann Cuìrnean. The huddles of stones strewn through this valley suggests there was once a settlement here. A victim of the clearances? The prominent hill to the left is Streap." class="thickbox" rel="set_15" >
								<img title="Streap" alt="Streap" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_streap.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-148" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/frog.jpg" title="Scottish wildlife. More at home in this weather than me, I expect." class="thickbox" rel="set_15" >
								<img title="Scottish wildlife" alt="Scottish wildlife" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_frog.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-147" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/arkaig.jpg" title="Strathan and Loch Arkaig. The ground here was a nightmare 'Bog of Eternal Stench'. I recommend trying your luck in the forest." class="thickbox" rel="set_15" >
								<img title="Strathan and Loch Arkaig" alt="Strathan and Loch Arkaig" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_arkaig.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-152" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/strathan.jpg" title="Strathan in the morning after the first night's camping." class="thickbox" rel="set_15" >
								<img title="Strathan in the morning" alt="Strathan in the morning" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_strathan.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-149" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/glendassary.jpg" title="Glendassary." class="thickbox" rel="set_15" >
								<img title="Glendassary" alt="Glendassary" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_glendassary.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-150" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/glendassary2.jpg" title="Climbing toward the Glendassary ridge." class="thickbox" rel="set_15" >
								<img title="Glendassary" alt="Glendassary" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_glendassary2.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-169" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/wall.jpg" title="I wonder what's over this wall..." class="thickbox" rel="set_15" >
								<img title="The West Glendassary Ridge" alt="The West Glendassary Ridge" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_wall.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-164" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/quoich.jpg" title="...A spectacular view of Loch Quoich." class="thickbox" rel="set_15" >
								<img title="Loch Quoich from the West Glendassary Ridge" alt="Loch Quoich from the West Glendassary Ridge" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_quoich.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-167" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/rocks.jpg" title="I think I understand why many mountaineers take an interest in geology, and vice versa." class="thickbox" rel="set_15" >
								<img title="Rocks" alt="Rocks" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_rocks.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-162" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/munroes.jpg" title="Boobies. ( I kid you not, that's Garbh Chioch Mhòr and Sgùrr Na Cìche, or 'Big Rough Place of the Breast' and 'Peak of the Breast', respectively. )" class="thickbox" rel="set_15" >
								<img title="Boobies" alt="Boobies" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_munroes.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-168" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/sgurr.jpg" title="A big rock wall beneath the path, between Garbh Chioch Mhòr and Sgùrr Na Cìche." class="thickbox" rel="set_15" >
								<img title="Rock wall." alt="Rock wall." src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_sgurr.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-154" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/cairn1.jpg" title="Summit Cairn of Garbh Chioch Mhòr,  looking back over the whole ridge." class="thickbox" rel="set_15" >
								<img title="Summit Cairn of Garbh Chioch Mhòr" alt="Summit Cairn of Garbh Chioch Mhòr" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_cairn1.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-155" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/cairn2.jpg" title="Summit Cairn of Sgùrr Na Cìche" class="thickbox" rel="set_15" >
								<img title="Summit Cairn of Sgùrr Na Cìche" alt="Summit Cairn of Sgùrr Na Cìche" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_cairn2.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-165" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/ridge.jpg" title="Descending the West Glendassary Ridge, toward Loch Nevis.  The islands of the Inner Hebrides can be seen in the distance, Eigg is particularly distinctive dominated by a plateau with a single peak toward its southern end. Further out is Rum, and nearest is the Sleat peninsula on Skye. The bay at Inverie is to the right." class="thickbox" rel="set_15" >
								<img title="The West Glendassary Ridge" alt="The West Glendassary Ridge" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_ridge.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-156" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/camp2.jpg" title="Sunset over the Inner Hebrides, and a night's camp on the ridge above Loch Nevis, south west of  Sgùrr Na Cìche." class="thickbox" rel="set_15" >
								<img title="Wild camping on the ridge" alt="Wild camping on the ridge" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_camp2.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-166" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/river.jpg" title="The River Carnach. The effect of the night's heavy rain is in evidence. The footbridge in the next picture can just be seen at the narrowest point of the river." class="thickbox" rel="set_15" >
								<img title="The River Carnach" alt="The River Carnach" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_river.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-159" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/footbridge.jpg" title="The 'footbridge' over the river Carnach ( although I've seen worse ). Taken by a couple of friendly walkers who had stayed in the relative luxury of Sourlies Bothy." class="thickbox" rel="set_15" >
								<img title="The 'footbridge' over the river Carnach" alt="The 'footbridge' over the river Carnach" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_footbridge.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-158" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/flow.jpg" title="No fast flowing river photo is complete without a gratuitous long exposure shot." class="thickbox" rel="set_15" >
								<img title="Gratuitous long exposure" alt="Gratuitous long exposure" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_flow.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-157" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/cow.jpg" title="Give way to fellow road users. Especially if they have massive horns." class="thickbox" rel="set_15" >
								<img title="Fellow road user" alt="Fellow road user" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_cow.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-161" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/inverie_beach.jpg" title="The beach at Inverie." class="thickbox" rel="set_15" >
								<img title="The beach at Inverie" alt="The beach at Inverie" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_inverie_beach.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-160" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/inverie.jpg" title="Inverie." class="thickbox" rel="set_15" >
								<img title="Inverie" alt="Inverie" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_inverie.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-163" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/pub.jpg" title="&lt;a href=&quot;http://www.theoldforge.co.uk/&quot; target=&quot;_new&quot;&gt;The Old Forge&lt;/a&gt; at Inverie, and the most remote pub in mainland Britain. Pretty damn good seafood, too." class="thickbox" rel="set_15" >
								<img title="The Old Forge at Inverie" alt="The Old Forge at Inverie" src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_pub.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-170" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/cuillin.jpg" title="Cuillin the Dog. Patron of &lt;em&gt;The Grog and Gruel&lt;/em&gt; in Fort William, and resident of Skye." class="thickbox" rel="set_15" >
								<img title="Cuillin the Dog." alt="Cuillin the Dog." src="http://www.planetmarshall.co.uk/wp-content/gallery/knoydart/thumbs/thumbs_cuillin.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>


]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2011/09/adventures-in-knoydart/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An Illustrated Version of The Rime of the Ancient Mariner, for the Amazon Kindle</title>
		<link>http://www.planetmarshall.co.uk/2010/11/an-illustrated-version-of-the-rime-of-the-ancient-mariner-for-the-amazon-kindle/</link>
		<comments>http://www.planetmarshall.co.uk/2010/11/an-illustrated-version-of-the-rime-of-the-ancient-mariner-for-the-amazon-kindle/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 00:59:59 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Kindle]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=974</guid>
		<description><![CDATA[A few months ago I jumped on the e-reader bandwagon, and purchased the latest version of Amazon’s Kindle device. By and large I’m extremely pleased with it; reading Douglas Adams&#8217; Hitchhiker’s Guide to the Galaxy on a device that bears<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2010/11/an-illustrated-version-of-the-rime-of-the-ancient-mariner-for-the-amazon-kindle/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/mariner/cover.png" title="Cover image for the finishede book." class="thickbox" rel="singlepic145" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/145__150x_cover.png" alt="Cover image" title="Cover image" />
</a>

<p class="pm_first">A few months ago I jumped on the e-reader bandwagon, and purchased the latest version of Amazon’s Kindle device. By and large I’m extremely pleased with it; reading Douglas Adams&#8217; Hitchhiker’s Guide to the Galaxy on a device that bears an uncanny resemblance to the eponymous guide itself ( something I’m <a target="_new" href="http://xkcd.com/548/">not the first</a> to notice ), brings me no end of amusement.</p>
<p><span id="more-974"></span><br />
Nonetheless, many of the commercial e-books available via Amazon’s store leave much to be desired in terms of their suitability for reading on the device, largely down to cheap and/or lazy conversions, making some of the more expensive titles a dubious investment. There is, however, a vast library of free, out of copyright content provided by websites like <a href="http://www.gutenberg.org" target="_new">Project Gutenberg</a>. Being free, it would be churlish to complain about matters of style and formatting, particularly when this is easy to rectify with access to the source and a small amount of technical knowledge. For full details on creating content for the Kindle, see the <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&#038;docId=1000234621" target="_new">Amazon Kindle Publishing Program</a>.</p>
<p>Samuel Taylor Coleridge’s <em><a href="http://www.gutenberg.org/ebooks/151" target="_new">Rime of the Ancient Mariner</a></em> is one of many out of copyright texts provided by Project Gutenberg, in both epub and the Kindle’s native mobipocket format, kindly produced by Judy Boss and David Widger. However, as can be seen in the screenshots below from Amazon’s Kindle Previewer program, the formatting could do with some polish. Additionally, it is unillustrated, which is a shame because <a href="http://en.wikipedia.org/wiki/Gustave_Dor%C3%A9" target="_new">Gustav Dor&eacute;’s</a> wonderful artwork is also available in the public domain, at least in the resolution required for an ebook, from <a href="http://dore.artpassions.net/" target="_new">http://dore.artpassions.net/</a>.</p>

<a href="http://www.planetmarshall.co.uk/wp-content/gallery/mariner/gutenberg.png" title="The .mobi file from Project Gutenberg. The monospace font used by the Kindle to render &lt;pre/&gt; tags is not ideal for text." class="thickbox" rel="singlepic142" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/142__150x_gutenberg.png" alt="Original .mobi file from Project Gutenberg" title="Original .mobi file from Project Gutenberg" />
</a>

<p>Using the plain html file as a starting point, converting it directly results in a file that looks much like the mobi file on Project Gutenberg. However, with access to the source, we can do a bit better.</p>
<h3>Formatting the text for Kindle</h3>
<p>I’m using <a href="http://en.wikipedia.org/wiki/XSLT" target="_new">XSLT</a> 2.0 to create the xhtml source for Amazon’s kindlegen tool. As with the <a target="_new" href="http://www.planetmarshall.co.uk/2010/04/visualizing-the-prime-ministerial-debates/">Prime Ministerial debates project</a>, the input file needs cleaning up before passing it to an XSLT transformation tool such as <a href="http://saxon.sourceforge.net/" target="_new">Saxon</a>.</p>
<p>Following the suggestions here : <a target="_new" href="http://www.xmlplease.com/xhtmlxhtml">http://www.xmlplease.com/xhtmlxhtml</a>, I made the following changes to the input document to prepare it for processing</p>
<ol>
<li>Added xml header</li>
<li>Removed HTML DTD. If you don’t do this, most XSLT processors will try to resolve the DTD over the network and take forever as a result.</li>
<li>Added ENTITY declarations for any named HTML character entities used in the source, such as &#8216;&amp;mdash;&#8217;</li>
<li>Removed any invalid xhtml such as orphaned &lt;br&gt; and &lt;hr&gt; tags.</li>
</ol>
<p>Having done that, the document should parse. The snippet below uses XSLT 2.0&#8242;s regular expression support to add line breaks to the text, and wrap each verse in paragraph blocks. </p>
<pre class="brush: xml; title: ; notranslate">
&lt;xsl:template match=&quot;xhtml:pre&quot;&gt;
 &lt;div&gt;
 &lt;xsl:for-each select=&quot;tokenize(string(.),'nn')&quot;&gt;
  &lt;p&gt;&lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;
  &lt;xsl:analyze-string select=&quot;.&quot; regex=&quot;n&quot;&gt;
   &lt;xsl:matching-substring&gt;
    &lt;!-- add newlines to keep the source tidy --&gt;
    &lt;br/&gt;&lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;
   &lt;/xsl:matching-substring&gt;
   &lt;xsl:non-matching-substring&gt;
    &lt;xsl:value-of select=&quot;.&quot;/&gt;
   &lt;/xsl:non-matching-substring&gt;
  &lt;/xsl:analyze-string&gt;
  &lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;&lt;/p&gt;
 &lt;/xsl:for-each&gt;
 &lt;/div&gt;
&lt;/xsl:template&gt; 
</pre>
<p>After adding a stylesheet to centre text and add appropriate paragraph spacing, here is the result.</p>

<a href="http://www.planetmarshall.co.uk/wp-content/gallery/mariner/mariner_2.png" title="Centering the text and increasing paragraph separation with a CSS stylesheet completes the layout." class="thickbox" rel="singlepic144" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/144__150x_mariner_2.png" alt="Completed text layout." title="Completed text layout." />
</a>

<h3>Licensing and distribution</h3>
<p>I have chosen to license the completed ebook under a Creative Commons <a href="http://creativecommons.org/licenses/by-sa/3.0/" target="_new">share-and-share-alike license</a>, although this does not affect the public domain status of Coleridge&#8217;s text or Dor&eacute;&#8217;s illustrations. The compiled book is available for download from the <a href="http://openlibrary.org/books/OL24489895M/Rime_of_the_ancient_mariner" target="_new">Open Library</a> or directly from the <a href="http://www.archive.org/details/TheRimeOfTheAncientMarinerillustrated" target="_new">Internet Archive</a>. You can also <a href="http://www.planetmarshall.co.uk/files/mariner.zip">download the source</a>, excluding the images.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2010/11/an-illustrated-version-of-the-rime-of-the-ancient-mariner-for-the-amazon-kindle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drawing geodesic curves using the Bing maps Silverlight control</title>
		<link>http://www.planetmarshall.co.uk/2010/06/drawing-geodesic-curves-using-the-bing-maps-silverlight-control/</link>
		<comments>http://www.planetmarshall.co.uk/2010/06/drawing-geodesic-curves-using-the-bing-maps-silverlight-control/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 14:52:05 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=624</guid>
		<description><![CDATA[For an upcoming post I wanted to be able to plot the shortest routes between various positions on the Earth using the Bing Maps Silverlight control. Although since I started working on the problem Bing have provided a similar feature<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2010/06/drawing-geodesic-curves-using-the-bing-maps-silverlight-control/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p class="pm_first">For an upcoming post I wanted to be able to plot the shortest routes between various positions on the Earth using the <a title="Bing Maps Silverlight Control" href="http://msdn.microsoft.com/en-us/library/ee681884.aspx" target="_blank">Bing Maps Silverlight control</a>. Although since I started working on the problem Bing have provided a similar feature with their <a title="New Bing Map Apps: Gas Prices, Distance Calculator and Parking Finder" href="http://www.bing.com/community/blogs/maps/archive/2010/05/19/new-bing-map-apps-gas-prices-distance-calculator-and-parking-finder.aspx" target="_blank">Distance Calculator App</a>, the functions are not available for reuse via the public API. Interested developers may just want to skip the maths and just download the code.</p>
<p><a title="Source code in zip file for Silverlight 4.0" href="http://www.planetmarshall.co.uk/code/geodesic.zip">Geodesic source code for Silverlight 4.0</a></p>
<h2>Geodesics</h2>

<a href="http://www.planetmarshall.co.uk/wp-content/gallery/geodesic/geo.png" title="Geodesic showing the shortest distance between Cambridge and New York" class="thickbox" rel="singlepic118" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/118__150x_geo.png" alt="Geodesic " title="Geodesic " />
</a>

<p>The shortest path between two points on an arbitrary surface is called a <a title="Geodesic from MathWorld" href="http://mathworld.wolfram.com/Geodesic.html" target="_blank">Geodesic</a>, and on a sphere, it is a <a title="Great Circle from MathWorld" href="http://mathworld.wolfram.com/GreatCircle.html" target="_blank">Great Circle</a>. Modelling the surface of the earth as a perfect sphere, the shortest distance between any two locations on the surface is then described by a section of a Great Circle, ie an arc that lies on the plane that is described by the vectors between its start and end points and the Earth&#8217;s centre ( see figure 1 ).</p>
<p>With this information, one way ( and the way I have adopted ) to plot such a curve is as follows:</p>
<ol>
<li>Generate the points of the curve in two dimensions using the parametric equation of a circle.</li>
<li>Transform the plane of the 2d curve into 3D space such that it intersects the end points on the sphere, and the sphere&#8217;s centre.</li>
<li>Project the transformed points back into 2D space using the Mercator projection equations.</li>
</ol>
<p><span id="more-624"></span><br />
[silverlight: Geodesic.xap,520,384,false]</p>
<h2>A Parametric Representation of a Great Circle</h2>
<p>The <a title="Mercator Projection from MathWorld" href="http://mathworld.wolfram.com/MercatorProjection.html">Mercator projection</a> gives the 2D rectilinear coordinates (x,y) as a function of the latitude and longitude of a point on a sphere. However, it is easier to draw the point using a typical drawing API, if we have a representation that gives each point of the curve in terms of a single parameter. To derive such a function, we observe that the parametric equation for a circle is given by</p>
<p><img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/e5b8848371277d58a9dc8952b7cf5711.png"></p>
<p>Since a great circle is a rigid transformation of a circle in 3D space, it can also be represented as a function of a single parameter</p>
<p><img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/8534bc6d8f61891522e2cab9e29a4bcd.png"></p>
<p>where <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/e1fd601dbae82a538d518550acb1af19.png"> is a 2&#215;3 matrix that transforms the plane circle to a location on a sphere. Using <a title="Spherical Coordinates from MathWorld" href="http://mathworld.wolfram.com/SphericalCoordinates.html">spherical coordinates</a>, the Mercator projection of the curve specified above is then<br />
<img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/d28b323111eafa9b1752172618ef461d.png"><br />
Where <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/c6a6eb61fd9c6c913da73b3642ca147d.png"> and <img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/1ed346930917426bc46d41e22cc525ec.png"> are the longitude and latitude of the point to be projected, respectively. Writing the equation out in full gives,</p>
<p><img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/d7fa48691fe4625fecde98aac52f7127.png"></p>
<p>Now that we have a suitable parametric equation, we can draw the geodesic with a series of connected line segments by varying the parameter, t.</p>
<blockquote><p>Mathematical note &#8211; the parameterization given by this expression is highly non-uniform, meaning that there are many more points generated in some parts of the curve than in others. The mathematics of generating uniform ( or natural ) parameterizations belongs to the field of differential curve geometry and is beyond the scope of this article ( and my brain ).</p></blockquote>
<h2>Implementation notes</h2>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/geodesic/maps.jpg" title="The upper image shows what happens when aa curve wraps around the map boundary. The lower image shows the effect of splitting the curve at the boundary." class="thickbox" rel="singlepic141" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/index.php?callback=image&amp;pid=141&amp;width=150&amp;height=&amp;mode=" alt="Geodesic with Split" title="Geodesic with Split" />
</a>
 Inevitably, the mathematics alone is not sufficient to produce an implementation of a reuseable class for the Bing Silverlight control. There are two main issues to resolve; firstly, it is not immediately obvious how to derive from the provided <a title="Documentation on MapShapeBase from MSDN" href="http://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.core.mapshapebase.aspx" target="_blank"><code>MapShapeBase</code></a> class to create new shape overlays and secondly, how to handle drawing the curves when they &#8216;wrap&#8217; beyond the map&#8217;s viewable area ( this is easier to illustrate than to describe &#8211; see the figure opposite ).</p>
<h4>Inheriting from <code>MapShapeBase</code></h4>
<p>I must confess that I cheated slightly in implementing the <code>MapGeodesicPath</code> class, in that I used <a title="Reflector from Red-Gate. Stop sending them hate mail!" href="http://www.red-gate.com/products/reflector/" target="_blank">Reflector</a> to peer into the implementation of the base class. The existing derivations of this class simply defer to <code>MapShapeBase</code> for most of the work, which they can do since for a <code>MapPolygon</code> and <code>MapPolyline</code> there is a one-to-one relationship between <code>Locations</code>, latitude and longitude points on the map and <code>Points</code>, the actual 2D cartesian coordinates used to draw the shape. For the Geodesic, this is not the case, because we only want to specify the start and ending points of the curve, not every point in between. A solution is to delegate the point generation code to a secondary class, one that can be independently tested.</p>
<h4>Splitting the curves at the map boundary</h4>
<p>When the curves wrap around the map projection, they need to be split at the boundary. This is done by finding the parameter t for the longitude value of the boundary. Where the longitude value is +/- 180, this is straightforward as the equation above reduces to,<br />
<img src="http://www.planetmarshall.co.uk/wp-content/plugins/pm_latex/latexrender/pictures/ea9d5ccee06c0b25676cfd84e84b33be.png"><br />
For other longitude values, we simply offset the longitude values by the required amount, and calculate the value of t for the new matrix.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2010/06/drawing-geodesic-curves-using-the-bing-maps-silverlight-control/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Visualizing the Prime Ministerial Debates</title>
		<link>http://www.planetmarshall.co.uk/2010/04/visualizing-the-prime-ministerial-debates/</link>
		<comments>http://www.planetmarshall.co.uk/2010/04/visualizing-the-prime-ministerial-debates/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 08:30:19 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Imaging]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=805</guid>
		<description><![CDATA[For the first time, the main Prime Ministerial candidates for the 2010 UK General Elections, will take part in three live debates. Since the BBC have kindly made the full transcripts available, I decided to have a go at analyzing<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2010/04/visualizing-the-prime-ministerial-debates/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/brown_nouns.png" title="Nouns used by Gordon Brown in the first debate" class="thickbox" rel="singlepic131" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/131__140x_brown_nouns.png" alt="Nouns used by Gordon Brown" title="Nouns used by Gordon Brown" />
</a>

<p class="pm_first">For the first time, the main Prime Ministerial candidates for the 2010 UK General Elections, will take part in <a title="Debates page from the BBC" href="http://news.bbc.co.uk/1/hi/uk_politics/election_2010/the_debates/default.stm" target="_blank">three live debates</a>. Since the BBC have kindly made the full transcripts available, I decided to have a go at analyzing the data and creating a <a title="Jump to image gallery" href="#gallery" target="_self">visual representation</a> in the form of word clouds. I am currently working on my own visualization software, but in the meantime these have been done using <a title="Wordle" href="http://www.wordle.net/" target="_blank">Wordle</a>.</p>
<p>    <span id="more-805"></span><br />
<h3>Preparing the data</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/clegg_adj.png" title="Adjectives and Adverbs used by Nick Clegg in the first debate" class="thickbox" rel="singlepic138" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/138__140x_clegg_adj.png" alt="Adjectives and Adverbs used by Nick Clegg" title="Adjectives and Adverbs used by Nick Clegg" />
</a>
The BBC only provides the data in PDF form &#8211; to analyze it we need it in text form. Although this is easily done with Acrobat Reader&#8217;s &quot;Save as Text&quot; function, the output it produces is not really suitable for automatic processing, so some work has to be done by hand. This basically involves making sure each speaker&#8217;s comments are headed by their name and some kind of special character to split each record ( here I have used &#8216;@&#8217; ), which took about 15 minutes or so.</p>
<p><a title="First Prime Ministerial debate in raw text form" href="http://bit.ly/9QRrXx" target="_blank">Download </a>the raw text of the first debate.</p>
<p>Having done that, a command line tool such as <a href="http://www.gnu.org/manual/gawk/gawk.html" target="_blank">awk</a> can be used to split the data by speaker. For example, the following command outputs Clegg&#8217;s comments into a separate file:</p>
<pre class="brush: bash; title: ; notranslate">
awk 'BEGIN {RS=&quot;&quot;; FS=&quot;[@]&quot;} $1==&quot;NC&quot; { print $2 }' debate.txt &gt; clegg.txt
</pre>
<h3>Parsing the data</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/cameron_verbs.png" title="Verbs used by David Cameron in the first debate" class="thickbox" rel="singlepic137" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/137__140x_cameron_verbs.png" alt="Verbs used by David Cameron" title="Verbs used by David Cameron" />
</a>
<a title="Python homepage" href="http://www.python.org/" target="_blank">Python</a>&#8216;s <a title="The Natural Language Toolkit" href="http://www.nltk.org/" target="_blank">Natural Language Toolkit</a> provides all the functions needed to analyze the text data, such as tokenizing the text by word and even categorizing each word by type, such as proper nouns and prepositions. For example, having extracted Nick Clegg&#8217;s speech as above and read the file as a string using Python, the following commands parse the input for sentences, and then tokenize each word procucing a complete word list.</p>
<pre class="brush: python; title: ; notranslate">
from __future__ import division
import nltk, re, pprint

sentences = nltk.sent_tokenize(text)
tokens=[]
for s = sentences:
 tokens.extend(nltk.word_tokenize(s))
words=[t.lower() for t in tokens]
</pre>
<p>We can then categorize each word with a <a title="Wikipdeia page on POS tagging" href="http://en.wikipedia.org/wiki/Part-of-speech_tagging">POS tag</a> and extract a list appropriately, for example, using the word tokens above the following extracts all the nouns</p>
<pre class="brush: py; gutter: false; toolbar: false;"># this operation takes some time to execute
taggedwords=nltk.pos_tag(words)
nouns=[word for (word,tag) in words if t == 'NN']</pre>
<p>Such a list is enough to use with Wordle, however it&#8217;s straightforward to create a word frequency list for use with other software.</p>
<pre class="brush: python; title: ; notranslate">
nounfrequencies = nltk.FreqDist(nouns)
</pre>
<h3>Going further</h3>
<p>Word frequency analyses are fairly straightforward, however NLTK is a powerful library and allows for much more detailed and informative analysis based on grammar and sentence structure. It would be interesting to see the results of a more sophisticated approach.<br />
  <br /><a name="gallery"></a></p>
<h3>Gallery of word clouds from the first debate</h3>

<div class="ngg-galleryoverview" id="ngg-gallery-13-805">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.planetmarshall.co.uk/2010/04/visualizing-the-prime-ministerial-debates/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-131" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/brown_nouns.png" title="Nouns used by Gordon Brown in the first debate" class="thickbox" rel="set_13" >
								<img title="Nouns used by Gordon Brown" alt="Nouns used by Gordon Brown" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_brown_nouns.png" width="100" height="64" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-132" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/cameron_nouns.png" title="Nouns used by David Cameron in the first debate" class="thickbox" rel="set_13" >
								<img title="Nouns used by David Cameron" alt="Nouns used by David Cameron" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_cameron_nouns.png" width="100" height="64" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-133" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/clegg_nouns.png" title="Nouns used by Nick Clegg in the first debate" class="thickbox" rel="set_13" >
								<img title="Nouns used by Nick Clegg" alt="Nouns used by Nick Clegg" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_clegg_nouns.png" width="100" height="64" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-135" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/brown_verbs.png" title="Verbs used by Gordon Brown in the first debate" class="thickbox" rel="set_13" >
								<img title="Verbs used by Gordon Brown" alt="Verbs used by Gordon Brown" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_brown_verbs.png" width="100" height="64" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-137" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/cameron_verbs.png" title="Verbs used by David Cameron in the first debate" class="thickbox" rel="set_13" >
								<img title="Verbs used by David Cameron" alt="Verbs used by David Cameron" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_cameron_verbs.png" width="100" height="65" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-139" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/clegg_verbs.png" title="Verbs used by Nick Clegg in the first debate" class="thickbox" rel="set_13" >
								<img title="Verbs used by Nick Clegg" alt="Verbs used by Nick Clegg" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_clegg_verbs.png" width="100" height="65" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-134" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/brown_adj.png" title="Adjectives and Adverbs used by Gordon Brown in the first debate" class="thickbox" rel="set_13" >
								<img title="Adjectives and Adverbs used by Gordon Brown" alt="Adjectives and Adverbs used by Gordon Brown" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_brown_adj.png" width="100" height="63" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-136" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/cameron_adj.png" title="Adjectives and Adverbs used by David Cameron  in the first debate" class="thickbox" rel="set_13" >
								<img title="Adjectives and Adverbs used by David Cameron" alt="Adjectives and Adverbs used by David Cameron" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_cameron_adj.png" width="100" height="65" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-138" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/debates/clegg_adj.png" title="Adjectives and Adverbs used by Nick Clegg in the first debate" class="thickbox" rel="set_13" >
								<img title="Adjectives and Adverbs used by Nick Clegg" alt="Adjectives and Adverbs used by Nick Clegg" src="http://www.planetmarshall.co.uk/wp-content/gallery/debates/thumbs/thumbs_clegg_adj.png" width="100" height="65" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>


]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2010/04/visualizing-the-prime-ministerial-debates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Near Infra Red Pseudocolour using LAB Colour Separations</title>
		<link>http://www.planetmarshall.co.uk/2010/03/near-infra-red-pseudocolour-using-lab-colour-separations/</link>
		<comments>http://www.planetmarshall.co.uk/2010/03/near-infra-red-pseudocolour-using-lab-colour-separations/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 03:08:55 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Imaging]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=705</guid>
		<description><![CDATA[As 2010 is the 100th anniversary of the first published infra red photograph, I thought I&#8217;d try my hand using my own digital camera and some easily acquired accessories. If you want, you can skip the theory and go straight<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2010/03/near-infra-red-pseudocolour-using-lab-colour-separations/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/clare_lab.jpg" title="At the back of Clare College" class="thickbox" rel="singlepic124" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/124__120x_clare_lab.jpg" alt="At the back of Clare College" title="At the back of Clare College" />
</a>

<p class="pm_first">As 2010 is the <a title="BBC article on the history of Infra Red photography" href="http://www.bbc.co.uk/blogs/photoblog/2010/01/on_a_different_wavelength_100_years_of_infrared_ph.html" target="_blank">100th anniversary of the first published infra red photograph</a>, I thought I&#8217;d try my hand using my own digital camera and some easily acquired accessories. If you want, you can <a href="http://www.planetmarshall.co.uk/2010/03/near-infra-red-pseudocolour-using-lab-colour-separations/#method">skip</a> the theory and go straight to the description of the method and a script for Photoshop.</p>
<h3>A quick overview of IR photography</h3>
<p>The <a title="Wikipedia's entry on the Charge-Coupled Device" href="http://en.wikipedia.org/wiki/Charge-coupled_device" target="_blank">CCD</a> that is responsible for recording the images photographed by most digital cameras, is already sensitive to the near infra red part of the spectrum. That is, the part of the spectrum outside of the range visible to the human eye, but not so far as that used for, for example, thermal imaging. Since most photographers are not interested in light that they can&#8217;t see, this light is usually filtered out by an infra red <em>cutoff </em>filter placed inside the camera body, directly in front of the CCD. However, such filters are imperfect, so with some camera models by 
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/filters.png" title="CCD spectrum response" class="thickbox" rel="singlepic120" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/120__120x_filters.png" alt="CCD spectrum response" title="CCD spectrum response" />
</a>
 combining a long exposure with an infra red <em>transmitting </em>filter placed in front of the lens, some of that IR light can be recovered. The figure shows the basic principle, though I should add that the graphs are just a sketch to illustrate the principle and don&#8217;t represent an actual CCD response curve.</p>
<p><span id="more-705"></span></p>
<h3>Pseudocolour</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/irgreyscale.jpg" title="A greyscale representation of a Near Infra Red image" class="thickbox" rel="singlepic129" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/129__120x_irgreyscale.jpg" alt="A greyscale representation of a Near Infra Red image" title="A greyscale representation of a Near Infra Red image" />
</a>
Since IR light is invisible, some method is needed to represent it in terms of the colours that we can see. Typically, this is often done by simply mapping the intensities of the IR image to a greyscale, with the result being a black and white photo with a slightly surreal look. For my photographs, however, I wanted to try an alternative method.</p>
<h3>The LAB Colour Model</h3>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/lena_rgb.png" title="'Lena' with RGB colour separation" class="thickbox" rel="singlepic122" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/122__120x_lena_rgb.png" alt="'Lena' with RGB colour separation" title="'Lena' with RGB colour separation" />
</a>
The most common method of representing a colour image is by a combination of Red, Green and Blue &#8216;colour primaries&#8217;. The reason for this is simply because it then becomes relatively trivial to display an image using a video display, which also constructs an image using a combination of red, green and blue LEDs or phosphors. This is why such a model is known as a &#8216;device dependent&#8217; model. However, RGB is not the only colour model, and if you are at all familiar with Photoshop you may be aware of the LAB model.</p>
<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/lena_lab.png" title="'Lena' with Luminosity and Chromaticity colour separation" class="thickbox" rel="singlepic121" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/121__120x_lena_lab.png" alt="'Lena' with Luminosity and Chromaticity colour separation" title="'Lena' with Luminosity and Chromaticity colour separation" />
</a>
LAB, or <a title="Wikipedia's entry on the CIELAB colour space" href="http://en.wikipedia.org/wiki/Lab_color_space" target="_blank">CIELAB </a>to give it its full name, is a device independent model, which like RGB is composed of three components ( or channels ) but in this case only the &#8216;A&#8217; and &#8216;B&#8217; components contain colour information, whereas the &#8216;L&#8217; component contains pure luminosity information. Thus, by separating an image into LAB components it becomes possible to manipulate the luminosity and colour components of an image independently.<br />
<a name="method"></a></p>
<h3>Method and Implementation in Photoshop</h3>
<h4>Equipment</h4>
<ol>
<li>Canon G10 Digital Compact Camera</li>
<li>LA-DC58K lens adapter for same</li>
<li>Hoya R72 58mm Infra Red filter</li>
<li>Tripod</li>
<li>Photoshop ( or GIMP )</li>
</ol>
<p>The images in this post have been created from two source images, one a long exposure taken using the IR filter and the other a conventional colour image. Both images are converted into the LAB colour space, and a single image is then produced, using the Luminosity channel from the IR image and the &#8216;A&#8217; and &#8216;B&#8217; channels from the colour image. The photoshop script below will automate the process when applied to two source images, you can then manipulate the final image using the adjustment tools. You can also do much the same thing in GIMP using the Decompose/Compose features from the Colour menu, but it does not include Photoshop&#8217;s image registration or LAB colour adjustment features.</p>
<p>Download <a href="http://www.planetmarshall.co.uk/code/photoshop/ir_composite.jsx.zip">ir_composite.jsx.zip</a></p>
<p>To use the script, open the IR and corresponding colour image, and ensure that the IR image is selected. Then apply the script.</p>
<h3>Practicalities</h3>
<p>There are a number of limitations to multiple exposure photography methods such as this, especially ones which require long exposures and changes of camera equipment. It is best suited to landscape photography in good conditions where the multiple exposures can be easily aligned. If either image contains rapidly moving subjects these can ( and will ) show up as artefacts in the resulting image.</p>
<h3>Gallery</h3>

<div class="ngg-galleryoverview" id="ngg-gallery-12-705">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.planetmarshall.co.uk/2010/03/near-infra-red-pseudocolour-using-lab-colour-separations/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-123" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/backs.jpg" title="The back of the Cambridge colleges" class="thickbox" rel="set_12" >
								<img title="The back of the Cambridge colleges" alt="The back of the Cambridge colleges" src="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/thumbs/thumbs_backs.jpg" width="100" height="74" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-124" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/clare_lab.jpg" title="At the back of Clare College" class="thickbox" rel="set_12" >
								<img title="At the back of Clare College" alt="At the back of Clare College" src="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/thumbs/thumbs_clare_lab.jpg" width="92" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-125" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/clare_lb.jpg" title="At the back of Clare College. This image has had the 'a' chromaticity channel removed" class="thickbox" rel="set_12" >
								<img title="At the back of Clare College" alt="At the back of Clare College" src="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/thumbs/thumbs_clare_lb.jpg" width="92" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-126" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/garden.jpg" title="My back garden. This was the first image I created with this method." class="thickbox" rel="set_12" >
								<img title="My back garden" alt="My back garden" src="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/thumbs/thumbs_garden.jpg" width="80" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-127" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/kings.jpg" title="A view of the back of Kings College. This image has also had the 'a' channel removed." class="thickbox" rel="set_12" >
								<img title="A view of the back of Kings College" alt="A view of the back of Kings College" src="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/thumbs/thumbs_kings.jpg" width="100" height="74" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-128" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/river.jpg" title="Clare College from the River Cam." class="thickbox" rel="set_12" >
								<img title="Clare College from the River Cam." alt="Clare College from the River Cam." src="http://www.planetmarshall.co.uk/wp-content/gallery/infrared/thumbs/thumbs_river.jpg" width="100" height="74" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>


]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2010/03/near-infra-red-pseudocolour-using-lab-colour-separations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Winter Camping</title>
		<link>http://www.planetmarshall.co.uk/2010/01/winter-camping/</link>
		<comments>http://www.planetmarshall.co.uk/2010/01/winter-camping/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 00:53:58 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[Hiking]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Swimming]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=513</guid>
		<description><![CDATA[Last week myself and a group of friends took a winter camping trip up to the Lake District. An odd decision, it could be argued, seen as the region has recently seen both some of its worst flooding and coldest<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2010/01/winter-camping/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0310.JPG" title="Figured out the self timer" class="thickbox" rel="singlepic102" >
	<img class="ngg-singlepic ngg-left" src="http://www.planetmarshall.co.uk/index.php?callback=image&amp;pid=102&amp;width=120&amp;height=&amp;mode=" alt="Figured out the self timer" title="Figured out the self timer" />
</a>

<p class="pm_first">Last week myself and a group of friends took a winter camping trip up to the <a title="The Lake District National Park" href="http://www.lakedistrict.gov.uk" target="_blank">Lake District</a>. An odd decision, it could be argued, seen as the region has recently seen both some of its worst flooding and coldest winters in recent years.  Nonethless, equipped with ice axe, crampons and a generous supply of Kendal Mint Cake we set out to climb Scafell.</p>
<p><span id="more-513"></span></p>
<h3 class="pm_first">Some of the things I learned</h3>
<ol>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0299.JPG" title="Not the north face of the Eiger" class="thickbox" rel="singlepic98" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/index.php?callback=image&amp;pid=98&amp;width=120&amp;height=&amp;mode=" alt="" title="" />
</a>
</p>
<li>Elephants, though clearly signposted, are not common in the lake district. I didn&#8217;t see a single one all weekend. Sheep, however, are plentiful.</li>
<li>It may be effective as a deterrent against the <a title="Ravenous Bugblatter Beast of Traal" href="http://www.bbc.co.uk/dna/h2g2/A387029" target="_blank">Ravenous Bugblatter Beast of Traal</a>, but a towel is no replacement for an insulating mattress.</li>
<li>Pop up tents, though useful on the beach, are less effective in torrential rain and gale force winds.</li>
<li>Retracing your steps back through the snow sounds easy, and it probably is for other people.</li>
<li>The <a title="The Wasdale Head Inn" href="http://www.wasdaleheadinn.co.uk/home.html">Wasdale Head Inn</a> serves an excellent selection of whiskeys, of which <a title="Wikipedia's entry on Lagavulin." href="http://en.wikipedia.org/wiki/Lagavulin_Single_Malt" target="_blank">Lagavulin </a>is the best. I should know, I tried all of them.</li>
<li>Swimming in Wastwater in January is almost exactly as cold as you&#8217;d expect.</li>
</ol>
<h3 class="pm_first">The Route</h3>
<p>The map below, which requires <a title="Microsoft Silverlight" href="http://www.microsoft.com/SILVERLIGHT/" target="_blank">Microsoft Silverlight</a>, was exported from my <a title="Garmin Forerunner 305" href="https://buy.garmin.com/shop/shop.do?cID=142&amp;pID=349" target="_blank">GPS wristwatch</a> and shows the route we took up Scafell before visibility made further progress a bit risky, and so we retraced our steps back through the snow. Or at least tried to before our steps mysteriously disappeared. There is also a <a title="Photosynth of Scafell" href="http://photosynth.net/view.aspx?cid=4b895bbc-3e41-4957-a35f-b3fab7155bfc" target="_blank">Photosynth </a>from part of our route available.</p>
<p>[silverlight: osmap.xap,520,350,show]</p>
<h3>Swimming in Wastwater</h3>
<p>Although as an amateur triathlete I&#8217;ve done many open water swims, I&#8217;ve never done one in winter and never without a wetsuit. So, in an attempt to kill both birds with one stone I decided to go for a swim in Wastwater in January. I lasted about two minutes. I&#8217;m no <a title="Ice Swimmer Lewis Gordon Pugh" href="http://www.lewispugh.com/" target="_blank">Lewis Gordon Pugh</a>. It was cold, but it really wasn&#8217;t as bad as you might think.  The water was beautifully clear but unfortunately sharp rocks do not a beach make.</p>
<h3>Gallery</h3>

<div class="ngg-galleryoverview" id="ngg-gallery-9-513">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.planetmarshall.co.uk/2010/01/winter-camping/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-83" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0247.JPG" title="Dave and Lizzy on the way to the campsite" class="thickbox" rel="set_9" >
								<img title="Dave and Lizzy on the way to the campsite" alt="Dave and Lizzy on the way to the campsite" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0247.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-84" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0248.JPG" title="Jamie by Wastwater" class="thickbox" rel="set_9" >
								<img title="Jamie by Wastwater" alt="Jamie by Wastwater" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0248.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-85" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0253.JPG" title="View from the campsite" class="thickbox" rel="set_9" >
								<img title="View from the campsite" alt="View from the campsite" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0253.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-109" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0333.JPG" title="The campsite" class="thickbox" rel="set_9" >
								<img title="The campsite" alt="The campsite" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0333.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-86" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0260.JPG" title="The Wasdale Head Inn" class="thickbox" rel="set_9" >
								<img title="The Wasdale Head Inn" alt="The Wasdale Head Inn" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0260.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-87" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0261.JPG" title="Before the morning's walk" class="thickbox" rel="set_9" >
								<img title="Before the morning's walk" alt="Before the morning's walk" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0261.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-88" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0264.JPG" title="Some water" class="thickbox" rel="set_9" >
								<img title="Some water" alt="Some water" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0264.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-89" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0271.JPG" title="On the way up Scafell..." class="thickbox" rel="set_9" >
								<img title="On the way up Scafell..." alt="On the way up Scafell..." src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0271.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-90" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0274.JPG" title="...still on the way up Scafell" class="thickbox" rel="set_9" >
								<img title="...still on the way up Scafell" alt="...still on the way up Scafell" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0274.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-91" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0275.JPG" title="A look back over Wastwater" class="thickbox" rel="set_9" >
								<img title="A look back over Wastwater" alt="A look back over Wastwater" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0275.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-92" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0278.JPG" title="First glimpses of snow up Scafell" class="thickbox" rel="set_9" >
								<img title="First glimpses of snow up Scafell" alt="First glimpses of snow up Scafell" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0278.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-93" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0288.JPG" title="Starting to get serious" class="thickbox" rel="set_9" >
								<img title="Starting to get serious" alt="Starting to get serious" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0288.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-94" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0293.JPG" title="Touching the void" class="thickbox" rel="set_9" >
								<img title="Touching the void" alt="Touching the void" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0293.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-95" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0294.JPG" title=" " class="thickbox" rel="set_9" >
								<img title=" " alt=" " src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0294.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-96" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0295.JPG" title=" " class="thickbox" rel="set_9" >
								<img title=" " alt=" " src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0295.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-97" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0298.JPG" title="England, believe it or not." class="thickbox" rel="set_9" >
								<img title="England, believe it or not." alt="England, believe it or not." src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0298.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-98" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0299.JPG" title="Not the north face of the Eiger" class="thickbox" rel="set_9" >
								<img title=" " alt=" " src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0299.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-99" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0300.JPG" title=" " class="thickbox" rel="set_9" >
								<img title=" " alt=" " src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0300.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-100" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0303.JPG" title=" " class="thickbox" rel="set_9" >
								<img title=" " alt=" " src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0303.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-101" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0305.JPG" title="Getting to grips with the self timer." class="thickbox" rel="set_9" >
								<img title="Getting to grips with the self timer." alt="Getting to grips with the self timer." src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0305.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-102" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0310.JPG" title="Figured out the self timer" class="thickbox" rel="set_9" >
								<img title="Figured out the self timer" alt="Figured out the self timer" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0310.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-103" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0314.JPG" title="Stopping, briefly, for lunch." class="thickbox" rel="set_9" >
								<img title="Stopping, briefly, for lunch." alt="Stopping, briefly, for lunch." src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0314.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-104" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0316.JPG" title="Axe and cake" class="thickbox" rel="set_9" >
								<img title="Axe and cake" alt="Axe and cake" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0316.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-106" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0322.JPG" title="On the way down." class="thickbox" rel="set_9" >
								<img title="On the way down." alt="On the way down." src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0322.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-105" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0318.JPG" title="Andy looking down over Wasdale" class="thickbox" rel="set_9" >
								<img title="Andy looking down over Wasdale" alt="Andy looking down over Wasdale" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0318.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-115" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/img_0320.jpg" title="Dave surveys his domain" class="thickbox" rel="set_9" >
								<img title="Dave surveys his domain" alt="Dave surveys his domain" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_img_0320.jpg" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-107" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0327.JPG" title="A night heron." class="thickbox" rel="set_9" >
								<img title="A night heron." alt="A night heron." src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0327.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-108" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0329.JPG" title="Lakes wildlife" class="thickbox" rel="set_9" >
								<img title="Lakes wildlife" alt="Lakes wildlife" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0329.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-111" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0342.JPG" title="Wastwater" class="thickbox" rel="set_9" >
								<img title="Wastwater" alt="Wastwater" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0342.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-113" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/IMG_0345.JPG" title="Walking by Wastwater." class="thickbox" rel="set_9" >
								<img title="Walking by Wastwater." alt="Walking by Wastwater." src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_IMG_0345.JPG" width="64" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-79" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/DSC_0278.JPG" title="Preparing for a swim in Wastwater" class="thickbox" rel="set_9" >
								<img title="Preparing for a swim in Wastwater" alt="Preparing for a swim in Wastwater" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_DSC_0278.JPG" width="64" height="42" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-80" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/DSC_0279_1.JPG" title="Wastwater in winter" class="thickbox" rel="set_9" >
								<img title="Wastwater in winter" alt="Wastwater in winter" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_DSC_0279_1.JPG" width="64" height="52" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-81" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/DSC_0283.JPG" title="Wading in Wastwater" class="thickbox" rel="set_9" >
								<img title="Wading in Wastwater" alt="Wading in Wastwater" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_DSC_0283.JPG" width="64" height="42" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-82" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/DSC_0284.JPG" title="Swimming in Wastwater" class="thickbox" rel="set_9" >
								<img title="Swimming in Wastwater" alt="Swimming in Wastwater" src="http://www.planetmarshall.co.uk/wp-content/gallery/winter_camp/thumbs/thumbs_DSC_0284.JPG" width="64" height="42" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>


]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2010/01/winter-camping/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight and CUDA interop</title>
		<link>http://www.planetmarshall.co.uk/2010/01/silverlight-and-cuda-interop/</link>
		<comments>http://www.planetmarshall.co.uk/2010/01/silverlight-and-cuda-interop/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 02:11:58 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CUDA]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.planetmarshall.co.uk/?p=389</guid>
		<description><![CDATA[Update &#8211; source code now available Microsoft have recently released a beta of Silverlight 4, which has limited support for native interoperation using COM. Potentially, this example could be applied to any number of native interop scenarios, however for this<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.planetmarshall.co.uk/2010/01/silverlight-and-cuda-interop/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>
<a href="http://www.planetmarshall.co.uk/wp-content/gallery/cuda-interop/mandrill.jpg" title="mandrill" class="thickbox" rel="singlepic78" >
	<img class="ngg-singlepic ngg-right" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/78__x96_mandrill.jpg" alt="mandrill" title="mandrill" />
</a>
<br />
<em>Update &#8211; <a href="#source">source code</a> now available</em></p>
<p class="pm_first">Microsoft have recently released a beta of Silverlight 4, which has limited support for native interoperation using COM. Potentially, this example could be applied to any number of native interop scenarios, however for this example I have chosen to use Nvidia&#8217;s CUDA technology.</p>
<blockquote><p>Disclaimer : This is an example of what can be done, not necessarily, and in all likelihood, an example of how it should be done.</p></blockquote>
<h3>About CUDA</h3>
<p>Up until around 2001 PC graphics cards, though powerful, implemented a fixed function pipeline that limited use to whatever was exposed by the APIs, usually Direct3D or OpenGL. The addition of a programmable pixel pipeline led to the use of graphics cards for more general computation tasks; at first using shaders directly, followed by higher level GPU specific programming languages, such as Brook, SH, and later NVidia&#8217;s CUDA. Most of this work was, and is, documented by the <a title="GPGPU" href="http://gpgpu.org/" target="_blank">GPGPU</a> group. <a href="http://www.nvidia.com/object/cuda_home.html#" target="_blank">NVIDIA&#8217;s website</a> shows CUDA being used in a wide variety of applications but in practice it is best employed in so called &#8220;<a title="Wikipedia : Embarrassingly Parallel" href="http://en.wikipedia.org/wiki/Embarrassingly_parallel" target="_blank">embarassingly parallel</a>&#8221; problems.<br />
<span id="more-389"></span></p>
<h3>The demonstration application</h3>
<p>The demo below shows a Silverlight 4 beta application, which implements a recursive gaussian filter. Note that this is not the same algorithm provided by the sample in the CUDA SDK, but a more efficient method, which is described in detail in <a href="#young">[1]</a> for those interested. The main advantage of a filter implemented in this way is that the computation time is independent of the width of the filter.<br />
To enable CUDA interop, you&#8217;ll need a CUDA compatible graphics card. Then do the following,</p>
<ol>
<li>Install the MFC COM application (link below). The installer should register the application with COM automatically.</li>
<li>Right click on the Silverlight App and install it for running outside of the browser. The CUDA option should now be available from the Combo box.</li>
</ol>
<p>Source code : <a title="Download source code" href="http://planetmarshall.co.uk/silverlight/cuda_interop/SilverlightCudaInteropDemo.zip" name="source">SilverlightCudaInteropDemo.zip</a><br />
<a title="Install CUDA Server application" href="http://planetmarshall.co.uk/silverlight/cuda_interop/CudaServer.msi">Install MFC COM Application (5.5 Mb)</a><br />
[silverlight: cuda_interop/SlCudaInteropDemo.xap,520,580,false]</p>
<h3>The native component</h3>
<p>The native component takes the form of a COM Automation server, implemented as a client side MFC application.</p>
<blockquote><p>Note: Make sure you run Visual Studio with Administrator privileges, otherwise registering the automation server with COM will fail.</p></blockquote>
<p>MFC and Automation are beyond the scope of this article, but the basic process I followed was thus</p>
<ol>
<li>Create an MFC Dialog application using the Wizard. Make sure to enable Automation support</li>
<li>Add a method to the autmation interface using the add Method wizard from the Class View</li>
<li>Add a dual interface using this <a title="TN065: Dual-Interface Support for OLE Automation Servers" href="http://msdn.microsoft.com/en-us/library/4h56szat%28VS.100%29.aspx" target="_blank">Technical Note</a> from MSDN.</li>
<li>If you get link errors, make sure to include the output of MIDL in the application class ( the one that contains OnInitInstance). I couldn&#8217;t find any reference to this step, but it&#8217;s how the samples work.</li>
<li>Make sure that the run time library options passed to nvcc and msvc match, ie they should all use a DLL or Static linking, not a mixture of both</li>
<li>If you get stuck, take a look at the <a title="MFC Samples" href="http://msdn.microsoft.com/en-us/library/482ck6x8%28VS.100%29.aspx" target="_blank">MFC Samples</a>, particularly <a title="ACDUAL Sample: Adds Dual Interfaces to an Automation Application" href="http://msdn.microsoft.com/en-us/library/xfx55tf8%28VS.100%29.aspx" target="_blank">acdual</a>.</li>
</ol>
<p>when you pass a native array through COM Automation, it is converted to a <a title="Array Manipulation Functions from MSDN" href="http://msdn.microsoft.com/en-us/library/ms221145%28VS.100%29.aspx" target="_blank"><code>SAFEARRAY</code></a> on the native side. Note that I couldn&#8217;t find any documentation on this, I discovered it through experience. The code snippets below show sending and receiving array data between Silverlight and the MFC application.</p>
<pre class="brush: csharp; title: ; notranslate">
// note that ComAutomationFactory has become AutomationFactory
// in Silverlight 4 RC
dynamic cuda = AutomationFactory.CreateObject(&quot;CudaServer.Application&quot;);
float[] data = new [] {1.0f, 3.14f };
dynamic retData = cuda.Process( data );
// retData is a managed float array
</pre>
<pre class="brush: cpp; title: ; notranslate">
VARIANT CCudaServer::Process(VARIANT &amp;amp;data)
{
  SAFEARRAY *pSrcData =  data.parray;

  // this will copy the safe array into the variant
  CComVariant var(pSrcData);

  // when we return the VARIANT containing the SAFEARRAY
  // it will be marshaled to Silverlight as a managed array
  VARIANT retVal;
  VariantInit( &amp;amp;retVal );
  var.Detach( &amp;amp;retVal );
  retVal.vt = VT_ARRAY | VT_R4;
  return retVal;
}
</pre>
<h3>Using MEF to implement the application</h3>
<p>The <a title="Managed Extensibility Framework at Codeplex" href="http://www.codeplex.com/MEF" target="_blank">Managed Extensibility Framework</a> is an extensible plugin framework for .NET applications and Silverlight. I have used it to dynamically discover implementations of <code>IProcessorProvider</code> based on the permissions available to the Silverlight application. The figure below shows the component structure of the application.</p>

<a href="http://www.planetmarshall.co.uk/wp-content/gallery/cuda-interop/slcuda_component.png" title="Component diagram for demo application" class="thickbox" rel="singlepic77" >
	<img class="ngg-singlepic" src="http://www.planetmarshall.co.uk/wp-content/gallery/cache/77__475x_slcuda_component.png" alt="slcuda_component" title="slcuda_component" />
</a>

<h3>Performance notes</h3>
<h4>Silverlight</h4>
<p>Unlike the <a title="My Reaction-Diffusion simulator" href="http://www.planetmarshall.co.uk/index.php/2009/03/reaction-diffusion-models/">Reaction Diffusion simulation</a>, for this application I have chosen to use Silverlight&#8217;s <a title="WirteableBitmap in Silverlight 3, from MSDN" href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap%28VS.95%29.aspx" target="_blank"><code>WriteableBitmap</code></a>, introduced in Silverlight 3, rather than <a title="Joe Stegman's PNG Encoder for Silverlight" href="http://blogs.msdn.com/jstegman/archive/2008/04/21/dynamic-image-generation-in-silverlight.aspx" target="_blank">dynamic PNG encoding</a>. This revealed an interesting performance issue when using a typical double loop to iterate over the pixels. Initial timings revealed that the vast majority of the time was spent in updating the <code>WriteableBitmap</code> rather than actually performing the image processing. The initial update loop used the <code>PixelWidth</code> and <code>PixelHeight</code> properties to bound the loop counters, taking about 200ms to iterate over the loop.</p>
<pre class="brush: csharp; title: ; notranslate">
for (int j = 0; j &amp;lt; bmp.PixelHeight; ++j)
{
  for (int i = 0; i &amp;lt; bmp.PixelWidth; ++i)
  {
     // update pixels
   }
}
</pre>
<p>By caching the bitmap properties in local variables, the timing was reduced to ~5ms. Needless to say I was shocked by how much of a difference such a seemingly trivial change made.</p>
<pre class="brush: csharp; title: ; notranslate">
int pxWidth =  bmp.PixelWidth;
int pxHeight = bmp.PixelHeight;
for (int j = 0; j &amp;lt; pxHeight; ++j)
{
  for (int i = 0; i &amp;lt; pxWidth; ++i)
  {
     // update pixels
   }
}
</pre>
<h4>OLE Automation</h4>
<p>The guidelines for building performant automation code is much the same as that for other unmanaged interop scenarios in .NET : avoid chatty interfaces. Note that this is exactly what I have not done here. In fact, the time it takes CUDA to perform the image processing is dwarfed by the time it takes to marshal the data between Silverlight and COM. This can be mitigated somewhat by splitting the blur call into two operations, one to load the image, which is called only upon initialization, and one to perform the blur.</p>
<h4>CUDA</h4>
<p>CUDA operations are extremely sensitive to data alignment and the order in which threads access data. Kernels should be written in such a way that threads access adjacent data elements, meaning that the row major access pattern familiar to C and C# developers would produce suboptimal performance ( sometimes by as much as an order of magnitude ). Instead, array accesses should be performed in a manner more reminiscent of FORTRAN. In addition, 2D arrays should be padded out so that threads access data elements that are correctly aligned ( see the CUDA documentation for the correct alignment values ). A full exposition of performance optimization for CUDA is really beyond the scope of this article, there are many examples in the <a title="Learn More about CUDA - NVIDIA" href="http://www.nvidia.com/object/cuda_education.html" target="_blank">NVIDIA documentation</a> although the terminology can be somewhat opaque. One of the clearest explanations I have found is this <a title="Supercomputing 2007 CUDA Tutorial" href="http://gpgpu.org/sc2007" target="_blank">presentation </a>from Mark Harris at Supercomputing 2007.</p>
<pre class="brush: cpp; title: ; notranslate">
__global__ void kernel( float *destData, float *srcData, int stride, int height )
{
  // suboptimal access. Each thread accesses elements
 // in a striding pattern
  int rowStart = (blockDim.x*blockIdx.x+threadIdx.x)*stride;
  for ( int i = rowStart; i &amp;lt; rowStart+stride; ++i ) {
    destData[i] = srcData[i];
  }
}
</pre>
<pre class="brush: cpp; title: ; notranslate">
__global__ void kernel( float *destData, float *srcData, int stride, int height )
{
  // optimal access pattern, each thread accesses adjacent elements
  int colStart = blockDim.x*blockIdx.x+threadIdx.x;
  // this case, 16*sizeof(float)= 64 bytes
  for ( int i = colStart ; i &amp;lt; colStart+(stride*height); i+=stride ) {
    destData[i] = srcData[i];
  }
}
</pre>
<h3>References</h3>
<ol>
<li><span class="p1"><a name="young"></a>Young, I.T. &amp; van Vliet,L.J, 1995. <a title="Recursive Implementation of the Gaussian Filter" href="http://www.sciencedirect.com/science?_ob=ArticleURL&amp;_udi=B6V18-3YS90HC-D&amp;_user=10&amp;_coverDate=06%2F30%2F1995&amp;_rdoc=2&amp;_fmt=high&amp;_orig=browse&amp;_srch=doc-info%28%23toc%235668%231995%23999559997%23172292%23FLP%23display%23Volume%29&amp;_cdi=5668&amp;_sort=d&amp;_docanchor=&amp;_ct=11&amp;_acct=C000050221&amp;_version=1&amp;_urlVersion=0&amp;_userid=10&amp;md5=cdfad44c178fc20739d26562c5f26e04" target="_blank">Recursive implementation of the Gaussian filter</a>. <em>Signal Processing</em>, 44, pp.139-151. </span></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.planetmarshall.co.uk/2010/01/silverlight-and-cuda-interop/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
