Skip to content

Commit

Permalink
fix att selection (#125)
Browse files Browse the repository at this point in the history
* fix att selection

* fix test

* fix test
  • Loading branch information
mdoucet authored Jul 16, 2024
1 parent 51fe80b commit 5cced0e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
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

3 comments on commit 5cced0e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/592563"

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred-qa has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/592833"

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/593852"

Please sign in to comment.