Hi Vitor,
The U-Pb python example does not yet work out the error correlations, but adding it in is relatively straight-forward. In the future, perhaps we will add some helper functions to the API to simplify the process.
In iolite 4, things like error correlations are setup as associated results. That is, they are results that are not derived from a specific channel (unlike, e.g. 'Final Pb206/U238'), but are calculated in some way and are associated with a selection. The tricky bit is that we don't just want to calculate these associated results at the time that the DRS runs -- they should update any time a selection is modified. To make that happen, we can use data.registerAssociatedResult(name, function)
.
For example, if we wanted to add an error correlation associated result to the U-Pb python example, we could define a function as follows:
def error_correlation(s):
r68 = data.timeSeries('Final Pb206/U238').dataForSelection(s)
r75 = data.timeSeries('Final Pb207/U235').dataForSelection(s)
res = Result(np.corrcoef(r68, r75)[0,1], 0.001)
return res
and then towards the end of the runDRS
function, add a line with:
data.registerAssociatedResult('rho Pb206/U238 v Pb207/U235', error_correlation)
being sure to import the required modules before they're needed:
import numpy as np
from iolite.types import Result
That should do the trick, but there are a couple of caveats with this approach:
- The associated results will not be re-established when re-opening a session. Not that big of a deal -- just run the DRS again.
- If you switch to another DRS it will likely stop updating.
Please let us know how it goes and whether you have any additional questions. I'll add a task to our todo list to make it a bit easier and better integrated (e.g. fixing issues 1+2 above).
All the best,