Changes in src/sas/sascalc/fit/pagestate.py [aca687a:59873e1] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/fit/pagestate.py
raca687a r59873e1 1 1 """ 2 2 Class that holds a fit page state 3 4 Pagestate fields reflect the names of the gui controls from the sasview 3.x5 fit page, so they are somewhat difficult to interpret.6 7 Pagestate attributes are as follows:8 9 # =>name: desc indicates the attribute is derived10 # name(xml): desc indicates the attribute name differs from the xml tag11 12 # SasView version which saved the file13 version: (4, 1, 2) from <fitting_plug_in version="major.minor.point">14 15 # Session information16 group_id: unique id for fit page in running system (int)17 => data_group_id: unique id for data item in running system (None)18 19 # Data file20 data: contents of <SASdata> (Data1D or Data2D)21 data_name: filename + [num] (latex_smeared.xml [1])22 data_id: filename + [num] + timestamp (latex_smeared.xml [1]1523303027.73)23 file: filename + [date time] (latex_smeared.xml [Apr 09 15:45])24 name: ?? (None)25 npts: number of points (float)26 enable2D: True if data is 2D (or if model is 2D and no data)27 is_data: True (pagestate will not save if there is no data attached)28 29 # Data weighting30 dI_didata: True if dy = data.dy31 dI_idata: True if dy = data.y32 dI_noweight: True if dy = 133 dI_sqrdata: True if dy = sqrt(data.y)34 35 # Data selection36 qmax: maximum q (float)37 qmin: minimum q (float)38 => qmax_x: ?? (None)39 => qmin_x: ?? (None)40 41 # Resolution smearing42 enable_smearer: True if use data.dx43 disable_smearer: True if no smearing44 pinhole_smearer: True if custom pinhole smear45 slit_smearer: True if custom slit smear46 dq_l: 2D resolution <dQp>47 dq_r: 2D resolution <dQs>48 dx_old: True for 3.x version of custom pinhole, which used dx_min rather49 than dx_percent, with dx_percent interpreted as 100 * dx_percent/q[0]50 dx_percent: custom pinhole resolution percentage51 dxl: slit height for custom slit resolution52 dxw: slit width for custom slit resolution53 smearer: repr() for active smearer (None on load)54 smear_type: None (None on load)55 56 # Model selection57 categorycombobox: model category58 formfactorcombobox: model name (could be "[plug-in] name")59 structurecombobox: structure factor model name (string or None or "None")60 multi_factor: multiplicity (integer or None)61 magnetic_on: True if model is magnetic (only for 2D data for now)62 => model: active model object (None on load)63 64 # Model parameters65 # Parameter is a tuple with the following structure. The parentheses66 # indicate xml attribute for the <parameter .../> tag:67 # fitted(selected_to_fit): True if parameter is fitted68 # name(name): display name for the parameter (string)69 # value(value): displayed parameter value (string)70 # => plusminus: '+/-' (constant string)71 # => uncertainty: tuple72 # (uncertainty_displayed): True if there is an uncertainty73 # (uncertainty_value): displayed uncertainty (string)74 # => lower: tuple75 # (minimum_displayed): True if there is a lower bound76 # (minimum_value): displayed lower bound (string)77 # => upper: tuple78 # (maximum_displayed): True if there is a upper bound79 # (maximum_value): displayed upper bound (string)80 # units(unit): displayed units81 parameters: list of normal parameters82 fixed_param: list of non-fitting parameters (nsigma, npts in dispersity)83 fittable_param: list of fittable dispersity parameters (distribution width)84 str_parameters: list of selection parameters (e.g, shell forms in spherical_sld)85 orientation_params(orientation_parameters): list of orientation and86 magnetic parameters (already included in parameters, so safe to ignore)87 orientation_params_disp(dispersity_parameters): list of orientation88 disperisty parameters (already included in fixed_param and89 fittable_param so safe to ignore)90 91 # Dispersity controls92 enable_disp: True if dispersity parameters93 disable_disp: True if no dispersity parameters94 disp_obj_dict(disp_obj): {'parameter.width': 'dispersity distribution'}95 values: {'parameter.width': [array distribution parameter values] }96 weights: {'parameter.width': [array distribution parameter weights] }97 => disp_box 098 => disp_cb_dict {}99 => disp_list []100 101 # Simultaneous fitting102 103 => images: None (initialized but unused?)104 => reset: False (initialized but unused?)105 => event_owner None106 => m_name None107 => manager None108 => page_name109 => param_toFit: []110 => process: list of process done on object [] (maybe managed by guiframe?)111 => saved_states {}112 => cb1: False (simfit cb1 is now stored in select_all)113 114 tcChi 1.3463115 theory_data None116 timestamp 1523303103.74117 118 Constraint attributes are as follows:119 120 constraint_dict {}121 constraints_list122 {'model_cbox': 'M2', 'param_cbox': 'scale', 'egal_txt': ' = ', 'constraint': 'M1.scale'}123 {'model_cbox': 'M2', 'param_cbox': 'radius', 'egal_txt': ' = ', 'constraint': 'M1.radius'}124 {'model_cbox': 'M2', 'param_cbox': 'radius.width', 'egal_txt': ' = ', 'constraint': 'M1.radius.width'}125 fit_page_no None126 model_list127 {'fit_number': '393', 'checked': 'True', 'fit_page_source': 'M2', 'name': 'latex_smeared.xml [1]1523535051.03', 'model_name': 'sphere'}128 {'fit_number': '335', 'checked': 'True', 'fit_page_source': 'M1', 'name': 'latex_smeared.xml 1523535050.03', 'model_name': 'sphere'}129 model_to_fit130 no_constraint 0131 select_all True132 133 134 3 """ 135 4 # TODO: Refactor code so we don't need to use getattr/setattr … … 144 13 ################################################################################ 145 14 import time 15 import re 146 16 import os 147 17 import sys … … 292 162 self.theory_data = None 293 163 # Is 2D 164 self.is_2D = False 294 165 self.images = None 295 166 … … 686 557 temp_parameters = [] 687 558 temp_fittable_param = [] 559 if self.data.__class__.__name__ == "Data2D": 560 self.is_2D = True 561 else: 562 self.is_2D = False 688 563 if self.data is not None: 689 is_2D = (self.data.__class__.__name__ == "Data2D") 690 if not is_2D: 564 if not self.is_2D: 691 565 for item in self.parameters: 692 566 if item not in self.orientation_params: … … 773 647 name = value.split(':', 1)[1].strip() 774 648 file_value = "File name:" + name 649 #Truncating string so print doesn't complain of being outside margins 650 if sys.platform != "win32": 651 MAX_STRING_LENGHT = 50 652 if len(file_value) > MAX_STRING_LENGHT: 653 file_value = "File name:.."+file_value[-MAX_STRING_LENGHT+10:] 775 654 file_name = CENTRE % file_value 776 655 if len(title) == 0: … … 848 727 html_str, text_str, title = self._get_report_string() 849 728 # Allow 2 figures to append 850 image_links = [FEET_2%fig for fig in fig_urls] 851 729 #Constraining image width for OSX and linux, so print doesn't complain of being outside margins 730 if sys.platform == "win32": 731 image_links = [FEET_2%fig for fig in fig_urls] 732 else: 733 image_links = [FEET_2_unix%fig for fig in fig_urls] 852 734 # final report html strings 853 735 report_str = html_str + ELINE.join(image_links) 854 736 report_str += FEET_3 855 737 return report_str, text_str 856 738 … … 1081 963 if node.get('version'): 1082 964 # Get the version for model conversion purposes 1083 self.version = tuple(int(e) for e in1084 str.split(node.get('version'), "."))965 x = re.sub('[^\d.]', '', node.get('version')) 966 self.version = tuple(int(e) for e in str.split(x, ".")) 1085 967 # The tuple must be at least 3 items long 1086 968 while len(self.version) < 3: … … 1495 1377 """ 1496 1378 FEET_2 = \ 1497 """<img src="%s" ></img> 1379 """<img src="%s"></img> 1380 """ 1381 FEET_2_unix = \ 1382 """<img src="%s" width="540"></img> 1498 1383 """ 1499 1384 FEET_3 = \
Note: See TracChangeset
for help on using the changeset viewer.