<?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>LogicalChaos</title>
	<atom:link href="http://logicalchaos.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://logicalchaos.org/blog</link>
	<description></description>
	<lastBuildDate>Thu, 24 Feb 2011 04:43:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Calculating wind chill with RRDTool</title>
		<link>http://logicalchaos.org/blog/2011/01/calculating-wind-chill-with-rrdtool/</link>
		<comments>http://logicalchaos.org/blog/2011/01/calculating-wind-chill-with-rrdtool/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 04:17:54 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[weather]]></category>

		<guid isPermaLink="false">http://logicalchaos.org/blog/?p=95</guid>
		<description><![CDATA[How to calculate wind chill using wind speed and temperature in rrd. <a href="http://logicalchaos.org/blog/2011/01/calculating-wind-chill-with-rrdtool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In the process of switching over my <a href="http://www.gnuplot.info/">Gnuplot</a> <a href="http://www.logicalchaos.org/weather/gnuplot/minute.html">graphs</a> to <a href="http://www.mrtg.org/rrdtool/">RRD</a>, I needed to re-do the SQL function I used for calculating <a href="http://en.wikipedia.org/wiki/Wind_chill">wind chill</a> into RPN notation.  Quite straight forward in sql:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><br />
<span class="kw1">CREATE</span> <span class="kw1">OR</span> <span class="kw1">REPLACE</span> <span class="kw1">FUNCTION</span> apparent_temp<span class="br0">&#40;</span> float<span class="sy0">,</span> float<span class="sy0">,</span> float <span class="br0">&#41;</span><br />
RETURNS float <span class="kw1">AS</span> <span class="st0">&#8216;<br />
DECLARE<br />
tempf &nbsp;ALIAS FOR $1;<br />
relh &nbsp; ALIAS FOR $2;<br />
speed &nbsp;ALIAS FOR $3;<br />
aptemp &nbsp;float;<br />
BEGIN<br />
IF tempf &amp;gt;= 80 AND relh &amp;gt;= 40 THEN<br />
aptemp = -42.379 + 2.04901523*tempf + 10.14333127*relh<br />
- 0.22475541*tempf*relh &#8211; 0.00683783*(tempf^2)<br />
- 0.05481717*(relh^2) + 0.00122874*(tempf^2)*relh<br />
+ .00085282*tempf*(relh^2) &#8211; 0.00000199*(tempf^2)*(relh^2);<br />
ELSIF speed &amp;gt;= 3 AND tempf &amp;lt;= 50 THEN<br />
aptemp = &nbsp; 35.74 + .6215*tempf &#8211; 35.75*(speed^.16)<br />
+ .4275*tempf*(speed^.16);<br />
ELSE<br />
aptemp = tempf;<br />
END IF;<br />
RETURN aptemp;<br />
END;<br />
&#8216;</span> <span class="kw1">LANGUAGE</span> plpgsql IMMUTABLE STRICT;</div>
</div>
<p>Could not find anything quickly in Google for doing this in RRD, so I had to think on my own.  The calculation is not quite as obvious in RRD RPN notation, but doable.  It&#8217;s complicated by not having the power function in RRD:</p>
<div class="codesnip-container" ><span style="font-size: x-small;">DEF:ot=weather.rrd:outsidetemp:AVERAGE<br />
DEF:ws=weather.rrd:windspeedaverage1:AVERAGE<br />
CDEF:chill=ot,50,GE,ot,ws,3,LE,ot,35.74,.6215,ot,*,+,ws,LOG,.16,*,EXP,DUP,ot,*,.4275,*,EXC,35.75,*,-,+,IF,IF</span></div>
<p><a rel="attachment wp-att-106" href="http://logicalchaos.org/blog/2011/01/calculating-wind-chill-with-rrdtool/outsidetemp_24hours-2/"><img class="alignright size-medium wp-image-106" title="Temperature with wind chill" src="http://logicalchaos.org/blog/wp-content/uploads/2011/01/outsidetemp_24hours1-300x98.png" alt="" width="300" height="98" /></a><br />
<em><strong>ot</strong></em> &#8211; outside temperature in fahrenheit<br />
<em><strong>ws</strong></em> &#8211; windspeed in miles per hour<br />
This calculation will present the current temperature if the temperature is &gt; 50 degrees fahrenheit or the windspeed &lt; 3 mph.</p>
<p>Heat index comes next.</p>
]]></content:encoded>
			<wfw:commentRss>http://logicalchaos.org/blog/2011/01/calculating-wind-chill-with-rrdtool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

