Saturday, October 22, 2011

A combined KMZ file for BEST, GHCN, GSOD and CRUTEM3

Update I have modified the ALL4.kmz file, which you can download here. I updated the data.txt file, where BEST had mistakenly posted the MAX file. And I found the problem which had led to the previous version showing very little early BEST data. BEST had a  column saying how many days in each month had readings, and I set a filter to require at least 10 days. However, much of the early period had this set to -99, which meant the data was rejected. I have removed the filter, and now there are a lot of pre-1850 sites.


This is a development foreshadowed in the previous post. I have put a combined .kmz file with data from 4 land station datasets. GHCN is actually v2, but there is very little difference at this level between v2 and v3. CRUTEM3 is the version released in July, discussed here. GSOD was discussed here.

There is now much more information - in fact, when you open the file in Google Earth, it looks colorful but cluttered. The pushpins are colored according to dataset - yellow for BEST, green for GHCN, red for GSOD, and a sort of dull green for CRUTEM3. They also vary in size - the smallest has 0-30 years of data, next has 31-60, and the largest has more than 60.

But the key to looking it is that the data is stored in folders. At the top level, there is a folder for each dataset. At the next level down, they are classified according to start year of data. The ranges are 0-1850, 1851-80, 1881-1900,1901-1920, 1921-30, 1931-40, 1841-50, 1951-60, 1961-70, 1971-80, 1981-90, 1991-2000, and 2001-2011. As I'll show in the next picture, in Google earth you can toggle on/off at any level. If a dataset is on, you can toggle the year folders. If you want to see in any set the years before 1921, just toggle off the later folders.

Update - I had a warning briefly that there were spurious sites in the BEST folder. These had start years of -9.9999 and so went into the pre-1950 folder. That is fixed, but there's a new problem that the pre-1850 folder is almost empty. That could be real, but the BEST Team have done analyses for this period. See below for a discussion of the data.Fixed

The Start year, End year and Duration have been added to the pop-up balloon that you get by clicking on a station. The file is called ALL4.kmz, and can be found here.

Here's a GE snapshot of the toggle facility. You have to click on a few +s to see this. GSOD and CRUTEM3 are not visible. BEST shows only stations with data before 1971. GHCN is visible, but you'd have to open that menu to see which years. I had it matching BEST.

Added: To get the data years for BEST, I used the data.txt file in their PreliminaryTextDataset folder. That looks right, but I need to investigate to see if it includes everything. There seem to be early stations missing.

A KMZ file for the BEST stations

Update - the latest post points to a more comprehensive KMZ file
In the BEST text data zip (warning - 200 Mb), there is a listing of 36736 stations in the file site_detail.txt. I've made a KMZ file (1300 Kb), which is in the file repository under the name "best.kmz". If you download it and click on it, it will bring up Google Earth (if you have it installed) with all the stations marked with yellow pushpins.

