Ignore:
Timestamp:
Aug 19, 2016 7:21:28 AM (8 years ago)
Author:
lewis
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
c476457
Parents:
d3e1870 (diff), 4abcc93a (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.
Message:

Merge branch 'master' into file-converter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r7f71637 rfdd3ba1  
    206206        # Go through each child in the parent element 
    207207        for node in dom: 
     208            attr = node.attrib 
     209            name = attr.get("name", "") 
     210            type = attr.get("type", "") 
    208211            # Get the element name and set the current names level 
    209212            tagname = node.tag.replace(self.base_ns, "") 
     
    223226                ## Recursion step to access data within the group 
    224227                self._parse_entry(node) 
     228                if tagname == "SASsample": 
     229                    self.current_datainfo.sample.name = name 
     230                elif tagname == "beam_size": 
     231                    self.current_datainfo.source.beam_size_name = name 
     232                elif tagname == "SAScollimation": 
     233                    self.collimation.name = name 
     234                elif tagname == "aperture": 
     235                    self.aperture.name = name 
     236                    self.aperture.type = type 
    225237                self.add_intermediate() 
    226238            else: 
     
    229241                ## If this is a dataset, store the data appropriately 
    230242                if tagname == 'Run': 
     243                    self.current_datainfo.run_name[data_point] = name 
    231244                    self.current_datainfo.run.append(data_point) 
    232245                elif tagname == 'Title': 
     
    369382                    self.process.notes.append(data_point) 
    370383                elif tagname == 'term' and self.parent_class == 'SASprocess': 
    371                     self.process.term.append(data_point) 
     384                    unit = attr.get("unit", "") 
     385                    dic = {} 
     386                    dic["name"] = name 
     387                    dic["value"] = data_point 
     388                    dic["unit"] = unit 
     389                    self.process.term.append(dic) 
    372390 
    373391                ## Transmission Spectrum 
     
    531549            self.current_datainfo.collimation.append(self.collimation) 
    532550            self.collimation = Collimation() 
    533         elif self.parent_class == 'SASaperture': 
     551        elif self.parent_class == 'aperture': 
    534552            self.collimation.aperture.append(self.aperture) 
    535553            self.aperture = Aperture() 
     
    646664        err_msg = None 
    647665        default_unit = None 
    648         if 'unit' in attr and attr.get('unit') is not None and not self.ns_list.ns_optional: 
     666        if not isinstance(node_value, float): 
     667            node_value = float(node_value) 
     668        if 'unit' in attr and attr.get('unit') is not None: 
    649669            try: 
    650670                local_unit = attr['unit'] 
    651                 if not isinstance(node_value, float): 
    652                     node_value = float(node_value) 
    653671                unitname = self.ns_list.current_level.get("unit", "") 
    654672                if "SASdetector" in self.names: 
     
    907925                self.write_node(point, "I", datainfo.y[i], 
    908926                                {'unit': datainfo.y_unit}) 
    909             if datainfo.dy != None and len(datainfo.dy) > i: 
     927            if datainfo.dy is not None and len(datainfo.dy) > i: 
    910928                self.write_node(point, "Idev", datainfo.dy[i], 
    911929                                {'unit': datainfo.y_unit}) 
    912             if datainfo.dx != None and len(datainfo.dx) > i: 
     930            if datainfo.dx is not None and len(datainfo.dx) > i: 
    913931                self.write_node(point, "Qdev", datainfo.dx[i], 
    914932                                {'unit': datainfo.x_unit}) 
    915             if datainfo.dxw != None and len(datainfo.dxw) > i: 
     933            if datainfo.dxw is not None and len(datainfo.dxw) > i: 
    916934                self.write_node(point, "dQw", datainfo.dxw[i], 
    917935                                {'unit': datainfo.x_unit}) 
    918             if datainfo.dxl != None and len(datainfo.dxl) > i: 
     936            if datainfo.dxl is not None and len(datainfo.dxl) > i: 
    919937                self.write_node(point, "dQl", datainfo.dxl[i], 
    920938                                {'unit': datainfo.x_unit}) 
     
    11841202                if isinstance(term, list): 
    11851203                    value = term['value'] 
     1204                    del term['value'] 
     1205                elif isinstance(term, dict): 
     1206                    value = term.get("value") 
    11861207                    del term['value'] 
    11871208                else: 
Note: See TracChangeset for help on using the changeset viewer.