Comments (7)
I tried this:
from lmfit import report_fit
from D47crunch import *
mydata = D47data(virtual_data(
session = 'mysession',
samples = [
dict(Sample = 'ETH-1', N = 4),
dict(Sample = 'ETH-2', N = 4),
dict(Sample = 'ETH-3', N = 4),
dict(Sample = 'FOO', N = 4, D47 = 0.6, D48 = 0.1, d13C_VPDB = -4.0, d18O_VPDB = -12.0),
]), verbose = True)
mydata.refresh()
mydata.wg()
mydata.crunch()
report_fit(mydata.standardize(
constraints = {'b_mysession': '0'}
))
mydata.table_of_sessions()
And got the same error as you in D4xdata.consolidate_sessions()
:
Traceback (most recent call last):
File "/Users/daeron/temp/D47crunch_constraints/./foo.py", line 18, in <module>
report_fit(mydata.standardize(
File "/opt/homebrew/lib/python3.9/site-packages/D47crunch/__init__.py", line 1006, in newfun
out = oldfun(*args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/D47crunch/__init__.py", line 1689, in standardize
self.consolidate(tables = consolidate_tables, plots = consolidate_plots)
File "/opt/homebrew/lib/python3.9/site-packages/D47crunch/__init__.py", line 1006, in newfun
out = oldfun(*args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/D47crunch/__init__.py", line 2297, in consolidate
self.consolidate_sessions()
File "/opt/homebrew/lib/python3.9/site-packages/D47crunch/__init__.py", line 2200, in consolidate_sessions
i = self.standardization.var_names.index(f'b_{pf(session)}')
ValueError: 'b_mysession' is not in list
That is definitely a "book keeping" bug: the standardization performs as expected but the reporting/book keeping functions after that were never modified to account for potential missing parameters (because of how lmfit
works). In the past I had only ever used constraints
to force D47 differences between samples (e.g., between heated and 25C equilibrated CO2). My bad.
I know what to do about this (add the missing parameters explicitly after the standardization regression is done). Thanks to you I have an incentive to do so quickly. I'll report here when it is done.
from d47crunch.
Great. Beware that you may still get errors in some cases, e.g., I havent patched D4xdata.sample_D4x_correl()
to account for zero-variance values in the fixed parameters. I'll look into it but not right away.
from d47crunch.
Can you try constraints = {f'b_{D47crunch.pf("2018-02-23")}': 0}
?
from d47crunch.
mydata.standardize(constraints = {f'b_{mydata.pf("session0")}' : 0})
AttributeError: 'D47data' object has no attribute 'pf'. Did you mean: 'Nf'?
from d47crunch.
pf
is not a class method of D47data
(so mydata.pf()
will fail) but a function defined at the package level. So from D47crunch import pf; pf('foo')
, from D47crunch import *; pf('foo')
and D47crunch.pf('foo')
will all work the same.
from d47crunch.
Can you please check if the new branch cleanup_after_using_stdz_constraints
produces any new errors?
I tested it with the following code:
from lmfit import report_fit
from D47crunch import *
mydata = D47data(virtual_data(
session = 'mysession',
samples = [
dict(Sample = 'ETH-1', N = 4),
dict(Sample = 'ETH-2', N = 4),
dict(Sample = 'ETH-3', N = 4),
dict(Sample = 'FOO', N = 4, D47 = 0.6, D48 = 0.1, d13C_VPDB = -4.0, d18O_VPDB = -12.0),
]), verbose = True)
mydata.refresh()
mydata.wg()
mydata.crunch()
report_fit(mydata.standardize(
constraints = {'b_mysession': '0'}
))
mydata.table_of_sessions()
mydata.table_of_samples()
mydata.plot_sessions()
This seems to work as it should:
[table_of_sessions]
––––––––– –– –– ––––––––––– –––––––––––– –––––– –––––– –––––– ––––––––––––– ––––––––––––– ––––––––––––––
Session Na Nu d13Cwg_VPDB d18Owg_VSMOW r_d13C r_d18O r_D47 a ± SE 1e3 x b ± SE c ± SE
––––––––– –– –– ––––––––––– –––––––––––– –––––– –––––– –––––– ––––––––––––– ––––––––––––– ––––––––––––––
mysession 12 4 -4.000 26.000 0.0000 0.0000 0.0160 1.014 ± 0.024 0.000 ± 0.000 -0.898 ± 0.009
––––––––– –– –– ––––––––––– –––––––––––– –––––– –––––– –––––– ––––––––––––– ––––––––––––– ––––––––––––––
[table_of_samples]
–––––– – ––––––––– –––––––––– –––––– –––––– –––––––– –––––– ––––––––
Sample N d13C_VPDB d18O_VSMOW D47 SE 95% CL SD p_Levene
–––––– – ––––––––– –––––––––– –––––– –––––– –––––––– –––––– ––––––––
ETH-1 4 2.02 37.02 0.2052 0.0235
ETH-2 4 -10.17 19.88 0.2085 0.0098
ETH-3 4 1.71 37.45 0.6132 0.0180
FOO 4 -4.00 26.83 0.5934 0.0106 ± 0.0229 0.0057 0.006
–––––– – ––––––––– –––––––––– –––––– –––––– –––––––– –––––– ––––––––
Also, as expected, the standardization errors no longer vary with δ47:
from d47crunch.
Yep this works exactly as advertised for my data! Results are very similar to what I got before, however (as expected, I had very few non-ETH-1--3 and because the small δ values were already corrected for pressure-baseline effects the influence of δ47 should be very small) so I'll get back to you in the email if I have further ideas of what could be the cause of the big difference. Thanks! This resolves this issue!
from d47crunch.
Related Issues (15)
- Implementation of Δ48 standardization HOT 6
- crunch throws an error with failed d45 type HOT 11
- standardize throws an error because of package lmfit HOT 5
- Improve `plot_distribution_of_analyses` or throw warnings in case there are many sessions/samples HOT 7
- `standardize` is slow with large datasets HOT 2
- decide on how to make plotting interfaces consistent HOT 5
- add a **see also** section to readme HOT 2
- clumpycrunch formatting
- D47crunch name HOT 2
- missing depency: rich? HOT 1
- UTF-8 encoding of csv HOT 4
- Output temperature in Table of Samples? HOT 2
- `indep_sessions` standardization is not working HOT 1
- Update module-level table functions for Δ49
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d47crunch.