Hansen and the GHCN Manual

We’ve been discussing the bewildering methods that Hansen used to do what appears to be a trivial task: combining slightly variant versions of GHCN data at an individual station – versions, that in many cases are identical for many of their readings. As it turns out, GHCN has a manual on their data set, including a section on “Duplicate Elimination”. If Hansen had read this manual, here’s what he would have read: Continue reading

Crossword Puzzle #3

Let’s move from the 2 column case to the 3 column case (e.g. Bagdarin, already considered) applying the results here. Some of the hypotheses from the earlier discussion have to be re-visited. Bagdarin has 3 dset=0 versions (0,1,2). As we’ve seen in the 2-column case, the column that continues to the present (version 2) exactly matches the dset=1 version in the later part of the record when there is only version. Bagdarin version 0 is reduced by 0.3 deg C, version 2 by 0.2 deg C. Given these adjustments, dset=1 more or less follows.

Versions 0 and 1 are scribal variations for 1980 and after and from 1951 to 1960, but are discrepant between 1960 and 1980. For analysis, it might be a good idea to find a record that has 3 columns and is only scribal.

Hansen and Lebedeff 1987 describe an iterative procedure for combining the versions net of the deductions. My experiments indicate that this boils down to a simple unweighted average of the versions net of deductions, but this is experimental so far.

Hansen’s description (for whatever that’s worth) indicates to me that he first calculated the delta between versions 0 and 1 (or alternatively between 1 and 2), then formed an interim composite and repeated the procedure. However, I couldn’t get everyting to work. If I apply the proposed 2-column Hansen-delta calculation to versions 0 and 1, I get a delta of -0.2, followed by a delta between the interim series and version 2 of +0.1: so this doesn’t work.

If I try version 1 against version 2 first, I get a delta of 0 followed by a delta of -0.2 between the interim series and version 1.

These deltas seem quite unstable to ordering in a first peek.

So today’s puzzle: find a system for the 3-column case, consistent with 2-column results.

Of course, Hansen could always free the code.

Hurricanes 2007

New Thread.

Crossword Puzzle – Tuesday

The question today is: how does Hansen calculate quarterly and annual averages when there are missing values? It’s not obvious.

The issue arose in the previous puzzle in trying to calculate Hansen’s adjustment prior to combining scribal versions. Essentially what happens as reported in the prior post is that when there is a missing value, Hansen estimates the missing value (without doing the obvious thing and uses the available reading from a different version.) His estimates typically differ a lot from the actual value. He then says – aha, there is a bias between these versions and adjusts everything down.

As noted, Praha Dec 1986 is missing from one version and is 1.4 deg C in another version. Hansen then estimates the missing value at -3.6 deg C, a value of no less than 5 deg C lower than the actual value. There are 48 months in common, so he then concludes that the average bias is -0.1 deg C and adjusts all early Praha values down by 0.1 deg C. It sounds pretty absurd when written down. The methodology is not reported in the publications that NASA spokesman Gavin Schmidt has said to contain a comprehensive description of calculations.

Today’s puzzle: how did Hansen estimate Dec 1986 temperatures at Praha at -5 deg C (and other similar estimates)?

Your Sunday Crossword Puzzle

For your Sunday edification, today’s crossword puzzle pulls together 3 examples of Hansen data “combining”. The question is to find an AlGore-ithm that accounts for all three versions. The three data sets each have 3 columns: the first two are data versions; the third column is Hansen-combined. In each case, there is an overlap between data versions and where the data versions overlap, they are identical. In each case, during the period of one overlap, one version has one value missing and as a result of this one missing value, the early values of the version which has the earlier values is adjusted.

In one case, the missing value is a winter value; in the other two cases. In the case where a winter value was missing the earlier version was adjusted down; in a case where a summer value was missing, the earlier version was adjusted up.

