Refactoring #2011

PythonAPI: improve access to the simulation results

Added by ganeva over 2 years ago. Updated 2 months ago.

Status:BacklogStart date:14 Mar 2018
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

Request: plot simulated and experimental data together in the same units, the same scale, with the same ROI and the same masks.

Problems.
1. If detector resolution is present, masked area looks noisy. To avoid that, I set the all masked bins to have zero signal:

simulation.runSimulation()
result = simulation.result().histogram2d(ba.AxesUnits.MM)
for i in range(result.getTotalNumberOfBins()):
    if simulation.getInstrument().getDetectorMask().isMasked(i):
        result.setBinContent(i, 0)

Better would be if simulation would return already correct result, so that this step will not be necessary any more.

2. There is no way to apply the mask to the experimental data. The work around is:

def apply_mask(from_data, to_data):
    for i in range(from_data.getTotalNumberOfBins()):
        if from_data.getBinContent(i) == 0:
            to_data.setBinContent(i, 0)

to be continued


Related issues

Related to BornAgain - Refactoring #2130: Core API: Reduce the number of possible ways to access data through SimulationResult Backlog 30 Jul 2018
Related to BornAgain - Refactoring #1918: Core API: review IHistogram class family Backlog 06 Dec 2017

History

#1 Updated by wuttke 2 months ago

  • Subject changed from API changes to access the simulation results to PythonAPI: improve access to the simulation results
  • Status changed from New to Backlog

#2 Updated by wuttke 2 months ago

  • Related to Refactoring #2130: Core API: Reduce the number of possible ways to access data through SimulationResult added

#3 Updated by wuttke 2 months ago

Also available in: Atom PDF