Skip to content

Commit

Permalink
Now program keeps memory of the last incident medium list/index and s…
Browse files Browse the repository at this point in the history
…f config file name. This refs #5071
  • Loading branch information
JeanBilheux committed Jun 8, 2012
1 parent a2820c2 commit 1011e87
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 26 deletions.
48 changes: 24 additions & 24 deletions Code/Mantid/Framework/PythonAPI/PythonAlgorithms/sfCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,14 @@ def outputFittingParameters(a, b, error_a, error_b,
_line = 'IncidentMedium=' + incident_medium.strip() + ' '
_line += 'LambdaRequested=' + str(lambda_requested) + ' '

_S1H = "{0:.8f}".format(abs(S1H[i]))
_S2H = "{0:.8f}".format(abs(S2H[i]))
_S1W = "{0:.8f}".format(abs(S1W[i]))
_S2W = "{0:.8f}".format(abs(S2W[i]))
_a = "{0:.8f}".format(a[i])
_b = "{0:.8f}".format(b[i])
_error_a = "{0:.8f}".format(float(error_a[i]))
_error_b = "{0:.8f}".format(float(error_b[i]))
_S1H = "{0:.2f}".format(abs(S1H[i]))
_S2H = "{0:.2f}".format(abs(S2H[i]))
_S1W = "{0:.2f}".format(abs(S1W[i]))
_S2W = "{0:.2f}".format(abs(S2W[i]))
_a = "{0:.2f}".format(a[i])
_b = "{0:.2f}".format(b[i])
_error_a = "{0:.2f}".format(float(error_a[i]))
_error_b = "{0:.2f}".format(float(error_b[i]))

_line += 'S1H=' + _S1H + ' ' + 'S2H=' + _S2H + ' '
_line += 'S1W=' + _S1W + ' ' + 'S2W=' + _S2W + ' '
Expand All @@ -519,14 +519,14 @@ def outputFittingParameters(a, b, error_a, error_b,
_line = 'IncidentMedium=' + incident_medium + ' '
_line += 'LambdaRequested=' + str(lambda_requested) + ' '

_S1H = "{0:.8f}".format(abs(S1H[j]))
_S2H = "{0:.8f}".format(abs(S2H[j]))
_S1W = "{0:.8f}".format(abs(S1W[j]))
_S2W = "{0:.8f}".format(abs(S2W[j]))
_a = "{0:.8f}".format(a[j])
_b = "{0:.8f}".format(b[j])
_error_a = "{0:.8f}".format(float(error_a[j]))
_error_b = "{0:.8f}".format(float(error_b[j]))
_S1H = "{0:.2f}".format(abs(S1H[j]))
_S2H = "{0:.2f}".format(abs(S2H[j]))
_S1W = "{0:.2f}".format(abs(S1W[j]))
_S2W = "{0:.2f}".format(abs(S2W[j]))
_a = "{0:.2f}".format(a[j])
_b = "{0:.2f}".format(b[j])
_error_a = "{0:.2f}".format(float(error_a[j]))
_error_b = "{0:.2f}".format(float(error_b[j]))

_line += 'S1H=' + _S1H + ' ' + 'S2H=' + _S2H + ' '
_line += 'S1W=' + _S1W + ' ' + 'S2W=' + _S2W + ' '
Expand All @@ -550,14 +550,14 @@ def outputFittingParameters(a, b, error_a, error_b,
_line = 'IncidentMedium=' + incident_medium.strip() + ' '
_line += 'LambdaRequested=' + str(lambda_requested) + ' '

_S1H = "{0:.8f}".format(abs(S1H[i]))
_S2H = "{0:.8f}".format(abs(S2H[i]))
_S1W = "{0:.8f}".format(abs(S1W[i]))
_S2W = "{0:.8f}".format(abs(S2W[i]))
_a = "{0:.8f}".format(a[i])
_b = "{0:.8f}".format(b[i])
_error_a = "{0:.8f}".format(float(error_a[i]))
_error_b = "{0:.8f}".format(float(error_b[i]))
_S1H = "{0:.2f}".format(abs(S1H[i]))
_S2H = "{0:.2f}".format(abs(S2H[i]))
_S1W = "{0:.2f}".format(abs(S1W[i]))
_S2W = "{0:.2f}".format(abs(S2W[i]))
_a = "{0:.2f}".format(a[i])
_b = "{0:.2f}".format(b[i])
_error_a = "{0:.2f}".format(float(error_a[i]))
_error_b = "{0:.2f}".format(float(error_b[i]))

_line += 'S1H=' + _S1H + ' ' + 'S2H=' + _S2H + ' '
_line += 'S1W=' + _S1W + ' ' + 'S2W=' + _S2W + ' '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class DataSets(BaseScriptElement):

data_file = 0
incident_medium_list = ['H2O']
incident_medium_list_bkup = incident_medium_list
incident_medium_index_selected = 0
incident_medium_index_selected_bkup = incident_medium_index_selected
number_attenuator = 0
peak_selection = [0,0]
back_selection = [0,0]
Expand Down Expand Up @@ -83,6 +85,7 @@ def to_xml(self):
xml += "<s2w>%s</s2w>\n" % str(self.s2w)
xml += "<scaling_factor_file>%s</scaling_factor_file>\n" % str(self.scaling_factor_file)
xml += "</RefLSFCalculator>\n"

return xml

def from_xml(self, xml_str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ def call_back(xmin, xmax):
return min, max

def _remove_item(self):
if self._summary.angle_list.count()==1:
#about to remove last element
m = REFLDataSets()
m.scaling_factor_file = self._summary.cfg_scaling_factor_file_name.text()

if self._summary.angle_list.count()==0:
return
self._summary.angle_list.setEnabled(False)
Expand All @@ -253,6 +258,8 @@ def _remove_item(self):
self._summary.angle_list.setEnabled(True)
self._summary.remove_btn.setEnabled(True)



def _edit_event(self, text=None, ctrl=None):
self._summary.edited_warning_label.show()
util.set_edited(ctrl,True)
Expand Down Expand Up @@ -285,14 +292,15 @@ def _add_data(self):
run_numbers = self._summary.data_run_number_edit.text()
if (run_numbers == ''):
return

list_items = self._summary.angle_list.findItems(run_numbers, QtCore.Qt.MatchFixedString)

if len(list_items)>0:
list_items[0].setData(QtCore.Qt.UserRole, state)
in_list = True

#loop over all the already defined states and give all of them the
#same tof_min, tof_max and incident_medium list and index selected
#same tof_min, tof_max and incident_medium list and index selected...
i=0
while i < self._summary.angle_list.count():
#print self._summary.angle_list.item(i)
Expand Down Expand Up @@ -320,7 +328,19 @@ def _add_data(self):
current_item.setData(QtCore.Qt.UserRole, state)
i+=1
else:

item_widget = QtGui.QListWidgetItem(run_numbers, self._summary.angle_list)
state.scaling_factor_file = self._summary.cfg_scaling_factor_file_name.text()

#incident medium
_incident_medium_list = [str(self._summary.incident_medium_combobox.itemText(j))
for j in range(self._summary.incident_medium_combobox.count())]
_incident_medium_index_selected = self._summary.incident_medium_combobox.currentIndex()

_incident_medium_string = (',').join(_incident_medium_list)
state.incident_medium_list = [_incident_medium_string]

state.incident_medium_index_selected = _incident_medium_index_selected
item_widget.setData(QtCore.Qt.UserRole, state)

# # Read logs
Expand Down Expand Up @@ -362,6 +382,8 @@ def set_state(self, state):
@param state: data object
"""

print 'in set_state'

self._summary.angle_list.clear()
if len(state.data_sets) == 1 and state.data_sets[0].data_file==0:
pass
Expand Down

0 comments on commit 1011e87

Please sign in to comment.