heavily revised Locey_McGlinn_2013.py -KL