This set of python scripts calculates the overall change in fractional organic burial over Earth history using regression analysis, as described in J. Krissansen-Totton, R. Buick and D.C. Catling (2015) A statistical analysis of the carbon isotope record from the Archean to the Phanerozoic and implications for the rise of oxygen, American Journal of Science. The python script Main_code reproduces the values in tables 1 and 2 in the main text, and the distributions used to produce figure 4. There will be minor differences between the results reported in the text and the results from this code because it is a Monte Carlo method.

Requirements:
Python, numpy module, scipy module, statsmodels module
Python and all the packages above are available for free through in the Enthought Canopy (Canopy Express) available here: https://store.enthought.com/

Main_code: 
This should be run in python to reproduce values in main text. It obtains distributions for the gradient and intercept for all three linear regression methods, ordinary least squares (OLS), classical generalized least squares (GLS) and bootstrap GLS. These distributions are sampled to obtain changes in fractional organic burial for all the regression methods (table 2, main text). It also calculates changes in organic and carbonate isotopes separately (table 1, main text).

GLS_shell:
This script contains a function used by Main_code and performs the overall GLS algorithm as described in the main text.

bootratp_GLS:
This is a subsidiary function that calculates the boostrap GLS regression.

classical_GLS:
This is a subsidiary function that calculates the classical GLS regression.

data_select:
This function loads isotope data from file and changes time range if necessary. This is called at various places in the other scripts.

The data files used by this script are numpy array files that contain filtered data, binned using 10 my year intervals. These are easily produced from the excel file containing all our data. The files include:
carb_10my_t.npy: carbonates, time axis
carb_10my_v.npy: carbonates, isotope values
org_10my_t.npy: organics, time axis
org_10my_v.npy: organics, isotope values

carb_many.npy and org_many.npy are created by Main_code, and can be loaded in future calculations to avoid having to perform the computationally intensive bootstrap iterations again. The code is inefficient because it was adapted from a more complex version that required data be loaded from file at each iteration.