If you click on a pushpin, a balloon will pop up with some minimal data (Name,ID's, Altitude, Lat/Lon). Later if I get some analysis done, I'll produce versions with folders, colors and more info. Here's a GE snapshot:




Friday, October 21, 2011

The Berkeley Surface Temperature (BEST) analysis

I woke up this morning and saw that the BEST analysis papers and data where online. And there were already posts at Judith Curry's, WUWT, Tamino's and Stoat, and soon one by Zeke at the Blackboard. The dynamic blogroll here put Zeke's upbeat "Some interesting results from BEST" directly above Stoat's pithier "BEST is boring".

My expectations had been somewhat more in line with Stoat's, and indeed the concensus seems to be that it confirms what had been known. But I was interested in the analysis, mainly because the claimed novelty was the least squares method that TempLS uses, which I thought David Brillinger would have improved considerably.

One of the minor surprises was that DB was not on the list of authors of the main analysis paper, despite being one of the big names on the Team. However, he is acknowledged handsomely, and the sophistication of the statistics does indicate his contribution.

There have been a number of other analyses in the last two years which, like BEST, confirm the major indices. Some were land-only, others included sea surface temperatures.

So, with that preamble, here is a very preliminary discussion, mainly of the paper Berkeley Earth Temperature Averaging Process.



The main thing that has puzzled me about this project is that they have restricted themselves to land-only. I heard that the funding ran out before they could include oceans, but I thought the priority was odd. There isn't much point in fancy stats when 2/3 of the globe is missing. They go into a discussion of the different ways the land-only indices handle this problem. They, like NOAA, treat the stations as representing land only. GISS weights the stations in such a way that they attempt to represent the whole globe. BEST says the issue has had insufficient discussion. I think that the BEST discussion fills a much-needed gap in the literature. The land-only indices should really be of only historical interest.

Anyway, they have done some things in the modelling I had been putting off, specifically kriging. TempLS analysis is based on OLS, which effectively assumes that the residuals are independent, identically distributed. Of course that isn't true, and it is possible to improve. I had that on the back burner, mainly because I suspected it would make no real difference to the mean estimate, though it gives a better handle on the error. I think that BEST have affirmed that, which is valuable.

Their model (eq (4)) is
\(d_i(t_j) = \theta(t_j)+b_i+W(\vec(x)_i,t_j) + \epsilon_{i,j}\)
for the temperature in the i-th station at the j-th timestep, and bi is the baseline temp at station i. θ is the global variation. The TempLS equivalent (omitting the noise ε) is:
dsmy  ~  bsm  +  θy

 TempLS decomposes timestep into years y, months m and s corresponds to i above. A big apparent difference is that TempLS includes seasonality in the baseline. It's not currentrly clear to me what BEST does here. The online summary says that they allow for it at a later stage. The TempLS global function can be assumed to vary with year only or with year and month. For trends it makes little difference to the result.

BEST's weather term W  is estimated from correlations. I'm not sure why it is done this way rather than including the correlation in the weight function.

TempLS does a weighted fit in which the weight is by area density (and zero for no record). BEST put a lot mote into their weighting. They use a kind of kriging which adds spatial structure, and they weight by the confidence they have in the reading. Naturally this is only very approximately estimated.

An interesting sub-discussion is on the number of degrees of freedom. They say that 180 well-placed stations should be enough, echoing a figure of Phil Jones. Others  say even sixty would do, and TempLS did this analysis, fairly successfully.

TempLS avoided homogenization (with little apparent effect); BEST introduce a new technique - the scalpel. Or fairly new - they break the series into two when they suspect a station discontinuity, and reduce the weighting nearby to compensate for the greater uncertainty. I suspect the loss of information here is rather great - with the lower weighting, of course, but also the much lower confidence in the baseline means of the fragments (assumed independent) rather than the higher confidence you would have in a longer period.

They also intervene to identify outliers - not by removing them but by reducing the weighting (with similar effect). There are some dangers in this, and one needs to think with a dataset like GHCN how it interacts with the efforts that have already been made to remove outliers. "Outliers" in a preprocessed data set are much more likely to represent real data.

They do a much more sophisticated uncertainty analysis than TempLS, and I like their jackknife approach, and will probably use it. On the other hand, I think their spatial uncertainty analysis is rather pointless when they cover land only.

They break the station baseline temperatures (climatologies) down by latitude and altitude. I'm not sure why, as it isn't helpful for an analysis of global temperature. It is of independent interest, but the analysis could have been done separately on the derived baselines.

There will be several posts to come. I've only just started to look at the Matlab code. An ambition is to port it to R, but there is quite a lot of it. Currently the zip file of text data is somewhat corrupted - I've managed to get all but the flag.txt file, which probably is not needed to get started. Of course, the paper discussed here uses GHCN data only. Maybe I'll be able to compare BEST and GISS on the same data.


Monday, October 17, 2011

GISS Sep 11 - down 0.13°C

Giss Data is out, so, as I have done recently, I'll compare with the TempLS calculation. The monthly global mean anomaly average was down from 0.61°C to 0.48°C (1951-1980 base). TempLS had a small decrease (0.025°C). NOAA had an even smaller one, UAH slightly larger, and RSS had a minute rise. Numbers and plots are here.

Below the jump are the GISS global plot and TempLS. Similar features, but GISS showed larger excursions. This is to be expected, as the TempLS fitting process has a smoothing effect.


Here is the GISS Plot:


And here is the TempLS plot. It comes from this post  which also showed an interactive spherical projection.





Saturday, October 8, 2011

September GMST - TempLS down from 0.444 to 0.42

The TempLS analysis, based on GHCNV3 land temperatures and the ERSST sea temps, showed a slight cooling from August. The August temp itself came down from 0.45 °C to 0.444°C with inclusion of late data, and September's mean land/sea temperature anomaly came out as 0.42°C, relative to the 1961-1990 base period. The data and plots are at the latest ice and temperature data page.

Below is the graph (lat/lon) of temperature distribution for September. There is also an interactive world map.




This is done with the GISS colors and temperature intervals, and I'll post a comparison when GISS comes out.

And here, from the data page, is the plot of the last four months:



Finally, here is the interactive worldview of Sept surface temperatures. Just click on the yellow squares to see different views of the Earth. The bottom square is the S pole view. The first click takes a second or two for loading.


Monday, September 26, 2011

Feedback

There's been more feedback discussion at Climate Audit. And since people are talking from different professional points of view (lots from EEs lately) I thought it would be useful to try to draw together the terminologies, and relate the concepts.

Here's a TOC:


Electrical

I'll draw heavily on Wikipedia in this post. Here's a diagram of a feedback amplifier:

Engineers think of how this circuit would operate on sinusoids, so the open loop gain AOL and the feedback factor β may be frequency dependent. The formula for closed loop gain is:


If β is positive, in this convention, the feedback is negative, because it is fed back to the negative input port. And the closed loop gain is less than open-loop. But note that the statement that it is negative is frequency dependent.

The closed loop gain is the factor by which you multiply a frequency component of the input I(f) to get the output O(f).\[O(f)=A_{fb}(f) I(f)\] And if you go to the time domain by inverse Fourier Transform, this becomes a convolution: \[O(t)=\int_{-\infty}^{t}\hat{A}(t-\tau)I(\tau) d\tau\] where \(\hat{A}\) is the inverse Fourier Transform of the closed loop gain Afb

Factor: For consistency, set α = -β. Then the ranges are:
  1. α < 0 : negative feedback - stable
  2. 0 < α < 1/AOL : positive feedback - stable (but getting less so)
  3. α > 1/AOL : positive feedback - unstable (oscillation)

Z-transform

EE's often use a Z-transform to represent time series in a kinda frequency domain way. I think of it as a modified discrete-time Fourier transform. It renders the transfer function as, often, a rational function and allows you to study the stability and other aspects of the response in terms of the location of its poles. More later

Time Series

Feedback is the AR part of ARMA. The transfer function is analogous to a version with exogenous inputs (ARMAX). Or you can look at the original version as formally analogous with the noise acting as input.

Anyway, if you treat the lag operator as a symbolic variable, you see again a rational function acting as a transfer function. That is developed into a Z-transform equivalence here.

Factor: In time series, there isn't a commonly used equivalent of the boundary between positive and negative feedback, in the amplifier sense. There is a stability criterion, which can be got from the Z-transform expression. It requires locating the roots of the denominator polynomial (poles). Then, in this formulation, the roots have to have magnitude >1 for stability. For 1st order: \[y_n+a_1 y_{n-1}=...\] the requirement is that |a1| < 1.

Climate - equilibrium

This goes back at least to the Cess definition used by Zhang et al 94, for example. Suppose you have equilibrium T=0 and flux=0. Then you impose a forcing G W/m2. The system incorporates a number of temperature dependent flux terms Fi, which, with the sign convention of G, each vary with T as
                                    ΔFi = -λi ΔT.
So the new equilibrium temperature is
                                   T = G/λ,
where λ is the sum of the λi. The nett feedback is negative, else runaway, but the components of the sum could be positive or negative.

Globally, for example, there is a base "no-feedback sensitivity" feedback of about 3.3 W/m2/C, based just on BB radiation. The exact amount is not important here. That gives the often quoted 1.2 C per CO2 doubling. Although not usually thought of as a feedback, it goes into the sum of feedback factors. The λi that add to it are called negative feedbacks, because they add to the stabilization. Those that subtract are positive.


Comparison with Elec and Time Series - much simpler.It's equilibrium (DC) - there are no dynamics. Time does not appear.

Climate - non-equilibrium

DS11 and SB11 add some thermal dynamics, with the equation \[C dT/dt = G - \lambda T\] measuring the time response to the perturbation provided by G. Their time scales are too short to assume equilibrium. This approaches steady state as the temperature approaches G/λ, the sensitivity value. C is the thermal capacity. Adding the gross dynamics does not change the feedback concepts (though it expresses the potential for thermal runaway). In EE terms, C is a single capacitance,and you could think of it as a resistance (1/λ)-capacitance(C) circuit. But I don't think that changes any of our feedback issues.

[Added:]
The DE shows an ARMA analogue if you convert the derivative to a difference: \[T_n-T_{n-1} = -\lambda {\delta}t T_n + {\delta}t F(t_n) \] or \[T_n = (T_{n-1}+ {\delta}t F(t_n))/(1+\lambda {\delta}t) T_n \] which starts to look like the closed loop gain equation. But it's also very like ARMAX(1,0,1)

The differential equation has the solution: \[O(t)=\int_{-\infty}^{t}e^{\lambda*(t-\tau)}F(\tau) d\tau\] very like the iFT time domain expression of the closed loop gain. It has, however, a restricted transfer function, corresponding in EE terms to a single pole. This can be seen by Laplace Transform: \[s \hat{T} - T(0)=-\lambda \hat{T} +\hat{F}\] or \[\hat{T}= (T(0) + \hat{F})/(s +\lambda)\]

There are plenty of ways to generalise the de approach. T could be a vector and λ a square matrix, which would give multiple poles. Or λ could be a function of t, perhaps with a convolution operation.

Comparison with Elec and Time Series - simple dynamics of heat storage. But there are no time-scales associated with the individual feedbacks. They are not reactive. I don't think there is any need to consider phase shift in the feedback.




Sunday, September 18, 2011

A faulty tapering

I see there's renewed interest at Climate Audit in discussing Bart's code for relating temperature and cloud radiative fluxes (CRF). I've discussed it a lot there, and on the past few posts here. But I'm bogged down there explaining what I believe is a simple error, which I'd like to explain here in more detail.

There is questioning at CA as to whether the whole approach is the right way to try to analyse feedback between these variables. There is a confused notion of causality. I agree with that. But here the aim is more limited.



Here's the problem. We have a variable dR (CRF) and we have a model for its dependence on T: \[dR(t) = \int_{-\infty}^\infty h(t-\tau) T(\tau) d\tau\] Just convolution. This can be resolved by Fourier transform FT, which converts convolution into a product: \[FT(dR) = FT(h) * FT(T)\] and so \[h = iFT(FT(dR)/FT(T))\] iFT being the inverse FT. Of course, all this is implemented wqith the discrete Fourier transform (DFT), and in practice with FFT.

I'll analyse a simplified version of Bart's code translated to R. Here it is:

data=read.csv("flux.csv",skip=0);
data[is.na(data)]=0;
temp=data[,9];
dR=data[,5]-data[,8];
# temp and dR are the data vectors, length 124 months N=length(dR);
dT=1/12;
Nsamp = 8192;
Npad=Nsamp-N;
X=fft(c(temp,rep(0,Npad))); # pad temp to 8192 points and FFt
Y=fft(c(dR,rep(0,Npad)));
# Inverse FFT to get the impulse response
h = Re(fft(Y/X,inv=T))/dT/Nsamp;
# now h is tapered; Nc=Nsamp/8;
w=c(rep(1,Nc),(1+cos(pi*(1:Nc-1)/(Nc-1)))/2,rep(0,6*Nc));
H=dT*fft(h*w); # Fourier transform of tapered h;


So X and Y are duly FFT'd, with lots of padding. There are 8192 frequencies, all multiples of a base frequency (1/8192) RPM (revs per month), and 8192 month in the time range.

Periodicity

Now the first thing to remember with the DFT is that everything is periodic, with period 8192 units. That is because everything is expressed in linear combinations of harmonics of that base frequency. That applies to everything that emerges from an FFT or an iFFT. Being periodic, it is best to visualize it on a circle.

Impulse response

So back to the code. Down to the calculation of h, as an FFT of Y/X, it's straightforward. And h is indeed the vector which convolves with T to give dR to near machine accuracy. To emphasise the periodicity, I'll show two periods. It looks like this:


The y-axis is scaled for the smoothed h (30 month triangular filter). The unsmoothed is scaled down by a factor of 40. Now I'll show a window about t=0:


There's clearly a lot of noise. The reason is basically that there are only 104 units of real information of temp, and the large number of vectors orthogonal to that are used to fit the padding.

Both sides matter

Now Bart says that the negative t part of h is pure noise and can be discarded. That's not true. To show this, just run the problem with the data in reverse order. The problem has exactly the same form. What does the smoothed h then look like:


The same as before, but exactly reversed. Is the negative t part now noise? It's exactly the same numbers as before, on the positive side.

Very strange taper



So Bart wants to taper h. He creates a taper w which looks like this. Again it's periodic (there's no other domain), so I'll show 2 periods:


