Changeset eed601e in sasview for invariantview/perspectives/invariant
- Timestamp:
- Apr 7, 2010 6:36:10 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 199cef2
- Parents:
- 3fab6ef
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant_details.py
r3fab6ef reed601e 37 37 def __init__(self): 38 38 #invariant at low range 39 self.qstar_low = 0.039 self.qstar_low = None 40 40 #invariant at low range error 41 self.qstar_low_err = 0.041 self.qstar_low_err = None 42 42 #invariant 43 self.qstar = 0.043 self.qstar = None 44 44 #invariant error 45 self.qstar_err = 0.045 self.qstar_err = None 46 46 #invariant at high range 47 self.qstar_high = 0.047 self.qstar_high = None 48 48 #invariant at high range error 49 self.qstar_high_err = 0.049 self.qstar_high_err = None 50 50 #invariant total 51 51 self.qstar_total = None … … 53 53 self.qstar_total_err = None 54 54 #scale 55 self.qstar_low_percent = 0.056 self.qstar_high_percent = 0.057 self.qstar_percent = 0.055 self.qstar_low_percent = None 56 self.qstar_high_percent = None 57 self.qstar_percent = None 58 58 # warning message 59 59 self.existing_warning = False … … 64 64 Compute percentage of each invariant 65 65 """ 66 if self.qstar_total is not None and self.qstar_total != 0: 67 #compute invariant percentage 68 if self.qstar is None: 69 self.qstar = 0.0 70 self.qstar_percent = self.qstar/self.qstar_total 71 #compute low q invariant percentage 72 if self.qstar_low is None: 73 self.qstar_low = 0.0 74 self.qstar_low_percent = self.qstar_low/self.qstar_total 75 #compute high q invariant percentage 76 if self.qstar_high is None: 77 self.qstar_high = 0.0 78 self.qstar_high_percent = self.qstar_high/self.qstar_total 66 if self.qstar_total is None: 67 self.qstar_percent = None 68 self.qstar_low = None 69 self.qstar_high = None 70 self.check_values() 71 return 72 73 #compute invariant percentage 74 if self.qstar is None: 75 self.qstar_percent = None 76 else: 77 try: 78 self.qstar_percent = float(self.qstar)/float(self.qstar_total) 79 except: 80 self.qstar_percent = 'error' 81 #compute low q invariant percentage 82 if self.qstar_low is None: 83 self.qstar_low_percent = None 84 else: 85 try: 86 self.qstar_low_percent = float(self.qstar_low)/float(self.qstar_total) 87 except: 88 self.qstar_low_percent = 'error' 89 #compute high q invariant percentage 90 if self.qstar_high is None: 91 self.qstar_high_percent = None 92 else: 93 try: 94 self.qstar_high_percent = float(self.qstar_high)/float(self.qstar_total) 95 except: 96 self.qstar_high_percent = 'error' 79 97 self.check_values() 80 98 … … 83 101 check the validity if invariant 84 102 """ 103 if self.qstar_total is None and self.qstar is None: 104 self.warning_msg = "Invariant not calculated.\n" 105 return 106 if self.qstar_total == 0: 107 self.existing_warning = True 108 self.warning_msg = "Invariant is zero. \n" 109 self.warning_msg += "The calculations are likely to be unreliable!\n" 110 return 85 111 #warning to the user when the extrapolated invariant is greater than %5 86 112 msg = '' 87 if self.qstar_low_percent >= 0.05: 113 if self.qstar_percent == 'error': 114 self.existing_warning = True 115 msg = 'Error occurred when computing invariant from data.\n ' 116 117 if self.qstar_low_percent == 'error': 118 self.existing_warning = True 119 msg = 'Error occurred when computing extrapolated invariant at low-Q region.\n' 120 elif self.qstar_low_percent is not None and self.qstar_low_percent >= 0.05: 88 121 self.existing_warning = True 89 122 msg += "Extrapolated contribution at Low Q is higher " 90 123 msg += "than 5% of the invariant.\n" 91 if self.qstar_high_percent >= 0.05: 124 if self.qstar_high_percent == 'error': 125 self.existing_warning = True 126 msg += 'Error occurred when computing extrapolated invariant at high-Q region.\n' 127 elif self.qstar_high_percent is not None and self.qstar_high_percent >= 0.05: 92 128 self.existing_warning = True 93 129 msg += "Extrapolated contribution at High Q is higher " 94 130 msg += "than 5% of the invariant.\n" 95 if self.qstar_low_percent + self.qstar_high_percent >= 0.05: 131 if (self.qstar_low_percent not in [None, "error"]) and \ 132 (self.qstar_high_percent not in [None, "error"])\ 133 and self.qstar_low_percent + self.qstar_high_percent >= 0.05: 96 134 self.existing_warning = True 97 135 msg += "The sum of all extrapolated contributions is higher " … … 132 170 self.high_scale = self.get_scale(percentage=self.high_inv_percent, 133 171 scale_name="Extrapolated at High Q") 134 172 135 173 #Default color the extrapolation bar is grey 136 174 self.extrapolation_color_low = wx.Colour(169, 169, 168, 128) … … 181 219 unit_invariant = '[1/(cm * A)]' 182 220 183 invariant_txt = wx.StaticText(self, -1, 'Invariant') 221 invariant_txt = wx.StaticText(self, -1, 'Q* from Data ') 222 invariant_txt.SetToolTipString("Invariant in the data set's Q range.") 184 223 self.invariant_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 185 224 self.invariant_tcl.SetToolTipString("Invariant in the data set's Q range.") 186 225 self.invariant_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 187 self.invariant_err_tcl.SetToolTipString("Uncertainty on the invariant .")226 self.invariant_err_tcl.SetToolTipString("Uncertainty on the invariant from data's range.") 188 227 invariant_units_txt = wx.StaticText(self, -1, unit_invariant) 228 invariant_units_txt.SetToolTipString("Unit of the invariant from data's Q range") 189 229 190 invariant_low_txt = wx.StaticText(self, -1, 'Invariant in low-Q region') 230 invariant_low_txt = wx.StaticText(self, -1, 'Q* from Low-Q') 231 invariant_low_txt.SetToolTipString("Extrapolated invariant from low-Q range.") 191 232 self.invariant_low_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 192 self.invariant_low_tcl.SetToolTipString(" Invariant computed with the extrapolated low-Q data.")233 self.invariant_low_tcl.SetToolTipString("Extrapolated invariant from low-Q range.") 193 234 self.invariant_low_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 194 self.invariant_low_err_tcl.SetToolTipString("Uncertainty on the invariant .")235 self.invariant_low_err_tcl.SetToolTipString("Uncertainty on the invariant from low-Q range.") 195 236 invariant_low_units_txt = wx.StaticText(self, -1, unit_invariant) 196 197 invariant_high_txt = wx.StaticText(self, -1, 'Invariant in high-Q region') 237 invariant_low_units_txt.SetToolTipString("Unit of the extrapolated invariant from low-Q range") 238 239 invariant_high_txt = wx.StaticText(self, -1, 'Q* from High-Q') 240 invariant_high_txt.SetToolTipString("Extrapolated invariant from high-Q range") 198 241 self.invariant_high_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 199 self.invariant_high_tcl.SetToolTipString(" Invariant computed with the extrapolated high-Q data")242 self.invariant_high_tcl.SetToolTipString("Extrapolated invariant from high-Q range") 200 243 self.invariant_high_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 201 self.invariant_high_err_tcl.SetToolTipString("Uncertainty on the invariant .")244 self.invariant_high_err_tcl.SetToolTipString("Uncertainty on the invariant from high-Q range.") 202 245 invariant_high_units_txt = wx.StaticText(self, -1, unit_invariant) 246 invariant_high_units_txt.SetToolTipString("Unit of the extrapolated invariant from high-Q range") 203 247 204 248 #Invariant low … … 308 352 Check scale receive in this panel. 309 353 """ 354 scale = RECTANGLE_SCALE 310 355 try: 311 if percentage is None or percentage == 0.0: 312 percentage = RECTANGLE_SCALE 313 percentage = float(percentage) 356 if percentage in [None, 0.0, "error"]: 357 scale = RECTANGLE_SCALE 358 return scale 359 scale = float(percentage) 314 360 except: 315 percentage = RECTANGLE_SCALE361 scale = RECTANGLE_SCALE 316 362 self.warning_msg += "Receive an invalid scale for %s\n" 317 363 self.warning_msg += "check this value : %s\n"%(str(scale_name),str(percentage)) 318 return percentage364 return scale 319 365 320 366 def set_color_bar(self): … … 357 403 #Draw low rectangle 358 404 gc.PushState() 359 label = "Q* AtLow-Q"405 label = "Q* from Low-Q" 360 406 PathFunc = gc.DrawPath 361 407 w, h = gc.GetTextExtent(label) … … 367 413 gc.SetPen(wx.Pen("black", 1)) 368 414 gc.SetBrush(wx.Brush(self.extrapolation_color_low)) 369 low_percent = format_number(self.low_inv_percent*100)+ '%' 415 if self.low_inv_percent is None: 416 low_percent = 'Not Computed' 417 elif self.low_inv_percent == 'error': 418 low_percent = 'Error' 419 else: 420 low_percent = format_number(self.low_inv_percent*100)+ '%' 370 421 x_center = 20 371 422 y_center = -h … … 378 429 gc.PushState() # save it again 379 430 y_origine += 20 380 gc.DrawText("Q* In range", x_origine, y_origine)431 gc.DrawText("Q* from Data", x_origine, y_origine) 381 432 # offset to the lower part of the window 382 433 x_center = x_origine + RECTANGLE_WIDTH * self.inv_scale/2 + w + 10 … … 386 437 gc.SetBrush(wx.Brush(wx.Colour(67, 208, 128, 128))) 387 438 # Increase width by self.inv_scale 388 inv_percent = format_number(self.inv_percent*100)+ '%' 439 if self.inv_percent is None: 440 inv_percent = 'Not Computed' 441 elif self.inv_percent == 'error': 442 inv_percent = 'Error' 443 else: 444 inv_percent = format_number(self.inv_percent*100)+ '%' 389 445 x_center = 20 390 446 y_center = -h … … 397 453 gc.PushState() 398 454 y_origine += 20 399 gc.DrawText("Q* AtHigh-Q", x_origine, y_origine)455 gc.DrawText("Q* from High-Q", x_origine, y_origine) 400 456 #define the position of the new rectangle 401 457 x_center = x_origine + RECTANGLE_WIDTH * self.high_scale/2 + w + 10 … … 404 460 gc.SetBrush(wx.Brush(self.extrapolation_color_high)) 405 461 # increase scale by self.high_scale 406 high_percent = format_number(self.high_inv_percent*100)+ '%' 462 if self.high_inv_percent is None: 463 high_percent = 'Not Computed' 464 elif self.high_inv_percent == 'error': 465 high_percent = 'Error' 466 else: 467 high_percent = format_number(self.high_inv_percent*100)+ '%' 407 468 x_center = 20 408 469 y_center = -h … … 418 479 container = InvariantContainer() 419 480 container.qstar_total = 100.0 420 container.qstar = 15.0421 container.qstar_low = 0.001422 container.qstar_high = 100.0481 container.qstar = 50 482 container.qstar_low = None 483 container.qstar_high = "alina" 423 484 container.compute_percentage() 485 424 486 dlg = InvariantDetailsPanel(qstar_container=container) 425 487 dlg.ShowModal() -
invariantview/perspectives/invariant/invariant_panel.py
r4e74e13 reed601e 879 879 uncertainty = "+/-" 880 880 unit_invariant = '[1/(cm * A)]' 881 invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total ')881 invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total [Q*]') 882 882 self.invariant_total_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 883 msg_hint = "Total invariant , including extrapolated regions."883 msg_hint = "Total invariant [Q*], including extrapolated regions." 884 884 self.invariant_total_tcl.SetToolTipString(msg_hint) 885 885 self.invariant_total_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1))
Note: See TracChangeset
for help on using the changeset viewer.