Code for global sea ice calcs
Posted by Jeff Condon on December 14, 2008
The code used for generating the global ice trend plots is below. Instructions are in the code. This should be easily reproducible in excel with some time spent breaking the data into annual basis for conversion into anomaly.
WordPress italicized my quotes again. If you use R for replication you need to fix all the quotes — sorry.
I also apologize for the heavy C accent in my code. I gave up trying to work out the R syntax after several hours. Hints for improvement would be appreciated.
library(gplots)
source(“http://www.climateaudit.org/scripts/utilities.txt”)
nb=read.csv(“c:/agw/sea ice/global sea ice compiled.csv”, header=FALSE)#I used microsoft excel to represent years as decimals of days. I.e. 1978.23 This was done in the CSV file before running.
#the data is in 3 columns, Year, global nasateam area summation, global bootstrap summation
#missing data may require cells to be “cleared” not just whitespaced
#data can be downloaded to excel from the follwing websites
#http://nsidc.org/data/smmr_ssmi_ancillary/area_extent.html — main page with data description
#ftp://sidads.colorado.edu/pub/DATASETS/seaice/polar-stereo/trends-climatologies/ice-extent/nasateam/ — nasa team data add .n and .s together for global numbers
#ftp://sidads.colorado.edu/pub/DATASETS/seaice/polar-stereo/trends-climatologies/ice-extent/bootstrap/ — bootstrap data add .n and .s together for global numbersnb[,2]=nb[,2]/1000000
nb[,3]=nb[,3]/1000000ll=length(nb[,1])
annual=array(0,dim=365)
anncount=array(0,dim=365)
anomaly=array(0,dim=ll)
anomalyb=array(0,dim=ll)
nbts=ts(nb[,2],start=nb[1,1])##########nasateam plots
#break data into annual basis
for(j in 1:ll)
{
ind=as.integer((nb[j,1]-as.integer(nb[j,1]))*365+.5)+1
if(!is.na(nb[j,2]))
{
annual[ind]=annual[ind]+nb[j,2]
anncount[ind]=anncount[ind]+1
}
}
#calc annualied average
for(j in 1:365)
{
if(anncount[j]!=0)
{
annual[j]=(annual[j]/anncount[j])
}
}#use average to calc anomaly
for(j in 1:ll)
{
ind=as.integer((nb[j,1]-as.integer(nb[j,1]))*365+.5)+1anomaly[j]=nb[j,2]-annual[ind]
}#plot results
plot(annual,type=”l”,ylab=”Ice Area 1e6 Km^2″, xlab=”Day of Year”,main=”Global 30 yr Average Sea Ice Area\nNasaTeam Algorithm”)
grid()
savePlot(paste(“c:/agw/sea ice/Global 30 year average NasaTeam Algorithm AREA.jpg”),type=”jpg”)meanwind=nb[,1]<2000
anomalyb=anomaly-mean(anomaly[meanwind],na.rm=TRUE)
plot(nb[,1],anomaly,type=”l”,ylab=”Ice Area Anomaly 1e6 Km^2″, xlab=”Year”,main=”Global Sea Ice Area Anomaly\nNasaTeam Algorithm”)grid()
abline(lsfit(nb[,1], anomaly,NULL), col=”red”)
coef(lsfit(nb[,1], anomaly,NULL))
savePlot(paste(“c:/agw/sea ice/Global Sea Ice Area Anomaly NasaTeam Algorithm.jpg”),type=”jpg”)plot(nb[,1], nb[,2], type = “l”, ylab=”Ice Area 1e6 Km^2″,xlab = “Year”,main=”Global Sea Ice Area\nNasaTeam Algorithm”,ylim=c(0,24))
grid()
abline(lsfit(nb[,1], nb[,2],NULL), col=”red”)
coef(lsfit(nb[,1], nb[,2],NULL))
mean(nb[,2],na.rm=TRUE)
savePlot(paste(“c:/agw/sea ice/Global Sea Ice NasaTeam Algorithm AREA.jpg”),type=”jpg”)
###########bootstrap plots
#break data into annual basisannual[1:365]=0
anncount[1:365]=0for(j in 1:ll)
{
ind=as.integer((nb[j,1]-as.integer(nb[j,1]))*365+.5)+1
if(!is.na(nb[j,3]))
{
annual[ind]=annual[ind]+nb[j,3]
anncount[ind]=anncount[ind]+1
}
}
#calc annual average
for(j in 1:365)
{
if(anncount[j]!=0)
{
annual[j]=annual[j]/anncount[j]
}
}
#calc anomaly
for(j in 1:ll)
{
ind=as.integer((nb[j,1]-as.integer(nb[j,1]))*365+.5)+1anomalyb[j]=(nb[j,3]-annual[ind])
}plot(annual,type=”l”,ylab=”Ice Area 1e6 Km^2″, xlab=”Day of Year”,main=”Global 30 yr Average Sea Ice Area\nBootstrap Algorithm”)
grid()
savePlot(paste(“c:/agw/sea ice/Global 30 year average bootstrap Algorithm AREA.jpg”),type=”jpg”)meanwind=nb[,1]<2000
anomalyb=anomalyb-mean(anomalyb[meanwind],na.rm=TRUE)
plot(nb[,1],anomalyb,type=”l”,ylab=”Ice Area Anomaly 1e6 Km^2″, xlab=”Year”,main=”Global Sea Ice Area Anomaly\nBootstrap Algorithm”,ylim=c(-3,3))
grid()
abline(lsfit(nb[,1], anomalyb,NULL), col=”red”)
coef(lsfit(nb[,1], anomalyb,NULL))savePlot(paste(“c:/agw/sea ice/Global Sea Ice Area Anomaly bootstrap Algorithm.jpg”),type=”jpg”)
plot(nb[,1], nb[,3], type = “l”, ylab=”Ice Area 1e6 Km^2″,xlab = “Year”,main=”Global Sea Ice Area\nBootstrap Algorithm”,ylim=c(0,24))
grid()
abline(lsfit(nb[,1], nb[,3],NULL), col=”red”)
b=nb[,1]<2008
coef(lsfit(nb[,1], nb[,3],NULL))
coef(lsfit(nb[,1][b], nb[,3][b],NULL))
abline(lsfit(nb[,1][b], nb[,3][b],NULL), col=”blue”)
mean(nb[,3],na.rm=TRUE)
savePlot(paste(“c:/agw/sea ice/Global Sea Ice Area bootstrap Algorithm.jpg”),type=”jpg”)


cmb said
Where is this code from?
Jeff Id said
My hands.
cmb said
Then I guess I’m wondering about this:
source(”http://www.climateaudit.org/scripts/utilities.txt”)
As I’m sure you know, ClimateAudit is undegreed ex-mining-consultant Steve McIntyre’s lie site. You wrote those subroutines, did you?
Jeff Id said
CMB I like the fact that you are fairly well informed on your subject, but you have only scratched the surface of the information you like to cite. I bet many of your peers are blown away by your knowledge. Still, understand that what I am doing is digging deeper into the papers and data. Not to disprove AGW but to look for some truth.
I linked to the climate audit routine for his gaussian filter algorithm. It was unused in the code if you can read R.
A gaussian filter for a time series is a weighted filter based on a bell curve distribution with an area under the curve equal to 1. The filter sums the surrounding values multiplied by the weight and divided by the area under the curve. I have written many of these types of filters in 1 and 2 dimensions in my time but Steve has some nice endpoint treatment and has done a bunch of verification of filter performance.
Steve McIntyre posts the most open science on the subject of global warming anywhere on the web. If you find mistakes in his work, please point them out he would be happy to know. Your criticism is undeserved for sure. Again, please refrain from using the word “lie” unless you can back up your claim of intent to deceive. I assure you that Steve McIntyre has no intent to deceive.
Each time he has made an error, it has been addressed and corrected. Unlike real climate and tamino, dissenting posts are not blocked as long as they are on topic and posts are snipped in an open manner when he feels necessary.
You seem concerned that I might not be able to write this code.
In addition to the above simple code I have written algorithms for:
3 and 4 axis robotics – control system code as well as operational
image processing vision systems
computer controls for hybrid car
Headlamp alignment vision systems
Image intensity measurement using CCD cameras
Neural network adaptive pattern extraction from noisy data
Fringe analysis software for holographic interferometry
Solving multivariate differential matrices for optical optimization
Lens analysis vision systems for endoscopic lens trains
Computer control of optical testing systems
Vision systems for identification of picoliter samples in bio-testing
Computer control of optical coating systems
3D display and predicion of holographic fringe generation
–Among many other things (I’m sure I have forgotten some)
I hope that addresses your concerns about my ability to write code.
cmb said
Odd – what makes you think it is your ability I am concerned about? It’s your constant handwaving without evidence that makes it inadvisable to trust your work. Using lie site ClimateAudit’s work doesn’t help, of course.
Jeff Id said
You make the point because I may use an algorithm which is untested, perhaps I wouldn’t understand a gaussian filter. Yet if you could read the code you can see there are no function calls. Your snide tone and references to lie again is designed to make me angry, it ain’t workin.
I have laid everything out here, there is no magic or hidden info. You can download R for free and run the code yourself. You only have to build the files according to my instructions at the top. How is this handwaving?
cmb said
Jeff Id Says:
December 22, 2008 at 5:48 pm
You make the point because I may use an algorithm which is untested, perhaps I wouldn’t understand a gaussian filter.
– You persist in making up unlikely motivations for me. Is this sort of off-the-cuff invention looked upon favorably in your profession?
No, I make the point because your blog, which coincidentally is filled with crap like “leftists AGW movement” and “intentional” errors, routinely makes claims on sea ice that are the reverse of reality. Why that is occurring is actually your job to ascertain, not mine – but your post on kangaroo meat was very telling. =)