mdaeron / D47crunch

Python library for processing and standardizing carbonate clumped-isotope analyses, from low-level data out of a dual-inlet mass spectrometer to final, “absolute” Δ47, Δ48, and Δ49 values with fully propagated analytical error estimates.
MIT License
8 stars 3 forks source link

`indep_sessions` standardization is not working #19

Open itsMig opened 1 year ago

itsMig commented 1 year ago

Hi @mdaeron, I didn't notice so far since we almost entirely use the pooled approach, but self.standardize(method='indep_sessions') is not working for me after updating D47crunch .

Python v3.9.6 D47crunch v2.3.2

import D47crunch
mydata = D47crunch.D47data()
mydata.read('rawdata.csv')
mydata.wg()
mydata.crunch()
mydata.standardize(method = 'indep_sessions')
Traceback (most recent call last):
  File ".../TESTING_D47crunch/test.py", line 14, in <module>
    mydata.standardize(
  File ".../TESTING_D47crunch/venv/lib/python3.9/site-packages/D47crunch/__init__.py", line 957, in newfun
    out = oldfun(*args, **kwargs)
  File ".../TESTING_D47crunch/venv/lib/python3.9/site-packages/D47crunch/__init__.py", line 1757, in standardize
    self.consolidate(tables = consolidate_tables, plots = consolidate_plots)
  File ".../TESTING_D47crunch/venv/lib/python3.9/site-packages/D47crunch/__init__.py", line 957, in newfun
    out = oldfun(*args, **kwargs)
  File ".../TESTING_D47crunch/venv/lib/python3.9/site-packages/D47crunch/__init__.py", line 2322, in consolidate
    self.consolidate_sessions()
  File ".../TESTING_D47crunch/venv/lib/python3.9/site-packages/D47crunch/__init__.py", line 2215, in consolidate_sessions
    self.sessions[session][f'r_D{self._4x}'] = self.compute_r(f'D{self._4x}', sessions = [session])
  File ".../TESTING_D47crunch/venv/lib/python3.9/site-packages/D47crunch/__init__.py", line 957, in newfun
    out = oldfun(*args, **kwargs)
  File ".../TESTING_D47crunch/venv/lib/python3.9/site-packages/D47crunch/__init__.py", line 2399, in compute_r
    _ for _ in self.standardization.params
AttributeError: 'D47data' object has no attribute 'standardization'
mdaeron commented 1 year ago

Yuck. I knew supporting indep_sessions would end up being a pain.

Short term solution: I'll try to debug this particular error.

Long-term solution: choose between

(1) deprecating, then removing indep_sessions entirely, leaving an example to mimic the old behavior:

data.split_samples(grouping = 'by_session')`
data.standardize()
data.unsplit_samples()

(2) keep indep_sessions but transparently implement it as in the above example.