Skip to content

Commit

Permalink
Fixes #167
Browse files Browse the repository at this point in the history
  • Loading branch information
Janik Zikovsky committed Jun 15, 2010
1 parent 6341a25 commit 1ed328c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 12 deletions.
3 changes: 3 additions & 0 deletions gui/display_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def check_for_changes():
reflections_recalculated = True
elif not (ref_mask is None):
#Just the mask is changing
# The I/sigI threshold might be different
model.experiment.exp.get_reflections_times_real_measured(ref_mask.threshold)
#Now do the mask
model.experiment.exp.calculate_reflections_mask()
reflections_changed = True

Expand Down
28 changes: 28 additions & 0 deletions gui/frame_qspace_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ def init_view_objects(self, *args):
self.points_module_surface.visible = False
self.points_module_glyph.visible = False

#Get the color look-up table
self.points_lut = self.points_module_glyph.module_manager.scalar_lut_manager.lut.table.to_array()
self.points_lut_original = 1 * self.points_lut

# ---- Simple outline for all of the data. -----
self.outline = Outline()
Expand Down Expand Up @@ -445,6 +448,28 @@ def init_view_objects(self, *args):
#Re-enable drawing
self.scene.disable_render = False

#-----------------------------------------------------------------------------------------------
def set_points_lut(self, predicted):
"""Set the look-up table (colormap).
Parameters:
predicted: bool, True for the "predicted" color map; measured otherwise"""
if not hasattr(self, 'points_lut'):
print "No LUT!"
return
# print "setting lut ", predicted
if predicted or True:
#Predicted style; copy the original
self.points_lut[:,:] = self.points_lut_original[:,:]
else:
#Measured style
self.points_lut[:,0] = 255-self.points_lut_original[:,0]
self.points_lut[:,1] = self.points_lut_original[:,1]
self.points_lut[:,2] = self.points_lut_original[:,2]
# self.points_lut[:,0] = np.arange(0,256,1)
# self.points_lut[:,1] = 0 #G
# self.points_lut[:,2] = 255 #B
self.points_lut[:,3] = 255 #alpha


#-----------------------------------------------------------------------------------------------
def show_pipeline(self):
Expand Down Expand Up @@ -632,6 +657,9 @@ def update_data_points(self, *args):
#Generate a new data object to make
self.point_data_src.data = self.make_point_data()

#Set the color map
self.set_points_lut(display.color_map == display.COLOR_BY_PREDICTED)

if self.in_pixel_mode():
# ------------ Pixel View -----------------------
self.pixel_view = True
Expand Down
3 changes: 2 additions & 1 deletion gui/panel_reflections_view_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _init_ctrls(self, prnt):
self.radioPredicted.SetValue(True)

self.staticTextThreshold = wx.StaticText(label=u'I/sigI threshold', parent=self, style=0)
self.textThreshold = wx.TextCtrl(value=u'2.0', parent=self, style=0)
self.textThreshold = wx.TextCtrl(value=u'2.0', parent=self, style=wx.TE_PROCESS_ENTER)
self.textThreshold.Bind(wx.EVT_TEXT_ENTER, self.OntextThreshold)
self.textThreshold.Bind(wx.EVT_KILL_FOCUS, self.OnChangeMaskingSettings)

Expand Down Expand Up @@ -405,6 +405,7 @@ def OnCheckRealtimeSliceCheckbox(self, event):
event.Skip()

def OntextThreshold(self, event):
print "pressed enter>:?"
self.controller.change_masking_settings()
event.Skip()

Expand Down
2 changes: 1 addition & 1 deletion gui/value_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _init_ctrls(self, prnt):
name=u'textValue', parent=self, pos=wx.Point(80, 0),
size=wx.Size(80, 27), style=wx.TE_PROCESS_ENTER, value=u'0')
self.textValue.Bind(wx.EVT_TEXT, self.OnTextValueText)
self.textValue.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter)
self.textValue.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter) #Don't forget the wx.TE_PROCESS_ENTER otherwise it doesn't work.
self.textValue.Bind(wx.EVT_KILL_FOCUS, self.OnTextEnter)
self.textValue.Bind(wx.EVT_KEY_UP, self.OnTextValueKeyUp)

Expand Down
23 changes: 17 additions & 6 deletions model/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,13 @@ def initialize_reflections(self):
#Clear the list of reflection times measured
self.get_reflections_times_measured(clear_list=True)

#And if you had any peaks files loaded, reload them.
self.reload_peaks_files()

#At this point, the reflections mask needs to be updated since the reflections changed.
self.calculate_reflections_mask()

#And if you had any peaks files loaded, reload them.
self.reload_peaks_files()



#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -1007,9 +1009,7 @@ def recalculate_reflections(self, pos_param, calculation_callback=None):
self.get_reflections_times_measured(None)

#We make the array of how many times REALLY measured, for all the positions
refmask = self.params[PARAM_REFLECTION_MASKING] #@type refmask ParamReflectionMasking
if refmask is None: refmask = ParamReflectionMasking()
self.get_reflections_times_real_measured(refmask.threshold)
self.get_reflections_times_real_measured(None)

#Continue on with masking
self.calculate_reflections_mask()
Expand Down Expand Up @@ -1154,8 +1154,16 @@ def get_reflections_times_real_measured(self, threshold):
-----------
pos_param: a ParamPositions object holding which positions to keep in the calculation.
None means use all of them (default).
threshold: I/sigI threshold to consider a peak "measured"
threshold: I/sigI threshold to consider a peak "measured". Set None to use the last
saved parameter.
"""

#Find the threshold if not specified.
if threshold is None:
refmask = self.params[PARAM_REFLECTION_MASKING] #@type refmask ParamReflectionMasking
if refmask is None: refmask = ParamReflectionMasking()
threshold = refmask.threshold

#Initialize the arrays
rtm = np.zeros( (len(self.reflections), 1) )
rtme = np.zeros( (len(self.reflections), 1) )
Expand Down Expand Up @@ -2087,6 +2095,9 @@ def reload_peaks_files(self):
else:
self.load_peaks_file(filename, append=True)

#Now, redo the stats
self.get_reflections_times_real_measured(None)

#---------------------------------------------------------------------------------------------
def compare_to_peaks_file(self, filename):
"""Compare the contents of an ISAW .peaks file with the measurements in this experiment."""
Expand Down
13 changes: 9 additions & 4 deletions model/reflections.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,15 @@ def times_real_measured(self, threshold=-1.0, add_equivalent_ones=False):
#@type rrm ReflectionRealMeasurement
for rrm in ref.real_measurements:
if not rrm is None:
#Don't divide by 0
if rrm.sigI > 1e-8:
if (rrm.integrated / rrm.sigI) > threshold:
total += 1
if threshold <= 0:
#A zero or lower threshold = take all comers
total += 1
else:
#Check the I/sigI value.
#Avoid divide by 0
if (rrm.sigI > 1e-8):
if (rrm.integrated / rrm.sigI) > threshold:
total += 1

return total

Expand Down

0 comments on commit 1ed328c

Please sign in to comment.