Hello Bence and Joe,
I have created a DRS file to process Rb/Sr data but the output are coming opposite. For example, the actual Raw Data labelled as corrected data and vice versa. Could you please check the code for me and see where is the error?
Thanks for your help in advance
`from iolite import QtGui
from time import sleep
import numpy as np
def runDRS():
drs.message("Starting baseline subtract DRS...")
drs.progress(0)
# Get settings
settings = drs.settings()
print(settings)
indexChannel = data.timeSeries(settings["IndexChannel"])
rmName = settings["ReferenceMaterial"]
maskChannel = data.timeSeries(settings["MaskChannel"])
cutoff = settings["MaskCutoff"]
trim = settings["MaskTrim"]
propErrors = settings["PropagateError"]
# Create debug messages for the settings being used
IoLog.debug("indexChannelName = %s" % indexChannel.name)
IoLog.debug("maskChannelName = %s" % maskChannel.name)
IoLog.debug("maskCutoff = %f" % cutoff)
IoLog.debug("maskTrim = %f" % trim)
# Setup index time
drs.message("Setting up index time...")
drs.progress(5)
drs.setIndexChannel(indexChannel)
# Setup the mask
drs.message("Making mask...")
drs.progress(10)
mask = drs.createMaskFromCutoff(maskChannel, cutoff, trim)
# Interp onto index time and baseline subtract
drs.message("Interpolating onto index time and baseline subtracting...")
drs.progress(25)
allInputChannels = data.timeSeriesList(data.Input)
for counter, channel in enumerate(allInputChannels):
drs.message("Baseline subtracting %s" % channel.name)
drs.progress(25 + 50*counter/len(allInputChannels))
sleep(0.5) # Sleeping only so that the progress can be observed
drs.baselineSubtract(data.selectionGroup("Baseline"), [allInputChannels[counter]], mask, 25, 100)
Rb85 = data.timeSeries("Rb85_CPS").data()
Sr87 = data.timeSeries("Sr87_CPS").data()
Sr86 = data.timeSeries("Sr86_CPS").data()
Rb87=Rb85*0.38562
Rb87_Sr86_Raw = Rb87 / Sr86 * mask
Sr87_Sr86_Raw = Sr87 / Sr86 * mask
data.createTimeSeries("Rb87_CPS", data.Output, indexChannel.time(), Rb87)
data.createTimeSeries("Rb87_Sr86_Raw", data.Output, indexChannel.time(),Rb87_Sr86_Raw)
data.createTimeSeries("Sr87_Sr86_Raw", data.Output, indexChannel.time(),Sr87_Sr86_Raw)
#std correction
StdSpline_Rb87_Sr86 = data.spline(rmName, "Rb87_Sr86_Raw").data()
StdValue_Rb87_Sr86 = data.referenceMaterialData(rmName)["87Rb/86Sr"].value()
print("StdSpline_Rb87_Sr86 mean = %f"%StdSpline_Rb87_Sr86.mean())
print("StdValue_Rb87_Sr86 = %f"%StdValue_Rb87_Sr86)
StdCorr_Rb87_Sr86 = (Rb87_Sr86_Raw)* StdValue_Rb87_Sr86 / StdSpline_Rb87_Sr86
data.createTimeSeries("StdCorr_Rb87_Sr86", data.Output, indexChannel.time(), StdCorr_Rb87_Sr86)
StdSpline_Sr87_Sr86 = data.spline(rmName, "Sr87_Sr86_Raw").data()
StdValue_Sr87_Sr86 = data.referenceMaterialData(rmName)["87Sr/86Sr"].value()
print("StdSpline_Sr87_Sr86 mean = %f"%StdSpline_Sr87_Sr86.mean())
print("StdValue_Sr87_Sr86 = %f"%StdValue_Sr87_Sr86)
StdCorr_Sr87_Sr86 = (Sr87_Sr86_Raw)* StdValue_Sr87_Sr86 / StdSpline_Sr87_Sr86
data.createTimeSeries("StdCorr_Sr87_Sr86", data.Output, indexChannel.time(), StdCorr_Sr87_Sr86)
if propErrors:
groups = [s for s in data.selectionGroupList() if s.type != data.Baseline]
data.propagateErrors(groups, [data.timeSeries("StdCorr_Rb87_Sr86")], data.timeSeries("Rb87_Sr86_Raw"), rmName)
data.propagateErrors(groups, [data.timeSeries("StdCorr_Sr87_Sr86")], data.timeSeries("Sr87_Sr86_Raw"), rmName)
drs.message("Finished!")
drs.progress(100)
drs.finished()
def settingsWidget():
widget = QtGui.QWidget()
formLayout = QtGui.QFormLayout()
widget.setLayout(formLayout)
timeSeriesNames = data.timeSeriesNames(data.Input)
defaultChannelName = ""
if timeSeriesNames:
defaultChannelName = timeSeriesNames[0]
rmNames = data.selectionGroupNames(data.ReferenceMaterial)
drs.setSetting("IndexChannel","Sr86")
drs.setSetting("ReferenceMaterial", "M_MicaMG")
drs.setSetting("MaskChannel", "Sr86")
drs.setSetting("MaskCutoff", 0.1)
drs.setSetting("MaskTrim", 0.0)
drs.setSetting("PropagateError", True)
settings = drs.settings()
indexComboBox = QtGui.QComboBox(widget)
indexComboBox.addItems(data.timeSeriesNames(data.Input))
indexComboBox.setCurrentText(settings["IndexChannel"])
indexComboBox.currentTextChanged.connect(lambda t: drs.setSetting("IndexChannel", t))
rmComboBox = QtGui.QComboBox(widget)
rmComboBox.addItems(rmNames)
rmComboBox.setCurrentText(settings["ReferenceMaterial"])
rmComboBox.currentTextChanged.connect(lambda t: drs.setSetting("ReferenceMaterial", t))
maskComboBox = QtGui.QComboBox(widget)
maskComboBox.addItems(data.timeSeriesNames(data.Input))
maskComboBox.setCurrentText(settings["MaskChannel"])
maskComboBox.currentTextChanged.connect(lambda t: drs.setSetting("MaskChannel", t))
maskLineEdit = QtGui.QLineEdit(widget)
maskLineEdit.setText(settings["MaskCutoff"])
maskLineEdit.textChanged.connect(lambda t: drs.setSetting("MaskCutoff", float(t)))
maskTrimLineEdit = QtGui.QLineEdit(widget)
maskTrimLineEdit.setText(settings["MaskTrim"])
maskTrimLineEdit.textChanged.connect(lambda t: drs.setSetting("MaskTrim", float(t)))
propCheckBox = QtGui.QCheckBox(widget)
propCheckBox.setChecked(settings["PropagateError"])
propCheckBox.toggled.connect(lambda t: drs.setSetting("PropagateError", bool(t)))
formLayout.addRow("Index channel", indexComboBox)
formLayout.addRow("Reference material", rmComboBox)
formLayout.addRow("Mask channel", maskComboBox)
formLayout.addRow("Mask cutoff", maskLineEdit)
formLayout.addRow("Mask trim", maskTrimLineEdit)
formLayout.addRow("PropagateError", propCheckBox)
drs.setSettingsWidget(widget)
`