@@ -625,21 +625,29 @@ def wg(self, samples = '', a18_acid = ''):
625625 for s in self .sessions :
626626 db = [r for r in self .sessions [s ]['data' ] if r ['Sample' ] in samples ]
627627 assert db , f'No sample from { samples } found in session "{ s } ".'
628- dbsamples = sorted ({r ['Sample' ] for r in db })
629- if len (dbsamples ) > 1 :
630- X = [r ['d45' ] for r in db ]
631- Y = [R45R46_standards [r ['Sample' ]][0 ] for r in db ]
628+ # dbsamples = sorted({r['Sample'] for r in db})
629+
630+ X = [r ['d45' ] for r in db ]
631+ Y = [R45R46_standards [r ['Sample' ]][0 ] for r in db ]
632+ x1 , x2 = np .min (X ), np .max (X )
633+ wgcoord = x1 / (x1 - x2 )
634+ if wgcoord < - .5 or wgcoord > 1.5 :
635+ # unreasonable to extrapolate to d45 = 0
636+ R45_wg = np .mean ([y / (1 + x / 1000 ) for x ,y in zip (X ,Y )])
637+ else :
638+ # d45 = 0 is reasonably well bracketed
632639 R45_wg = np .polyfit (X , Y , 1 )[1 ]
633640
634- X = [r ['d46' ] for r in db ]
635- Y = [R45R46_standards [r ['Sample' ]][1 ] for r in db ]
641+ X = [r ['d46' ] for r in db ]
642+ Y = [R45R46_standards [r ['Sample' ]][1 ] for r in db ]
643+ x1 , x2 = np .min (X ), np .max (X )
644+ wgcoord = x1 / (x1 - x2 )
645+ if wgcoord < - .5 or wgcoord > 1.5 :
646+ # unreasonable to extrapolate to d46 = 0
647+ R46_wg = np .mean ([y / (1 + x / 1000 ) for x ,y in zip (X ,Y )])
648+ else :
649+ # d46 = 0 is reasonably well bracketed
636650 R46_wg = np .polyfit (X , Y , 1 )[1 ]
637- elif len (dbsamples ) == 1 :
638- sample = dbsamples [0 ]
639- d45_s = np .mean ([r ['d45' ] for r in db ])
640- d46_s = np .mean ([r ['d46' ] for r in db ])
641- R45_wg = R45R46_standards [sample ][0 ] / (1 + d45_s / 1000 )
642- R46_wg = R45R46_standards [sample ][1 ] / (1 + d46_s / 1000 )
643651
644652 d13Cwg_VPDB , d18Owg_VSMOW = self .compute_bulk_delta (R45_wg , R46_wg )
645653
0 commit comments