Home > Uncategorized > Moshtemp4.0


Now that SST has been processed with raster we can return to the land processing and put that on the same footing. To get there I’ll rebuild from scratch making some minor adjustments along the way. As we go foward the amount of code we have to write should become less and less because we are letting raster do things for us.

As much as I hate to trash old code I wrote putting everything into raster will be the right thing to do. In the end the vast majority of the code we have will be basic bookkeeping code and project organizing code. So, I spent sometime looking at new R packages ( project template) and spent time trying to bullet proof the installation and the file handling. As a result, the code will now check for installed packages and install them only of they are not installed. The other problem that remains is the “uncompress” issue with .Z files. Following Ron Broberg, SteveMc has a nifty little solution for this problem. First, what’s the problem:

Many of the files we deal with are tar and/or .Z files. .Z is a old Unix compression standard. many folks have moved on from this. But there  are some who still use the format. Ron’s solution and Steve’s after him was to put the uncompress exe in on the system path and then invoke an R system() call, calling the uncompress with  the file as a parameter. Pretty slick!  I tried to use the R package “uncompress” but I get failures as did SteveMc. I prefer the R package approach. So, I’m trying to contact the maintainer to update his package. The source is available, so any c programmer should be able to figure it out. When Time permits I’ll look at his source and see if I can find the bug. It’s a unexpected EOF type error. I’m suspecting that he only tested on Linux since he’s a linux guy and that the tests Cran runs are not sufficient. SteveMc runs windows and I use MAC. Wonder if Ron Broberg had any luck on linux.

We will start by rebaselining. Moshtemp4 Zip will go up at the drop and in the box on this page.

Unzip it. Make it your working directory and run Downloadall.R That script will take a while. It will download all the assets you need. The files, masks, inventories, and CRU results which we will eventually calibrate against.  you will then have to manually uncompress v2.mean.Z. On the Mac thats just a click and on linux uncompressed should also be built it.

next run SetUpData.R.  That script will create

1. V2Mean.Rdata: this is a processed version of v2mean with all duplicates averaged

2. V2Anomalies.Rdata: this is giant matrix of all stations. StationID is in the column. Every row is a month of anomaly in C ( not tenths) from 1900 to 2009.

3. SST.Rdata: a brick of SST anomalies from 1900 to 2009

After SetUpData completes, you can test it by doing this:


You could even loop thru all 5072 stations and plot every one [ see the routine, plotAnomalySeries() ] You can also check out the calibration data:


[1] “Years”   “Annual”  “Monthly” “Percent”
then Y$Monthly or Y$Annual to check out the numbers
Finally, Robert has sped up some features in raster (stackApply) and he’s got some new code that will help me build a raster brick directly from my matrix of V2Anomalies. So in one line we will take that V2Anomaly object and ‘grid’ it, average stations within a grid, and build a brick where every layer is a month. I end up throwing away some of the final bits of the code I wrote. So, while he and I test that stuff have at Moshtemp4.
Categories: Uncategorized
  1. No comments yet.
  1. September 5, 2010 at 5:26 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 47 other followers

%d bloggers like this: