<?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>I Drivel &#187; python</title>
	<atom:link href="http://blog.justinlintz.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justinlintz.com</link>
	<description>whatever comes to mind</description>
	<lastBuildDate>Wed, 12 Oct 2011 01:37:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Determining my most used focal length in photos with python and dcraw</title>
		<link>http://blog.justinlintz.com/2010/12/determining-my-most-used-focal-length-in-photos-with-python-and-dcraw/</link>
		<comments>http://blog.justinlintz.com/2010/12/determining-my-most-used-focal-length-in-photos-with-python-and-dcraw/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 05:52:50 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.justinlintz.com/?p=138</guid>
		<description><![CDATA[<p>For the holidays I got a new Canon 7D camera. I&#8217;ve been saving quite a few amazon gift cards over the last year that I was previously planning on using towards purchasing the camera but thankfully Santa delivered me one. My current lens collection consists of </p> 10-22mm f/3.5-4.5 70-200mm f/4 50mm f/1.8 18-55mm <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.justinlintz.com/2010/12/determining-my-most-used-focal-length-in-photos-with-python-and-dcraw/">Determining my most used focal length in photos with python and dcraw</a></span>]]></description>
			<content:encoded><![CDATA[<p>For the holidays I got a new <a href="http://www.usa.canon.com/cusa/consumer/products/cameras/slr_cameras/eos_7d">Canon 7D</a> camera.  I&#8217;ve been saving quite a few amazon gift cards over the last year that I was previously planning on using towards purchasing the camera but thankfully Santa delivered me one.  My current lens collection consists of </p>
<ul>
<li><a href="http://www.usa.canon.com/cusa/consumer/products/cameras/ef_lens_lineup/ef_s_10_22mm_f_3_5_4_5_usm">10-22mm f/3.5-4.5</a></ul>
<ul>
<li><a href="http://www.usa.canon.com/cusa/consumer/products/cameras/ef_lens_lineup/ef_70_200mm_f_4l_usm">70-200mm f/4</a></ul>
<ul>
<li><a href="http://www.usa.canon.com/cusa/consumer/products/cameras/ef_lens_lineup/ef_50mm_f_1_8_ii">50mm f/1.8</a></ul>
<ul>
<li><a href="http://www.usa.canon.com/cusa/support/consumer/eos_slr_camera_systems/lenses/ef_s_18_55mm_f_3_5_5_6_usm">18-55mm f/3.5-5.6</a> (kit lens)</ul>
<p>The lens collection has been built over the last 4 years from when I first got my <a href="http://www.usa.canon.com/cusa/support/consumer/eos_slr_camera_systems/eos_digital_slr_cameras/digital_rebel_xt">Canon Rebel XT</a> and I&#8217;ve been fairly happy with them thus far.  As part of looking into what new lens to get I wanted to know what focal length I shot with the most over the previous years.  A quick look with</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-type</span> f <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.CR2'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-l</span></div></div>
<p>shows I have 4697 RAW images in my photos folder, so I&#8217;ll need some sort of automated solution to figure this out.</p>
<p>My first inclination was to poke around Python&#8217;s PIL and see if it supported reading of RAW images, it didn&#8217;t appear to do so that option was out.  I looked at the Canon RAW format at <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/canon_raw.html">http://www.sno.phy.queensu.ca/~phil/exiftool/canon_raw.html</a> and contemplated doing some parsing of the files to extract the info I needed from the EXIF data.  I remembered in the past I had used <a href="http://ufraw.sourceforge.net/">UFRaw</a> to play around with RAW conversion in Linux a while back and saw they are using a nice simple tool to do their RAW parsing called <a href="http://www.cybercom.net/~dcoffin/dcraw/">dcraw</a>.  It&#8217;s a small C program that I was able to compile the source with the following commands&#8230;</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> libjpeg-dev liblcms-dev <br />
<span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-o</span> dcraw <span style="color: #660033;">-O4</span> dcraw.c <span style="color: #660033;">-lm</span> <span style="color: #660033;">-ljpeg</span> <span style="color: #660033;">-llcms</span></div></div>
<p>Using dcraw seemed like the path of least resistance and now I just needed to wrap some code around it to go through all of my RAW images and extract the EXIF info and keep a hash table of the focal length value.  I whipped up a small python script and posted a gist of it over on github.<br />
<script src="http://gist.github.com/756716.js"></script><br />
It&#8217;s fairly straight forward and could easily be modified to do more, like collect aperture sizes or any other EXIF data.  I may go back and build it out a bit more to make it more flexible in what data it collects, but for now this suited my needs at the time.  My top 10 focal lengths ended up being</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Total pics to process: <span style="color: #000000;">4697</span><br />
Length: <span style="color: #000000;">50.0</span> &nbsp;, Count: <span style="color: #000000;">1624</span><br />
Length: <span style="color: #000000;">22.0</span> &nbsp;, Count: <span style="color: #000000;">576</span><br />
Length: <span style="color: #000000;">18.0</span> &nbsp;, Count: <span style="color: #000000;">423</span><br />
Length: <span style="color: #000000;">200.0</span> &nbsp;, Count: <span style="color: #000000;">404</span><br />
Length: <span style="color: #000000;">55.0</span> &nbsp;, Count: <span style="color: #000000;">373</span><br />
Length: <span style="color: #000000;">10.0</span> &nbsp;, Count: <span style="color: #000000;">192</span><br />
Length: <span style="color: #000000;">70.0</span> &nbsp;, Count: <span style="color: #000000;">176</span><br />
Length: <span style="color: #000000;">37.0</span> &nbsp;, Count: <span style="color: #000000;">74</span><br />
Length: <span style="color: #000000;">16.0</span> &nbsp;, Count: <span style="color: #000000;">33</span></div></div>
<p>Takes close to 11 seconds on average to calculate that for 4697 images.  </p>
<p>I had been wanting to upgrade my 50mm f/1.8 lens for a bit as I&#8217;d really started to notice the short comings of it.  The lens has a hard time focusing and also had a bit of a back focusing issue.  Since my Uncle borrows my camera a lot when he goes on vacation I worked out a deal with him to purchase the 50mm f/1.4 for me and in exchange I&#8217;d give him my old Canon Rebel XT with the kit lens and the 50mm f/1.8 lens.  </p>
<p>The kit lens was a great walk about lens so I&#8217;m currently trying to decide on a good and reasonably priced lens to cover somewhere in the 18-100mm range. I&#8217;m reading through a bunch of comments on amazon reviews and dpreview forums to figure out what my best bang for my buck would be for a lens in that range.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justinlintz.com/2010/12/determining-my-most-used-focal-length-in-photos-with-python-and-dcraw/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python pip on Ubuntu Lucid Lynx</title>
		<link>http://blog.justinlintz.com/2010/09/python-pip-on-ubuntu-lucid-lynx/</link>
		<comments>http://blog.justinlintz.com/2010/09/python-pip-on-ubuntu-lucid-lynx/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 04:48:24 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.justinlintz.com/?p=135</guid>
		<description><![CDATA[<p>Lately I&#8217;ve been reading up on Django a bit in an effort to get back into programming.  It seems the preferred way of running Django is inside a virtualenv environment.  I try to stick to packages when possible for installing applications and saw that the python-virtualenv package wasn&#8217;t too far behind at version 1.4.5, <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.justinlintz.com/2010/09/python-pip-on-ubuntu-lucid-lynx/">Python pip on Ubuntu Lucid Lynx</a></span>]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been reading up on Django a bit in an effort to get back into programming.  It seems the preferred way of running Django is inside a <a href="http://pypi.python.org/pypi/virtualenv">virtualenv</a> environment.  I try to stick to packages when possible for installing applications and saw that the python-virtualenv package wasn&#8217;t too far behind at version 1.4.5, where the latest is at 1.5.1.  This appeared at first to suit me just fine until I discovered the version of pip that gets installed along with python-virtualenv is at 0.3.1, where the latest is at 0.8.1.  The version of pip installed is so old that it doesn&#8217;t have support for the &#8220;uninstall&#8221; command yet, blech.  Luckily you can do the following from within pip to upgrade itself</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> pip <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">--upgrade</span> pip</div></div>
<p>Now back to reading about setting up a virtualenv environment</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justinlintz.com/2010/09/python-pip-on-ubuntu-lucid-lynx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python Quote module</title>
		<link>http://blog.justinlintz.com/2010/01/python-quote-module/</link>
		<comments>http://blog.justinlintz.com/2010/01/python-quote-module/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 05:38:37 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.justinlintz.com/?p=81</guid>
		<description><![CDATA[<p>Over the past couple of years I&#8217;ve been wanting to learn Python more seriously but really haven&#8217;t sat down and just done it.   I&#8217;ve written a couple of various scripts for personal and work use but always felt they weren&#8217;t coded in a &#8220;pythonic&#8221; way.  I&#8217;m now reading Learning Python (4th edition) from the <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.justinlintz.com/2010/01/python-quote-module/">Python Quote module</a></span>]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of years I&#8217;ve been wanting to learn Python more seriously but really haven&#8217;t sat down and just done it.   I&#8217;ve written a couple of various scripts for personal and work use but always felt they weren&#8217;t coded in a &#8220;pythonic&#8221; way.  I&#8217;m now reading <a href="oreilly.com/catalog/9780596158071">Learning Python (4th edition)</a> from the beginning and making sure I learn things properly from the ground up.  When I was writing my code in the past I wasn&#8217;t aware of what objects were immutable vs mutable or how generators worked.  I basically knew what I wanted to accomplish before writing my code and would reference the online documentation and just go at it.  Overtime I picked up on some &#8220;pythonic&#8221; methods from looking at code examples, for example, using optparse for handling arguments passed into your program.</p>
<p>My first project I decided to tackle as I go through my book is writing a module that will fetch stock quotes from Yahoo&#8217;s Finance page and store them in memcached.  I just pushed it out to github available @ <a href="http://github.com/jlintz/python_quote">http://github.com/jlintz/python_quote</a>.  I&#8217;m hoping to get some feedback from some people on where I can improve in my code and hopefully it will be useful to someone else out there.  As I go through the book I plan on going back and looking at the code and see what I can refactor and I&#8217;m sure along the way I&#8217;ll probably re-architect things.</p>
<p>One thing I know I need to do is write some unit tests for the module.   When I was in my Computer Science program in college, we really never had any exposure to unit tests.  The unit tests consisted of assert statements and really never had any real lessons on them.  I need to do more reading on <a href="http://docs.python.org/library/unittest.html">unittest</a>.  I know many developers write their unit tests first before writing a single line of code in a test driven development approach.  It&#8217;s something I want to look at more and see if I should consider picking that up.</p>
<p>Also as part of this coding project, it was a good excuse to get some exercise with <a href="http://git-scm.com/">Git</a>.  It&#8217;s pretty easy to work with and I haven&#8217;t even scratched the surface of its potential.  I just need to begin looking at some of its more advanced features and incorporating them into my work flow.</p>
<p>Vim is another program I&#8217;m getting some finger exercise in.  When I started my job 3 years ago I had never really opened Vim/Vi but one day forced myself to learn it because as a sysadmin, Vi will always be there for you, <a href="http://www.familyguyquotes.com/quotes/695.html">like your friend Stewie</a>.  In my day to day uses of Vi, I just used the basics, hjkl and :wq.  Slowly I picked up some commands from co-workers and got used to using them daily.  When writing code in Vim , there are a lot of tricks and commands to aide you in writing code , I&#8217;ve read about many but now it&#8217;s a matter of incorporating them so I don&#8217;t have to think much and breaking my old habits to use the new commands I&#8217;ve read about.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justinlintz.com/2010/01/python-quote-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

