diff --git a/Core/Lattice/Lattice2D.cpp b/Core/Lattice/Lattice2D.cpp index e475901d4faff7d27e72cda8a5c0cfb002a572b9..6235f0e679891559df681be15f6b1406d8992673 100644 --- a/Core/Lattice/Lattice2D.cpp +++ b/Core/Lattice/Lattice2D.cpp @@ -33,7 +33,7 @@ Lattice2D::Lattice2D(double length1, double length2, double angle, double rotati double Lattice2D::unitCellArea() const { - return std::abs(m_length1*m_length2*std::sin(m_angle)); + return std::abs(length1()*length2()*std::sin(latticeAngle())); } Lattice2D::ReciprocalBases Lattice2D::reciprocalBases() const diff --git a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py index db7debce1ce5217eab9e519e15966833f8ca89cd..d975f5b32f2dd0fe08d7e65543779d6ba1738b21 100644 --- a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py +++ b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py @@ -63,6 +63,8 @@ def create_real_data(): real_data = simulation.getIntensityData().getArray() # spoiling simulated data with the noise to produce "real" data + # random seed made as in FitSPheresInHexLattice_builder.py example + np.random.seed(0) noise_factor = 0.1 noisy = np.random.normal(real_data, noise_factor*np.sqrt(real_data)) noisy[noisy < 0.1] = 0.1 @@ -76,8 +78,6 @@ def run_fitting(): simulation = get_simulation() sample = get_sample() simulation.setSample(sample) - print(simulation.treeToString()) - print(simulation.parametersToString()) real_data = create_real_data() @@ -89,10 +89,13 @@ def run_fitting(): draw_observer = ba.DefaultFitObserver(draw_every_nth=10) fit_suite.attachObserver(draw_observer) - fit_suite.addFitParameter( - "*HexagonalLattice/LatticeLength", 8.*nm, ba.AttLimits.limited(4., 12.)) fit_suite.addFitParameter( "*/FullSphere/Radius", 8.*nm, ba.AttLimits.limited(4., 12.)) + fit_suite.addFitParameter( + "*HexagonalLattice/LatticeLength", 8.*nm, ba.AttLimits.limited(4., 12.)) + + print(fit_suite.treeToString()) + print(fit_suite.parametersToString()) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py index 364c1bca19f8712b5a60714f40a265b61a6b83ce..96f0a5a73a4b9569e1b79f787f00a73ab282f3fa 100644 --- a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py +++ b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py @@ -83,6 +83,8 @@ def create_real_data(): real_data = simulation.getIntensityData().getArray() # spoiling simulated data with the noise to produce "real" data + # random seed made as in FitSPheresInHexLattice.py example + np.random.seed(0) noise_factor = 0.1 noisy = np.random.normal(real_data, noise_factor*np.sqrt(real_data)) noisy[noisy < 0.1] = 0.1 @@ -93,21 +95,14 @@ def run_fitting(): """ main function to run fitting """ - # print("1.1") - # builder = MySampleBuilder() - # print(builder.parametersToString()) - # print("1.2") - - simulation = get_simulation() simulation.setSampleBuilder(MySampleBuilder()) - print(simulation.parametersToString()) real_data = create_real_data() fit_suite = ba.FitSuite() fit_suite.addSimulationAndRealData(simulation, real_data) - fit_suite.initPrint(1) + fit_suite.initPrint(10) draw_observer = ba.DefaultFitObserver(draw_every_nth=10) fit_suite.attachObserver(draw_observer)