<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Steven Mosher&#039;s Blog</title>
	<atom:link href="http://stevemosher.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://stevemosher.wordpress.com</link>
	<description>Creative License</description>
	<lastBuildDate>Wed, 04 Jan 2012 10:05:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='stevemosher.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Steven Mosher&#039;s Blog</title>
		<link>http://stevemosher.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://stevemosher.wordpress.com/osd.xml" title="Steven Mosher&#039;s Blog" />
	<atom:link rel='hub' href='http://stevemosher.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Climate Reference Network:  package crn 1.0</title>
		<link>http://stevemosher.wordpress.com/2011/09/21/climate-reference-network-package-crn-1-0/</link>
		<comments>http://stevemosher.wordpress.com/2011/09/21/climate-reference-network-package-crn-1-0/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 04:33:39 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=1059</guid>
		<description><![CDATA[I&#8217;ve just finished and uploaded another climate data package for R. This one focuses on  CRN the climate Reference Network Here is their home page &#160; The package for now is really simple, but all of the packages  I&#8217;m building are getting simpler. In the end ( whenever that is ) I think I&#8217;ll end [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1059&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished and uploaded another climate data package for R. This one focuses on  CRN the climate Reference Network</p>
<p>Here is their <a href="http://www.ncdc.noaa.gov/crn/">home page</a></p>
<p><img class="aligncenter" src="http://www.ncdc.noaa.gov/crn/site-image.jpg" alt="" width="720" height="282" /></p>
<p>&nbsp;</p>
<p>The package for now is really simple, but all of the packages  I&#8217;m building are getting simpler. In the end ( whenever that is ) I think I&#8217;ll end up with a host of packages that manage the downloading of data and the formating of it into &#8220;analysis friendly&#8221; formats.  The CRN posed an interesting challenge. They have hourly data and  over 30 measurands.  Going forward I&#8217;m seeing a collection of packages that looks like this: a series of packages that takes online climate data and reformats it into some standard formats that a few of us have been converging on.  In an OOP design they will become the core objects. Then we have a series of functions for doing basic spatial and time series stats, and we have our spatial tools and Time series tools.  Here is the package line up as of today</p>
<p>1. RghcnV3:   data formation and analysis</p>
<p>2. CHCN ( enviroment canada data )</p>
<p>3. Ghcndaily:  ghcn daily data</p>
<p>4. crn : climate reference network</p>
<p>5. Metadata.</p>
<p>Over time the goal will be to refactor RghcnV3 and strip out the analysis part of it into a separate package. All the data formating packages thus would have a common set of formats and objects and then analysis code would be written as methods on that.. eh well thats the dream</p>
<p>So here is what you can do with the crn package today. There are 3 core functions:  downloadCRN, collate*, and writeDataset().  The download function does all the heavy lifting to download both daily and hourly data from CRN. Data starts in the year 2000 and extend to today. The downloadCRN function uses RCurl to get the directory listings from the ftp and create the download lists. Then the process of downloading the 1000 + files starts.</p>
<p>The function lets you control whether you want daily files or hourly. I just get both.  the data comes in station files. One file for every station for every year.  The  next step  we take is to collate these files into one monolithic file. One file that contains the data for all the stations. For daily data we use collateDaily() and for hourly data we use collateHourly().  These functions have two side effects. They write a consolidated datafile and a metadata file that records station names, lat/lon and Id number. In the case of the hourly data this file is quite large over 1GB. Moreover the file contains all the variables:  T min, tmax, solar radiation, soil temperatures.  The last function turns these monolithic files into what we are used to. Files with one variable for all stations.  That function is  writeDataset(). The function operates on either hourly or daily files and collects  a single variable such as T_MEAN.  the function is defined like so</p>
<p>writeDataset(filename, cnames = colnamesDaily, varname = &#8220;T_DAILY_MEAN&#8221;)</p>
<p>The first variable filename  is supplied to point to either the monolithic daily data or hourly data. the next variable &#8220;cnames&#8221;  points to the column names of the dataset. These are predefined as constants for the package. the last variable &#8220;varname&#8221; is the variable you want to collect. When you run this function the side effect is a file is written contain all the T_DAILY_MEAN data for every station. Effectively the package allows you to download the CRN data and build subsets of data from the huge collection. There are over 30 climate variables available, so I constructed the tool so that you can build datasets from the source data.</p>
<p>Version 1.0 is posted to CRAN, should be up shortly.  In the next installment I&#8217;ll probably add support for &#8220;zoo&#8221; objects and function to create daily from hourly and monthly from daily. At that point it will be fully integrated with the RghcnV3 data structures</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/1059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/1059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/1059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/1059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/1059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/1059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/1059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/1059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/1059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/1059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/1059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/1059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/1059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/1059/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1059&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/09/21/climate-reference-network-package-crn-1-0/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>

		<media:content url="http://www.ncdc.noaa.gov/crn/site-image.jpg" medium="image" />
	</item>
		<item>
		<title>rgdal + raster + RCurl = My next package</title>
		<link>http://stevemosher.wordpress.com/2011/09/19/rgdal-raster-rcurl-my-next-package/</link>
		<comments>http://stevemosher.wordpress.com/2011/09/19/rgdal-raster-rcurl-my-next-package/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 04:40:02 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=1053</guid>
		<description><![CDATA[UPDATE:  uploaded  Metadata 1.0 to CRAN this  am. So quick demos when it hits This package has been a long time in the making.  In the end it&#8217;s more of a data package than a functional package, but pulling all the pieces together required me to learn some really cool packages: raster ( which I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1053&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>UPDATE:  uploaded  Metadata 1.0 to CRAN this  am.</p>
<p>So quick demos when it hits</p>
<p>This package has been a long time in the making.  In the end it&#8217;s more of a data package than a functional package, but pulling all the pieces together required me to learn some really cool packages: raster ( which I already knew ) rgdal and RCurl.  I&#8217;ll provide a littlebit of an overview of what comes together on this package and why I built it, and then maybe some future directions.</p>
<p>In the course of looking at climate stations and the question of UHI I got kinda fascinated with the question of metadata: the variables that describe a stations location and physical features.  The goal of the project was to assemble a somewhat complete set of datasets to describe the geographical conditions of  any climate station.  I set out some requirements, first and foremost I wanted to use data that was open and not behind registration walls. That way I can write code to simply go get the data, download it and unpack it for the package user. I failed. In the end I ended up with a few datasets that require minimal registration headaches. I think with some help from RCurl experts I could tackle most of those issues. we will see.  Lets start by canvasing all the datasets I collected</p>
<p>1. GHRSST distance from coast dataset.  This 1km resolution file gives you the distance from the coast for all bodies of water.</p>
<p>2. NASA distance from Coast. This 1km dataset gives you distance from coast for  sea pixels only.</p>
<p>Dataset 1 and 2 along with some other files can be used to create a 1km land mask. Here I use them to tell if a station is on the coast or not.</p>
<p>3. Nightlights data.  radiance calibrated nightlights from  DSMP. a 1km dataset of radiance calibrated nightlights. This is the latest and greatest nightlights data with a much larger dynamic range than other products.</p>
<p>4. Impervious surface data. another 1km data product of impervious surfaces</p>
<p>5. Airports. 40K plus airport locations are rasterized into a 1km raster.  When I get time I&#8217;ll turn this into a distance map ( one call in raster) so that each cell contains distance to the nearest airport.</p>
<p>6. Harmonized Land Use data.  The package build a raster brick from 7 land use files  at 5 minutes resolution: urban land, cultivated land,irrigated land, rain irrigated land, forest, sparse vegetation, grassland.</p>
<p>7. Bluewater irrigation in 5 minute resolution: The amount of bluewater used for irrigation on the croplands in the grid.</p>
<p>8. Modis urban extent. 500 meter data. This file  requires registration and permission from the PI. Its freely given and I really wanted to use the new Moid data</p>
<p>7. Landcover. This is a previous Modis product that also requires registration, but its painless. Also cool because the data is in 72 tiles</p>
<p>8. Hyde population. Historical population density in 5 minute resolution. Also rural population counts and urban population counts. This requires regsitration</p>
<p>9. GPW population. Gridded population of the world in 2.5 minute resolution. Requires registration.</p>
<p>10. Grump urban extent. Urban extent at 1km resolution. requires registration.</p>
<p>With the exception of Modis I&#8217;m pretty sure if I were better with RCurl I could get those to download by filling in the registration forms programatically. Hyde is also easy except the server likes to download incomplete files and I should probably work on that a bit. For now, you have to download a few of the files manually.</p>
<p>The package has just a couple core functions that are tied to these files. The functions are primarily for doing complilations of datasets. The first function createRasters() just does the work of reading in files and creating native raster files. So for Hyde, ISA, landcover, airports, and Modis, I found it beneficial to reclass some of the datasets and save them as native rasters. That function takes a while to run but you only run it once. The next function if collateMetadata(). This function takes a dataframe of lat/lons and attaches metadata for every position. Obviously of you know raster you dont need any of this as you can just use the raster &#8220;extract&#8221; function to pull metadata from any of the assets.</p>
<p>test code just finished and it&#8217;s headed to CRAN in the morning.</p>
<p>Must sleep</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/1053/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/1053/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/1053/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/1053/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/1053/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/1053/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/1053/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/1053/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/1053/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/1053/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/1053/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/1053/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/1053/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/1053/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1053&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/09/19/rgdal-raster-rcurl-my-next-package/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>
	</item>
		<item>
		<title>Forbush events</title>
		<link>http://stevemosher.wordpress.com/2011/09/12/forbush-events/</link>
		<comments>http://stevemosher.wordpress.com/2011/09/12/forbush-events/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 17:57:03 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=1043</guid>
		<description><![CDATA[As noted here there is a new paper linking Forbush events with changes in DTR. Simply, during a Forbush event  cosmic rays are modulated ( the flux reaching the earth decreases. The theory goes something like this. If GCRs play a role in cloud formation, then when they decrease you should be able to detect an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1043&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As noted<a href="http://wattsupwiththat.com/2011/09/11/new-paper-links-cosmic-rays-clouds-and-temperature/"> here</a> there is a new paper linking Forbush events with changes in DTR. Simply, during a Forbush event  cosmic rays are modulated ( the flux reaching the earth decreases. The theory goes something like this. If GCRs play a role in cloud formation, then when they decrease you should be able to detect an decrease in cloudiness or conversely an increase in solar radiation reaching the surface.</p>
<p>Here&#8217;s another <a href="http://calderup.wordpress.com/2011/09/10/do-clouds-disappear-4/">link providing some back ground</a></p>
<p>And here is a link to a paper on the subject <a href="http://www.astrophys-space-sci-trans.net/7/315/2011/astra-7-315-2011.pdf">http://www.astrophys-space-sci-trans.net/7/315/2011/astra-7-315-2011.pdf</a></p>
<p>That paper took a rather indirect approach to the problem looking at  changes to DTR and making two inferences. The first inference of course is that the change in DTR is related to Forbush events. The second inference is that the change in DTR was related to changes in cloud cover.</p>
<p>I&#8217;m going to take a more direct approach. The hypothesis is that decreased GCR (coincident with a Forbush event) should lead to a decrease in clouds and hence an increase in solar radiation reaching the surface.</p>
<p>The dataset  I have is collected  is from  the best climate stations in the US:  CRN</p>
<p>The data is solar radiation reaching the surface.  I&#8217;ve just started the test code, downloading all the datasets and getting the data into nice formats for plotting an analysis. I&#8217;ll give you a taste of it here:  On feb 19th, 2011 there was a Forbush event. Below, see the hourly solar radiation for 1 of 206 stations in the CRN database.</p>
<p><a href="http://stevemosher.files.wordpress.com/2011/09/forbush1.png"><img class="aligncenter size-full wp-image-1045" title="Forbush" src="http://stevemosher.files.wordpress.com/2011/09/forbush1.png?w=600" alt=""   /></a> And below find a sample of 9 stations ( ignore the date&#8211; my bad it says jan but its feb ) and an example of 25 charts</p>
<p>So,  while I wait on some bug fixes to be upstreamed for the metadata project, I may play around with the solar data.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://stevemosher.files.wordpress.com/2011/09/example.png"><img class="aligncenter size-full wp-image-1050" title="example" src="http://stevemosher.files.wordpress.com/2011/09/example.png?w=600" alt=""   /></a><a href="http://stevemosher.files.wordpress.com/2011/09/solar.png"><img class="aligncenter size-full wp-image-1047" title="Solar" src="http://stevemosher.files.wordpress.com/2011/09/solar.png?w=600" alt=""   /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/1043/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/1043/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/1043/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/1043/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/1043/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/1043/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/1043/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/1043/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/1043/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/1043/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/1043/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/1043/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/1043/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/1043/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1043&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/09/12/forbush-events/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>

		<media:content url="http://stevemosher.files.wordpress.com/2011/09/forbush1.png" medium="image">
			<media:title type="html">Forbush</media:title>
		</media:content>

		<media:content url="http://stevemosher.files.wordpress.com/2011/09/example.png" medium="image">
			<media:title type="html">example</media:title>
		</media:content>

		<media:content url="http://stevemosher.files.wordpress.com/2011/09/solar.png" medium="image">
			<media:title type="html">Solar</media:title>
		</media:content>
	</item>
		<item>
		<title>RghcnV3 2.0</title>
		<link>http://stevemosher.wordpress.com/2011/08/08/rghcnv3-2-0/</link>
		<comments>http://stevemosher.wordpress.com/2011/08/08/rghcnv3-2-0/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 22:29:47 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=1040</guid>
		<description><![CDATA[Well, version 2.0 is in the can and I&#8217;ll be uploading to CRAN over the next couple of days. Lets go over the highlights. Prior to version 2.0 we had basically 3 kinds of data flowing around the package: V3 14 column format, zoo objects and mts objects.  The 14 column format has always been [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1040&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, version 2.0 is in the can and I&#8217;ll be uploading to CRAN over the next couple of days. Lets go over the highlights. Prior to version 2.0 we had basically 3 kinds of data flowing around the package: V3 14 column format, zoo objects and mts objects.  The 14 column format has always been a PITA and much of the code was designed to provide ways to transform that into 2D zoo or mts objects with station data organized into columns. After reviewing some of Nick&#8217;s code it became clear that there was a way to get rid of the 14 column data and streamline a bunch of the code. Going forward there are three types of objects: Zoo and Mts  which are 2D representations of station data and Nick&#8217;s 3D version which is an array. From input then you select which style you like and the readV3Data() function has been restructured for both speed and configurability:</p>
<p>readV3Data(filename=&#8221;foo&#8221;, output = c(&#8220;Array&#8221;,&#8221;Zoo&#8221;,&#8221;Mts&#8221;).  On ingest you decide what format you want to work in. If you change your mind there are a set of functions to handle transformation:  asZoo(), asMts(), asArray() and of course a set of logical functions to determine types. The core analysis functions have also been rewritten to accept ANY of these three object types. So, passesCamZoo() and passesCamMts()  etc have all been replaced with one function passesCam() that function accepts all three types of objects and just works. Some functions such as Roman&#8217;s function and Tamino&#8217;s function, and rasterizeZoo()  still have limited input: they require, for example, an Mts input or Zoo input. I&#8217;ll probably enhance those functions in another release and then it&#8217;s done.</p>
<p>With 2.0 thus you have these  kind of paths</p>
<p>readV3Data(); passesCam();anomalize();rasterizeZoo()  and you have stations selected by CAM and area averaged</p>
<p>readV3data(); averageStations() rasterizeCells() and you have stations estimated by Romans regression by grid cell</p>
<p>readV3Data(); inverseDensity();solveTemperature() and you have Nick stokes solution</p>
<p>and then you have Taminos approach as well. What we know faster all this is that the methods of computing averages for temperature stations yield the same global answers. There may however be slightly different answers if you look at smaller regions or have data that is too sparse in the temporal domain for CAM.</p>
<p>Next Steps:</p>
<p>There are several things I want to do and a few things I have to do.</p>
<p>1. Start work on GHCN Daily</p>
<p>2. incorporate Zeke&#8217;s paired station approach</p>
<p>3. Do some more work on CHCN</p>
<p>4. OOP. S4 classes and methods</p>
<p>5. Incorporate more of Nicks work</p>
<p>6. metadata package.</p>
<p>7. Demos and studies.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/1040/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1040&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/08/08/rghcnv3-2-0/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>
	</item>
		<item>
		<title>CHCN: Canadian Historical Climate Network</title>
		<link>http://stevemosher.wordpress.com/2011/08/05/chcn-canadian-historical-climate-network/</link>
		<comments>http://stevemosher.wordpress.com/2011/08/05/chcn-canadian-historical-climate-network/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 20:56:04 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=1026</guid>
		<description><![CDATA[A reader asked a question about data from   environment canada.  He wanted to know if that data could somehow be integrated into the RGhcnV3 package.  That turned out to be a bit more challenging that I expected.  In short order I&#8217;d found a couple other people who had done something similar.  DrJ of course was [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1026&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A reader asked a question about data from  <a href="http://climate.weatheroffice.gc.ca/Welcome_e.html"> environment canada</a>.  He wanted to know if that data could somehow be integrated into the RGhcnV3 package.  That turned out to be a bit more challenging that I expected.  In short order I&#8217;d found a couple other people who had done something similar.  DrJ of course was in the house <a href="http://scraperwiki.com/scrapers/canada-temperature-data/">with his scraper</a>. That scraper relies on another scraper <a href="http://scraperwiki.com/scrapers/can-weather-stations/">found here</a>.  That let me know it was possible and an email from Environment Canada let me know it was acceptable.</p>
<p>So,  it&#8217;s ok to write a scraper and possible to write one.  My goal was to do this in R.  I  really enjoy DrJ&#8217;s  code and his other work, but I had to try this on my own. The folks at Environment Canada suggested that scraping was the best option as their SOAP and REST mechanism wasnt entirely supported. That was fine with me as SOAP in R  wasn&#8217;t a good option. I won&#8217;t go into the reasons. So my plan of attack was to leverage a small piece of DrJs work and do the rest in R.</p>
<p>The Key master file is created by  one of DrJs scrapers and can be downloaded here as a <a href="http://scraperwiki.com/api/1.0/datastore/sqlite?format=csv&amp;name=can-weather-stations&amp;query=select+*+from+`swdata`">csv</a>.  At some point I will go duplicate that in R, but for now I rely on this file. The file lists the master list of all stations. It contains the two bits of information we need to scrape data: the station webId and the FIRST YEAR of monthly data.  So there is a function to get that csv file, cleverly named downloadMaster().  The next step is to read that file and select only those stations that report monthly data:  writeMonthlyStations().  The next step is to scrape the data: I looked at several ways of doing this. First I tried &#8220;on the fly&#8221; scraping. That means making a request, and then parsing the file into a  friendly R object. This was some nasty code since the csv file is in an unfriendly format. Metadata in the first 17 lines and then 25 columns of climate data. It took some fiddling but I was able to manage it. It involved doing two reads on the connection. The first read to just get the metadata and the second read to skip the metadata and read the data. That function worked if the server cooperated. Alas, the server had a habit of crapping out and dumping the connection.  The prospect of doing error trapping in R &#8220;trycatch()&#8221;  wasn&#8217;t in the cards.  But I suppose in a future version I will do that. So I oped for the brute force. Download every file. As it turns out that is  7676 csv files. The good new is that with a downloaded CSV file I can work at my leisure and not try to debug things hoping that the connection will time out so I can test the code.</p>
<p>Consequency we have a function scrapeToCsv()  which takes the list of stations and makes a http request for every one. That works pretty slick and takes a long time. Of course, that process is also prone to server timeouts. When it balks we have a function to clean up after that: this function getMissingScrape() looks at your download directory and the files there, looks at the list of stations you wanted to scrape and figures out what is missing. calling scrapeToCvs(get = getMissingScrape())  will restart a scrape and chug along.  When the scrapes are finished you have to do one last check  getEmptyCsv(). There are times when the  connection is made, the local file name is written, but no data is transmitted. So you get zero sized files. No problem, we detect that and rescrape:  scrapeToCsv(get = getEmptyCsv()). Clever folks can just write a while loop that exits on the conditions that all files are there and non empty.</p>
<p>After downloading 7676 files you then create a inventory with metadata:  createInventory() This includes the station name, lat, lon province. and various identifiers ( WMO etc).</p>
<pre>      "Id" "Lat" "Lon" "Altitude" "Name" "Province" "ClimateId" "WMO" "TCid"
  99111111 "49.91" "-99.95" "409.40" "BRANDON.A" "MANITOBA" "5010480" "71140" "YBR"
  99111112 "51.10" "-100.05" "304.50" "DAUPHIN.A" "MANITOBA" "5040680" "" "PDH"</pre>
<p>Then you create a huge master datafile  createDataset(). This has all the data ( temperatures, rain etc). Next you can just extract the mean temperature  asChcn() which creates a GHCN like data structure of temperature data.</p>
<p>version 1.1 is done and is being tested. Should hit CRAN when some outside users report back.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/1026/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1026&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/08/05/chcn-canadian-historical-climate-network/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>
	</item>
		<item>
		<title>CRU Data in RghcnV3</title>
		<link>http://stevemosher.wordpress.com/2011/08/01/cru-data-in-rghcnv3/</link>
		<comments>http://stevemosher.wordpress.com/2011/08/01/cru-data-in-rghcnv3/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 01:20:03 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=1011</guid>
		<description><![CDATA[As many have noted CRU have posted their data a bit ago and the usual gang has started to put it through the various &#8220;engines&#8221; for calculating a global temperature index. Thanks to others who worked this problem ahead of me getting the data in Rghcnv3 was not that hard, but it was not without [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1011&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As many have noted CRU have posted their data a bit ago and the usual gang has started to put it through the various &#8220;engines&#8221; for calculating a global temperature index. Thanks to others who worked this problem ahead of me getting the data in Rghcnv3 was not that hard, but it was not without it&#8217;s challenges given the format. On the CRU site the format consists of a file with two types of  &#8221;lines&#8221; in it. Header lines that give a station metadata, followed by data &#8220;lines&#8221; that contain the data for the station.  That entailed doing some ugly things to read the data in, so I tried to make the ugliness somewhat clearer.  The code:</p>
<pre></pre>
<p>readCruStations &lt;- function(filename=&#8221;stations-data.txt&#8221;, output = c(&#8220;Array&#8221;,&#8221;Zoo&#8221;,&#8221;Mts&#8221;)){</p>
<p>if (length(output) &gt; 1) {<br />
warning(&#8220;Select One of either V3 or ARRAY or Mts. Using first element by default&#8221;)<br />
returnType &lt;- output[1]<br />
} else {<br />
returnType &lt;- output<br />
}<br />
X &lt;- readLines(&#8220;station-data.txt&#8221;)</p>
<p># suck out the headers and work on them to make an inventory<br />
dex &lt;- which(nchar(X[]) == 72)<br />
headers &lt;- X[dex]</p>
<p>#  build an inventory that RghcnV3 likes!</p>
<p>Inv &lt;- data.frame(Id = as.numeric(substr(headers,1,6)),<br />
Lat = as.numeric(substr(headers,7,10)),<br />
Lon = as.numeric(substr(headers,11,15)),<br />
Altitude = as.numeric(substr(headers,16,20)),<br />
Name = substr(headers,22,42),<br />
Country = substr(headers,43,56),<br />
StartYear = as.numeric(substr(headers,57,60)),<br />
EndYear = as.numeric(substr(headers,61,64)),<br />
Source = as.numeric(substr(headers,67,68)),<br />
GoodFirst = as.numeric(substr(headers,69,72)))</p>
<p>Inv$Lat[Inv$Lat == -999] &lt;- NA<br />
Inv$Lon[Inv$Lon == -1999] &lt;- NA<br />
Inv$Lat &lt;- Inv$Lat / 10<br />
Inv$Lon &lt;- Inv$Lon / 10</p>
<p>Inv$Altitude[Inv$Altitude == -999] &lt;- NA</p>
<p>begin &lt;- min(Inv$StartYear)<br />
end &lt;- max(Inv$EndYear)<br />
Years &lt;- begin:end<br />
stations &lt;- nrow(Inv)</p>
<p>##  build a data array that RghcnV3 likes !<br />
DATA &lt;- array(NA,dim=c(stations,12,length(Years)))<br />
dimnames(DATA)&lt;-list(Inv$Id,month.abb,Years)</p>
<p>stationCount &lt;- 0<br />
for(line in 1:length(X)){<br />
if (nchar(X[line]) == 72){<br />
# we have a header. increment station counter ( its an array index)<br />
stationCount &lt;- stationCount + 1<br />
} else {<br />
# we have a data record.  use the regular expression  (&#8221; +&#8221;) to split the string into numbers<br />
thisLine &lt;- as.numeric(unlist(strsplit(X[line],&#8221; +&#8221;)))<br />
thisLine[thisLine == -999] &lt;-NA<br />
thisYear &lt;- thisLine[1] &#8211; begin + 1<br />
DATA[stationCount,,thisYear] &lt;- thisLine[2:13]/10</p>
<p>}<br />
}<br />
## Prepare for output<br />
if (returnType == &#8220;Mts&#8221; | returnType == &#8220;Zoo&#8221;){<br />
DATA &lt;- apply(DATA,MARGIN = 1, FUN = c)<br />
DATA &lt;- ts(DATA, start = minYear, frequency = 12)<br />
if (returnType == &#8220;Zoo&#8221;) DATA &lt;- asZoo(DATA)<br />
}<br />
if (returnType == &#8220;Mts&#8221;){<br />
return(list(Inventory = Inv,Mts = DATA))</p>
<p>}<br />
if (returnType == &#8220;Zoo&#8221;){<br />
return(list(Inventory = Inv,Zoo = DATA))<br />
}<br />
if (returnType == &#8220;Array&#8221;){<br />
return(list(Inventory = Inv,Array = DATA))<br />
}</p>
<p>}</p>
<p>&nbsp;</p>
<p>Of course, then it is a simple matter to load that data into a raster and compute the area averaged global temperature:  What&#8217;s it show? Given CRU&#8217;s source data and given an algorithm that is patterned after their&#8217;s, They are cooler. Perhaps, they posted only the source data and not any adjustments they do.  These results match Nick Stokes who is also a bit warmer than CRU.</p>
<p><a href="http://stevemosher.files.wordpress.com/2011/08/crutest.png"><img class="aligncenter size-full wp-image-1023" title="crutest" src="http://stevemosher.files.wordpress.com/2011/08/crutest.png?w=600" alt=""   /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/1011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/1011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/1011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/1011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/1011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/1011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/1011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/1011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/1011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/1011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/1011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/1011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/1011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/1011/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=1011&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/08/01/cru-data-in-rghcnv3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>

		<media:content url="http://stevemosher.files.wordpress.com/2011/08/crutest.png" medium="image">
			<media:title type="html">crutest</media:title>
		</media:content>
	</item>
		<item>
		<title>Forking Myself</title>
		<link>http://stevemosher.wordpress.com/2011/07/30/forking-myself/</link>
		<comments>http://stevemosher.wordpress.com/2011/07/30/forking-myself/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 05:22:24 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=990</guid>
		<description><![CDATA[I&#8217;ve spent some time forking myself. Over the past few days when I could steal away an hour here  or there I decided to make a big change to the package. But it&#8217;s a good change. First some book-keeping. The Romantest.R file has a minor bug in it. Not really a bug, I just pulled [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=990&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent some time forking myself. Over the past few days when I could steal away an hour here  or there I decided to make a big change to the package. But it&#8217;s a good change. First some book-keeping. The Romantest.R file has a minor bug in it. Not really a bug, I just pulled out the wrong statistic from the brick &#8221; cellStats(..,sum),  should be cellStats(&#8230;mean) unless you want to errr &#8220;add&#8221; all the cells together. Too eager to post.</p>
<p>On with the forking. Nick Stokes and I exchanged a few emails looking at various ways of speeding up readV3Data().  During the course of that we found a small &#8220;bug&#8221; to report to NCDC. As I thought more about his data structure, a 3D array of stations, months, and years it became obvious that the whole package could be easily rewritten to support it. And I could bury forever the old 14 column v2 format. The way I&#8217;ve implemented that is an option on the readV3data() function. You specify which kind of object you want returned: a zoo object, mts object or an Array type object. Zoo and mts are just variants of each other with station data in columns and time in rows. Then I defined a series of functions asZoo(), asMts(), asArray(), which allow you to switch from one representation to another. Then I rewrote all the functions to accept any type of object. This cut down the number of actual functions I need and moved me closer to OOP. A couple of the functions, still accept only one type of data, for example Romans and Taminos, are still &#8220;mts/zoo&#8221; centric.  Some routines disappeared all together: windowV3() is gone and windowArray() takes it place, although you could do  test &lt;- asArray(window(asZoo(Data),start =1920, end = 1940 +11/12).</p>
<p>so you can now  write  anomalize() and pass it a zoo, mts or Array. And  passesCam() replaces the several variants.  The demos have been rewritten and I added a couple test programs. Building a new package will take time as the manual will require much rewriting.</p>
<p>Then I had another little task. Rewriting Nick&#8217;s  weights program. The function is used to calculate a series of weights for the data array. These weights are a function of the monthly count of reports in a grid cell and an area weight for that gridcell. My main goal here was to see if I could rewrite the code using raster. Well, I did, but it wasn&#8217;t entirely clear and last bits of it were particularly nasty so I decided instead to stick with Nicks code, add some clearer variable names, and change it so that you can use any size grid cell. Here is what the algorithm does: It takes a all the temperatures series and  gives them a &#8220;cell&#8221; id,  exactly like the cell value in a raster. Every cell receives a weight that is proportional to its area, basically sin() of Latitude so that cells at the equatoer which are larger have a weight of 1 and cells toward the poles are weighted less. Then a &#8220;count&#8221; is established for every valid temperature measure in the cell for every month of every year.  So a given cell could have 5 reports one month and no reports the next month or 3 or 2, and so forth. Then the area weight is divided by the counts in that cell. And I refer to this as &#8220;inverse density&#8221;  the more reports, the less each report is weighted. The smaller the area, the smaller the weight.  As the function stands now, I&#8217;ve added a  raster as a calling parameter. I&#8217;ll probably change that to simply a cell size, as everything I need can be calculated from a cell size.  Here is the code. This function, of course, doesnt take a zoo or mts as a parameter, but that&#8217;s relatively easy to handle with the asArray() function, so I&#8217;ll probably change that as well before adding it.</p>
<p><pre class="brush: r;">
inverseDensity &lt;- function(inv, Data, r = GLOBE5){

rClass &lt;- class(r)[1]
isRL &lt;- rClass == &quot;RasterLayer&quot;
if (isInventory(inv) &amp; isArray(Data) &amp; isRL){
# check that inventory stations and Data stations match
if (!identical(getStations(inv), getStations(Data))) stop(&quot;stations must match&quot;)
# dimensions of Array
dimensions &lt;- dim(Data)
# array of weights for output that looks like temperatures
weights &lt;- array(NA,dimensions)

lonBin &lt;- ncol(r)
latBin &lt;- nrow(r)
halfLat &lt;- latBin/2
eq &lt;- halfLat * (lonBin +1) + (halfLat+1)
cellSize &lt;- res(r)[1]
cellId &lt;- floor(inv$Lat/cellSize) * lonBin + floor(inv$Lon/cellSize) + eq
#weights for latitude changes
latWeight &lt;- sin((1:latBin-0.5)*pi/latBin)
#weights for every lat/lon
allWeights &lt;- rep(latWeight, each = lonBin)
for(months in 1:dimensions[2]){
      for(years in 1:dimensions[3]){
      # get T/F if temperature is there
      reports &lt;- !is.na(Data[ , months, years])
      # get the cell numbers of those cells with reports
      cells &lt;- cellId[reports]
      # a count of reports per cell per month
      counts &lt;- tabulate(c(cells, lonBin * latBin))
      # Ok is the logical of counts &gt; 0
      ok &lt;- counts &gt; 0
      # make a copy of allweights to modify
      density &lt;- allWeights
      # note only &quot;ok&quot; elements are valid
      density[ok] &lt;- allWeights[ok] / counts[ok]
      #print(density[ok]) those True cells get a density area/count
      weights[reports, months, years] &lt;- density[cells]

    }

  }
return(weights)
}
if ( !isInventory(inv) ) stop(&quot; must be a valid inventory&quot;)
if ( !isArray(Data)) stop(&quot;must be a valid data array&quot;)
if ( !isRL ) stop(&quot;must be a valid raster&quot;)

}
 </pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/990/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/990/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/990/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/990/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/990/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/990/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/990/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/990/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/990/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/990/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/990/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/990/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/990/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/990/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=990&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/07/30/forking-myself/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>
	</item>
		<item>
		<title>Nick Stoke&#8217;s Improvements</title>
		<link>http://stevemosher.wordpress.com/2011/07/25/nick-stokes-improvements/</link>
		<comments>http://stevemosher.wordpress.com/2011/07/25/nick-stokes-improvements/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 17:25:47 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=980</guid>
		<description><![CDATA[Fast on the heels of getting RomanM&#8217;s code up and running in RghcnV3,  Nick Stokes whipped out a version of his approach which he covered on his blog here: We exchanged code and few mails thrashing through details and I&#8217;m now in a position to start the integration work of his approach into Rghcnv3. In [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=980&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Fast on the heels of getting RomanM&#8217;s code up and running in RghcnV3,  Nick Stokes whipped out a version of his approach which he covered on his blog<a href="http://moyhu.blogspot.com/2011/07/using-rghcnv3-very-simple-templs.html"> here:</a></p>
<p>We exchanged code and few mails thrashing through details and I&#8217;m now in a position to start the integration work of his approach into Rghcnv3. In addition to providing a new method Nick also contributed some code to make the import of data considerably faster. It&#8217;s a good lesson in some of the trade offs between code clarity and maintainability and raw speed. The function in question was readV3data().  My approach with that function was to build something that was maintainable, so the function relies on a set of constants or FILE.PARAMETERS.  While GHCNV3 was in beta I wanted to build something that could be changed easily by changing constants in one place rather than by editing code. So the function relies on read.fwf() and that function is controlled by constants in parameters. With GhcnV3  NCDC has added 34 extra columns of data. That drives the read time up to 8 minutes. By tweaking the &#8220;widths&#8217; parameter I was able to get this down to 2.5 minutes. Nick&#8217;s approach BLEW THE DOORS off that tweak.  His approach comes at a small price. The price is code clarity and maintainability. After spending some time working back and forth we were able to fix a bug and make the code more clear  and robust. If NCDC decides to change format, then I&#8217;ll have to change code and not just constants. I don&#8217;t think that is likely. So I choose speed here.  How fast was Nick&#8217;s approach? 30-40 seconds.   The approach depends upon  using readLine() and then &#8220;manually&#8221; editing the lines using substr() to get the file into a format that can be read by  read.table().  That requires writing a temporary file. I think that step may also be unnecessary, but I&#8217;ll leave that for another day.</p>
<p>Next up was integrating the code that Nick produced for doing his method. If you&#8217;re unfamilar with his method please have a look at the link above . The unique thing about Nick&#8217;s approach, from my software perspective, was his data structure. Most people who work at this use a 2D data structure of some sort. You have time series. You have stations. That has to mean you should use a 2D structure ! So all of RghcnV3 looks to get the data into the right 2D structure  so that various functions can use them. Nick does something entirely different and it took me a while to wrap my head around it. Since the problem was bigger than my head that took some time and plodding. But the result has some wonderful properties for data manipulation which I will cover later.</p>
<p>The 3D data structure is an array. The dimensions are Stations, Months, Years. Picture a cube. The face of the cube has stations on the left, months across the top, and is years deep.  That&#8217;s a really nice arrangement for some of the things we want to do with station data.  Below find the code that takes a 2D v3 format ( 14 columns,  with a row per station) and creates a 3D structure. Most importantly, this code will insert missing years into the data, a function that v3ToZoo() and v3ToMts() perform. That opens a new possibility that I&#8217;ll show at the end.</p>
<p>Nicks Code, adapted and formatted to be more in line with R style guides:</p>
<p><pre class="brush: r;">
&lt;/pre&gt;
v3ToArray &lt;-  function(v3Data){
 # author Nick Stokes
 # Steve Mosher: rewrite for style, interface, error checking and comments
 # check the input data and set up parameters for processing
 if  (!isV3(v3Data))  stop(&quot;v3Data must be a v3 object&quot;)
 stations &lt;- nrow(v3Data)
 # the first year gets an offset for computing some indices below
 start &lt;- min(v3Data$Year) - 1
 end &lt;- max(v3Data$Year)
 # Inside a v3 format every station takes up a different number
 # of rows. we are going to process those rows in &quot;chunks&quot;
 # station index is a vector of where different stations start and stop.
 # a subset command could be used inside the loop but this quick
 stationIndex &lt;- c(0, which(diff(v3Data$Id) &gt; 0), stations)
 stationCount &lt;- length(stationIndex) - 1
 # the array is stations by months by number of years
 x &lt;- array(NA,c(stationCount,12, end - start))
 # I add dimnames because I like to use them to identify what is what
 # also, I can now easily reconcile a temperature data file with an inventory
 dimnames(x) &lt;- list(unique(v3Data$Id),month.abb,min(v3Data$Year):max(v3Data$Year))
 # the tricky part. You grab a stations work of data and insert it into
 # the 3D array.
 for(i in 1:stationCount){ # loop over stations
 # this gets you the start row and end row for a station
 records &lt;- c(stationIndex[i]+1, stationIndex[i+1])
 iy &lt;- as.matrix(v3Data[records[1]:records[2], ])
 oy &lt;- (iy[ ,2] &gt; start) &amp; (iy[ ,2] &lt;= end)

 if(sum(oy) &lt; 2 ) next
 iz &lt;- iy[oy, ]
 x[i, , iz[ ,2]  -  start] &lt;-  t(iz[ ,3:14])
 }
 return(x)
 }
&lt;pre&gt;</pre></p>
<p>And now for the real treat.  Because we&#8217;ve increased the speed of readV3data(), we can actually create Nicks data structure when we read the data in. So  readv3Data()  now has an output format</p>
<p>readV3Data(filename, output = c(&#8220;V3&#8243;, &#8220;ARRAY&#8221;), Parameters = FILE.PARAMETERS)</p>
<p>That means you can read the data into the program in about 10 seconds using the &#8220;V3&#8243; output format, or select the ARRAY output format and be all set to call Nick&#8217;s method with the data output by the red function. Basically, v3ToArray() gets called immediately after the read.</p>
<p>I&#8217;ve got one more test to run on this code and then it goes into version 1.6.  version 1.5 is on CRAN.  Version 1.6 will have Roman&#8217;s Method, a demo of romans method and Nick Stokes faster readv3Data().  The rest of Nick&#8217;s code is slated for 1.7.</p>
<p>PASSED.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/980/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/980/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/980/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/980/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/980/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/980/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/980/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/980/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/980/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/980/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/980/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/980/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/980/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/980/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=980&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/07/25/nick-stokes-improvements/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>
	</item>
		<item>
		<title>RomanM&#8217;s Method</title>
		<link>http://stevemosher.wordpress.com/2011/07/23/romanms-method/</link>
		<comments>http://stevemosher.wordpress.com/2011/07/23/romanms-method/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 02:41:42 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=963</guid>
		<description><![CDATA[UPDATE:  Romantest.R  has been added to the box on your right. The test includes all of Romans code, and the two routines needed to feed data into a raster brick.  averageBycell() and rasterizeCells().  The code should work with version 1.3+.  version 1.5 is headed to CRAN.  Note there appear to be bugs with &#8220;image&#8221; in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=963&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>UPDATE:  Romantest.R  has been added to the box on your right. The test includes all of Romans code, and the two routines needed to feed data into a raster brick.  averageBycell() and rasterizeCells().  The code should work with version 1.3+.  version 1.5 is headed to CRAN.  Note there appear to be bugs with &#8220;image&#8221; in R 2.13.1.  so plots are not pretty. fix is coming, you can probably revert to 2.13</p>
<p>I&#8217;ve succeeded in getting a version of RomanM and JeffId&#8217;s Thermal hammer working with version 1.3 of RghcnV3. This is going to be a long post because there is a lot of ground to cover. First, some errata, the &#8220;Globe&#8221; demo in V1.3 appears to have a missing line, looks like an editor bug, so I will have to push 1.4 to CRAN. CRAN has not been building packages for a bit, so I&#8217;ll post 1.4 here.</p>
<p>Roman&#8217;s method. Roman&#8217;s method is covered at a variety of posts at his site and at Jeffs. My goal here isn&#8217;t to explain his method in detail but rather to show how it will fit into RghcnV3,  Roman&#8217;s method works by using all the information in all the time series to come up with an  average of all the time series.  The function is currently called  &#8221;temp.combine(), however that name will change as we move it into RghcnV3. I will also rename the function that uses Tamino&#8217;s method.  As it stands temp.combine() takes a &#8220;mts&#8221; object or multiple time series object and  a series of weights. It outputs a single time series, offsets for all time series, predicted values for all time series and residuals.  For the first iteration I will leave the weights in. In discussions with Roman he indicated that these weights could be used for distance weighting, but we won&#8217;t we using that in today&#8217;s work.</p>
<p>As I plowed through the code it became apparent to me that the paradigm of holding station data in columns ( the method used by me, roman and tamino) actually has some drawbacks especially when it comes to combining stations with &#8216;aggregate()&#8217;.  I&#8217;m not in the mood to change a bunch of code from column based to row based; and, its not simply a matter of doing a few transpositions. Practically what this means is that some of the code used in Roman&#8217;s method will use loops. I&#8217;m actively working to remove that, but loops work, so working code wins the day.</p>
<p>Plan of attack:</p>
<p>The goal for this exercise is to  use Roman&#8217;s method to calculate an average for a  grid cell. In the CAM method we use a simple &#8216;mean&#8217; to calculate the average for a grid cell. That happens in the function &#8220;rasterizeZoo()&#8221;. That function takes an inventory of stations and a 2 dimensional Zoo object and &#8220;rasterizes&#8221; stations into the grid structure of a 3D brick. A brick is lat/lon/time.  Some side notes on rasterizeZoo(). RasterizeZoo() calls the raster function &#8220;rasterize&#8221;. Rasterize need the following inputs: a matrix of xy points (station lon/lat), a base raster to use for every layer, a matrix of values to rasterize into cells, and a function. The matrix has to have time in columns, stations in rows.  So we feed it a zoo object and we transpose that zoo object  &#8217;under the hood&#8217; inside the function. The lastest version of zoo just added a transpose function. arrg I needed that a couple months back. But again, I&#8217;m not rewriting a bunch of code, just yet.</p>
<p>Our plan then will be to call a function like rasterizeZoo().  However, it will be slightly different. RasterizeZoo() takes multiple stations and averages them per cell. When we use Roman&#8217;s method we will  do this &#8216;averaging&#8217;  BEFORE we call &#8216;rasterize&#8217;. Essentially we will call &#8220;rasterize&#8221; with &#8220;cells&#8221; rather than &#8220;points&#8221;.  We could also use the raster function &#8220;setValues()&#8221;  but  that function needs a little tweak to allow this, so I&#8217;ll work with rasterize. That&#8217;s our goal. Get a zoo data structure and associated CELLS  (not points) to feed to rasterize.  Our first function must then take a mutiple time series, divide the stations into the right CELLS, and then romanize those stations to come up with a cell time series.</p>
<p>Here we go:</p>
<p><pre class="brush: r;">
averageByCell &lt;- function(r =GLOBE5, inventory, Mts){
  # check classes code goes here
  # check to make sure that all the inputs are the right classes. To do.
  # get the cell number associated with each station. xy maps to a cell in the raster
  myCells &lt;-  cellFromXY(r, getLonLat(inventory))
       # a obscure hack to get the stations associated with a cell!
       # used to get the column numbers for each cell
       # recall that every column is a station. so we will use column numbers to subset
  DF &lt;- data.frame(Id =getStations(inventory), Cell = myCells)

  # now we get a cell count. we are going to loop over the unique cells
  cellcount &lt;- length(unique(myCells))
  # we need the unique cells in a vector for referencing and for NAMING output columns
  uCells &lt;- unique(myCells)
 # loop over cells. IF mts were transposed we could use aggregate
 # but that would entail rewriting all of romans code.. or maybe use mapply
  for( cell in 1:cellcount){
       # dex will hold the positions of stations in DF$Cell. its also the columns we need
       dex &lt;- which(DF$Cell == uCells[cell])
       # call temp.combine NOTE I can also call taminos here or a simple mean
       CellAve &lt;- temp.combine(Mts[ ,dex])
       if (cell == 1){
          out &lt;-  CellAve$temps
        }else {
          out &lt;- cbind(out,CellAve$temps)
          # COPY the cell number to the column name! Critical
          colnames(out)&lt;-uCells[1:cell]
         }
   }
  # make it a zoo object! we want to pass a zoo object to rasterizeZoo()
  Zout &lt;- as.zoo(out)
  # put out the xy for every cell. This will probably be dropped in production
  xy   &lt;- xyFromCell(r,uCells)
  return(list(Points=xy,Zoo=Zout))

}
</pre></p>
<p>So that&#8217;s it. We have a function that we feed  the following values: a mts object. an inventory and a blank raster. That function will figure out which stations belong in which cells. It will then call &#8220;temp.combine()&#8221;  with  SUBSETS of the full mts object.  temp.combine(Mts[,dex]) uses &#8220;dex&#8221; to select those stations that have matching cell numbers. So temp.combine works on a grid cell at a time. Then all those individual time series ( grid series) are collected into a zoo object that has CELL NUMBERS as column names. This is different from zoo objects that have station Ids as column names.</p>
<p>Now that we have a zoo object of averaged grid cells, we will call a function like &#8220;rasterizeZoo&#8221;  but for clarity I&#8217;ll create a different function.  I&#8217;ll probably come up with a special class for this and have just once function, but for now we have two. Here is that function.</p>
<p><pre class="brush: r;">
rasterizeCells &lt;- function( ZooCells, r = GLOBE5){
  require(&quot;zoo&quot;)
  require(&quot;raster&quot;)
  # check the various calling parameters
  # check for a good cellsize

  #check Zoo as a zoo
  # stop if they dont match
  # proceeding otherwise
  if (!is.zoo(ZooCells)){
    cat(&quot;Zoo is a &quot;, class(ZooCells), &quot;\n&quot; )
    stop(&quot;Zoo must be a zoo object&quot;)
  }
  # now we should check that the cells in the column names can be found in
  # the raster. What we really need is a tighter coupling so we KNOW the resolution matches: OOP someday
  cells &lt;- 1:ncell(r)
  zoo.cells &lt;- as.integer(colnames(ZooCells))
  common    &lt;- intersect(zoo.cells,cells)

  matching &lt;- identical(intersect(zoo.cells,cells),zoo.cells)

  if (matching == FALSE){
    print(&quot; mismatching cells between Zoocell and raster&quot;)
    stop(&quot;check your Raster&quot;)

  }
  if (!class(r)[1] == &quot;RasterLayer&quot;) stop(&quot;r must be a raster object&quot;)
  resolution &lt;- res(r)
  if (resolution[1] != resolution[2])stop(&quot; must use a raster with square cells&quot;)

  ###########  ready to process
  #  get the lon lats of Cells
  #  suck the time out of the zoo object
  #  transform the zoo object into a matrix with right orientation
  #  rasterize with mean. Need to see if we can change rasterize to merely copy.
  # also replace this code with zoo  transform.. requires LATEST zoo library, so change depends

  xy      &lt;- xyFromCell(r,zoo.cells)
  TIME    &lt;- time(ZooCells)
  # core data wacks the row names
  data    &lt;- coredata(ZooCells)
  dimnames(data)[[1]] &lt;- TIME
  tdata   &lt;- t(data)
  gridded &lt;- rasterize(xy, r, field = tdata, fun = mean, na.rm = TRUE)
  gridded &lt;- setZ(gridded, as.yearmon(time(ZooCells)), name = 'time')
  return(gridded)

}
</pre></p>
<p>That&#8217;s it.  We now will be able to call  readV3data(),  v3ToMts(), averageByCell(), rasterizeCells()  and  the result will be a brick where every grid cell has the average temperature as computed by Roman&#8217;s method. Slick.</p>
<p>So I did a little test with Texas.  Here is what a month of texas data looks like: Please note the nasty image bug with R.2.13.1. yuk. Note also that I used a 3&#215;3 grid to do this.</p>
<p><a href="http://stevemosher.files.wordpress.com/2011/07/texasarea.png"><img class="aligncenter size-full wp-image-970" title="TexasArea" src="http://stevemosher.files.wordpress.com/2011/07/texasarea.png?w=600" alt=""   /></a>And if you compare  the answer you get with and without grid based averaging</p>
<p><a href="http://stevemosher.files.wordpress.com/2011/07/averaging.png"><img class="aligncenter size-full wp-image-972" title="averaging" src="http://stevemosher.files.wordpress.com/2011/07/averaging.png?w=600" alt=""   /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/963/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/963/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=963&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/07/23/romanms-method/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>

		<media:content url="http://stevemosher.files.wordpress.com/2011/07/texasarea.png" medium="image">
			<media:title type="html">TexasArea</media:title>
		</media:content>

		<media:content url="http://stevemosher.files.wordpress.com/2011/07/averaging.png" medium="image">
			<media:title type="html">averaging</media:title>
		</media:content>
	</item>
		<item>
		<title>Version 1.3 Verified</title>
		<link>http://stevemosher.wordpress.com/2011/07/20/version-1-3-verified/</link>
		<comments>http://stevemosher.wordpress.com/2011/07/20/version-1-3-verified/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 20:39:56 +0000</pubDate>
		<dc:creator>Steven Mosher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stevemosher.wordpress.com/?p=955</guid>
		<description><![CDATA[Whew, Update: Sources and windows package in the drop box.   CRAN is a bit slow in getting around to things. Update: AirVent Post source is in the drop box. For a few hours last night I struggled with a bug, err several bugs. In the end some of the bugs were mine, some of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=955&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whew,</p>
<p>Update: Sources and windows package in the drop box.   CRAN is a bit slow in getting around to things.</p>
<p>Update: AirVent Post source is in the drop box.</p>
<p>For a few hours last night I struggled with a bug, err several bugs. In the end some of the bugs were mine, some of them were &#8220;upstream&#8221; and some of them were  far &#8220;upstream&#8221;.  Image  bugs in R 2.13.1. But the math bugs ( or flat out errors on my part) have all been fixed. And the verification of the results is done.  version 1.3 should be available for download here in  bit, I just need to pretty up some code in the demos.</p>
<p>The process of using raster bricks  to create a global average is a bit tricky if you are not used to thinking  in simple operations.</p>
<p>Anyway, I worked my way through my own stupidity and ended up with this</p>
<p><a href="http://stevemosher.files.wordpress.com/2011/07/verification.png"><img class="aligncenter size-full wp-image-956" title="Verification" src="http://stevemosher.files.wordpress.com/2011/07/verification.png?w=600" alt=""   /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevemosher.wordpress.com/955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevemosher.wordpress.com/955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevemosher.wordpress.com/955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevemosher.wordpress.com/955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevemosher.wordpress.com/955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevemosher.wordpress.com/955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevemosher.wordpress.com/955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevemosher.wordpress.com/955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevemosher.wordpress.com/955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevemosher.wordpress.com/955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevemosher.wordpress.com/955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevemosher.wordpress.com/955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevemosher.wordpress.com/955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevemosher.wordpress.com/955/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevemosher.wordpress.com&amp;blog=8212404&amp;post=955&amp;subd=stevemosher&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevemosher.wordpress.com/2011/07/20/version-1-3-verified/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/72731ded6aa5ea75024ed11fee92ea8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevemosher</media:title>
		</media:content>

		<media:content url="http://stevemosher.files.wordpress.com/2011/07/verification.png" medium="image">
			<media:title type="html">Verification</media:title>
		</media:content>
	</item>
	</channel>
</rss>