Max w is 1; the y axis is scaled for h, which is shown in the background.

So now there are two problems. One is that the taper cuts of a part of h that matters - the negative t part. This has the result that the tapered h no longer convolves with T to give dR. In fact, it gives this, after a little smoothing (10 mth triangular):



The red curve from h exactly matches; the gold curve from tapered h does not. That's serious, because reproducing dR is what h is supposed to do. If it reproduces something else, then any results apply to that quantity.

Frequency response of taper

A less serious, but even more obvious issue is the taper itself. When you cut data, you in effect multiply by a gate function, which is 0 where you cut, and 1 elsewhere. The effect in the frequency domain is to convolve with the FT of the gate. You want to make as little difference as possible in medium frequency ranges, so that FT should be narrow, like a delta function. But an actual gate (square wave) tapers off slowly in the frequency domain, as inverse freq, often described as 6 dB/octave.

The rule is that the rate of roll-off (in dB) is proportional to the order of the first derivative that does not exist (somewhere). For a gate, that is 1. For a Hann taper, which is a  period of cos^2, the second derivative exists, but is discontinuous at the join. So the roll-off is 18 dB/octave.

Now Bart is using half a Hann filter, with an adjoining flat stretch. That's fine, but is spoilt by the cut at zero. In the frequency domain, his taper looks like this (magnitude). The red line has slope 6 dB/octave