Praha http://data.climateaudit.org/data/giss/61111520000.dat
Joenssu http://data.climateaudit.org/data/giss/61402929000.dat
Gassim http://data.climateaudit.org/data/giss/22340405000.dat

These are all tab-separated and can be read into Excel for Excel users.

The issue is not to find a rational algorithm that yields the adjustments: the only rational way to combine the data is just to combine the available values. The issue is to find any algorithm, however improbable. I’ve posted notes on my efforts, but am now stuck. Some things seem likely but don’t be limited by my guesses as they may be wrong.

Notwithstanding these caveats, as noted before, it appears that Hansen calculates the first month of overlapping values and last month of overlapping values. One possibility was that he calculated the difference in means over available months without any allowance for whether it was a summer or winter month missing and then uses a form of Hansen-rounding to calculate a 1-digit adjustment. I was able to get a semi-plausible formula that fit Praha and then failed Joenssu; then one that fit Praha and Joenssu, but failed Gassim. Praha has a negative adjustment to early values; Joenssu and Gassim positive adjustments. From inspecting quite a few series, I would say that negative adjustments are by far more prevalent, but we’re working here with 2-version examples for simplicity. Who knows what will happen when we get to 3 version stations.

UPDATE #1
Thank you for the various contributions and suggestions, especially to John Goetz both for identifying the problem and solving the calculation of the delta. I think that we’ve solved quite a bit of what Hansen’s done and ended up turning over another large stone: how Hansen calculates seasonal and annual averages for individual station versions. Now that we’re close to describing what he did, it appears increasingly likely to me that Hansen has corrupted his entire data set. Whether the corruption of the data set “matters” is a different issue, but the evidence is now quite powerful that the data set has been corrupted through the problems discussed below.

Let me summarize what I think that we know. In some cases, there are perhaps alternative ways at arriving at an answer and I’ve picked approaches that seem most likely to me to have been used.

Single-Digit Adjustment
I think that the evidence is overwhelming that Hansen makes an adjustment in even tenths to one column in these two-column arrays of monthly data. The delta for Praha is -0.1 to the first column; +0.2 for Gassim and +0.1 for Joenssu. After adjusting one column, Hansen then calculates a combined monthly series, that is not a direct average, but a “Hansen average” as discussed below. This leaves two problems: (1) how the single-digit delta is calculated; and (2) how the combined version is calculated from from the adjusted matrix.

Integer Arithmetic
There is convincing evidence that Hansen uses integer arithmetic in tenths of a degree. It’s possible to emulate integer arithmetic to some extent in R with a little thought. Floating point arithmetic with conventional rounding won’t yield Hansen combined series.

Calculation of the Delta
I am convinced that John G has solved the calculation of the delta. By collating monthly series, I complicated the solution of the problem because I (and people following my collations) were working only with monthly data versions. Hansen’s GISS version also includes annual versions. While it is presently unknown how Hansen calculated the annual and quarterly averages (as his method of filling missing data is unknown), John G’s method (and I’ve confirmed this with a slight variation) will recover the deltas.

Briefly, the two versions are compared to determine which years have values for both versions – this is 4-5 years in the Praha, Gassim and Joensuu cases. Then the difference between the averages is calculated, yielding the required delta (-0.1, 0.2, 0.1). In the Gassim case, the result is exactly 0.15 and when I calculated the result using floating point arithmetic, I got 0.1 instead of 0.2. So you do have to take care that one emulates integer arithmetic.

Hansen Averaging
We’ve had a variety of suggestions on how to obtain the combined value once the adjusted matrix is created – some of which are probably equivalent. I’ve re-stated my own solution to the problem since I’ve spent time confirming that it works – without excluding the possibility that some other variation was used. (BTW I think that it is very unlikely that Hansen detoured through Kelvin in these calculations though.) As I noted in a post below, here’s the evidence to consider:

