Skip to content

Commit

Permalink
Re #6151 adding transmission options to APIv2 reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Dec 6, 2012
1 parent 0a2679c commit 5d5fdf5
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 236 deletions.
228 changes: 0 additions & 228 deletions Code/Mantid/Framework/PythonAPI/PythonAlgorithms/EQSANSTofOffset.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,32 @@ def PyExec(self):
output_msg += self.process_data_file(output_ws)

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

if "TransmissionAlgorithm" in property_list:
p=property_manager.getProperty("TransmissionAlgorithm")
alg=Algorithm.fromString(p.valueAsStr)
alg.setProperty("InputWorkspace", output_ws)
alg.setProperty("OutputWorkspace", '__'+output_ws+"_reduced")

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

if alg.existsProperty("ReductionProperties"):
alg.setProperty("ReductionProperties", property_manager_name)
alg.execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def _dark(workspace, dark_current_property):
alg=Algorithm.fromString(p.valueAsStr)
alg.setProperty("InputWorkspace", workspace)
alg.setProperty("OutputWorkspace", workspace)
alg.setProperty("Filename", dark_current_data)
if alg.existsProperty("PersistentCorrection"):
alg.setProperty("PersistentCorrection", False)
if alg.existsProperty("ReductionProperties"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def _dark(workspace, dark_current_property):
alg=Algorithm.fromString(p.valueAsStr)
alg.setProperty("InputWorkspace", workspace)
alg.setProperty("OutputWorkspace", workspace)
alg.setProperty("Filename", dark_current_data)
if alg.existsProperty("PersistentCorrection"):
alg.setProperty("PersistentCorrection", False)
if alg.existsProperty("ReductionProperties"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ void SetupHFIRReduction::init()
setPropertySettings("SpreaderTransmissionError",
new VisibleWhenProperty("TransmissionMethod", IS_EQUAL_TO, "BeamSpreader"));

declareProperty(new API::FileProperty("TransmissionDarkCurrentFile", "", API::FileProperty::OptionalLoad, ".xml"),
"The name of the input data file to load as transmission dark current.");
setPropertySettings("TransmissionDarkCurrentFile",
new VisibleWhenProperty("TransmissionMethod", IS_NOT_EQUAL_TO, "Value"));

declareProperty("ThetaDependentTransmission", true,
"If true, a theta-dependent transmission correction will be applied.");

Expand All @@ -282,6 +287,7 @@ void SetupHFIRReduction::init()
setPropertyGroup("TransDirectScatteringFilename", trans_grp);
setPropertyGroup("SpreaderTransmissionValue", trans_grp);
setPropertyGroup("SpreaderTransmissionError", trans_grp);
setPropertyGroup("TransmissionDarkCurrentFile", trans_grp);
setPropertyGroup("ThetaDependentTransmission", trans_grp);

// Background options
Expand Down Expand Up @@ -748,6 +754,7 @@ void SetupHFIRReduction::setupTransmission(boost::shared_ptr<PropertyManager> re
// Transmission options
const bool thetaDependentTrans = getProperty("ThetaDependentTransmission");
const std::string transMethod = getProperty("TransmissionMethod");
const std::string darkCurrent = getPropertyValue("TransmissionDarkCurrentFile");

// Transmission is entered by hand
if (boost::iequals(transMethod, "Value"))
Expand Down Expand Up @@ -783,6 +790,7 @@ void SetupHFIRReduction::setupTransmission(boost::shared_ptr<PropertyManager> re
transAlg->setProperty("SampleDataFilename", sampleFilename);
transAlg->setProperty("EmptyDataFilename", emptyFilename);
transAlg->setProperty("BeamRadius", beamRadius);
transAlg->setProperty("DarkCurrentFilename", darkCurrent);

// Beam center option for transmission data
if (boost::iequals(centerMethod, "Value") && !isEmpty(beamX) && !isEmpty(beamY))
Expand Down Expand Up @@ -831,6 +839,7 @@ void SetupHFIRReduction::setupTransmission(boost::shared_ptr<PropertyManager> re
transAlg->setProperty("DirectScatteringFilename", directScatt);
transAlg->setProperty("SpreaderTransmissionValue", spreaderTrValue);
transAlg->setProperty("SpreaderTransmissionError", spreaderTrError);
transAlg->setProperty("DarkCurrentFilename", darkCurrent);
transAlg->setProperty("ThetaDependent", thetaDependentTrans);
AlgorithmProperty *algProp = new AlgorithmProperty("TransmissionAlgorithm");
algProp->setValue(transAlg->toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ def DirectBeamTransmission(sample_file, empty_file, beam_radius=3.0, theta_depen
ReductionSingleton().reduction_properties["ThetaDependentTransmission"] = theta_dependent

def TransmissionDarkCurrent(dark_current=None):
#TODO
dark_current=find_data(dark_current, instrument=ReductionSingleton().instrument.name())
ReductionSingleton().get_transmission().set_dark_current(dark_current)
if dark_current is not None:
ReductionSingleton().reduction_properties["TransmissionDarkCurrentFile"] = dark_current
elif ReductionSingleton().reduction_properties.has_key("TransmissionDarkCurrentFile"):
del ReductionSingleton().reduction_properties["TransmissionDarkCurrentFile"]

def ThetaDependentTransmission(theta_dependence=True):
ReductionSingleton().reduction_properties["ThetaDependentTransmission"] = theta_dependence
Expand Down Expand Up @@ -176,11 +177,9 @@ def SetTransmissionBeamCenter(x, y):
ReductionSingleton().reduction_properties["TransmissionBeamCenterY"] = y

def TransmissionDirectBeamCenter(datafile):
#TODO
find_data(datafile, instrument=ReductionSingleton().instrument.name())
if ReductionSingleton().get_transmission() is None:
raise RuntimeError, "A transmission algorithm must be selected before setting the transmission beam center."
ReductionSingleton().get_transmission().set_beam_finder(sans_reduction_steps.DirectBeamCenter(datafile).set_persistent(False))
find_data(datafile, instrument=ReductionSingleton().get_instrument())
ReductionSingleton().reduction_properties["TransmissionBeamCenterMethod"] = "DirectBeam"
ReductionSingleton().reduction_properties["TransmissionBeamCenterFile"] = datafile

def Mask(nx_low=0, nx_high=0, ny_low=0, ny_high=0):
#TODO
Expand Down

0 comments on commit 5d5fdf5

Please sign in to comment.