Skip to content

Commit

Permalink
Closes #155. Volume coverage with crystal symmetry, and huge speed up…
Browse files Browse the repository at this point in the history
… with inline c
  • Loading branch information
Janik Zikovsky committed Jun 10, 2010
1 parent 595c34e commit 35b9a8b
Show file tree
Hide file tree
Showing 11 changed files with 310 additions and 318 deletions.
10 changes: 5 additions & 5 deletions doc_maker/user_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,18 +557,18 @@ def user_guide_script():
ca(screenshot_of, tv.sliceControl, '3d-sliceControl', margin=10)


ca(screenshot_of, tv.checkHemisphere, 'volume_options-checkHemisphere', margin=check_margin)
ca(check, tv.checkHemisphere, True)
ca(screenshot_of, tv.checkSymmetry, 'volume_options-checkSymmetry', margin=check_margin)
ca(check, tv.checkSymmetry, True)
wait(600)
ca(screenshot_of, fv.control, '3d-hemisphere', margin=control_margins, gradient_edge=control_gradient_edge)
ca(screenshot_of, fv.panelStats, '3d-panelStats-hemisphere', margin=10)
ca(screenshot_of, fv.control, '3d-symmetry', margin=control_margins, gradient_edge=control_gradient_edge)
ca(screenshot_of, fv.panelStats, '3d-panelStats-symmetry', margin=10)

ca(screenshot_of, tv.checkInvert, 'volume_options-checkInvert', margin=check_margin)
ca(check, tv.checkInvert, True)
wait(600)
ca(screenshot_of, fv.control, '3d-inverted', margin=control_margins, gradient_edge=control_gradient_edge)
ca(check, tv.checkInvert, False)
ca(check, tv.checkHemisphere, False)
ca(check, tv.checkSymmetry, False)
ca(check, tv.checkShowRedundancy, True)
wait(1200)

Expand Down
6 changes: 3 additions & 3 deletions gui/display_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def check_for_changes():
pos = ChangedParams[model.experiment.PARAM_POSITIONS]
trypos = ChangedParams[model.experiment.PARAM_TRY_POSITION]
det = ChangedParams[model.experiment.PARAM_DETECTORS]
hemi = ChangedParams[model.experiment.PARAM_HEMISPHERE]
symmetry = ChangedParams[model.experiment.PARAM_SYMMETRY]
invert = ChangedParams[model.experiment.PARAM_INVERT]
energy_slice = ChangedParams[model.experiment.PARAM_ENERGY_SLICE]
slice = ChangedParams[model.experiment.PARAM_SLICE]
Expand Down Expand Up @@ -170,8 +170,8 @@ def check_for_changes():
reflections_changed = True
reflections_recalculated = True

elif not (hemi is None):
#Just the hemisphere - no need to recalc reflections
elif not (symmetry is None):
#Just the symmetry - no need to recalc reflections
model.experiment.exp.calculate_coverage()
qspace_changed = True

Expand Down
2 changes: 1 addition & 1 deletion gui/frame_qspace_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def update_stats_panel(self, *args):
if self.in_volume_mode():
#Volume coverage
self.parent_frame.stats_panel.show_stats( \
exp.use_hemisphere(),
exp.use_symmetry(),
exp.overall_coverage,
exp.overall_redundancy )
else:
Expand Down
19 changes: 4 additions & 15 deletions gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,10 @@ def launch_gui(inelastic):
model.experiment.exp = model.experiment.Experiment(model.instrument.inst)
model.experiment.exp.crystal.point_group_name = model.crystals.get_point_group_names(long_name=True)[0]

#Some initial calculations
if False:
import numpy as np
for i in np.deg2rad([-5, 0, 5]):
model.instrument.inst.simulate_position(list([i,i,i]))
pd = dict()
for pos in model.instrument.inst.positions:
pd[ id(pos) ] = True
display_thread.NextParams[model.experiment.PARAM_POSITIONS] = model.experiment.ParamPositions(pd)
#Do some reflections
model.experiment.exp.initialize_reflections()
model.experiment.exp.recalculate_reflections(model.experiment.ParamPositions(pd))
else:
model.experiment.exp.initialize_reflections()
model.experiment.exp.recalculate_reflections(None)
#Initialize what needs to.
model.experiment.exp.initialize_volume_symmetry_map()
model.experiment.exp.initialize_reflections()
model.experiment.exp.recalculate_reflections(None)

#Initialize the application
application = CrystalPlanApp(0)
Expand Down
6 changes: 3 additions & 3 deletions gui/panel_coverage_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def __init__(self, parent, id, pos, size, style, name):


#-----------------------------------------------------------------------------------------------
def show_stats(self, hemisphere, coverage_pct, redundant_pct):
def show_stats(self, symmetry, coverage_pct, redundant_pct):
"""Update the information displayed on the statistics panel."""
if hemisphere:
self.staticTextStats1.SetLabel("Hemisphere Coverage:")
if symmetry:
self.staticTextStats1.SetLabel("Coverage with Symmetry:")
else:
self.staticTextStats1.SetLabel("Full Sphere Coverage:")

