Changes in src/sas/sasgui/perspectives/fitting/basepage.py [e28f34d:7988501] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/sas/sasgui/perspectives/fitting/basepage.py ¶
re28f34d r7988501 9 9 import copy 10 10 import math 11 import string 11 12 import json 12 13 import logging … … 142 143 self.theory_qmin_x = None 143 144 self.theory_qmax_x = None 145 self.cb1 = None 144 146 self.btEditMask = None 145 147 self.btFit = None … … 280 282 num=self.npts_x, endpoint=True) 281 283 self.data = Data1D(x=x) 282 self.data.xaxis('\\rm{Q}', "A^{-1}") 283 self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 284 #self.data.xaxis('\\rm{Q}', "A^{-1}") 285 self.data.xaxis('\\rm{X}', "") 286 #self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 287 self.data.yaxis('\\rm{Y}', "") 284 288 self.data.is_data = False 285 289 self.data.id = str(self.uid) + " data" … … 306 310 num=self.npts_x, endpoint=True, base=10.0) 307 311 self.data = Data1D(x=x) 308 self.data.xaxis('\\rm{Q}', "A^{-1}") 309 self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 312 #self.data.xaxis('\\rm{Q}', "A^{-1}") 313 #self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 314 self.data.xaxis('\\rm{X}', "") 315 self.data.yaxis('\\rm{Y}', "") 310 316 self.data.is_data = False 311 317 self.data.id = str(self.uid) + " data" … … 334 340 self.data.detector[index].beam_center.x = qmax 335 341 self.data.detector[index].beam_center.y = qmax 342 ## create x_bins and y_bins of the model 2D 343 #pixel_width_x = self.data.detector[index].pixel_size.x 344 #pixel_width_y = self.data.detector[index].pixel_size.y 345 #center_x = self.data.detector[index].beam_center.x/pixel_width_x 346 #center_y = self.data.detector[index].beam_center.y/pixel_width_y 347 # theory default: assume the beam 348 #center is located at the center of sqr detector 336 349 xmax = qmax 337 350 xmin = -qmax … … 352 365 # set all True (standing for unmasked) as default 353 366 mask = numpy.ones(len(qx_data), dtype=bool) 367 # calculate the range of qx and qy: this way, 368 # it is a little more independent 369 #x_size = xmax - xmin 370 #y_size = ymax - ymin 354 371 # store x and y bin centers in q space 355 372 x_bins = x 356 373 y_bins = y 374 # bin size: x- & y-directions 375 #xstep = x_size / len(x_bins - 1) 376 #ystep = y_size / len(y_bins - 1) 357 377 358 378 self.data.source = Source() … … 395 415 batch_menu.Enable(self.batch_on and flag) 396 416 417 def set_page_info(self, page_info): 418 """ 419 set some page important information at once 420 """ 421 # THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED. Started up program 422 # and started new fit window and PR and Invariant and a fit in fitting 423 # but never entered this routine which should be an initialization 424 # routine. Leave for a while but probably something to clean up at 425 # some point? 426 # 427 # PDB April 13 2014 428 # 429 ##window_name 430 self.window_name = page_info.window_name 431 ##window_caption 432 self.window_caption = page_info.window_caption 433 ## manager is the fitting plugin 434 self._manager = page_info.manager 435 ## owner of the page (fitting plugin) 436 self.event_owner = page_info.event_owner 437 ## current model 438 self.model = page_info.model 439 ## data 440 self.data = page_info.data 441 ## dictionary containing list of models 442 self.model_list_box = page_info.model_list_box 443 ## Data member to store the dispersion object created 444 self.populate_box(model_dict=self.model_list_box) 445 397 446 def onContextMenu(self, event): 398 447 """ 399 448 Retrieve the state selected state 400 449 """ 450 # Skipping the save state functionality for release 0.9.0 451 #return 452 401 453 pos = event.GetPosition() 402 454 pos = self.ScreenToClient(pos) 455 403 456 self.PopupMenu(self.popUpMenu, pos) 404 457 … … 426 479 self.sizer2 = wx.BoxSizer(wx.VERTICAL) 427 480 self.sizer3 = wx.BoxSizer(wx.VERTICAL) 481 self.sizerTrafo = wx.BoxSizer(wx.VERTICAL) 428 482 self.sizer4 = wx.BoxSizer(wx.VERTICAL) 429 483 self.sizer5 = wx.BoxSizer(wx.VERTICAL) … … 434 488 self.sizer2.SetMinSize((PANEL_WIDTH, -1)) 435 489 self.sizer3.SetMinSize((PANEL_WIDTH, -1)) 490 self.sizerTrafo.SetMinSize((PANEL_WIDTH, -1)) 436 491 self.sizer4.SetMinSize((PANEL_WIDTH, -1)) 437 492 self.sizer5.SetMinSize((PANEL_WIDTH, -1)) … … 442 497 self.vbox.Add(self.sizer2) 443 498 self.vbox.Add(self.sizer3) 499 self.vbox.Add(self.sizerTrafo) 444 500 self.vbox.Add(self.sizer4) 445 501 self.vbox.Add(self.sizer5) … … 514 570 def initialize_combox(self): 515 571 """ 516 put default value in the combo box 517 """ 518 if self.model_list_box is not None and len(self.model_list_box) > 0: 572 put default value in the combobox 573 """ 574 ## fill combox box 575 if self.model_list_box is None: 576 return 577 if len(self.model_list_box) > 0: 578 ## This is obsolete code since form factor box is no longer static. 579 ## It is now set dynamically through _show_combox and _show_combos_helper 580 ## These are called for first time by formfactor_combo_init 581 ## itself called from fitpanel only. If we find that I'm wrong and 582 ## we DO need to initialize somehow here - do it by a call to 583 ## formfactor_combo_init 584 ## self.formfator_combo_init() 585 ## BUT NOT HERE -- make it last line of this 586 ## method so that structure box is populated before _show_comboox_helper 587 ## is called. Otherwise wx will complain mightily:-) 588 ## 589 ## Also change the name to initiatlize_structurebox along with changes 590 ## to other combobox methods (_populate_listbox --> _populate_categorybox 591 ## etc ) 592 ## 593 ## PDB 4/26/2014 594 # self._populate_box(self.formfactorbox, 595 # self.model_list_box["Shapes"]) 519 596 self._populate_box(self.structurebox, 520 597 self.model_list_box["Structure Factors"]) … … 525 602 self.structurebox.Disable() 526 603 self.text2.Disable() 604 605 if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]: 606 self.structurebox.Show() 607 self.text2.Show() 608 self.structurebox.Enable() 609 self.text2.Enable() 610 527 611 528 612 def set_dispers_sizer(self): … … 662 746 else: 663 747 wx.CallAfter(self.get_copy) 748 664 749 665 750 def on_paste(self, event): … … 875 960 self.state.orientation_params) 876 961 self._copy_parameters_state(self.orientation_params_disp, 877 self.state.orientation_params_disp)962 self.state.orientation_params_disp) 878 963 879 964 self._copy_parameters_state(self.parameters, self.state.parameters) 880 965 self._copy_parameters_state(self.fittable_param, 881 self.state.fittable_param)966 self.state.fittable_param) 882 967 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 883 968 #save chisqr … … 967 1052 self.disp_cb_dict = state.disp_cb_dict 968 1053 self.disp_list = state.disp_list 1054 1055 ## set the state of the radio box 1056 #self.shape_rbutton.SetValue(state.shape_rbutton) 1057 #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 1058 #self.struct_rbutton.SetValue(state.struct_rbutton) 1059 #self.plugin_rbutton.SetValue(state.plugin_rbutton) 969 1060 970 1061 ## fill model combobox … … 1113 1204 # set data, etc. from the state 1114 1205 # reset page between theory and fitting from bookmarking 1206 #if state.data == None: 1207 # data = None 1208 #else: 1115 1209 data = state.data 1116 1210 … … 1138 1232 self.disp_cb_dict = state.disp_cb_dict 1139 1233 self.disp_list = state.disp_list 1234 1235 ## set the state of the radio box 1236 #self.shape_rbutton.SetValue(state.shape_rbutton) 1237 #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 1238 #self.struct_rbutton.SetValue(state.struct_rbutton) 1239 #self.plugin_rbutton.SetValue(state.plugin_rbutton) 1140 1240 1141 1241 ## fill model combobox … … 1193 1293 else: 1194 1294 self.model_view.SetLabel("1D Mode") 1295 1296 ## set the select all check box to the a given state 1297 self.cb1.SetValue(state.cb1) 1195 1298 1196 1299 ## reset state of checkbox,textcrtl and regular parameters value … … 1323 1426 logging.error(traceback.format_exc()) 1324 1427 1428 # Make sure the check box updated when all checked 1429 if self.cb1.GetValue(): 1430 self.select_all_param(None) 1431 1325 1432 def _selectDlg(self): 1326 1433 """ … … 1420 1527 else: 1421 1528 self.fitrange = False 1529 1530 if not self.data.is_data: 1531 is_modified = True 1422 1532 1423 1533 ## if any value is modify draw model with new value … … 1436 1546 self._draw_model() 1437 1547 self.Refresh() 1438 1439 logging.info("is_modified flag set to %g",is_modified)1440 1548 return is_modified 1441 1549 … … 1778 1886 if mod_cat == custom_model: 1779 1887 for model in self.model_list_box[mod_cat]: 1780 m_list.append(self.model_dict[model.name]) 1888 str_m = model.id if hasattr(model, 'id') else model.name 1889 m_list.append(self.model_dict[str_m]) 1781 1890 else: 1782 1891 cat_dic = self.master_category_dict[mod_cat] … … 1784 1893 if enabled: 1785 1894 m_list.append(self.model_dict[model]) 1895 #else: 1896 # msg = "This model is disabled by Category Manager." 1897 # wx.PostEvent(self.parent.parent, 1898 # StatusEvent(status=msg, info="error")) 1786 1899 except Exception: 1787 1900 msg = traceback.format_exc() … … 1954 2067 form_factor = self.formfactorbox.GetClientData(f_id) 1955 2068 1956 if form_factor is None or not form_factor.is_form_factor:2069 if not form_factor in self.model_list_box["multiplication"]: 1957 2070 self.structurebox.Hide() 1958 2071 self.text2.Hide() … … 2452 2565 item[2].Enable() 2453 2566 2454 # Make sure the check box updated 2455 self.get_all_checked_params() 2567 # Make sure the check box updated when all checked 2568 if self.cb1.GetValue(): 2569 #self.select_all_param(None) 2570 self.get_all_checked_params() 2456 2571 2457 2572 # update params … … 3359 3474 self.by_model_dict = defaultdict(list) 3360 3475 self.model_enabled_dict = defaultdict(bool) 3361 categorization_file = CategoryInstaller.get_user_file() 3362 with open(categorization_file, 'rb') as f: 3363 self.master_category_dict = json.load(f) 3364 self._regenerate_model_dict() 3476 3477 try: 3478 categorization_file = CategoryInstaller.get_user_file() 3479 if not os.path.isfile(categorization_file): 3480 categorization_file = CategoryInstaller.get_default_file() 3481 cat_file = open(categorization_file, 'rb') 3482 self.master_category_dict = json.load(cat_file) 3483 self._regenerate_model_dict() 3484 cat_file.close() 3485 except IOError: 3486 raise 3487 print 'Problem reading in category file.' 3488 print 'We even looked for it, made sure it was there.' 3489 print 'An existential crisis if there ever was one.' 3365 3490 3366 3491 def _regenerate_model_dict(self): … … 3598 3723 call back for model selection if implemented 3599 3724 """ 3725 def select_all_param(self, event): 3726 """ 3727 set to true or false all checkBox if implemented 3728 """ 3600 3729 def get_weight_flag(self): 3601 3730 """
Note: See TracChangeset
for help on using the changeset viewer.