Hello all,
I need help regarding baseline subtract. I have no experience with Python, but I am trying to create a DRS that can calculate isotopic ratios. To do that I used some function from the templates in github which work very well. However, I am facing an issue with the baseline subtract as baseline comes very large which makes inspecting the selection of the ratios very difficult. I know that fixing the Cutoff Threshold could help with this but I have no idea what is the appropriate function that can used to do that.
Here is the lines that I am trying to use for baseline
`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"]
threshold = setting["MaskThreshold"] #trying to add 'maskthershold'
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("maskthreshold= %f" %threshold) #trying to add 'maskthershold'
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)
#I thins this above line need to be changed but what is the correct function?
# 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)`
Also, here is the settingsWidget() part
`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",defaultChannelName)
drs.setSetting("ReferenceMaterial", "M_MicaMG")
drs.setSetting("MaskChannel", defaultChannelName)
drs.setSetting("MaskCutoff", 100000.0)
drs.setSetting("MaskThreshold", 1000) #trying to add MaskThreshold
drs.setSetting("MaskTrim", 0.0)
drs.setSetting("PropagateError", False)
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)))
maskLineEdit = QtGui.QLineEdit(widget) # Is this part correct?
maskLineEdit.setText(settings["MaskThreshold"])
maskLineEdit.textChanged.connect(lambda t: drs.setSetting("MaskThreshold", 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)`
Thanks for you help in advanced
Regards,
Ahmad