Saturday, March 23, 2013

Proxy viewer with choice of dating and range



In a previous post I showed an active viewer for the Marcott et al proxies, and in the next I described the code. There has been interest in various extensions, to give the option of showing the revised dating of Marcott et al, and also to show a closeup on more recent times.

This is a combined viewer that does those things. The format change is simply that there are a few more entries in the key table, in black at the start. They are
  • "AuthHolo", for Published (author) dating, -50 to 11300 BP
  • "MarcHolo", for Marcott et al dating, -50 to 11300 BP
  • "Auth2000", for Published (author) dating, -50 to 1950 BP
  • "Marc2000", for Marcott et al dating, -50 to 1950 BP
If you click on any of these, it will change to that scale. You have to click again to select a proxy.






Friday, March 22, 2013

February GISS Temp down by 0.11°C


There's a mixture of trends this month. GISS LOTI went from 0.6°C in January to 0.49°C. Satellite measures were well down, but NOAA rose from 0.54°C to 0.58°C. TempLS showed a small decline.

In other news, the equatorial Pacific jet changed from cold to warm in March. That may be transient.

The GISS map for Feb is not yet available. I'll update with a comparison when it is.
Update The map is available - I've compared below.


Update. The GISS site had this note:
"2013-03-21: The update this month was postponed a week while we investigated some bad reports from various stations in Mongolia. NCDC eliminated the reports today."

Here is the GISS map for Feb 2013:


And here, with the same scale and color scheme, is the earlier TempLS map using spherical harmonics



Previous Months

January
December 2012
November
October
September
August
July
June
May
April
March
February
January
December 2011
November
October
September
August 2011

More data and plots



Thursday, March 21, 2013

Code for the spaghetti plot active viewer



I have occasionally posted active viewers of spaghetti plots - most recently the Marcott proxies. There has been interest in how it's done, so I am posting here a fairly generic code. A combination of R and Javascript is required, although I've been able to make the Javascript work from data, so it doesn't have to be specially written for each plot. The work is done in R.


So I'll post the R code and make the Javascript available in a zip file. In R, the spaghetti plot is made, and then a minimal plot with transparent background is made of each component curve, in black. These are png files. The Javascript organises the superposition of them.

Everything you need should be on this zip file. You need to run your data through the makejs() R routine, then display the active.html file.
Update 11.47am 21/3 GMT I fixed something in the zip file

The R program

The key element of the R program is the function makejs(). This takes arguments similar to what you would supply to a spaghetti plot routine. The first, xy, is a list of 2-column coordinate matrices, one for each curve. Then xlim, ylim are the x and y ranges, eg c(0,9). These are all required, as is a vector of labels for each curve, to go in the clickable table.

Then there are inputs with defaults. met is a vector of metadata to be displayed with each visible curve, one string of HTML for each. Default is "", which means no display. Fil is a vector with first component a directory, and second a filename prefix. The directory and prefix will be attached to graphics files, and the directory is passed to the Javascript.

In the program as shown, I then assemble the inputs for the Marcott proxies and run the function. Outputs are the spaghetti plot, black line plots and a file called prox.js, which carries information to the Javascript.

HTML and Javascript

It's best at this stage to run with all files in the same directory, with the images in a subdirectory. The html is called active.html, and you can run it locally. Just click in the file explorer. Files you should have there are:
active.html, prox.js
reddot.gif, X.png, X101.png et seq, and Xkey.png (the table).
X is your file prefix (input to makejs()); images should be in your designated graphics dir.

The Marcott stuff uses prox.sav as data - also on the zip.

The R program code


# This program was written by Nick Stokes, www.moyhu.blogspot.com Mar 21 2013, to process input for a complex plot, and to output the graphics and js files for an active plotter. Describes at: www.moyhu.blogspot.com
# Made available under the terms of the GNU GPL

#The key routine is makesjs(), which can be used generally.
#I am using it here for the Marcott et al proxies, described
#https://moyhu.blogspot.com.au/2013/03/an-active-viewer-for-marcott-et-al.html