1) if there is only one available value from the two-column matrix after adjustments, the adjusted value is taken whether it comes from column 1 (adjusted) or column 2 (unadjusted). No problem here. So we only need to consider averaging where both columns have values.
2) If the sum of the two columns (in tenths) is even, then the combined value is the average – no problem.
3) for Praha, if the sum of the two columns (in tenths) is odd, then the combined value is averaged up. For Joensuu, if the sum of the two columns (in tenths) is odd, then the combined value is averaged down. For Gassim, there is only one case where the sum of the two columns (in tenths) is odd – May 1990- and in this case, the combined value is averaged down.

The rounding up or rounding down depends on the sign of the adjustment. If there is a negative adjustment to column 1, it’s averaged up; if there’s a positive adjustment, it’s averaged down. I was able to implement this by checking whether the sum of the two entries was even or odd, calculating the “Hansen-average” as follows:

1) if there’s only one available value, use it.
2) if the sum of the two values is even, take a simple average;
3) if the sum of the two values is odd, add 1 if the delta is positive (i.e. subtraction in the first column) and subtract 1 if the delta is negative (i.e. addition in the first column). Then take an average.

If it seems a little longwinded, remember that we have to consider integer arithmetic.

Seasonal Averages
Now we turn to the seasonal and annual averages that underlie the troublesome delta calculations. Here we have another crossword puzzle. I’ve shown below the relevant overlapping years for the two Praha-Libu” versions – I apologize for the ragged format. I’ve bolded points of difference.

The 1986 year does not enter into the delta calculations but December values enter into the quarterly DJF calculations of the following year. The only difference between the two versions here is that Version 0 has a December 1986 value of 1.4, while Verson 1 is missing a December 1986 value. The 1987 DJF estimated first quarter for the version with a missing month (version 1) is -3.7, while the 1987 actual DJF first quarter for the version with all three months is calculated arithmetically to be -2.0. There is a second smaller difference in 1991 values which is hard to understand since all 1991 values are identical in the two versions. (Explaining this is a new puzzle.) To calculate the deltas from raw data, we have to be able to replicate how Hansen fills in missing data.

In the example below, the actual Praha temperature in Dec 1986 according to version 0 was 1.4 deg C. This information was missing from version 1. By calculating the Dec 1986 temperature required to yield the 1987 DJF average, one can easily see that Hansen estimated the version 1 Dec 1986 temperature at -3.6 deg C – fully 5.0 deg C lower than the actual temperature (Version 0). He then said – aha, version 1 measures cold relative to version 0 and therefore version 0 (which contains the older data) needs to be adjusted down (in this case by 0.1 deg C.) It’s crazy.

Praha Version 611115200000
year jan feb mar apr may jun jul aug sep oct nov dec DJF MAM JJA SON ANN
1986 0.1 -6.4 3.9 9.4 16.2 17.1 18.2 17.8 12.6 9.4 5.0 1.4 -0.8 9.8 17.7 9.0 8.93

1987 -6.7 -0.8 -0.7 9.8 11.6 15.6 18.6 16.3 15.5 9.6 4.9 1.8 -2.0 6.9 16.8 10.0 7.93
1988 2.6 2.2 2.7 9.3 15.7 16.3 18.6 18.3 14.1 9.9 1.3 2.7 2.2 9.2 17.7 8.4 9.40
1989 1.2 3.6 7.5 9.2 14.7 16.2 18.8 18.3 15.0 10.6 1.9 1.6 2.5 10.5 17.8 9.2 9.98
1990 1.5 5.5 7.9 8.1 15.3 17.4 18.7 19.8 12.0 9.6 4.4 0.3 2.9 10.4 18.6 8.7 10.15
1991 1.3 -2.9 6.2 7.8 10.2 15.6 20.0 18.5 15.3 NA 3.2 NA -0.4 8.1 18.0 9.2 8.73

Praha Version 611115200001
year jan feb mar apr may jun jul aug sep oct nov dec DJF MAM JJA SON ANN
1986 NA NA NA NA NA NA NA NA NA NA 5.0 NA NA NA NA NA NA

