<?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>Biospherica &#187; GFS</title>
	<atom:link href="http://joewheatley.net/tag/gfs/feed/" rel="self" type="application/rss+xml" />
	<link>http://joewheatley.net</link>
	<description>Earth Vegetation</description>
	<lastBuildDate>Tue, 17 Aug 2010 14:01:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>NCEP Global Forecast System</title>
		<link>http://joewheatley.net/ncep-global-forecast-system/</link>
		<comments>http://joewheatley.net/ncep-global-forecast-system/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 11:14:32 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Climate]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[GFS]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[weather forecast]]></category>

		<guid isPermaLink="false">http://joewheatley.net/?p=1192</guid>
		<description><![CDATA[Just about everyone is familiar with weather maps. There are many situations where it is useful to combine the underlying numerical weather data with other types of information. Accessing  the weather data is a necessary first step.
The output from the U.S. National Centers for Environmental Prediction (NCEP) Global  Forecast System (GFS) is freely available. The [...]]]></description>
			<content:encoded><![CDATA[<p>Just about everyone is familiar with weather maps. There are many situations where it is useful to combine the underlying numerical weather data with other types of information. Accessing  the weather data is a necessary first step.</p>
<p>The output from the U.S. National Centers for Environmental Prediction (<strong><a href="http://www.nco.ncep.noaa.gov/" target="_blank">NCEP</a></strong>) Global  Forecast System (GFS) is freely available. The surface resolution of the model is ≈ 0.3º× 0.3°. The model runs every 6 hours, producing forecasts at 3-hourly intervals extending out to 16 days. As an example of output from GFS, the map (below) shows the predicted average  temperature at 2 metres over the entire globe for the next 24 hr (date of this post). The map shows predicted cold conditions in Europe, and the continuing heatwave in Australia.</p>
<p><a href="http://joewheatley.net/wp-content/uploads/2009/12/t2m.jpeg"><img class="aligncenter size-large wp-image-1685" title="t2m" src="http://joewheatley.net/wp-content/uploads/2009/12/t2m-1024x572.jpg" alt="t2m" width="1024" height="572" /></a></p>
<h3>How the map was made</h3>
<p><strong><a href="http://www.nco.ncep.noaa.gov/pmb/products/gfs/" target="_blank">GFS forecasts</a></strong> are in a format called GRIB2. According to Wikipedia, <em><strong>&#8220;</strong>GRIB (GRIdded Binary) is a mathematically concise data format commonly used in meteorology to store historical and forecast weather data.&#8221; </em>GRIB files contain physical fields such as temperature, humidity etc defined on a spatial grid, as well as boundary conditions such as vegetation type and elevation. The data might be assimilated from observations, or output from a forecast model.</p>
<p>The first step is to translate the GRIB into a raster format such as <strong><a href="http://www.unidata.ucar.edu/software/netcdf/" target="_blank">netcdf</a></strong> which can be read in <em>R</em><strong><em>. </em></strong>For example, the GRIB2 file <em>gfs.2009121700/gfs.t00z.sfluxgrbf03.grib2</em> contains the 3-hr forecast surface data on 17 Dec 2009  produced at 00 UTC (midnight universal time). An inventory of the data contained in this file can be seen <strong><a href="http://www.nco.ncep.noaa.gov/pmb/products/gfs/gfs.t00z.sfluxgrbf00.grib2.shtml" target="_blank">here</a></strong>. Download this forecast as <em>temp.grb</em></p>
<p><code>loc=file.path("ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.2009121700/gfs.t00z.sfluxgrbf03.grib2")<br />
download.file(loc,"temp.grb",mode="wb")</code></p>
<p>To read <em>temp.grb</em> a utility called <strong><a href="http://www.cpc.noaa.gov/products/wesley/wgrib2/" target="_blank">wgrib2</a></strong> needs to be installed on your system. Then data such as land fraction can extracted into a netcdf file <em>LAND.nc</em> using the <em>R</em> shell command</p>
<p><code>shell("wgrib2 -s temp03.grb | grep :LAND: | wgrib2 -i temp00.grb -netcdf LAND.nc",intern=T)</code></p>
<p>The ncdf package can now be used to read the contents of <em>LAND.nc</em>.</p>
<p><code>library(ncdf)<br />
landFrac &lt;-open.ncdf("LAND.nc")<br />
land &lt;- get.var.ncdf(landFrac,"LAND_surface")<br />
x &lt;- get.var.ncdf(landFrac,"longitude")<br />
y &lt;- get.var.ncdf(landFrac,"latitude")</code></p>
<p>The 1152×576 matrix <em>land</em> takes values 1 for land and 0 for water (sea-ice is 1). x and y are the longitude and latitude of the non-uniform GFS grid.</p>
<p>2m temperature data can be read in the same way. The average of the first 8  forecasts was called <em>t2m.mean</em> and plotted using <em>image.plot()</em> from the fields package:</p>
<p><code>library(fields)<br />
rgb.palette &lt;- colorRampPalette(c("snow1","snow2","snow3","seagreen","orange","firebrick"), space = "rgb")#colors<br />
image.plot(x,y,t2m.mean,col=rgb.palette(200),axes=F,main=as.expression(paste("GFS 24hr Average 2M Temperature",day,"00 UTC",sep="")),axes=F,legend.lab="o C")<br />
contour(x,y,land,add=TRUE,lwd=1,levels=0.99,drawlabels=FALSE,col="grey30") #add land outline </code></p>
]]></content:encoded>
			<wfw:commentRss>http://joewheatley.net/ncep-global-forecast-system/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.258 seconds -->