makejs=function(xy,xlim,ylim,lab,met="",Fil=c("./","proxy")){
N=length(xy); fil=paste(Fil, collapse="")
# Working out the layout for the key
ii=round(sqrt(N/2));jj=N%/%ii+1;
iw=round(max(nchar(lab))*7.5);nw=iw*ii;nh=jj*18;
# Assembling data for javascript
b=sprintf('Yxdir=["%s","%s"]; YxT=[%s,%s,%s,%s,%s];',
Fil[1],fil,N,jj,ii,iw,18)
b=c(b,paste("Yxmet=['",paste(met,collapse="','"),"'];",sep=""))
write(b,file="prox.js")

# The spaghetti plot
cls=rainbow(N,v=0.99,end=0.9)
png(sprintf("%s.png",fil),width=wid)
plot(xlim,ylim,type="n",xlab="Years BP",ylab="proxy anomaly deg C")
for(i in 1:N){
lines(xy[[i]],col=cls[i])
}
dev.off()
# The black line plots
for(i in 1:N){
png(sprintf("%s%s.png",fil,100+i),width=wid)
par(bg="#ffffff00") # The transparent background
plot(xlim,ylim,type="n",axes=F,xlab="",ylab="")
lines(xy[[i]],lwd=2)
dev.off()
}
cls=rainbow(N,v=0.7,end=0.9) # darken the colors
# Now make the key - labels lab[]
png(sprintf("%skey.png",fil),width=nw,height=nh)
par(mai=c(0,0,0,0))
plot(c(0,nw),c(0,nh),type="n",xlim=c(0,nw),ylim=c(0,nh),xlab="",ylab="",axes=F,xaxs="i",yaxs="i")
for(i in 1:ii-1)for(j in 1:jj-1){
k=i*jj+j;
if(k<N) text(i*iw,nh-j*18-9,lab=lab[k+1], col=cls[k+1],pos=4);
}
dev.off()
} # End function makejs

## End of generic code. The rest is the Marcott example

# Make anomalies about tm period
anomalize=function(tm,xy){
for(i in 1:length(xy)){
p=xy[[i]]
y=approx(p[,1],p[,2],xout=tm)
xy[[i]][,2]=p[,2]-mean(y$y)
}
xy
}

load("prox.sav") # loading data from Marcott et el SM
wid=800
graphics.off()
cls=rainbow(73,v=1,end=0.9)
xlim=c(-50,11300); ylim=c(-5,5);
prox=anomalize(4500:5500,prox)
# Input xlim,ylim,xy,proxst
# xy is list(N) of nx2 matrices, one for each proxy (variable n)
# proxst is a Nx2 string - labels and metadata
lab=c("GeoB5844-2","ODP-1019D","SO136-GC11","JR51GC-35","ME005A-43JC","MD95-2043","M39-008","MD95-2011","ODP 984","GeoB 7702-3","Moose Lake","ODP 658C","MD95-2011;HM79-4","IOW225517","IOW225514","M25/4-KL11","ODP 1084B","AD91-17","74KL","74KL","NIOP-905","NIOP-905","MD01-2421; KR02-06","GeoB 3910","Dome C","GeoB 7139-2","Dome F","18287-3","GeoB 1023-5","GeoB 5901-2","KY07-04-01","Hanging Lake","GeoB 3313-1","Lake 850","Lake Nujulla","PL07-39PC","MD02-2529","MD98-2165","MD79-257","BJ8 13GGC","BJ8 70GGC","MD95-2015","Homestead Scarp","Mount Honey","GeoB 10038-4","TN05-17","MD97-2120","MD97-2121","17940","Vostok","D13822","M35003-4","OCE326-GGC26","OCE326-GGC30", "CH07-98-GGC19","GIK23258-2","GeoB 6518-1","Flarken Lake", "Tsuolbmajavri Lake","MD01-2390","EDML","MD98-2176","MD98-2181","A7" ,"RAPID-12-1K","NP04-KH3, -KH4","Agassiz & Renland","GeoB6518-1","MD03-2707","GeoB 3129","GeoB 4905","MD01-2378","MD02-2575");
lab=paste(1:73,lab)
# Make metadata strings
met=lab
s=c(" Proxy #","<br>Type: ","<br>Calibration: ","<br>Lat=",", Lon=",", Alt=",
"<br>Resolution = ","<br>Season: ","<br>Ref: ")
s=paste('<span style="color:blue">',s,'</span>',sep="")
for(i in 1:73){
p=meta[i,]
met[i]=sprintf("%s%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
s[1],p[1],p[2],s[2],p[3],s[3],p[4],s[4],p[5],s[5],p[6],s[6],p[7],s[7],p[8],s[8],p[9],s[9],p[10])
}
# Now run makejs()
makejs(prox,xlim,ylim,lab=lab,met=met,Fil=c("png/","prox"));

Tuesday, March 19, 2013

An active viewer for Marcott et al proxies



In previous  posts I have been going through a simplified emulation of the Marcott et al Holocene temperature reconstruction. I think it will be helpful to provide an active Javascript viewer of the individual proxy data given with that paper.

I made a spaghetti plot of the linearly interpolated proxy temperature anomalies (base 4500-5500 BP) against published dates (not modified). There is a table that you can click on to make each one show up as a black curve. At the same time, the metadata from the Marcott et al SM is shown, and there is a map which shows where the proxy is from.

Update. I've made an extended viewer which lets you look at the effect of dating change, and to see a plot of just the last 2000 years.

Update. At Climate Audit, it was suggested that it would be good to be able to black two (or more) curves at once. That is easy, but it is not so easy to make clear which is which. So I've added a swap button. To compare two curves, select one, then the other, and then click swap as often as you want. The last two curves will alternate.