1987 -6.7 -0.8 -0.7 9.8 11.6 15.6 18.6 16.3 15.5 9.6 4.9 1.8 -3.7 6.9 16.8 10.0 7.50
1988 2.6 2.2 2.7 9.3 15.7 16.3 18.6 18.3 14.1 9.9 1.3 2.7 2.2 9.2 17.7 8.4 9.40
1989 1.2 3.6 7.5 9.2 14.7 16.2 18.8 18.3 15.0 10.6 1.9 1.6 2.5 10.5 17.8 9.2 9.98
1990 1.5 5.5 7.9 8.1 15.3 17.4 18.7 19.8 12.0 9.6 4.4 0.3 2.9 10.4 18.6 8.7 10.15
1991 1.3 -2.9 6.2 7.8 10.2 15.6 20.0 18.5 15.3 NA 3.2 -0.7 -0.4 8.1 18.0 9.4 8.77

Difference
year jan feb mar apr may jun jul aug sep oct nov dec DJF MAM JJA SON ANN
1987 0 0 0 0 0 0 0 0 0 0 0 0 -1.7 0 0 0.0 -0.43
1988 0 0 0 0 0 0 0 0 0 0 0 0 0.0 0 0 0.0 0.00
1989 0 0 0 0 0 0 0 0 0 0 0 0 0.0 0 0 0.0 0.00
1990 0 0 0 0 0 0 0 0 0 0 0 0 0.0 0 0 0.0 0.00
1991 0 0 0 0 0 0 0 0 0 NA 0 NA 0.0 0 0 0.2 0.04

Appropriateness of “Bias Method” for Scribal Errors
When one puts down what Hansen did in black and white, the inappropriateness becomes increasingly clear.

In this case, Hansen has estimated a value for the missing December 1986 value in Version 1. The most obvious method for estimating the value would be to use the available December 1986 value in Version 0, since these values coincide for all other points. In linear regression terms, the r2 is 1. Instead of doing this, Hansen used an unknown method to estimate the missing value. He then calculated the difference between his estimate and the actual values in the other version and stated that this difference was a bias in the versions. He then used this bias to adjust the data.

It’s pretty hard for a statistical method to be as “wrong” as this one. In the cases that we’ve seen, the error sometimes adds to early values; it is my impression that the error more often increases the apparent trend. Estimating the impact of this Hansen error on the data set is a different project. We’ll see where this goes.

UPDATE #2
The following R-function appears to calculate the Hansen-delta between two station versions. X and Y are R-data frames in GISS format with a column with name “ANN” corresponding to the 18th column in GISS format.

hansen_bias=function(X,Y) {
temp1=!is.na(X$ANN); temp2=!is.na(Y$ANN)
test=match(Y$year[temp2],X$year[temp1]);temp=!is.na(test)
A=Y$ANN[temp2][temp];#A
B= X$ANN[temp1][test[temp]]
a= sum( floor(100*A -100*B)) ; K=length(A)
hansen_bias= sign(a) *round(floor( (abs(a) + 5*K)/K)/100,1)
hansen_bias}


UPDATE #3 (Sept 8, 2007)

Hansen released source code yesterday. In a quick look at the code for this step, the combination of station information is done in Step 1 using the program comb_records.py which unfortunately, like Hansen’s other programs, and for that matter, Juckes’ Python programs, lacks comments. However, with the work already done, we can still navigate through the shoals.

The delta calculation described above appears to be done in the routine get_longest_overlap where a value diff is calculated. Squinting at the code, there appear to be references to the annual column, confirming the surmise made by CA readers. It doesn’t look like there is rounding at this stage – so maybe the rounding just occurring at the output stage, contrary to some of the above surmise. I still think that there’s some rounding somewhere in the system, but I can’t see where right now and this could be an incorrect surmise.

