Changeset 6b0fc72 in sasview for src/sas/perspectives/fitting/pagestate.py
- Timestamp:
- Mar 9, 2015 11:31:19 AM (10 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:
- d26dea0
- Parents:
- 418e59f (diff), b1e609c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/pagestate.py
rd838715 rb1e609c 2 2 Class that holds a fit page state 3 3 """ 4 #TODO: Refactor code so we don't need to use getattr/setattr 4 5 ################################################################################ 5 6 #This software was developed by the University of Tennessee as part of the … … 35 36 CANSAS_NS = "cansas1d/1.0" 36 37 37 list_of_data_attributes = [["is_data", "is_data", "bool"], 38 ["group_id", "data_group_id", "string"], 39 ["data_name", "data_name", "string"], 40 ["data_id", "data_id", "string"], 41 ["name", "name", "string"], 42 ["data_name", "data_name", "string"]] 43 list_of_state_attributes = [["engine_type", "engine_type", "string"], 44 ["qmin", "qmin", "float"], 45 ["qmax", "qmax", "float"], 46 ["npts", "npts", "float"], 47 #["shape_rbutton", "shape_rbutton", "bool"], 48 #["shape_indep_rbutton", "shape_indep_rbutton", "bool"], 49 #["plugin_rbutton", "plugin_rbutton", "bool"], 50 #["struct_rbutton", "struct_rbutton", "bool"], 51 ["categorycombobox", "categorycombobox", "string"], 52 ["formfactorcombobox", "formfactorcombobox", "string"], 53 ["structurecombobox", "structurecombobox", "string"], 54 ["multi_factor","multi_factor","float"], 55 ["magnetic_on","magnetic_on", "bool"], 56 ["enable_smearer","enable_smearer","bool"], 57 ["disable_smearer","disable_smearer","bool"], 58 ["pinhole_smearer","pinhole_smearer","bool"], 59 ["slit_smearer","slit_smearer","bool"], 60 ["enable_disp","enable_disp","bool"], 61 ["disable_disp","disable_disp","bool"], 62 ["dI_noweight","dI_noweight","bool"], 63 ["dI_didata","dI_didata","bool"], 64 ["dI_sqrdata","dI_sqrdata","bool"], 65 ["dI_idata","dI_idata","bool"], 66 ["enable2D","enable2D","bool"], 67 ["cb1","cb1","bool"], 68 ["tcChi","tcChi","float"], 69 ["smearer", "smearer", "float"], 70 ["smear_type","smear_type", "string"], 71 ["dq_l", "dq_l", "string"], 72 ["dq_r","dq_r", "string"], 73 ["dx_max", "dx_max", "float"], 74 ["dx_min","dx_min", "float"], 75 ["dxl", "dxl", "float"], 76 ["dxw","dxw", "float"]] 77 78 list_of_model_attributes = [["values", "values"], 38 LIST_OF_DATA_ATTRIBUTES = [["is_data", "is_data", "bool"], 39 ["group_id", "data_group_id", "string"], 40 ["data_name", "data_name", "string"], 41 ["data_id", "data_id", "string"], 42 ["name", "name", "string"], 43 ["data_name", "data_name", "string"]] 44 LIST_OF_STATE_ATTRIBUTES = [["engine_type", "engine_type", "string"], 45 ["qmin", "qmin", "float"], 46 ["qmax", "qmax", "float"], 47 ["npts", "npts", "float"], 48 ["categorycombobox", "categorycombobox", "string"], 49 ["formfactorcombobox", "formfactorcombobox", "string"], 50 ["structurecombobox", "structurecombobox", "string"], 51 ["multi_factor", "multi_factor", "float"], 52 ["magnetic_on", "magnetic_on", "bool"], 53 ["enable_smearer", "enable_smearer", "bool"], 54 ["disable_smearer", "disable_smearer", "bool"], 55 ["pinhole_smearer", "pinhole_smearer", "bool"], 56 ["slit_smearer", "slit_smearer", "bool"], 57 ["enable_disp", "enable_disp", "bool"], 58 ["disable_disp", "disable_disp", "bool"], 59 ["dI_noweight", "dI_noweight", "bool"], 60 ["dI_didata", "dI_didata", "bool"], 61 ["dI_sqrdata", "dI_sqrdata", "bool"], 62 ["dI_idata", "dI_idata", "bool"], 63 ["enable2D", "enable2D", "bool"], 64 ["cb1", "cb1", "bool"], 65 ["tcChi", "tcChi", "float"], 66 ["smearer", "smearer", "float"], 67 ["smear_type", "smear_type", "string"], 68 ["dq_l", "dq_l", "string"], 69 ["dq_r", "dq_r", "string"], 70 ["dx_max", "dx_max", "float"], 71 ["dx_min", "dx_min", "float"], 72 ["dxl", "dxl", "float"], 73 ["dxw", "dxw", "float"]] 74 75 LIST_OF_MODEL_ATTRIBUTES = [["values", "values"], 79 76 ["weights", "weights"]] 80 77 81 list_of_obj_dic= [["disp_obj_dict", "_disp_obj_dict", "string"]]82 83 list_of_state_parameters= [["parameters", "parameters"],78 DISPERSION_LIST = [["disp_obj_dict", "_disp_obj_dict", "string"]] 79 80 LIST_OF_STATE_PARAMETERS = [["parameters", "parameters"], 84 81 ["str_parameters", "str_parameters"], 85 82 ["orientation_parameters", "orientation_params"], … … 87 84 ["fixed_param", "fixed_param"], 88 85 ["fittable_param", "fittable_param"]] 89 list_of_data_2d_attr= [["xmin", "xmin", "float"],86 LIST_OF_DATA_2D_ATTR = [["xmin", "xmin", "float"], 90 87 ["xmax", "xmax", "float"], 91 88 ["ymin", "ymin", "float"], … … 97 94 ["_zaxis", "_zaxis", "string"], 98 95 ["_zunit", "_zunit", "string"]] 99 list_of_data2d_values= [["qx_data", "qx_data", "float"],100 ["qy_data", "qy_data", "float"],101 ["dqx_data", "dqx_data", "float"],102 ["dqy_data", "dqy_data", "float"],103 ["data", "data", "float"],104 ["q_data", "q_data", "float"],105 ["err_data", "err_data", "float"],106 ["mask", "mask", "bool"]]96 LIST_OF_DATA_2D_VALUES = [["qx_data", "qx_data", "float"], 97 ["qy_data", "qy_data", "float"], 98 ["dqx_data", "dqx_data", "float"], 99 ["dqy_data", "dqy_data", "float"], 100 ["data", "data", "float"], 101 ["q_data", "q_data", "float"], 102 ["err_data", "err_data", "float"], 103 ["mask", "mask", "bool"]] 107 104 108 105 … … 110 107 """ 111 108 Create a numpy list from value extrated from the node 112 109 113 110 :param node: node from each the value is stored 114 111 :param item: list name of three strings.the two first are name of data 115 112 attribute and the third one is the type of the value of that 116 113 attribute. type can be string, float, bool, etc. 117 114 118 115 : return: numpy array 119 116 """ … … 124 121 try: 125 122 return node.get(item[0]).strip() == "True" 126 123 127 124 except: 128 125 return None … … 132 129 except: 133 130 return None 134 135 131 132 136 133 class PageState(object): 137 134 """ … … 141 138 """ 142 139 Initialize the current state 143 140 144 141 :param model: a selected model within a page 145 142 :param data: 146 143 147 144 """ 148 145 self.file = None … … 159 156 self.is_2D = False 160 157 self.images = None 161 158 162 159 #save additional information on data that dataloader.reader does not read 163 160 self.is_data = None … … 172 169 if self.data is not None and hasattr(self.data, "group_id"): 173 170 self.data_group_id = self.data.group_id 174 171 175 172 ## reset True change the state of exsiting button 176 173 self.reset = False 177 174 178 175 #engine type 179 176 self.engine_type = None … … 225 222 self.values = {} 226 223 self.weights = {} 227 224 228 225 #contains link between a model and selected parameters to fit 229 226 self.param_toFit = [] … … 251 248 self.qmax_x = None 252 249 self.qmin_x = None 253 250 254 251 self.npts = None 255 252 self.name = "" … … 269 266 self.enable_disp = False 270 267 self.disable_disp = True 271 268 272 269 ## state of selected all check button 273 270 self.cb1 = False 274 271 ## store value of chisqr 275 272 self.tcChi = None 276 273 277 274 def clone(self): 278 275 """ … … 292 289 obj.model_list_box = copy.deepcopy(self.model_list_box) 293 290 obj.engine_type = copy.deepcopy(self.engine_type) 294 291 295 292 obj.categorycombobox = self.categorycombobox 296 293 obj.formfactorcombobox = self.formfactorcombobox 297 294 obj.structurecombobox = self.structurecombobox 298 295 299 296 #obj.shape_rbutton = self.shape_rbutton 300 297 #obj.shape_indep_rbutton = self.shape_indep_rbutton 301 298 #obj.struct_rbutton = self.struct_rbutton 302 299 #obj.plugin_rbutton = self.plugin_rbutton 303 300 304 301 obj.manager = self.manager 305 302 obj.event_owner = self.event_owner 306 303 obj.disp_list = copy.deepcopy(self.disp_list) 307 304 308 305 obj.enable2D = copy.deepcopy(self.enable2D) 309 306 obj.parameters = copy.deepcopy(self.parameters) … … 316 313 obj.disable_disp = copy.deepcopy(self.disable_disp) 317 314 obj.tcChi = self.tcChi 318 315 319 316 if len(self._disp_obj_dict) > 0: 320 317 for k, v in self._disp_obj_dict.iteritems(): … … 343 340 obj.dx_min = copy.deepcopy(self.dx_min) 344 341 obj.dxl = copy.deepcopy(self.dxl) 345 obj.dxw = copy.deepcopy(self.dxw) 342 obj.dxw = copy.deepcopy(self.dxw) 346 343 obj.disp_box = copy.deepcopy(self.disp_box) 347 344 obj.qmin = copy.deepcopy(self.qmin) … … 352 349 obj.cb1 = copy.deepcopy(self.cb1) 353 350 obj.smearer = copy.deepcopy(self.smearer) 354 351 355 352 for name, state in self.saved_states.iteritems(): 356 353 copy_name = copy.deepcopy(name) … … 358 355 obj.saved_states[copy_name] = copy_state 359 356 return obj 360 357 361 358 def _repr_helper(self, list, rep): 362 359 """ … … 375 372 rep += "parameter unit: %s\n\n" % str(item[7]) 376 373 return rep 377 374 378 375 def __repr__(self): 379 376 """ … … 397 394 else: 398 395 rep += "model name : None\n" 399 #rep += "model type (form factor) selected: %s\n" % self.shape_rbutton400 396 rep += "multi_factor : %s\n" % str(self.multi_factor) 401 rep += "magnetic_on : %s\n" % str(self.magnetic_on)397 rep += "magnetic_on : %s\n" % str(self.magnetic_on) 402 398 rep += "model type (Category) selected: %s\n" % self.categorycombobox 403 #rep += "model type (shape independent) selected: %s\n" % self.shape_indep_rbutton404 #rep += "model type (structure factor) selected: %s\n" % self.struct_rbutton405 #rep += "model type (plug-in ) selected: %s\n" % self.plugin_rbutton406 399 rep += "data : %s\n" % str(self.data) 407 400 rep += "Plotting Range: min: %s, max: %s, steps: %s\n" % (str(self.qmin), 408 str(self.qmax), str(self.npts))401 str(self.qmax), str(self.npts)) 409 402 rep += "Dispersion selection : %s\n" % str(self.disp_box) 410 403 rep += "Smearing enable : %s\n" % str(self.enable_smearer) … … 415 408 rep += "Dispersity disable : %s\n" % str(self.disable_disp) 416 409 rep += "Slit smearer enable: %s\n" % str(self.slit_smearer) 417 410 418 411 rep += "dI_noweight : %s\n" % str(self.dI_noweight) 419 412 rep += "dI_didata : %s\n" % str(self.dI_didata) 420 413 rep += "dI_sqrdata : %s\n" % str(self.dI_sqrdata) 421 414 rep += "dI_idata : %s\n" % str(self.dI_idata) 422 415 423 416 rep += "2D enable : %s\n" % str(self.enable2D) 424 417 rep += "All parameters checkbox selected: %s\n" % (self.cb1) … … 429 422 rep += "dq_r : %s\n" % self.dq_r 430 423 rep += "dx_max : %s\n" % str(self.dx_max) 431 rep += "dx_min : %s\n" % str(self.dx_min) 424 rep += "dx_min : %s\n" % str(self.dx_min) 432 425 rep += "dxl : %s\n" % str(self.dxl) 433 rep += "dxw : %s\n" % str(self.dxw) 426 rep += "dxw : %s\n" % str(self.dxw) 434 427 rep += "model : %s\n\n" % str(self.model) 435 428 temp_parameters = [] … … 450 443 temp_parameters = self.parameters 451 444 temp_fittable_param = self.fittable_param 452 445 453 446 rep += "number parameters(self.parameters): %s\n" % len(temp_parameters) 454 447 rep = self._repr_helper(list=temp_parameters, rep=rep) … … 457 450 rep += "number fittable_param(self.fittable_param): %s\n" % len(temp_fittable_param) 458 451 rep = self._repr_helper(list=temp_fittable_param, rep=rep) 459 """460 if is_2D:461 rep += "number orientation parameters"462 rep += "(self.orientation_params): %s\n"%len(self.orientation_params)463 rep = self._repr_helper( list=self.orientation_params, rep=rep)464 rep += "number dispersity parameters"465 rep += "(self.orientation_params_disp): %s\n"%len(self.orientation_params_disp)466 rep = self._repr_helper( list=self.orientation_params_disp, rep=rep)467 """468 452 return rep 469 453 … … 481 465 paramval_string = "" 482 466 chi2_string = "" 483 multi_factor_string = ""484 467 q_range = "" 485 468 strings = self.__repr__() … … 494 477 value = content[1] 495 478 except: 496 pass479 logging.error(sys.exc_value) 497 480 if name.count("State created"): 498 481 repo_time = "" + value … … 508 491 if name == "value": 509 492 param_string += value + ',' 510 511 512 513 514 493 if name == "selected": 494 if value == u' False': 495 fixed_parameter = True 496 else: 497 fixed_parameter = False 515 498 if name == "error value": 516 517 518 499 if fixed_parameter: 500 param_string += '(fixed),' 501 else: 519 502 param_string += value + ',' 520 503 if name == "parameter unit": … … 523 506 chi2 = ("Chi2/Npts = " + value) 524 507 chi2_string = CENTRE % chi2 525 if name == "multi_factor ":526 muti_factor = ("muti_factor = " + value)527 muti_factor_string = CENTRE % muti_factor528 if name == "magentic_on ":529 magentic_on = ("magentic_on = " + value)530 if string(value) == 'True':531 magentic_on_string = CENTRE % magentic_on532 508 if name == "Title": 533 509 if len(value.strip()) == 0: … … 537 513 if name == "data ": 538 514 try: 539 file = ("File name:" + content[2])540 file_name = CENTRE % file 515 file_value = ("File name:" + content[2]) 516 file_name = CENTRE % file_value 541 517 if len(title) == 0: 542 518 title = content[2] + " [" + repo_time + "]" 543 519 title_name = HEADER % title 544 520 except: 545 pass521 logging.error(sys.exc_value) 546 522 if name == "model name ": 547 523 try: … … 550 526 modelname = "Model name:" + " NAN" 551 527 model_name = CENTRE % modelname 552 528 553 529 if name == "Plotting Range": 554 530 try: … … 558 534 q_range = CENTRE % q_name 559 535 except: 560 pass536 logging.error(sys.exc_value) 561 537 paramval = "" 562 538 for lines in param_string.split(":"): … … 572 548 paramval += param + "\n" 573 549 paramval_string += CENTRE % param + "\n" 574 550 575 551 text_string = "\n\n\n" + title + "\n\n" + file + \ 576 552 "\n" + q_name + \ 577 553 "\n" + chi2 + \ 578 554 "\n\n" + paramval 579 555 580 556 title_name = self._check_html_format(title_name) 581 557 file_name = self._check_html_format(file_name) 582 558 title = self._check_html_format(title) 583 559 584 560 html_string = title_name + "\n" + file_name + \ 585 561 "\n" + model_name + \ … … 591 567 "\n" + FEET_1 % title + \ 592 568 "\n" + FEET_2 593 569 594 570 return html_string, text_string, title 595 571 596 572 def _check_html_format(self, name): 597 573 """ … … 600 576 if name.count('%'): 601 577 name = name.replace('%', '%') 602 578 603 579 return name 604 580 605 581 def report(self, figs=None, canvases=None): 606 582 """ 607 583 Invoke report dialog panel 608 584 609 585 : param figs: list of pylab figures [list] 610 586 """ … … 638 614 dialog = ReportDialog(report_list, None, -1, "") 639 615 dialog.Show() 640 616 641 617 def _toXML_helper(self, thelist, element, newdoc): 642 618 """ … … 656 632 sub_element.setAttribute('unit', str(item[7])) 657 633 element.appendChild(sub_element) 658 634 659 635 def toXML(self, file="fitting_state.fitv", doc=None, entry_node=None): 660 636 """ 661 637 Writes the state of the InversionControl panel to file, as XML. 662 638 663 639 Compatible with standalone writing, or appending to an 664 640 already existing XML document. In that case, the XML document 665 641 is required. An optional entry node in the XML document may also be given. 666 642 667 643 :param file: file to write to 668 644 :param doc: XML document object [optional] 669 645 :param entry_node: XML node within the XML document at which we will append the data [optional] 670 646 671 647 """ 672 648 from xml.dom.minidom import getDOMImplementation … … 697 673 entry_node = node_list.item(0) 698 674 entry_node.appendChild(top_element) 699 675 700 676 attr = newdoc.createAttribute("version") 701 677 attr.nodeValue = '1.0' 702 678 top_element.setAttributeNode(attr) 703 679 704 680 # File name 705 681 element = newdoc.createElement("filename") … … 709 685 element.appendChild(newdoc.createTextNode(str(file))) 710 686 top_element.appendChild(element) 711 687 712 688 element = newdoc.createElement("timestamp") 713 689 element.appendChild(newdoc.createTextNode(time.ctime(self.timestamp))) … … 719 695 inputs = newdoc.createElement("Attributes") 720 696 top_element.appendChild(inputs) 721 697 722 698 if self.data is not None and hasattr(self.data, "group_id"): 723 699 self.data_group_id = self.data.group_id … … 728 704 if self.data is not None and hasattr(self.data, "id"): 729 705 self.data_id = self.data.id 730 731 for item in list_of_data_attributes:706 707 for item in LIST_OF_DATA_ATTRIBUTES: 732 708 element = newdoc.createElement(item[0]) 733 e xec "element.setAttribute(item[0], str(self.%s))" % (item[1])709 element.setAttribute(item[0], str(getattr(self, item[1]))) 734 710 inputs.appendChild(element) 735 736 for item in list_of_state_attributes:711 712 for item in LIST_OF_STATE_ATTRIBUTES: 737 713 element = newdoc.createElement(item[0]) 738 e xec "element.setAttribute(item[0], str(self.%s))" % (item[1])714 element.setAttribute(item[0], str(getattr(self, item[1]))) 739 715 inputs.appendChild(element) 740 716 741 717 # For self.values ={ disp_param_name: [vals,...],...} 742 718 # and for self.weights ={ disp_param_name: [weights,...],...} 743 list = {}744 for item in list_of_model_attributes:719 value_list = {} 720 for item in LIST_OF_MODEL_ATTRIBUTES: 745 721 element = newdoc.createElement(item[0]) 746 exec "list = self.%s" % item[1]747 for key, value in list.iteritems():722 value_list = getattr(self, item[1]) 723 for key, value in value_list.iteritems(): 748 724 sub_element = newdoc.createElement(key) 749 725 sub_element.setAttribute('name', str(key)) 750 726 for val in value: 751 com = "sub_element.appendChild" 752 com += "(newdoc.createTextNode(str(%s)))" 753 exec com % val 754 727 sub_element.appendChild(newdoc.createTextNode(str(val))) 728 755 729 element.appendChild(sub_element) 756 730 inputs.appendChild(element) 757 731 758 732 # Create doc for the dictionary of self._disp_obj_dic 759 for item in list_of_obj_dic:733 for item in DISPERSION_LIST: 760 734 element = newdoc.createElement(item[0]) 761 exec "list = self.%s" % item[1]762 for key, val in list.iteritems():735 value_list = getattr(self, item[1]) 736 for key, val in value_list.iteritems(): 763 737 value = repr(val) 764 738 sub_element = newdoc.createElement(key) … … 767 741 element.appendChild(sub_element) 768 742 inputs.appendChild(element) 769 770 for item in list_of_state_parameters:743 744 for item in LIST_OF_STATE_PARAMETERS: 771 745 element = newdoc.createElement(item[0]) 772 com = "self._toXML_helper(thelist=self.%s," 773 com += " element=element, newdoc=newdoc)" 774 exec com % item[1] 746 self._toXML_helper(thelist=getattr(self, item[1]), element=element, newdoc=newdoc) 775 747 inputs.appendChild(element) 776 748 777 749 # Save the file 778 750 if doc is None: … … 783 755 else: 784 756 return newdoc 785 757 786 758 def _fromXML_helper(self, node, list): 787 759 """ … … 833 805 [minimum_displayed, minimum_value], 834 806 [maximum_displayed, maximum_value], unit]) 835 807 836 808 def fromXML(self, file=None, node=None): 837 809 """ 838 810 Load fitting state from a file 839 811 840 812 :param file: .fitv file 841 813 :param node: node of a XML document to read from 842 814 843 815 """ 844 816 if file is not None: … … 846 818 msg += " format for fitting files" 847 819 raise RuntimeError, msg 848 820 849 821 if node.get('version')and node.get('version') == '1.0': 850 822 851 823 # Get file name 852 824 entry = get_content('ns:filename', node) 853 825 if entry is not None: 854 826 self.file = entry.text.strip() 855 827 856 828 # Get time stamp 857 829 entry = get_content('ns:timestamp', node) … … 863 835 msg += " read timestamp\n %s" % sys.exc_value 864 836 logging.error(msg) 865 837 866 838 # Parse fitting attributes 867 839 entry = get_content('ns:Attributes', node) 868 for item in list_of_data_attributes:840 for item in LIST_OF_DATA_ATTRIBUTES: 869 841 node = get_content('ns:%s' % item[0], entry) 870 try: 871 exec "self.%s = parse_entry_helper(node, item)" % item[0] 872 873 except: 874 raise 842 setattr(self, item[0], parse_entry_helper(node, item)) 875 843 876 844 if entry is not None: 877 878 for item in list_of_state_attributes: 845 for item in LIST_OF_STATE_ATTRIBUTES: 879 846 node = get_content('ns:%s' % item[0], entry) 880 try: 881 exec "self.%s = parse_entry_helper(node, item)" % \ 882 str(item[0]) 883 except: 884 raise 885 886 for item in list_of_state_parameters: 847 setattr(self, item[0], parse_entry_helper(node, item)) 848 849 for item in LIST_OF_STATE_PARAMETERS: 887 850 node = get_content("ns:%s" % item[0], entry) 888 exec "self._fromXML_helper(node=node, list=self.%s)" % \ 889 item[1] 890 851 self._fromXML_helper(node=node, list=getattr(self, item[1])) 852 891 853 # Recover _disp_obj_dict from xml file 892 854 self._disp_obj_dict = {} 893 disp_model = None 894 for item in list_of_obj_dic: 855 for item in DISPERSION_LIST: 895 856 # Get node 896 857 node = get_content("ns:%s" % item[0], entry) 897 858 for attr in node: 898 name = attr.get('name')859 name = str(attr.get('name')) 899 860 val = attr.get('value') 900 861 value = val.split(" instance")[0] … … 907 868 exec com % com_name 908 869 disp_model = disp() 909 exec "self.%s['%s'] = com_name" % (item[1], name) 870 attribute = getattr(self, item[1]) 871 attribute[name] = com_name 910 872 except: 911 pass912 873 logging.error(sys.exc_value) 874 913 875 # get self.values and self.weights dic. if exists 914 for item in list_of_model_attributes:876 for item in LIST_OF_MODEL_ATTRIBUTES: 915 877 node = get_content("ns:%s" % item[0], entry) 916 878 dic = {} 917 list = []879 value_list = [] 918 880 for par in node: 919 881 name = par.get('name') … … 923 885 try: 924 886 val = float(line) 925 list.append(val)887 value_list.append(val) 926 888 except: 927 889 # pass if line is empty (it happens) 928 pass929 dic[name] = numpy.array( list)930 exec "self.%s = dic" % item[1]931 890 logging.error(sys.exc_value) 891 dic[name] = numpy.array(value_list) 892 setattr(self, item[1], dic) 893 932 894 def set_plot_state(self, figs, canvases): 933 895 """ … … 943 905 self.imgRAM = None 944 906 wx.MemoryFSHandler() 945 907 946 908 # For no figures in the list, prepare empty plot 947 909 if figs == None or len(figs) == 0: 948 910 figs = [None] 949 911 950 912 # Loop over the list of figures 951 913 # use wx.MemoryFSHandler … … 955 917 ind = figs.index(fig) 956 918 canvas = canvases[ind] 957 958 #store the image in wx.FileSystem Object 919 920 #store the image in wx.FileSystem Object 959 921 wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 960 922 961 923 # index of the fig 962 924 ind = figs.index(fig) 963 925 964 926 #AddFile, image can be retrieved with 'memory:filename' 965 927 self.imgRAM.AddFile('img_fit%s.png' % ind, 966 928 canvas.bitmap, wx.BITMAP_TYPE_PNG) 967 929 968 930 #append figs 969 931 images.append(fig) 970 932 971 933 return images 972 934 … … 978 940 ## File type 979 941 type_name = "Fitting" 980 942 981 943 ## Wildcards 982 944 type = ["Fitting files (*.fitv)|*.fitv" … … 984 946 ## List of allowed extensions 985 947 ext = ['.fitv', '.FITV', '.svs', 'SVS'] 986 948 987 949 def __init__(self, call_back=None, cansas=True): 988 950 CansasReader.__init__(self) … … 990 952 Initialize the call-back method to be called 991 953 after we load a file 992 954 993 955 :param call_back: call-back method 994 956 :param cansas: True = files will be written/read in CanSAS format 995 957 False = write CanSAS format 996 958 997 959 """ 998 960 ## Call back method to be executed after a file is read … … 1001 963 self.cansas = cansas 1002 964 self.state = None 1003 965 1004 966 def get_state(self): 1005 967 return self.state 1006 968 1007 969 def read(self, path): 1008 970 """ 1009 971 Load a new P(r) inversion state from file 1010 972 1011 973 :param path: file path 1012 974 1013 975 """ 1014 976 if self.cansas == True: 1015 977 return self._read_cansas(path) 1016 978 1017 979 def _data2d_to_xml_doc(self, datainfo): 1018 980 """ 1019 981 Create an XML document to contain the content of a Data2D 1020 982 1021 983 :param datainfo: Data2D object 1022 984 1023 985 """ 1024 986 if not issubclass(datainfo.__class__, Data2D): 1025 987 raise RuntimeError, "The cansas writer expects a Data2D instance" 1026 988 1027 989 doc = xml.dom.minidom.Document() 1028 990 main_node = doc.createElement("SASroot") … … 1030 992 main_node.setAttribute("xmlns", "cansas1d/%s" % self.version) 1031 993 main_node.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") 1032 main_node.setAttribute("xsi:schemaLocation", "cansas1d/%s http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd" % self.version) 1033 994 main_node.setAttribute("xsi:schemaLocation", 995 "cansas1d/%s http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd" % self.version) 996 1034 997 doc.appendChild(main_node) 1035 998 1036 999 entry_node = doc.createElement("SASentry") 1037 1000 main_node.appendChild(entry_node) 1038 1001 1039 1002 write_node(doc, entry_node, "Title", datainfo.title) 1040 1003 if datainfo is not None: … … 1042 1005 for item in datainfo.run: 1043 1006 runname = {} 1044 if datainfo.run_name.has_key(item) and len(str(datainfo.run_name[item])) >1:1045 runname = {'name': datainfo.run_name[item] 1007 if datainfo.run_name.has_key(item) and len(str(datainfo.run_name[item])) > 1: 1008 runname = {'name': datainfo.run_name[item]} 1046 1009 write_node(doc, entry_node, "Run", item, runname) 1047 1010 # Data info 1048 1011 new_node = doc.createElement("SASdata") 1049 1012 entry_node.appendChild(new_node) 1050 for item in list_of_data_2d_attr:1013 for item in LIST_OF_DATA_2D_ATTR: 1051 1014 element = doc.createElement(item[0]) 1052 e xec "element.setAttribute(item[0], str(datainfo.%s))" % (item[1])1015 element.setAttribute(item[0], str(getattr(datainfo, item[1]))) 1053 1016 new_node.appendChild(element) 1054 1055 for item in list_of_data2d_values:1017 1018 for item in LIST_OF_DATA_2D_VALUES: 1056 1019 root_node = doc.createElement(item[0]) 1057 1020 new_node.appendChild(root_node) 1058 1021 temp_list = None 1059 exec "temp_list = datainfo.%s" % item[1]1060 1061 if temp_list is None or len(temp_list) == 0:1022 temp_list = getattr(datainfo, item[1]) 1023 1024 if temp_list is None or len(temp_list) == 0: 1062 1025 element = doc.createElement(item[0]) 1063 e xec "element.appendChild(doc.createTextNode(str(%s)))" % temp_list1026 element.appendChild(doc.createTextNode(str(temp_list))) 1064 1027 root_node.appendChild(element) 1065 1028 else: 1066 1029 for value in temp_list: 1067 1030 element = doc.createElement(item[0]) 1068 e xec "element.setAttribute(item[0], str(%s))" % value1031 element.setAttribute(item[0], str(value)) 1069 1032 root_node.appendChild(element) 1070 1033 1071 1034 # Sample info 1072 1035 sample = doc.createElement("SASsample") … … 1080 1043 write_node(doc, sample, "temperature", datainfo.sample.temperature, 1081 1044 {"unit": datainfo.sample.temperature_unit}) 1082 1045 1083 1046 for item in datainfo.sample.details: 1084 1047 write_node(doc, sample, "details", item) 1085 1048 1086 1049 pos = doc.createElement("position") 1087 1050 written = write_node(doc, pos, "x", datainfo.sample.position.x, … … 1095 1058 if written == True: 1096 1059 sample.appendChild(pos) 1097 1060 1098 1061 ori = doc.createElement("orientation") 1099 1062 written = write_node(doc, ori, "roll", datainfo.sample.orientation.x, … … 1107 1070 if written == True: 1108 1071 sample.appendChild(ori) 1109 1072 1110 1073 # Instrument info 1111 1074 instr = doc.createElement("SASinstrument") 1112 1075 entry_node.appendChild(instr) 1113 1076 1114 1077 write_node(doc, instr, "name", datainfo.instrument) 1115 1078 1116 1079 # Source 1117 1080 source = doc.createElement("SASsource") … … 1119 1082 source.setAttribute("name", str(datainfo.source.name)) 1120 1083 instr.appendChild(source) 1121 1084 1122 1085 write_node(doc, source, "radiation", datainfo.source.radiation) 1123 1086 write_node(doc, source, "beam_shape", datainfo.source.beam_shape) … … 1135 1098 if written == True: 1136 1099 source.appendChild(size) 1137 1100 1138 1101 write_node(doc, source, "wavelength", datainfo.source.wavelength, 1139 1102 {"unit": datainfo.source.wavelength_unit}) … … 1147 1110 datainfo.source.wavelength_spread, 1148 1111 {"unit": datainfo.source.wavelength_spread_unit}) 1149 1112 1150 1113 # Collimation 1151 1114 for item in datainfo.collimation: … … 1154 1117 coll.setAttribute("name", str(item.name)) 1155 1118 instr.appendChild(coll) 1156 1119 1157 1120 write_node(doc, coll, "length", item.length, 1158 1121 {"unit": item.length_unit}) 1159 1122 1160 1123 for apert in item.aperture: 1161 1124 ap = doc.createElement("aperture") … … 1165 1128 ap.setAttribute("type", str(apert.type)) 1166 1129 coll.appendChild(ap) 1167 1130 1168 1131 write_node(doc, ap, "distance", apert.distance, 1169 1132 {"unit": apert.distance_unit}) 1170 1133 1171 1134 size = doc.createElement("size") 1172 1135 if apert.size_name is not None: … … 1192 1155 if written == True: 1193 1156 instr.appendChild(det) 1194 1157 1195 1158 off = doc.createElement("offset") 1196 1159 written = write_node(doc, off, "x", item.offset.x, … … 1202 1165 if written == True: 1203 1166 det.appendChild(off) 1204 1167 1205 1168 center = doc.createElement("beam_center") 1206 1169 written = write_node(doc, center, "x", item.beam_center.x, … … 1214 1177 if written == True: 1215 1178 det.appendChild(center) 1216 1179 1217 1180 pix = doc.createElement("pixel_size") 1218 1181 written = write_node(doc, pix, "x", item.pixel_size.x, … … 1224 1187 if written == True: 1225 1188 det.appendChild(pix) 1226 1189 1227 1190 ori = doc.createElement("orientation") 1228 1191 written = write_node(doc, ori, "roll", item.orientation.x, … … 1235 1198 if written == True: 1236 1199 det.appendChild(ori) 1237 1200 1238 1201 # Processes info 1239 1202 for item in datainfo.process: … … 1253 1216 # the data we just wrote 1254 1217 return doc, entry_node 1255 1218 1256 1219 def _parse_state(self, entry): 1257 1220 """ 1258 1221 Read a fit result from an XML node 1259 1222 1260 1223 :param entry: XML node to read from 1261 1224 1262 1225 :return: PageState object 1263 1226 """ 1264 1227 # Create an empty state 1265 state = None 1228 state = None 1266 1229 # Locate the P(r) node 1267 1230 try: … … 1272 1235 state = PageState() 1273 1236 state.fromXML(node=nodes[0]) 1274 1237 1275 1238 except: 1276 1239 logging.info("XML document does not contain fitting information.\n %s" % sys.exc_value) 1277 1240 1278 1241 return state 1279 1242 1280 1243 def _parse_save_state_entry(self, dom): 1281 1244 """ 1282 1245 Parse a SASentry 1283 1246 1284 1247 :param node: SASentry node 1285 1248 1286 1249 :return: Data1D/Data2D object 1287 1250 1288 1251 """ 1289 1252 node = dom.xpath('ns:data_class', namespaces={'ns': CANSAS_NS}) … … 1305 1268 numpy.trim_zeros(return_value.dxl) 1306 1269 numpy.trim_zeros(return_value.dxw) 1307 1270 1308 1271 return return_value, _ 1309 1272 1310 1273 #Parse 2D 1311 1274 data_info = Data2D() 1312 1275 1313 1276 # Look up title 1314 1277 self._store_content('ns:Title', dom, 'title', data_info) 1315 1278 1316 1279 # Look up run number 1317 1280 nodes = dom.xpath('ns:Run', namespaces={'ns': CANSAS_NS}) … … 1323 1286 if item.get('name') is not None: 1324 1287 data_info.run_name[value] = item.get('name') 1325 1288 1326 1289 # Look up instrument name 1327 1290 self._store_content('ns:SASinstrument/ns:name', dom, … … 1340 1303 self.errors.append(err_mess) 1341 1304 logging.error(err_mess) 1342 1305 1343 1306 # Sample info ################### 1344 1307 entry = get_content('ns:SASsample', dom) 1345 1308 if entry is not None: 1346 1309 data_info.sample.name = entry.get('name') 1347 1348 self._store_content('ns:SASsample/ns:ID', 1349 dom, 'ID', data_info.sample) 1350 self._store_float('ns:SASsample/ns:thickness', 1351 dom, 'thickness', data_info.sample) 1352 self._store_float('ns:SASsample/ns:transmission', 1353 dom, 'transmission', data_info.sample) 1354 self._store_float('ns:SASsample/ns:temperature', 1355 dom, 'temperature', data_info.sample) 1356 1357 nodes = dom.xpath('ns:SASsample/ns:details', 1358 namespaces={'ns': CANSAS_NS}) 1310 1311 self._store_content('ns:SASsample/ns:ID', dom, 'ID', data_info.sample) 1312 self._store_float('ns:SASsample/ns:thickness', dom, 'thickness', data_info.sample) 1313 self._store_float('ns:SASsample/ns:transmission', dom, 'transmission', data_info.sample) 1314 self._store_float('ns:SASsample/ns:temperature', dom, 'temperature', data_info.sample) 1315 1316 nodes = dom.xpath('ns:SASsample/ns:details', namespaces={'ns': CANSAS_NS}) 1359 1317 for item in nodes: 1360 1318 try: … … 1367 1325 self.errors.append(err_mess) 1368 1326 logging.error(err_mess) 1369 1327 1370 1328 # Position (as a vector) 1371 self._store_float('ns:SASsample/ns:position/ns:x', 1372 dom, 'position.x', data_info.sample) 1373 self._store_float('ns:SASsample/ns:position/ns:y', 1374 dom, 'position.y', data_info.sample) 1375 self._store_float('ns:SASsample/ns:position/ns:z', 1376 dom, 'position.z', data_info.sample) 1377 1329 self._store_float('ns:SASsample/ns:position/ns:x', dom, 'position.x', data_info.sample) 1330 self._store_float('ns:SASsample/ns:position/ns:y', dom, 'position.y', data_info.sample) 1331 self._store_float('ns:SASsample/ns:position/ns:z', dom, 'position.z', data_info.sample) 1332 1378 1333 # Orientation (as a vector) 1379 1334 self._store_float('ns:SASsample/ns:orientation/ns:roll', 1380 dom, 'orientation.x', data_info.sample)1335 dom, 'orientation.x', data_info.sample) 1381 1336 self._store_float('ns:SASsample/ns:orientation/ns:pitch', 1382 dom, 'orientation.y', data_info.sample)1337 dom, 'orientation.y', data_info.sample) 1383 1338 self._store_float('ns:SASsample/ns:orientation/ns:yaw', 1384 dom, 'orientation.z', data_info.sample)1385 1339 dom, 'orientation.z', data_info.sample) 1340 1386 1341 # Source info ################### 1387 1342 entry = get_content('ns:SASinstrument/ns:SASsource', dom) 1388 1343 if entry is not None: 1389 1344 data_info.source.name = entry.get('name') 1390 1345 1391 1346 self._store_content('ns:SASinstrument/ns:SASsource/ns:radiation', 1392 dom, 'radiation', data_info.source)1347 dom, 'radiation', data_info.source) 1393 1348 self._store_content('ns:SASinstrument/ns:SASsource/ns:beam_shape', 1394 dom, 'beam_shape', data_info.source)1349 dom, 'beam_shape', data_info.source) 1395 1350 self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength', 1396 dom, 'wavelength', data_info.source)1351 dom, 'wavelength', data_info.source) 1397 1352 self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_min', 1398 dom, 'wavelength_min', data_info.source)1353 dom, 'wavelength_min', data_info.source) 1399 1354 self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_max', 1400 dom, 'wavelength_max', data_info.source)1355 dom, 'wavelength_max', data_info.source) 1401 1356 self._store_float('ns:SASinstrument/ns:SASsource/ns:wavelength_spread', 1402 dom, 'wavelength_spread', data_info.source)1403 1357 dom, 'wavelength_spread', data_info.source) 1358 1404 1359 # Beam size (as a vector) 1405 1360 entry = get_content('ns:SASinstrument/ns:SASsource/ns:beam_size', dom) 1406 1361 if entry is not None: 1407 1362 data_info.source.beam_size_name = entry.get('name') 1408 1363 1409 1364 self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:x', 1410 dom, 'beam_size.x', data_info.source)1365 dom, 'beam_size.x', data_info.source) 1411 1366 self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:y', 1412 dom, 'beam_size.y', data_info.source)1367 dom, 'beam_size.y', data_info.source) 1413 1368 self._store_float('ns:SASinstrument/ns:SASsource/ns:beam_size/ns:z', 1414 dom, 'beam_size.z', data_info.source)1415 1369 dom, 'beam_size.z', data_info.source) 1370 1416 1371 # Collimation info ################### 1417 1372 nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', … … 1422 1377 collim.name = item.get('name') 1423 1378 self._store_float('ns:length', item, 'length', collim) 1424 1379 1425 1380 # Look for apertures 1426 1381 apert_list = item.xpath('ns:aperture', … … 1428 1383 for apert in apert_list: 1429 1384 aperture = Aperture() 1430 1385 1431 1386 # Get the name and type of the aperture 1432 1387 aperture.name = apert.get('name') 1433 1388 aperture.type = apert.get('type') 1434 1389 1435 1390 self._store_float('ns:distance', apert, 'distance', aperture) 1436 1391 1437 1392 entry = get_content('ns:size', apert) 1438 1393 if entry is not None: 1439 1394 aperture.size_name = entry.get('name') 1440 1395 1441 1396 self._store_float('ns:size/ns:x', apert, 'size.x', aperture) 1442 1397 self._store_float('ns:size/ns:y', apert, 'size.y', aperture) 1443 1398 self._store_float('ns:size/ns:z', apert, 'size.z', aperture) 1444 1399 1445 1400 collim.aperture.append(aperture) 1446 1401 1447 1402 data_info.collimation.append(collim) 1448 1403 1449 1404 # Detector info ###################### 1450 1405 nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', 1451 1406 namespaces={'ns': CANSAS_NS}) 1452 1407 for item in nodes: 1453 1408 1454 1409 detector = Detector() 1455 1410 1456 1411 self._store_content('ns:name', item, 'name', detector) 1457 1412 self._store_float('ns:SDD', item, 'distance', detector) 1458 1413 1459 1414 # Detector offset (as a vector) 1460 1415 self._store_float('ns:offset/ns:x', item, 'offset.x', detector) 1461 1416 self._store_float('ns:offset/ns:y', item, 'offset.y', detector) 1462 1417 self._store_float('ns:offset/ns:z', item, 'offset.z', detector) 1463 1418 1464 1419 # Detector orientation (as a vector) 1465 1420 self._store_float('ns:orientation/ns:roll', item, … … 1469 1424 self._store_float('ns:orientation/ns:yaw', item, 1470 1425 'orientation.z', detector) 1471 1426 1472 1427 # Beam center (as a vector) 1473 1428 self._store_float('ns:beam_center/ns:x', item, … … 1477 1432 self._store_float('ns:beam_center/ns:z', item, 1478 1433 'beam_center.z', detector) 1479 1434 1480 1435 # Pixel size (as a vector) 1481 1436 self._store_float('ns:pixel_size/ns:x', item, … … 1485 1440 self._store_float('ns:pixel_size/ns:z', item, 1486 1441 'pixel_size.z', detector) 1487 1442 1488 1443 self._store_float('ns:slit_length', item, 'slit_length', detector) 1489 1444 1490 1445 data_info.detector.append(detector) 1491 1446 … … 1497 1452 self._store_content('ns:date', item, 'date', process) 1498 1453 self._store_content('ns:description', item, 'description', process) 1499 1454 1500 1455 term_list = item.xpath('ns:term', namespaces={'ns': CANSAS_NS}) 1501 1456 for term in term_list: … … 1511 1466 self.errors.append(err_mess) 1512 1467 logging.error(err_mess) 1513 1468 1514 1469 note_list = item.xpath('ns:SASprocessnote', 1515 1470 namespaces={'ns': CANSAS_NS}) … … 1517 1472 if note.text is not None: 1518 1473 process.notes.append(note.text.strip()) 1519 1474 1520 1475 data_info.process.append(process) 1521 1476 1522 1477 # Data info ###################### 1523 1478 nodes = dom.xpath('ns:SASdata', namespaces={'ns': CANSAS_NS}) 1524 1479 if len(nodes) > 1: 1525 1480 raise RuntimeError, "CanSAS reader is not compatible with multiple SASdata entries" 1526 1481 1527 1482 for entry in nodes: 1528 for item in list_of_data_2d_attr:1483 for item in LIST_OF_DATA_2D_ATTR: 1529 1484 #get node 1530 1485 node = get_content('ns:%s' % item[0], entry) 1531 exec "data_info.%s = parse_entry_helper(node, item)" % item[1]1532 1533 for item in list_of_data2d_values:1486 setattr(data_info, item[1], parse_entry_helper(node, item)) 1487 1488 for item in LIST_OF_DATA_2D_VALUES: 1534 1489 field = get_content('ns:%s' % item[0], entry) 1535 list = []1490 value_list = [] 1536 1491 if field is not None: 1537 list = [parse_entry_helper(node, item) for node in field]1538 if len( list) < 2:1539 exec "data_info.%s = None" % item[0]1492 value_list = [parse_entry_helper(node, item) for node in field] 1493 if len(value_list) < 2: 1494 setattr(data_info, item[0], None) 1540 1495 else: 1541 exec "data_info.%s = numpy.array(list)" % item[0]1542 1496 setattr(data_info, item[0], numpy.array(value_list)) 1497 1543 1498 return data_info 1544 1499 … … 1546 1501 """ 1547 1502 Load data and P(r) information from a CanSAS XML file. 1548 1503 1549 1504 :param path: file path 1550 1505 1551 1506 :return: Data1D object if a single SASentry was found, 1552 1507 or a list of Data1D objects if multiple entries were found, 1553 1508 or None of nothing was found 1554 1509 1555 1510 :raise RuntimeError: when the file can't be opened 1556 1511 :raise ValueError: when the length of the data vectors are inconsistent 1557 1512 1558 1513 """ 1559 1514 output = [] … … 1563 1518 try: 1564 1519 if os.path.isfile(path): 1565 1520 1566 1521 #TODO: eventually remove the check for .xml once 1567 1522 # the P(r) writer/reader is truly complete. 1568 1523 if ext in self.ext or \ 1569 1524 ext == '.xml': 1570 1525 1571 1526 tree = etree.parse(path, parser=etree.ETCompatXMLParser()) 1572 1527 # Check the format version number … … 1581 1536 raise 1582 1537 fitstate = self._parse_state(entry) 1583 1538 1584 1539 #state could be None when .svs file is loaded 1585 1540 #in this case, skip appending to output … … 1608 1563 original_fname = state.file[0:max_char] 1609 1564 state.file = original_fname + ' [' + time_str + ']' 1610 1565 1611 1566 if state is not None and state.is_data is not None: 1612 exec 'output[%d].is_data = state.is_data' % ind1613 1567 output[ind].is_data = state.is_data 1568 1614 1569 output[ind].filename = state.file 1615 1570 state.data = output[ind] … … 1629 1584 self.state = state 1630 1585 return output 1631 1632 1586 except: 1633 1587 self.call_back(format=ext) 1634 #self.state= state1635 1588 raise 1636 1589 1637 1590 def write(self, filename, datainfo=None, fitstate=None): 1638 1591 """ 1639 1592 Write the content of a Data1D as a CanSAS XML file only for standalone 1640 1593 1641 1594 :param filename: name of the file to write 1642 1595 :param datainfo: Data1D object 1643 1596 :param fitstate: PageState object 1644 1597 1645 1598 """ 1646 1599 # Sanity check … … 1651 1604 else: 1652 1605 doc = fitstate.toXML(file=filename) 1653 1606 1654 1607 # Save the document no matter the type 1655 1608 fd = open(filename, 'w') 1656 1609 fd.write(doc.toprettyxml()) 1657 1610 fd.close() 1658 1611 1659 1612 def write_toXML(self, datainfo=None, state=None): 1660 1613 """ 1661 1614 Write toXML, a helper for write(), 1662 1615 could be used by guimanager._on_save() 1663 1616 1664 1617 : return: xml doc 1665 1618 """ … … 1677 1630 state.data.run = [str(state.data.name)] 1678 1631 state.data.run_name[0] = state.data.name 1679 1632 1680 1633 if issubclass(state.data.__class__, 1681 1634 sas.dataloader.data_info.Data1D): … … 1685 1638 data = state.data 1686 1639 doc, sasentry = self._data2d_to_xml_doc(data) 1687 1640 1688 1641 if state is not None: 1689 1642 doc = state.toXML(doc=doc, file=data.filename, entry_node=sasentry) 1690 1643 1691 1644 return doc 1692 1645 1693 1646 # Simple html report templet 1694 1647 HEADER = "<html>\n" … … 1736 1689 #state.toXML() 1737 1690 """ 1738 1691 1739 1692 file = open("test_state", "w") 1740 1693 pickle.dump(state, file) … … 1769 1722 db.keys().sort() 1770 1723 print pickle.loads(db['state2']) 1771 1724 1772 1725 db.close()
Note: See TracChangeset
for help on using the changeset viewer.