Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix att selection #125

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions RefRed/sf_calculator/reduction_sf_calculator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# standard-library imports
import sys
import logging
import time
from typing import Optional, Union

# third-party imports
import numpy as np
from qtpy.QtWidgets import QApplication
from qtpy.QtWidgets import QFileDialog
from qtpy.QtWidgets import QApplication, QMessageBox, QFileDialog

# RefRed imports
from RefRed.utilities import convertTOF
Expand Down Expand Up @@ -102,15 +102,20 @@ def _handle_request(self):
string_runs = self.getStringRuns(from_index, to_index)
list_peak_back = self.getListPeakBack(from_index, to_index)
tof_range = self.getTofRange(from_index)
attenuators = self.table_settings[from_index : to_index + 1, 1]

if not self.export_script_flag:
self.launchScript(
string_runs=string_runs,
list_peak_back=list_peak_back,
incident_medium=incident_medium,
output_file_name=output_file_name,
tof_range=tof_range,
)
try:
self.launchScript(
string_runs=string_runs,
list_peak_back=list_peak_back,
incident_medium=incident_medium,
output_file_name=output_file_name,
tof_range=tof_range,
attenuators=attenuators,
)
except:
QMessageBox.information(self.sf_gui, "Error!", str(sys.exc_info()[1]))

self.refreshOutputFileContainPreview(output_file_name)
else:
Expand Down Expand Up @@ -158,6 +163,7 @@ def launchScript(
incident_medium="",
output_file_name="",
tof_range=[],
attenuators=[],
):
"""
Create scaling factor file
Expand All @@ -172,6 +178,7 @@ def launchScript(
DirectBeamRuns=run_list,
IncidentMedium=str(incident_medium),
TOFRange=tof_range,
Attenuators=attenuators,
TOFSteps=self.sf_gui.deadtime_tof_step,
SignalPeakPixelRange=peak_ranges,
SignalBackgroundPixelRange=bck_ranges,
Expand All @@ -190,6 +197,7 @@ def generate_script(
incident_medium="",
output_file_name="",
tof_range=[],
attenuators=[],
):
"""
Generate a scaling factor calculation script
Expand All @@ -210,6 +218,7 @@ def generate_script(
r" LRScalingFactors.LRScalingFactors,",
r" DirectBeamRuns={0},".format(run_list),
r" IncidentMedium='{0}',".format(incident_medium),
r" Attenuators={0},".format(attenuators),
r" TOFRange={0},".format(tof_range),
r" TOFSteps={0},".format(self.sf_gui.deadtime_tof_step),
r" SignalPeakPixelRange={0},".format(peak_ranges),
Expand Down
1 change: 1 addition & 0 deletions test/data/sf_export_script_184975_184989.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
LRScalingFactors.LRScalingFactors,
DirectBeamRuns=[184981, 184982, 184983, 184984, 184985, 184986, 184987, 184988, 184989],
IncidentMedium='air',
Attenuators=[],
TOFRange=[9970.0, 23250.0],
TOFSteps=150,
SignalPeakPixelRange=[137, 145, 137, 145, 136, 145, 136, 145, 136, 145, 136, 145, 135, 147, 135, 147, 135, 147],
Expand Down
1 change: 1 addition & 0 deletions test/data/sf_export_script_184977_184980.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
LRScalingFactors.LRScalingFactors,
DirectBeamRuns=[184978, 184979, 184980],
IncidentMedium='air',
Attenuators=[],
TOFRange=[20880.0, 34170.0],
TOFSteps=150,
SignalPeakPixelRange=[136, 145, 136, 145, 136, 145],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def setProperty(self, key, value):
assert key in {
'DirectBeamRuns',
'IncidentMedium',
'Attenuators',
'TOFRange',
'TOFSteps',
'SignalPeakPixelRange',
Expand Down
Loading