After calculating the delta (“diff”), this appears to be applied to the data in the routine combine which in turn uses the routine add (in which “diff” is an argument).

There is an interesting routine called get_best which ranks records in the order: MCDW, USHCN, SUMOFDAY and UNKNOWN and appears to use them in that order. I don’t recall seeing that mentioned in the documentation. I’m going to look for the location of this information in the new data as I don’t recall any prior availability of this information.

Slicing some Czech Salami

I’ve got an idea of how Hansen sliced the salami in Praha-Libus, an enterprise no doubt dear to Lubo” heart or, at least, stomach. There are only 2 series in play. Version 61111520000-0 goes from 1971 to 1991 and version 61111520000 – 1 goes from 1986 to 2007.

For all values where there is only the later version, the combined version is exactly equal to the later version 61111520000 – 1. During the period of overlap, there are 61 potential readings. In 59 of the 61 readings, both series are present and have identical values. So these series are in some sense merely scribal variations. In one of the 61 overlap readings, neither series is present. In one out of 61 readings, Version 61111520000-0 has a value of 1.4, while there is no reading for Version 61111520000-1.

When both versions are present, the combined value is equal to the common value.

But in the earlier portion of the record, the combined value is 0.1 deg C less than the value of Version 61111520000-0, imparting an erroneous slice of 0.1 deg C. from the early portion of the combined record – something that we’ve seen in many other series.

Ver0 Ver1 Combined
Jun 1985 14.4 NA 14.3
Jul 1985 18.7 NA 18.6
Aug 1985 18.0 NA 17.9

Nov 1986 5.0 5.0 5.0
Dec 1986 1.4 NA 1.3
Jan 1987 -6.7 -6.7 -6.7

May 2006 NA 14.2 14.2
Jun 2006 NA 18.1 18.1

But how can one derive this using any sort of algorithm? or Al-Gore-ithm?

Here’s a method for replicating this strange result, melding some of the ideas developed in different contexts as we’ve pondered this.

First – applying an idea that Damek presented for Bagdarin. Obviously if you calculate the difference between the two series for the months in which they have common values, you don’t generate any difference. Damek hypothesized that Hansen calculates the start and the end of the period for which the two series have common values and then calculates their means over the total period. So in this case, the mean for version 0 is calculated over 60 months and for version 1 is calculated over 59 months. Since the missing value of version 1 is a winter month, this yields an “upward bias” for version 1 of 0.1316102. I took this value to one digit 0.1 and then subtracted .01 from it (this derives the result, but there is probably some equivalent rendering), yielding a “warm bias” of 0.09 for version 2, the one continuing to the present. Here’s the code for this step:

temp=!is.na(X[,1])&!is.na(X[,2])
K= range(time(X)[temp])
temp1= (time(X)>=K[1])&(time(X)< =K[2]);sum(temp1)
m1=round(apply(X[temp1,1:2],2,mean,na.rm=TRUE),1)
delta=m1[2]-m1[1] -.01; delta #0.09

In this case, series 2 continues to the present and therefore is not adjusted. Instead of deducting the warm bias from the “warm” series, Hansen deducts it from the other series. It’s pretty hard to deduce a rationale for this, other than mixing up signs, but there is no doubt that it’s deducted from the earlier version. Then do Hansen-rounding: multiply by 10, add 0.49999, take the floor and divide by 10.

Bingo – an exact match.

y= floor(10* apply(cbind(X[,1]-delta,X[,2]),1,mean,na.rm=TRUE)+.4999 )/10
range(y-combine[,3],na.rm=T)
#[1] 0 0

In this particular case, there is quite obviously no bias in one version relative to the other. There is one missing value in one series. However, as a result of one missing value, Hansen added 0.1 deg C to the warming at Praha – Libus relative to a rational combining of records.

Is this what Hansen actually did? It will take some more experiments to find out? However, I’m convinced that this is getting the salient features on the table.

Hansen's "Bias Method"

