Skip to content

Commit

Permalink
Fixed issue with format of Scaling factor file format. Before, becaus…
Browse files Browse the repository at this point in the history
…e the programs was trying to find any matched entries, if the format was wrong, the new entries were not recorded.... Now, if the format is wrong, the containt of the file is simply replaced by the new entries. This refs #5071
  • Loading branch information
JeanBilheux committed May 23, 2012
1 parent bd3e9aa commit aff2177
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions Code/Mantid/Framework/PythonAPI/PythonAlgorithms/sfCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,37 @@ def outputFittingParameters(a, b, error_a, error_b,
if _match == False:
entry_list_to_add.append(i)

except:
except:
#replace file because this one has the wrong format
_content = ['#y=a+bx\n', '#\n',
'#lambdaRequested[Angstroms] S1H[mm] S2H[mm] S1W[mm] S2W[mm] a b error_a error_b\n', '#\n']
sz = len(a)
for i in range(sz):

_line = 'IncidentMedium=' + incident_medium.strip() + ' '
_line += 'LambdaRequested=' + str(lambda_requested) + ' '

pass
_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]))

_line += 'S1H=' + _S1H + ' ' + 'S2H=' + _S2H + ' '
_line += 'S1W=' + _S1W + ' ' + 'S2W=' + _S2W + ' '
_line += 'a=' + _a + ' '
_line += 'b=' + _b + ' '
_line += 'error_a=' + _error_a + ' '
_line += 'error_b=' + _error_b + '\n'
_content.append(_line)

f = open(output_file_name, 'w')
f.writelines(_content)
f.close()
return

_content = []
for j in entry_list_to_add:
Expand Down

0 comments on commit aff2177

Please sign in to comment.