Skip to content

Commit

Permalink
Re #6151 added background transmission
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Nov 30, 2012
1 parent d1d736f commit 0502e29
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,39 @@ def PyExec(self):
# Process background like we processed the sample data
bck_msg += self.process_data_file(background_ws)

trans_beam_center_x = None
trans_beam_center_y = None
if "BckTransmissionBeamCenterAlgorithm" in property_list:
# Execute the beam finding algorithm and set the beam
# center for the transmission calculation
p=property_manager.getProperty("BckTransmissionBeamCenterAlgorithm")
alg=Algorithm.fromString(p.valueAsStr)
if alg.existsProperty("ReductionProperties"):
alg.setProperty("ReductionProperties", property_manager_name)
alg.execute()
trans_beam_center_x = alg.getProperty("FoundBeamCenterX").value
trans_beam_center_y = alg.getProperty("FoundBeamCenterY").value

# Background transmission correction
if "BckTransmissionAlgorithm" in property_list:
p=property_manager.getProperty("BckTransmissionAlgorithm")
alg=Algorithm.fromString(p.valueAsStr)
alg.setProperty("InputWorkspace", background_ws)
alg.setProperty("OutputWorkspace", background_ws)
alg.setProperty("OutputWorkspace", '__'+background_ws+"_reduced")

if alg.existsProperty("BeamCenterX") \
and alg.existsProperty("BeamCenterY") \
and trans_beam_center_x is not None \
and trans_beam_center_y is not None:
alg.setProperty("BeamCenterX", trans_beam_center_x)
alg.setProperty("BeamCenterY", trans_beam_center_y)

if alg.existsProperty("ReductionProperties"):
alg.setProperty("ReductionProperties", property_manager_name)
alg.execute()
if alg.existsProperty("OutputMessage"):
output_msg += alg.getProperty("OutputMessage").value+'\n'
background_ws = '__'+background_ws+'_reduced'

# Subtract background
api.Minus(LHSWorkspace=output_ws,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def PyExec(self):
# 2- Apply correction (Note: Apply2DTransCorr)
input_ws_name = self.getPropertyValue("InputWorkspace")
if not AnalysisDataService.doesExist(input_ws_name):
Logger.get("SANSAzimuthalAverage").error("Could not find input workspace")
Logger.get("SANSDirectBeamTransmission").error("Could not find input workspace")
workspace = AnalysisDataService.retrieve(input_ws_name).getName()
api.CloneWorkspace(InputWorkspace=workspace, OutputWorkspace='__'+workspace)

Expand Down Expand Up @@ -98,16 +98,23 @@ def _load_monitors(self, property_manager):
if beam_center_x_input > 0 and beam_center_y_input > 0:
beam_center_x = beam_center_x_input
beam_center_y = beam_center_y_input
elif property_manager.existsProperty("TransmissionBeamCenterAlgorithm"):
p=property_manager.getProperty("TransmissionBeamCenterAlgorithm")
alg=Algorithm.fromString(p.valueAsStr)
if alg.existsProperty("ReductionProperties"):
alg.setProperty("ReductionProperties", property_manager_name)
alg.execute()
if alg.existsProperty("OutputMessage"):
output_str += " %s\n" % alg.getProperty("OutputMessage").value
beam_center_x = alg.getProperty("FoundBeamCenterX")
beam_center_y = alg.getProperty("FoundBeamCenterX")
#elif property_manager.existsProperty("TransmissionBeamCenterAlgorithm"):
# p=property_manager.getProperty("TransmissionBeamCenterAlgorithm")
# alg=Algorithm.fromString(p.valueAsStr)
# if alg.existsProperty("ReductionProperties"):
# alg.setProperty("ReductionProperties", property_manager_name)
# alg.execute()
# if alg.existsProperty("OutputMessage"):
# output_str += " %s\n" % alg.getProperty("OutputMessage").value
# beam_center_x = alg.getProperty("FoundBeamCenterX")
# beam_center_y = alg.getProperty("FoundBeamCenterX")
#else:
# if property_manager.existsProperty("LatestBeamCenterX") \
# and property_manager.existsProperty("LatestBeamCenterY"):
# beam_center_x = property_manager.getProperty("LatestBeamCenterX").value
# beam_center_y = property_manager.getProperty("LatestBeamCenterY").value
# else:
# Logger.get("SANSDirectBeamTransmission").notice("No beam center for transmission determination")

# Get instrument to use with FileFinder
instrument = ''
Expand All @@ -117,6 +124,7 @@ def _load_monitors(self, property_manager):
# Get the data loader
def _load_data(filename, output_ws):
if not property_manager.existsProperty("LoadAlgorithm"):
Logger.get("SANSDirectBeamTransmission").error("SANS reduction not set up properly: missing load algorithm")
raise RuntimeError, "SANS reduction not set up properly: missing load algorithm"
p=property_manager.getProperty("LoadAlgorithm")
alg=Algorithm.fromString(p.valueAsStr)
Expand Down Expand Up @@ -152,9 +160,9 @@ def _load_data(filename, output_ws):
output_str += " %s\n" % l_text

# Subtract dark current
use_sample_dc = self.getProperty("UseSampleDarkCurrent")
use_sample_dc = self.getProperty("UseSampleDarkCurrent").value
dark_current_data = self.getPropertyValue("DarkCurrentFilename")
if use_sample_dc:
if use_sample_dc is True:
# Dark current subtraction
if property_manager.existsProperty("DarkCurrentAlgorithm"):
def _dark(workspace):
Expand All @@ -178,7 +186,8 @@ def _dark(workspace):
output_str += partial_out

elif len(dark_current_data.strip())>0:
raise RuntimeError, "SANSDirectBeamTransmission dark current not implemented"
Logger.get("SANSDirectBeamTransmission").error("SANSDirectBeamTransmission dark current not implemented")
return
dark_current = find_data(dark_current_data, instrument=instrument)
#self.set_dark_current_subtracter(reducer._dark_current_subtracter_class,
# InputWorkspace=None, Filename=dark_current,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidKernel/PropertyManager.h"

namespace Mantid
{
Expand Down Expand Up @@ -59,6 +60,8 @@ class DLLExport SetupHFIRReduction : public API::Algorithm
void init();
/// Execution code
void exec();
void setupTransmission(boost::shared_ptr<Kernel::PropertyManager> reductionManager);
void setupBackground(boost::shared_ptr<Kernel::PropertyManager> reductionManager);

};

Expand Down

0 comments on commit 0502e29

Please sign in to comment.