Skip to content

Commit

Permalink
minor fixes and debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
rozyczko committed Feb 5, 2024
1 parent 5c3a6e7 commit 7cdcdfd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions easyDiffractionApp/Logic/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ def loadExperimentFromCifString(self, cifString="", job_name=""):
self._currentIndex = len(self._dataBlocksNoMeas) - 1
if not self.defined:
self.defined = bool(len(self._dataBlocksNoMeas))

self._job.interface = self._interface
self.dataBlocksChanged.emit()

def jobToBlock(self, job=None):
Expand Down Expand Up @@ -1180,6 +1182,10 @@ def runProfileCalculations(self):
# shove it all into the calculator.

result = self._interface.calculate_profile()
# debug stuff - remove before merging
# simx = self._xArrays
# simx = self._dataBlocksMeasOnly[0]['loops']['_pd_meas'][0]['2theta_scan']['value']
# result = self._job.create_simulation(simx)

console.debug(formatMsg('sub', 'Profle calculations', 'finished'))

Expand Down
12 changes: 9 additions & 3 deletions easyDiffractionApp/Logic/Fitting2.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ def __init__(self, proxy=None, interface=None):
self.interface = interface
# self.fitter = CoreFitter(self.parent.sample(), self.interface.fit_func)
self.fitter = CoreFitter(self.parent.experiment.job(), self.parent.experiment.job().create_simulation)
# self.fitter = CoreFitter(self.parent.experiment.job(), self.interface.fit_func)

# Multithreading
# self._fitter_thread = None
self.use_threading = True # change to False to disable threading for testing
self._fit_finished = True
self._fit_results = _defaultFitResults()
self.data = None
Expand Down Expand Up @@ -223,9 +225,13 @@ def startStop(self):
# self.data = self.parent.pdata()
name = 'pd_' + self.parent.experiment.job().name
self.data = self.interface.data()._inOutDict[name]
if not self.fit_thread.is_alive():
self.is_fitting_now = True
self.fit_thread.start()
if self.use_threading:
if not self.fit_thread.is_alive():
self.is_fitting_now = True
self.fit_thread.start()
else:
# non-threaded version
self.fit_threading()

@Property(str, notify=minimizerMethodChanged)
def minimizerMethod(self):
Expand Down
10 changes: 8 additions & 2 deletions easyDiffractionApp/Logic/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,11 @@ def loadModelsFromFiles(self, fpaths):
# @Slot(str)
def loadModelsFromEdCif(self, edCif):
# Update the Phases object
phase = Phases.from_cif_string(edCif)
self.phases.append(phase[0])
phases = Phases.from_cif_string(edCif)
phases.interface = self._interface
for phase in phases:
phase.scale.fixed = True
self.phases.append(phase)
self._currentIndex = len(self.phases) - 1
# convert phase into dataBlocks
dataBlocks = self.phaseToBlocks(self.phases)
Expand All @@ -236,6 +239,9 @@ def loadModelsFromEdCif(self, edCif):
self.dataBlocksChanged.emit()

def updateCifOnInterface(self):
'''
Update the CIF representation on the current interface
'''
cif = self._dataBlocksCif[self.currentIndex][0]
self._interface.updateModelCif(cif)

Expand Down

0 comments on commit 7cdcdfd

Please sign in to comment.