John Goetz sent me some scanned excerpts from Hansen and Lebedeff 1987 which (only somewhat) clarify what Hansen’s doing – although the descriptions below do not clarify the Kalakan problem of how the combined station record becomes colder than any of the measurements in the period. There are somewhat different issues in combining records which are only subject to scribal errors and records from different stations – something that Hansen didn’t discuss (and which I’ll try to get to). But bear in mind that both situations arise and may call [almost certainly call] for different techniques. The method that one gets used to in climate analyses is the “anomaly method” in which a reference period is established (say 1961-1990) and then deltas (“anomalies”) are calculated from averages (taken monthly) over the reference period.

My perception that Hansen didn’t appear to be using the anomaly method appears to be correct based on closer analysis of these excerpts. Instead, Hansen uses what he describes, with perhaps unintended irony, as the “bias method”. I’ll try to explain the method and then provide an example, suggesting that his nomenclature may be quite apt. Again, none of these comments are written in stone, as it’s hard to work through what they actually do in the absence of either adequate documentation or source code, and it’s easy to get wrongfooted. Continue reading

Waldo: Adjusting in Russia

Ever wonder how to adjust in Russia – or what sot of gestures Russian adjusters make when they’re jesting and not jetsetting? Here are Hansen’s urban adjustments for 4 different Russian “urban” sites.

In the graphics shown, an upward adjustment in the past is an upward re-statement to increase past temperatures to compare with present temperatures and is more or less what one expects. So why do Ivesk and St Petersburg have opposite patterns? Why does Hansen think that the UHI in St Petersburg has declined in the past 15 years? Why does Hansen adjust for UHI at Cita, Siberia back to 1980 and then cancel out the adjustment going back to the 1930s? Why is there no adjustment at Magadan?

The skill-testing question: provide a rational physical theory from which one can derive these urban adjustments.

waldo_59.gif

waldo_61.gif

waldo_62.gif

waldo_60.gif

Waldo in India

I’ve been rather looking forward to a post on Waldo in India. I’ve been to India 4 times, though not for many years. I’m probably the only climateaudit reader who’s swum across the Ganges and one of the few pictures of my 1968 that’s survived is me in the Ganges. Today Waldo has another potentially strange adventure – although again I feel like I’m just scratching the surface of this one right now. Continue reading

Waldo "Slices Salami"

I’ve noticed that even Hansen’s rounding seems to give a little edge to modern values relative to older values. It’s not a big effect, but Hansen doesn’t seem to like to leave any scraps on the table. Cara, Siberia has 3 versions – all of which appear to be the same station; all 3 versions cover more or less the same period (Data here ) and, in this particular case, the values only go to 1990.

As a first step, it seemed to make sense to take a simple average of the data (first 3 columns of data at link) and compare it to the Hansen combined version (4th column). The Hansen combined more or less matched the rounded average up to 0.1 deg C, but the differences were not random: Hansen was always lower as shown in the first panel. In the second panel, I’ve pretty much matched Hansen by doing the following:
1) calculate the average rounding to 2 digits; 2) multiply by 10, take the floor and then divide by 10.

Typically, this sort of situation only affects pre-1990 data. GHCN made a major collection effort around 1990. In this particular case, the data hasn’t been updated after 1990. IT’s not that this station necessarily ceased measuring temperatures (as often thought); it’s may be that GHCN (and thus NASA and CRU) merely haven’t updated it since 1990. GHCN says that it updates rural stations only “irregularly” and, as it happens, the “irregular” schedule apparently hasn’t included any updates since 1990 for large areas of the world – so NASA are CRU are “forced” to rely for more recent readings primarily on the WMO airport system, which presumably is more urban-biased than the historical network. For these later readings, multiple scribal versions do not arise and “Hansen rounding” doesn’t come into play. A small effect to be sure, but Waldo is voracious and seemingly no scrap is too small.

bagdar45.gif