Expand Down
29 changes: 14 additions & 15 deletions gui/panel_qspace_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
[wxID_PanelQspaceOptions, wxID_PanelQspaceOptionsCHECKHEMISPHERE,
[wxID_PanelQspaceOptions, wxID_PanelQspaceOptionsCHECKSYMMETRY,
wxID_PanelQspaceOptionsCHECKINVERT,
wxID_PanelQspaceOptionsCHECKREALTIMESLICE,
wxID_PanelQspaceOptionsCHECKSHOWREDUNDANCY,
Expand Down Expand Up @@ -55,10 +55,10 @@ def set_invert(self, inversion):
#Tell the experiment to invert and then recalculate the slice.
display_thread.NextParams[model.experiment.PARAM_INVERT] = model.experiment.ParamInvert(inversion)

def set_hemisphere(self, hemi):
"""Sets whether the coverage will use the optimal hemisphere."""
def set_symmetry(self, value):
"""Sets whether the coverage will use the crystal symmetry."""
#This will tell the display_thread what to do.
display_thread.NextParams[model.experiment.PARAM_HEMISPHERE] = model.experiment.ParamHemisphere(hemi)
display_thread.NextParams[model.experiment.PARAM_SYMMETRY] = model.experiment.ParamSymmetry(value)

def show_redundancy(self, value):
"""Sets whether the redundancy is displayed graphically (using transparent isosurfaces)."""
Expand Down Expand Up @@ -128,7 +128,7 @@ def _init_coll_boxSizerAll_Items(self, parent):
def _init_coll_boxSizerTop_Items(self, parent):
# generated method, don't edit

parent.AddWindow(self.checkHemisphere, 0, border=4,
parent.AddWindow(self.checkSymmetry, 0, border=4,
flag=wx.LEFT | wx.RIGHT)
parent.AddSpacer(wx.Size(8, 8), border=0, flag=0)
parent.AddWindow(self.checkShowRedundancy, 0, border=0, flag=0)
Expand Down Expand Up @@ -185,14 +185,13 @@ def _init_ctrls(self, prnt):
self.checkInvert.Bind(wx.EVT_CHECKBOX, self.OnCheckInvertCheckbox,
id=wxID_PanelQspaceOptionsCHECKINVERT)

self.checkHemisphere = wx.CheckBox(id=wxID_PanelQspaceOptionsCHECKHEMISPHERE,
label=u'Find and show the optimal hemisphere',
name=u'checkHemisphere', parent=self, pos=wx.Point(4, 0),
size=wx.Size(296, 22), style=0)
self.checkHemisphere.SetValue(False)
self.checkHemisphere.Bind(wx.EVT_CHECKBOX,
self.OnCheckHemisphereCheckbox,
id=wxID_PanelQspaceOptionsCHECKHEMISPHERE)
self.checkSymmetry = wx.CheckBox(id=wxID_PanelQspaceOptionsCHECKSYMMETRY,
label=u'Use crystal symmetry? ',
name=u'checkSymmetry', parent=self, pos=wx.Point(4, 0), style=0)
self.checkSymmetry.SetValue(False)
self.checkSymmetry.Bind(wx.EVT_CHECKBOX,
self.OnCheckSymmetryCheckbox,
id=wxID_PanelQspaceOptionsCHECKSYMMETRY)

self.checkShowRedundancy = wx.CheckBox(id=wxID_PanelQspaceOptionsCHECKSHOWREDUNDANCY,
label=u'Show Redundancy', name=u'checkShowRedundancy',
Expand Down Expand Up @@ -263,8 +262,8 @@ def OnCheckInvertCheckbox(self, event):
self.controller.set_invert( self.checkInvert.GetValue() )
event.Skip()

def OnCheckHemisphereCheckbox(self, event):
self.controller.set_hemisphere( self.checkHemisphere.GetValue() )
def OnCheckSymmetryCheckbox(self, event):
self.controller.set_symmetry( self.checkSymmetry.GetValue() )
event.Skip()

def OnCheckShowRedundancyCheckbox(self, event):
Expand Down
3 changes: 3 additions & 0 deletions gui/panel_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ def OnButtonEditCrystalButton(self, event):
old_U = model.experiment.exp.crystal.get_u_matrix()

if dialog_edit_crystal.show_dialog(self, model.experiment.exp.crystal):
#Whenever the crystal changes, you need a new symmetry map.
model.experiment.exp.initialize_volume_symmetry_map()

#User clicked okay, something (proably) changed
new_U = model.experiment.exp.crystal.get_u_matrix()
if not np.allclose(old_U, new_U):
Expand Down
3 changes: 3 additions & 0 deletions gui/panel_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def apply(self):
#This sets up the new size q-space
model.instrument.inst.change_qspace_size(self.get_params_dictionary())

#Whenever the q-space changes, you need a new symmetry map.
model.experiment.exp.initialize_volume_symmetry_map()

#Always re-initialize the reflections
model.experiment.exp.initialize_reflections()

Expand Down
Loading

0 comments on commit 35b9a8b

Please sign in to comment.