As a taper, it performs very poorly. It should attenuate at at least 18dB/octave. Now of course that is not so serious. It could be omitted. But it indicates the wrongness of the thinking.

For completeness, here is the R graphics code that I used:

# For display, I stretch the variables to cover two periods.
# Then I select subsections of the range using xlim
f1=c(1:15,15:1); f1=f1/sum(f1);
q=Mod(fft(w)); q=c(q,q);

w=c(w,w);h=c(h,h);
hs=filter(h,f1,circ=T);
hm=mean(h[1024:7168]); hh=h-hm;
f1=c(1:5,5:1); f1=f1/sum(f1);
cum=cumsum(hh)*dT; cum=filter(cum-cum[Nsamp/2],f1);
x=(1-Nsamp):Nsamp;
wh=w*h; wm=w*(max(wh)/2)
xl=c(1,Nsamp,-300,300,-800,800);
graphics.off();
cl=c("black","grey","red","green")

png("post/f1.png",width=1000);
plot(x,h/40,type="l",col=cl[2],ylim=c(-2.5,1.5),xlab="Month",ylab="Response W/m2/C",
main="Impulse response CFR to temp");
lines(x,hs,col=cl[3]);
legend("topright",c("h","h smoothed"),text.col=cl[2:3])
dev.off()

png("post/f2.png",width=1000);
plot(x,h/40,type="l",xlim=xl[3:4],ylim=c(-2.5,1.5),col=cl[2],xlab="Month",ylab="Response W/m2/C",
main="Impulse response CFR to temp");
lines(x,hs,col=cl[3]);
legend("topright",c("h","h smoothed"),text.col=cl[2:3])
dev.off()

png("post/f3.png", width=1000);
plot(x,wh,type="l",col=cl[2],xlab="Month",ylab="Response W/m2/C",
main="Tapered impulse response CFR to temp, and taper");
lines(x,wm,col=cl[3]);
legend("topright",c("Tapered h","taper"),text.col=cl[2:3])
dev.off()

png("post/f5.png");
plot(x/Nsamp,q,type="l",xlim=c(1,800)/Nsamp,log="xy",col=cl[1],xlab="Freq RPM",ylab="Mag FFT(taper)",
main="Impulse response CFR to temp");
lines(x/Nsamp,1000/x,col=cl[3]);
dev.off()