Changeset 882cfec in sasview for src/sas/sascalc/dataloader
- Timestamp:
- Nov 28, 2017 7:56:33 AM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b6b81a3, 19b5c886, fb7c816, 814ee32
- Parents:
- 45bfe3f1 (diff), c926a97 (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. - git-author:
- Paul Kienzle <pkienzle@…> (11/28/17 07:56:33)
- git-committer:
- GitHub <noreply@…> (11/28/17 07:56:33)
- Location:
- src/sas/sascalc/dataloader
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/file_reader_base_class.py
r9e6aeaf r20fa5fe 85 85 86 86 # Return a list of parsed entries that data_loader can manage 87 return self.output 87 final_data = self.output 88 self.reset_state() 89 return final_data 90 91 def reset_state(self): 92 """ 93 Resets the class state to a base case when loading a new data file so previous 94 data files do not appear a second time 95 """ 96 self.current_datainfo = None 97 self.current_dataset = None 98 self.output = [] 88 99 89 100 def nextline(self): … … 112 123 """ 113 124 Generic error handler to add an error to the current datainfo to 114 prop ogate the error up the error chain.125 propagate the error up the error chain. 115 126 :param msg: Error message 116 127 """ … … 314 325 def splitline(line): 315 326 """ 316 Splits a line into pieces based on common delim eters327 Splits a line into pieces based on common delimiters 317 328 :param line: A single line of text 318 329 :return: list of values -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r2b538cd r2469df7 68 68 data files do not appear a second time 69 69 """ 70 self.current_datainfo = None 71 self.current_dataset = None 72 self.current_data1d = None 70 super(Reader, self).reset_state() 73 71 self.data = [] 74 72 self.process = Process() … … 79 77 self.names = [] 80 78 self.cansas_defaults = {} 81 self.output = []82 79 self.ns_list = None 83 80 self.logging = [] … … 85 82 86 83 def read(self, xml_file, schema_path="", invalid=True): 87 if schema_path != "" or invalid != True:84 if schema_path != "" or not invalid: 88 85 # read has been called from self.get_file_contents because xml file doens't conform to schema 89 86 _, self.extension = os.path.splitext(os.path.basename(xml_file)) … … 945 942 pos, "z", datainfo.sample.position.z, 946 943 {"unit": datainfo.sample.position_unit}) 947 if written == True:944 if written: 948 945 self.append(pos, sample) 949 946 … … 958 955 ori, "yaw", datainfo.sample.orientation.z, 959 956 {"unit": datainfo.sample.orientation_unit}) 960 if written == True:957 if written: 961 958 self.append(ori, sample) 962 959 … … 1005 1002 size, "z", datainfo.source.beam_size.z, 1006 1003 {"unit": datainfo.source.beam_size_unit}) 1007 if written == True:1004 if written: 1008 1005 self.append(size, source) 1009 1006 … … 1061 1058 size, "z", aperture.size.z, 1062 1059 {"unit": aperture.size_unit}) 1063 if written == True:1060 if written: 1064 1061 self.append(size, apert) 1065 1062 … … 1084 1081 written = written | self.write_node(det, "SDD", item.distance, 1085 1082 {"unit": item.distance_unit}) 1086 if written == True:1083 if written: 1087 1084 self.append(det, instr) 1088 1085 … … 1094 1091 written = written | self.write_node(off, "z", item.offset.z, 1095 1092 {"unit": item.offset_unit}) 1096 if written == True:1093 if written: 1097 1094 self.append(off, det) 1098 1095 … … 1106 1103 item.orientation.z, 1107 1104 {"unit": item.orientation_unit}) 1108 if written == True:1105 if written: 1109 1106 self.append(ori, det) 1110 1107 … … 1118 1115 item.beam_center.z, 1119 1116 {"unit": item.beam_center_unit}) 1120 if written == True:1117 if written: 1121 1118 self.append(center, det) 1122 1119 … … 1128 1125 written = written | self.write_node(pix, "z", item.pixel_size.z, 1129 1126 {"unit": item.pixel_size_unit}) 1130 if written == True:1127 if written: 1131 1128 self.append(pix, det) 1132 1129 self.write_node(det, "slit_length", item.slit_length, -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r2b538cd r61f329f0 65 65 """ 66 66 # Reinitialize when loading a new data file to reset all class variables 67 self.reset_ class_variables()67 self.reset_state() 68 68 69 69 filename = self.f_open.name … … 101 101 raise FileContentsException("Fewer than 5 data points found.") 102 102 103 def reset_ class_variables(self):103 def reset_state(self): 104 104 """ 105 105 Create the reader object and define initial states for class variables 106 106 """ 107 self.current_datainfo = None 108 self.current_dataset = None 107 super(Reader, self).reset_state() 109 108 self.data1d = [] 110 109 self.data2d = [] … … 112 111 self.errors = set() 113 112 self.logging = [] 114 self.output = []115 113 self.parent_class = u'' 116 114 self.detector = Detector() -
src/sas/sascalc/dataloader/readers/danse_reader.py
raf3e9f5 r2469df7 157 157 # Store all data 158 158 # Store wavelength 159 if has_converter == Trueand self.current_datainfo.source.wavelength_unit != 'A':159 if has_converter and self.current_datainfo.source.wavelength_unit != 'A': 160 160 conv = Converter('A') 161 161 wavelength = conv(wavelength, … … 164 164 165 165 # Store distance 166 if has_converter == Trueand detector.distance_unit != 'm':166 if has_converter and detector.distance_unit != 'm': 167 167 conv = Converter('m') 168 168 distance = conv(distance, units=detector.distance_unit) … … 170 170 171 171 # Store pixel size 172 if has_converter == Trueand detector.pixel_size_unit != 'mm':172 if has_converter and detector.pixel_size_unit != 'mm': 173 173 conv = Converter('mm') 174 174 pixel = conv(pixel, units=detector.pixel_size_unit)
Note: See TracChangeset
for help on using the changeset viewer.