Changes in / [356af60e:9a0fc50] in sasview
- Files:
-
- 10 added
- 12 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/nxsunit.py
r574adc7 rb011ecb 136 136 sld = { '10^-6 Angstrom^-2': 1e-6, 'Angstrom^-2': 1 } 137 137 Q = { 'invA': 1, 'invAng': 1, 'invAngstroms': 1, '1/A': 1, 138 '1/Angstrom': 1, '1/angstrom': 1, 'A^{-1}': 1, 'cm^{-1}': 1e-8, 138 139 '10^-3 Angstrom^-1': 1e-3, '1/cm': 1e-8, '1/m': 1e-10, 139 'nm^ -1': 0.1, '1/nm': 0.1, 'n_m^-1': 0.1 }140 'nm^{-1}': 1, 'nm^-1': 0.1, '1/nm': 0.1, 'n_m^-1': 0.1 } 140 141 141 142 _caret_optional(sld) … … 157 158 # units for that particular dimension. 158 159 # Note: don't have support for dimensionless units. 159 unknown = {None:1, '???':1, '': 1, 'a.u.': 1 }160 unknown = {None:1, '???':1, '': 1, 'a.u.': 1, 'Counts': 1, 'counts': 1} 160 161 161 162 def __init__(self, name): -
src/sas/sascalc/dataloader/data_info.py
rdeaa0c6 r4fdcc65 954 954 _str += "Data:\n" 955 955 _str += " Type: %s\n" % self.__class__.__name__ 956 _str += " X- & Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 956 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit) 957 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 957 958 _str += " Z-axis: %s\t[%s]\n" % (self._zaxis, self._zunit) 958 959 _str += " Length: %g \n" % (len(self.data)) … … 983 984 qx_data=qx_data, qy_data=qy_data, 984 985 q_data=q_data, mask=mask) 986 987 clone._xaxis = self._xaxis 988 clone._yaxis = self._yaxis 989 clone._zaxis = self._zaxis 990 clone._xunit = self._xunit 991 clone._yunit = self._yunit 992 clone._zunit = self._zunit 993 clone.x_bins = self.x_bins 994 clone.y_bins = self.y_bins 985 995 986 996 clone.title = self.title … … 1153 1163 def combine_data_info_with_plottable(data, datainfo): 1154 1164 """ 1155 A function that combines the DataInfo data in self.current_datainto with a plottable_1D or 2D data object. 1165 A function that combines the DataInfo data in self.current_datainto with a 1166 plottable_1D or 2D data object. 1156 1167 1157 1168 :param data: A plottable_1D or plottable_2D data object … … 1171 1182 final_dataset.yaxis(data._yaxis, data._yunit) 1172 1183 elif isinstance(data, plottable_2D): 1173 final_dataset = Data2D(data.data, data.err_data, data.qx_data, data.qy_data, data.q_data, 1174 data.mask, data.dqx_data, data.dqy_data) 1184 final_dataset = Data2D(data.data, data.err_data, data.qx_data, 1185 data.qy_data, data.q_data, data.mask, 1186 data.dqx_data, data.dqy_data) 1175 1187 final_dataset.xaxis(data._xaxis, data._xunit) 1176 1188 final_dataset.yaxis(data._yaxis, data._yunit) 1177 1189 final_dataset.zaxis(data._zaxis, data._zunit) 1178 if len(data.data.shape) == 2: 1179 n_rows, n_cols = data.data.shape 1180 final_dataset.y_bins = data.qy_data[0::int(n_cols)] 1181 final_dataset.x_bins = data.qx_data[:int(n_cols)] 1190 final_dataset.y_bins = data.y_bins 1191 final_dataset.x_bins = data.x_bins 1182 1192 else: 1183 return_string = "Should Never Happen: _combine_data_info_with_plottable input is not a plottable1d or " + \ 1184 "plottable2d data object" 1193 return_string = ("Should Never Happen: _combine_data_info_with_plottabl" 1194 "e input is not a plottable1d or plottable2d data " 1195 "object") 1185 1196 return return_string 1186 1197 -
src/sas/sascalc/dataloader/file_reader_base_class.py
r4a8d55c r8d5e11c 16 16 from .data_info import Data1D, Data2D, DataInfo, plottable_1D, plottable_2D,\ 17 17 combine_data_info_with_plottable 18 from sas.sascalc.data_util.nxsunit import Converter 18 19 19 20 logger = logging.getLogger(__name__) … … 36 37 "load the file was made, but, should it be successful, " 37 38 "SasView cannot guarantee the accuracy of the data.") 39 38 40 39 41 class FileReader(object): … … 98 100 if len(self.output) > 0: 99 101 # Sort the data that's been loaded 100 self. sort_one_d_data()101 self.sort_ two_d_data()102 self.convert_data_units() 103 self.sort_data() 102 104 else: 103 105 msg = "Unable to find file at: {}\n".format(filepath) … … 140 142 Returns the entire file as a string. 141 143 """ 142 #return self.f_open.read()143 144 return decode(self.f_open.read()) 144 145 … … 166 167 self.output.append(data_obj) 167 168 168 def sort_ one_d_data(self):169 def sort_data(self): 169 170 """ 170 171 Sort 1D data along the X axis for consistency … … 174 175 # Normalize the units for 175 176 data.x_unit = self.format_unit(data.x_unit) 177 data._xunit = data.x_unit 176 178 data.y_unit = self.format_unit(data.y_unit) 179 data._yunit = data.y_unit 177 180 # Sort data by increasing x and remove 1st point 178 181 ind = np.lexsort((data.y, data.x)) … … 203 206 data.ymin = np.min(data.y) 204 207 data.ymax = np.max(data.y) 208 elif isinstance(data, Data2D): 209 # Normalize the units for 210 data.Q_unit = self.format_unit(data.Q_unit) 211 data.I_unit = self.format_unit(data.I_unit) 212 data._xunit = data.Q_unit 213 data._yunit = data.Q_unit 214 data._zunit = data.I_unit 215 data.data = data.data.astype(np.float64) 216 data.qx_data = data.qx_data.astype(np.float64) 217 data.xmin = np.min(data.qx_data) 218 data.xmax = np.max(data.qx_data) 219 data.qy_data = data.qy_data.astype(np.float64) 220 data.ymin = np.min(data.qy_data) 221 data.ymax = np.max(data.qy_data) 222 data.q_data = np.sqrt(data.qx_data * data.qx_data 223 + data.qy_data * data.qy_data) 224 if data.err_data is not None: 225 data.err_data = data.err_data.astype(np.float64) 226 if data.dqx_data is not None: 227 data.dqx_data = data.dqx_data.astype(np.float64) 228 if data.dqy_data is not None: 229 data.dqy_data = data.dqy_data.astype(np.float64) 230 if data.mask is not None: 231 data.mask = data.mask.astype(dtype=bool) 232 233 if len(data.data.shape) == 2: 234 n_rows, n_cols = data.data.shape 235 data.y_bins = data.qy_data[0::int(n_cols)] 236 data.x_bins = data.qx_data[:int(n_cols)] 237 data.data = data.data.flatten() 238 data = self._remove_nans_in_data(data) 239 if len(data.data) > 0: 240 data.xmin = np.min(data.qx_data) 241 data.xmax = np.max(data.qx_data) 242 data.ymin = np.min(data.qy_data) 243 data.ymax = np.max(data.qx_data) 205 244 206 245 @staticmethod … … 242 281 return data 243 282 244 def sort_two_d_data(self): 245 for dataset in self.output: 246 if isinstance(dataset, Data2D): 247 # Normalize the units for 248 dataset.x_unit = self.format_unit(dataset.Q_unit) 249 dataset.y_unit = self.format_unit(dataset.I_unit) 250 dataset.data = dataset.data.astype(np.float64) 251 dataset.qx_data = dataset.qx_data.astype(np.float64) 252 dataset.xmin = np.min(dataset.qx_data) 253 dataset.xmax = np.max(dataset.qx_data) 254 dataset.qy_data = dataset.qy_data.astype(np.float64) 255 dataset.ymin = np.min(dataset.qy_data) 256 dataset.ymax = np.max(dataset.qy_data) 257 dataset.q_data = np.sqrt(dataset.qx_data * dataset.qx_data 258 + dataset.qy_data * dataset.qy_data) 259 if dataset.err_data is not None: 260 dataset.err_data = dataset.err_data.astype(np.float64) 261 if dataset.dqx_data is not None: 262 dataset.dqx_data = dataset.dqx_data.astype(np.float64) 263 if dataset.dqy_data is not None: 264 dataset.dqy_data = dataset.dqy_data.astype(np.float64) 265 if dataset.mask is not None: 266 dataset.mask = dataset.mask.astype(dtype=bool) 267 268 if len(dataset.data.shape) == 2: 269 n_rows, n_cols = dataset.data.shape 270 dataset.y_bins = dataset.qy_data[0::int(n_cols)] 271 dataset.x_bins = dataset.qx_data[:int(n_cols)] 272 dataset.data = dataset.data.flatten() 273 dataset = self._remove_nans_in_data(dataset) 274 if len(dataset.data) > 0: 275 dataset.xmin = np.min(dataset.qx_data) 276 dataset.xmax = np.max(dataset.qx_data) 277 dataset.ymin = np.min(dataset.qy_data) 278 dataset.ymax = np.max(dataset.qx_data) 283 @staticmethod 284 def set_default_1d_units(data): 285 """ 286 Set the x and y axes to the default 1D units 287 :param data: 1D data set 288 :return: 289 """ 290 data.xaxis("\\rm{Q}", '1/A') 291 data.yaxis("\\rm{Intensity}", "1/cm") 292 return data 293 294 @staticmethod 295 def set_default_2d_units(data): 296 """ 297 Set the x and y axes to the default 2D units 298 :param data: 2D data set 299 :return: 300 """ 301 data.xaxis("\\rm{Q_{x}}", '1/A') 302 data.yaxis("\\rm{Q_{y}}", '1/A') 303 data.zaxis("\\rm{Intensity}", "1/cm") 304 return data 305 306 def convert_data_units(self, default_q_unit="1/A", default_i_unit="1/cm"): 307 """ 308 Converts al; data to the sasview default of units of A^{-1} for Q and 309 cm^{-1} for I. 310 :param default_q_unit: The default Q unit used by Sasview 311 :param default_i_unit: The default I unit used by Sasview 312 """ 313 new_output = [] 314 for data in self.output: 315 if data.isSesans: 316 new_output.append(data) 317 continue 318 file_x_unit = data._xunit 319 data_conv_x = Converter(file_x_unit) 320 file_y_unit = data._yunit 321 data_conv_y = Converter(file_y_unit) 322 if isinstance(data, Data1D): 323 try: 324 data.x = data_conv_x(data.x, units=default_q_unit) 325 data._xunit = default_q_unit 326 data.x_unit = default_q_unit 327 if data.dx is not None: 328 data.dx = data_conv_x(data.dx, units=default_q_unit) 329 if data.dxl is not None: 330 data.dxl = data_conv_x(data.dxl, units=default_q_unit) 331 if data.dxw is not None: 332 data.dxw = data_conv_x(data.dxw, units=default_q_unit) 333 except KeyError: 334 message = "Unable to convert Q units from {0} to 1/A." 335 message.format(default_q_unit) 336 data.errors.append(message) 337 try: 338 data.y = data_conv_y(data.y, units=default_i_unit) 339 data._yunit = default_i_unit 340 data.y_unit = default_i_unit 341 if data.dy is not None: 342 data.dy = data_conv_y(data.dy, units=default_i_unit) 343 except KeyError: 344 message = "Unable to convert I units from {0} to 1/cm." 345 message.format(default_q_unit) 346 data.errors.append(message) 347 elif isinstance(data, Data2D): 348 try: 349 data.qx_data = data_conv_x(data.qx_data, 350 units=default_q_unit) 351 if data.dqx_data is not None: 352 data.dqx_data = data_conv_x(data.dqx_data, 353 units=default_q_unit) 354 data.qy_data = data_conv_y(data.qy_data, 355 units=default_q_unit) 356 if data.dqy_data is not None: 357 data.dqy_data = data_conv_y(data.dqy_data, 358 units=default_q_unit) 359 except KeyError: 360 message = "Unable to convert Q units from {0} to 1/A." 361 message.format(default_q_unit) 362 data.errors.append(message) 363 try: 364 file_z_unit = data._zunit 365 data_conv_z = Converter(file_z_unit) 366 data.data = data_conv_z(data.data, units=default_i_unit) 367 if data.err_data is not None: 368 data.err_data = data_conv_z(data.err_data, 369 units=default_i_unit) 370 except KeyError: 371 message = "Unable to convert I units from {0} to 1/cm." 372 message.format(default_q_unit) 373 data.errors.append(message) 374 else: 375 # TODO: Throw error of some sort... 376 pass 377 new_output.append(data) 378 self.output = new_output 279 379 280 380 def format_unit(self, unit=None): … … 367 467 self.current_dataset.qy_data)) 368 468 if has_error_dy: 369 self.current_dataset.err_data = self.current_dataset.err_data[x != 0] 469 self.current_dataset.err_data = self.current_dataset.err_data[ 470 x != 0] 370 471 if has_error_dqx: 371 self.current_dataset.dqx_data = self.current_dataset.dqx_data[x != 0] 472 self.current_dataset.dqx_data = self.current_dataset.dqx_data[ 473 x != 0] 372 474 if has_error_dqy: 373 self.current_dataset.dqy_data = self.current_dataset.dqy_data[x != 0] 475 self.current_dataset.dqy_data = self.current_dataset.dqy_data[ 476 x != 0] 374 477 if has_mask: 375 478 self.current_dataset.mask = self.current_dataset.mask[x != 0] -
src/sas/sascalc/dataloader/loader.py
r4a8d55c r8d5e11c 367 367 try: 368 368 return fn(path, data) 369 except Exception :369 except Exception as exep: 370 370 pass # give other loaders a chance to succeed 371 371 # If we get here it is because all loaders failed 372 raise # reraises last exception372 raise exep # raises last exception 373 373 374 374 -
src/sas/sascalc/dataloader/readers/abs_reader.py
rbd5c3b1 rbd5c3b1 225 225 raise ValueError("ascii_reader: could not load file") 226 226 227 self.current_dataset = self.set_default_1d_units(self.current_dataset) 227 228 if data_conv_q is not None: 228 229 self.current_dataset.xaxis("\\rm{Q}", base_q_unit) 229 else:230 self.current_dataset.xaxis("\\rm{Q}", 'A^{-1}')231 230 if data_conv_i is not None: 232 231 self.current_dataset.yaxis("\\rm{Intensity}", base_i_unit) 233 else:234 self.current_dataset.yaxis("\\rm{Intensity}", "cm^{-1}")235 232 236 233 # Store loading process information -
src/sas/sascalc/dataloader/readers/ascii_reader.py
r7b07fbe r3bab401 157 157 158 158 self.remove_empty_q_values() 159 self.current_dataset.xaxis("\\rm{Q}", 'A^{-1}') 160 self.current_dataset.yaxis("\\rm{Intensity}", "cm^{-1}") 159 self.current_dataset = self.set_default_1d_units(self.current_dataset) 161 160 162 161 # Store loading process information -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r2469df7 r058f6c3 812 812 node.append(point) 813 813 self.write_node(point, "Q", datainfo.x[i], 814 {'unit': datainfo. x_unit})814 {'unit': datainfo._xunit}) 815 815 if len(datainfo.y) >= i: 816 816 self.write_node(point, "I", datainfo.y[i], 817 {'unit': datainfo. y_unit})817 {'unit': datainfo._yunit}) 818 818 if datainfo.dy is not None and len(datainfo.dy) > i: 819 819 self.write_node(point, "Idev", datainfo.dy[i], 820 {'unit': datainfo. y_unit})820 {'unit': datainfo._yunit}) 821 821 if datainfo.dx is not None and len(datainfo.dx) > i: 822 822 self.write_node(point, "Qdev", datainfo.dx[i], 823 {'unit': datainfo. x_unit})823 {'unit': datainfo._xunit}) 824 824 if datainfo.dxw is not None and len(datainfo.dxw) > i: 825 825 self.write_node(point, "dQw", datainfo.dxw[i], 826 {'unit': datainfo. x_unit})826 {'unit': datainfo._xunit}) 827 827 if datainfo.dxl is not None and len(datainfo.dxl) > i: 828 828 self.write_node(point, "dQl", datainfo.dxl[i], 829 {'unit': datainfo. x_unit})829 {'unit': datainfo._xunit}) 830 830 if datainfo.isSesans: 831 831 sesans_attrib = {'x_axis': datainfo._xaxis, -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r61f329f0 rfeec1cb 12 12 Data1D, Data2D, DataInfo, Process, Aperture, Collimation, \ 13 13 TransmissionSpectrum, Detector 14 from ..data_info import combine_data_info_with_plottable15 14 from ..loader_exceptions import FileContentsException, DefaultReaderException 16 15 from ..file_reader_base_class import FileReader, decode 17 16 17 18 18 def h5attr(node, key, default=None): 19 19 return decode(node.attrs.get(key, default)) 20 20 21 21 22 class Reader(FileReader): … … 38 39 # CanSAS version 39 40 cansas_version = 2.0 40 # Logged warnings or messages41 logging = None42 # List of errors for the current data set43 errors = None44 # Raw file contents to be processed45 raw_data = None46 # List of plottable1D objects that should be linked to the current_datainfo47 data1d = None48 # List of plottable2D objects that should be linked to the current_datainfo49 data2d = None50 41 # Data type name 51 type_name = " CanSAS 2.0"42 type_name = "NXcanSAS" 52 43 # Wildcards 53 type = [" CanSAS 2.0 HDF5 Files (*.h5)|*.h5"]44 type = ["NXcanSAS HDF5 Files (*.h5)|*.h5|"] 54 45 # List of allowed extensions 55 46 ext = ['.h5', '.H5'] … … 81 72 except Exception as e: 82 73 if extension not in self.ext: 83 msg = "CanSAS2.0 HDF5 Reader could not load file {}".format(basename + extension) 74 msg = "NXcanSAS Reader could not load file {}".format( 75 basename + extension) 84 76 raise DefaultReaderException(msg) 85 77 raise FileContentsException(e.message) … … 95 87 self.raw_data.close() 96 88 97 for dataset in self.output: 98 if isinstance(dataset, Data1D): 99 if dataset.x.size < 5: 100 self.output = [] 101 raise FileContentsException("Fewer than 5 data points found.") 89 for data_set in self.output: 90 if isinstance(data_set, Data1D): 91 if data_set.x.size < 5: 92 exception = FileContentsException( 93 "Fewer than 5 data points found.") 94 data_set.errors.append(exception) 102 95 103 96 def reset_state(self): … … 111 104 self.errors = set() 112 105 self.logging = [] 106 self.q_name = [] 107 self.mask_name = u'' 108 self.i_name = u'' 109 self.i_node = u'' 110 self.q_uncertainties = None 111 self.q_resolutions = None 112 self.i_uncertainties = u'' 113 113 self.parent_class = u'' 114 114 self.detector = Detector() … … 131 131 value = data.get(key) 132 132 class_name = h5attr(value, u'canSAS_class') 133 if isinstance(class_name, (list, tuple, np.ndarray)): 134 class_name = class_name[0] 133 135 if class_name is None: 134 136 class_name = h5attr(value, u'NX_class') … … 140 142 if isinstance(value, h5py.Group): 141 143 # Set parent class before recursion 144 last_parent_class = self.parent_class 142 145 self.parent_class = class_name 143 146 parent_list.append(key) … … 147 150 self.add_data_set(key) 148 151 elif class_prog.match(u'SASdata'): 149 self._initialize_new_data_set(parent_list) 152 self._initialize_new_data_set(value) 153 self._find_data_attributes(value) 150 154 # Recursion step to access data within the group 151 155 self.read_children(value, parent_list) 156 self.add_intermediate() 152 157 # Reset parent class when returning from recursive method 153 self.parent_class = class_name 154 self.add_intermediate() 158 self.parent_class = last_parent_class 155 159 parent_list.remove(key) 156 160 157 161 elif isinstance(value, h5py.Dataset): 158 162 # If this is a dataset, store the data appropriately 159 data_set = data[key][:]163 data_set = value.value 160 164 unit = self._get_unit(value) 161 162 # I and Q Data163 if key == u'I':164 if isinstance(self.current_dataset, plottable_2D):165 self.current_dataset.data = data_set166 self.current_dataset.zaxis("Intensity", unit)167 else:168 self.current_dataset.y = data_set.flatten()169 self.current_dataset.yaxis("Intensity", unit)170 continue171 elif key == u'Idev':172 if isinstance(self.current_dataset, plottable_2D):173 self.current_dataset.err_data = data_set.flatten()174 else:175 self.current_dataset.dy = data_set.flatten()176 continue177 elif key == u'Q':178 self.current_dataset.xaxis("Q", unit)179 if isinstance(self.current_dataset, plottable_2D):180 self.current_dataset.q = data_set.flatten()181 else:182 self.current_dataset.x = data_set.flatten()183 continue184 elif key == u'Qdev':185 self.current_dataset.dx = data_set.flatten()186 continue187 elif key == u'dQw':188 self.current_dataset.dxw = data_set.flatten()189 continue190 elif key == u'dQl':191 self.current_dataset.dxl = data_set.flatten()192 continue193 elif key == u'Qy':194 self.current_dataset.yaxis("Q_y", unit)195 self.current_dataset.qy_data = data_set.flatten()196 continue197 elif key == u'Qydev':198 self.current_dataset.dqy_data = data_set.flatten()199 continue200 elif key == u'Qx':201 self.current_dataset.xaxis("Q_x", unit)202 self.current_dataset.qx_data = data_set.flatten()203 continue204 elif key == u'Qxdev':205 self.current_dataset.dqx_data = data_set.flatten()206 continue207 elif key == u'Mask':208 self.current_dataset.mask = data_set.flatten()209 continue210 # Transmission Spectrum211 elif (key == u'T'212 and self.parent_class == u'SAStransmission_spectrum'):213 self.trans_spectrum.transmission = data_set.flatten()214 continue215 elif (key == u'Tdev'216 and self.parent_class == u'SAStransmission_spectrum'):217 self.trans_spectrum.transmission_deviation = \218 data_set.flatten()219 continue220 elif (key == u'lambda'221 and self.parent_class == u'SAStransmission_spectrum'):222 self.trans_spectrum.wavelength = data_set.flatten()223 continue224 165 225 166 for data_point in data_set: … … 232 173 if key == u'definition': 233 174 self.current_datainfo.meta_data['reader'] = data_point 175 # Run 234 176 elif key == u'run': 235 177 self.current_datainfo.run.append(data_point) … … 240 182 except Exception: 241 183 pass 184 # Title 242 185 elif key == u'title': 243 186 self.current_datainfo.title = data_point 187 # Note 244 188 elif key == u'SASnote': 245 189 self.current_datainfo.notes.append(data_point) 246 247 190 # Sample Information 248 # CanSAS 2.0 format 249 elif key == u'Title' and self.parent_class == u'SASsample': 250 self.current_datainfo.sample.name = data_point 251 # NXcanSAS format 252 elif key == u'name' and self.parent_class == u'SASsample': 253 self.current_datainfo.sample.name = data_point 254 # NXcanSAS format 255 elif key == u'ID' and self.parent_class == u'SASsample': 256 self.current_datainfo.sample.name = data_point 257 elif (key == u'thickness' 258 and self.parent_class == u'SASsample'): 259 self.current_datainfo.sample.thickness = data_point 260 elif (key == u'temperature' 261 and self.parent_class == u'SASsample'): 262 self.current_datainfo.sample.temperature = data_point 263 elif (key == u'transmission' 264 and self.parent_class == u'SASsample'): 265 self.current_datainfo.sample.transmission = data_point 266 elif (key == u'x_position' 267 and self.parent_class == u'SASsample'): 268 self.current_datainfo.sample.position.x = data_point 269 elif (key == u'y_position' 270 and self.parent_class == u'SASsample'): 271 self.current_datainfo.sample.position.y = data_point 272 elif key == u'pitch' and self.parent_class == u'SASsample': 273 self.current_datainfo.sample.orientation.x = data_point 274 elif key == u'yaw' and self.parent_class == u'SASsample': 275 self.current_datainfo.sample.orientation.y = data_point 276 elif key == u'roll' and self.parent_class == u'SASsample': 277 self.current_datainfo.sample.orientation.z = data_point 278 elif (key == u'details' 279 and self.parent_class == u'SASsample'): 280 self.current_datainfo.sample.details.append(data_point) 281 191 elif self.parent_class == u'SASsample': 192 self.process_sample(data_point, key) 282 193 # Instrumental Information 283 194 elif (key == u'name' 284 195 and self.parent_class == u'SASinstrument'): 285 196 self.current_datainfo.instrument = data_point 286 elif key == u'name' and self.parent_class == u'SASdetector': 287 self.detector.name = data_point 288 elif key == u'SDD' and self.parent_class == u'SASdetector': 289 self.detector.distance = float(data_point) 290 self.detector.distance_unit = unit 291 elif (key == u'slit_length' 292 and self.parent_class == u'SASdetector'): 293 self.detector.slit_length = float(data_point) 294 self.detector.slit_length_unit = unit 295 elif (key == u'x_position' 296 and self.parent_class == u'SASdetector'): 297 self.detector.offset.x = float(data_point) 298 self.detector.offset_unit = unit 299 elif (key == u'y_position' 300 and self.parent_class == u'SASdetector'): 301 self.detector.offset.y = float(data_point) 302 self.detector.offset_unit = unit 303 elif (key == u'pitch' 304 and self.parent_class == u'SASdetector'): 305 self.detector.orientation.x = float(data_point) 306 self.detector.orientation_unit = unit 307 elif key == u'roll' and self.parent_class == u'SASdetector': 308 self.detector.orientation.z = float(data_point) 309 self.detector.orientation_unit = unit 310 elif key == u'yaw' and self.parent_class == u'SASdetector': 311 self.detector.orientation.y = float(data_point) 312 self.detector.orientation_unit = unit 313 elif (key == u'beam_center_x' 314 and self.parent_class == u'SASdetector'): 315 self.detector.beam_center.x = float(data_point) 316 self.detector.beam_center_unit = unit 317 elif (key == u'beam_center_y' 318 and self.parent_class == u'SASdetector'): 319 self.detector.beam_center.y = float(data_point) 320 self.detector.beam_center_unit = unit 321 elif (key == u'x_pixel_size' 322 and self.parent_class == u'SASdetector'): 323 self.detector.pixel_size.x = float(data_point) 324 self.detector.pixel_size_unit = unit 325 elif (key == u'y_pixel_size' 326 and self.parent_class == u'SASdetector'): 327 self.detector.pixel_size.y = float(data_point) 328 self.detector.pixel_size_unit = unit 329 elif (key == u'distance' 330 and self.parent_class == u'SAScollimation'): 331 self.collimation.length = data_point 332 self.collimation.length_unit = unit 333 elif (key == u'name' 334 and self.parent_class == u'SAScollimation'): 335 self.collimation.name = data_point 336 elif (key == u'shape' 337 and self.parent_class == u'SASaperture'): 338 self.aperture.shape = data_point 339 elif (key == u'x_gap' 340 and self.parent_class == u'SASaperture'): 341 self.aperture.size.x = data_point 342 elif (key == u'y_gap' 343 and self.parent_class == u'SASaperture'): 344 self.aperture.size.y = data_point 345 197 # Detector 198 elif self.parent_class == u'SASdetector': 199 self.process_detector(data_point, key, unit) 200 # Collimation 201 elif self.parent_class == u'SAScollimation': 202 self.process_collimation(data_point, key, unit) 203 # Aperture 204 elif self.parent_class == u'SASaperture': 205 self.process_aperture(data_point, key) 346 206 # Process Information 347 elif (key == u'Title' 348 and self.parent_class == u'SASprocess'): # CanSAS 2.0 349 self.process.name = data_point 350 elif (key == u'name' 351 and self.parent_class == u'SASprocess'): # NXcanSAS 352 self.process.name = data_point 353 elif (key == u'description' 354 and self.parent_class == u'SASprocess'): 355 self.process.description = data_point 356 elif key == u'date' and self.parent_class == u'SASprocess': 357 self.process.date = data_point 358 elif key == u'term' and self.parent_class == u'SASprocess': 359 self.process.term = data_point 360 elif self.parent_class == u'SASprocess': 361 self.process.notes.append(data_point) 362 207 elif self.parent_class == u'SASprocess': # CanSAS 2.0 208 self.process_process(data_point, key) 363 209 # Source 364 elif (key == u'wavelength' 365 and self.parent_class == u'SASdata'): 366 self.current_datainfo.source.wavelength = data_point 367 self.current_datainfo.source.wavelength_unit = unit 368 elif (key == u'incident_wavelength' 369 and self.parent_class == 'SASsource'): 370 self.current_datainfo.source.wavelength = data_point 371 self.current_datainfo.source.wavelength_unit = unit 372 elif (key == u'wavelength_max' 373 and self.parent_class == u'SASsource'): 374 self.current_datainfo.source.wavelength_max = data_point 375 self.current_datainfo.source.wavelength_max_unit = unit 376 elif (key == u'wavelength_min' 377 and self.parent_class == u'SASsource'): 378 self.current_datainfo.source.wavelength_min = data_point 379 self.current_datainfo.source.wavelength_min_unit = unit 380 elif (key == u'incident_wavelength_spread' 381 and self.parent_class == u'SASsource'): 382 self.current_datainfo.source.wavelength_spread = \ 383 data_point 384 self.current_datainfo.source.wavelength_spread_unit = \ 385 unit 386 elif (key == u'beam_size_x' 387 and self.parent_class == u'SASsource'): 388 self.current_datainfo.source.beam_size.x = data_point 389 self.current_datainfo.source.beam_size_unit = unit 390 elif (key == u'beam_size_y' 391 and self.parent_class == u'SASsource'): 392 self.current_datainfo.source.beam_size.y = data_point 393 self.current_datainfo.source.beam_size_unit = unit 394 elif (key == u'beam_shape' 395 and self.parent_class == u'SASsource'): 396 self.current_datainfo.source.beam_shape = data_point 397 elif (key == u'radiation' 398 and self.parent_class == u'SASsource'): 399 self.current_datainfo.source.radiation = data_point 400 elif (key == u'transmission' 401 and self.parent_class == u'SASdata'): 402 self.current_datainfo.sample.transmission = data_point 403 210 elif self.parent_class == u'SASsource': 211 self.process_source(data_point, key, unit) 404 212 # Everything else goes in meta_data 213 elif self.parent_class == u'SASdata': 214 if isinstance(self.current_dataset, plottable_2D): 215 self.process_2d_data_object(data_set, key, unit) 216 else: 217 self.process_1d_data_object(data_set, key, unit) 218 219 break 220 elif self.parent_class == u'SAStransmission_spectrum': 221 self.process_trans_spectrum(data_set, key) 222 break 405 223 else: 406 224 new_key = self._create_unique_key( … … 411 229 # I don't know if this reachable code 412 230 self.errors.add("ShouldNeverHappenException") 231 232 def process_1d_data_object(self, data_set, key, unit): 233 """ 234 SASdata processor method for 1d data items 235 :param data_set: data from HDF5 file 236 :param key: canSAS_class attribute 237 :param unit: unit attribute 238 """ 239 if key == self.i_name: 240 self.current_dataset.y = data_set.flatten() 241 self.current_dataset.yaxis("Intensity", unit) 242 elif key == self.i_uncertainties: 243 self.current_dataset.dy = data_set.flatten() 244 elif key in self.q_name: 245 self.current_dataset.xaxis("Q", unit) 246 self.current_dataset.x = data_set.flatten() 247 elif key in self.q_uncertainties or key in self.q_resolutions: 248 if (len(self.q_resolutions) > 1 249 and np.where(self.q_resolutions == key)[0] == 0): 250 self.current_dataset.dxw = data_set.flatten() 251 elif (len(self.q_resolutions) > 1 252 and np.where(self.q_resolutions == key)[0] == 1): 253 self.current_dataset.dxl = data_set.flatten() 254 else: 255 self.current_dataset.dx = data_set.flatten() 256 elif key == self.mask_name: 257 self.current_dataset.mask = data_set.flatten() 258 elif key == u'wavelength': 259 self.current_datainfo.source.wavelength = data_set[0] 260 self.current_datainfo.source.wavelength_unit = unit 261 262 def process_2d_data_object(self, data_set, key, unit): 263 if key == self.i_name: 264 self.current_dataset.data = data_set 265 self.current_dataset.zaxis("Intensity", unit) 266 elif key == self.i_uncertainties: 267 self.current_dataset.err_data = data_set.flatten() 268 elif key in self.q_name: 269 self.current_dataset.xaxis("Q_x", unit) 270 self.current_dataset.yaxis("Q_y", unit) 271 if self.q_name[0] == self.q_name[1]: 272 # All q data in a single array 273 self.current_dataset.qx_data = data_set[0] 274 self.current_dataset.qy_data = data_set[1] 275 elif self.q_name.index(key) == 0: 276 self.current_dataset.qx_data = data_set 277 elif self.q_name.index(key) == 1: 278 self.current_dataset.qy_data = data_set 279 elif key in self.q_uncertainties or key in self.q_resolutions: 280 if ((self.q_uncertainties[0] == self.q_uncertainties[1]) or 281 (self.q_resolutions[0] == self.q_resolutions[1])): 282 # All q data in a single array 283 self.current_dataset.dqx_data = data_set[0].flatten() 284 self.current_dataset.dqy_data = data_set[1].flatten() 285 elif (self.q_uncertainties.index(key) == 0 or 286 self.q_resolutions.index(key) == 0): 287 self.current_dataset.dqx_data = data_set.flatten() 288 elif (self.q_uncertainties.index(key) == 1 or 289 self.q_resolutions.index(key) == 1): 290 self.current_dataset.dqy_data = data_set.flatten() 291 self.current_dataset.yaxis("Q_y", unit) 292 elif key == self.mask_name: 293 self.current_dataset.mask = data_set.flatten() 294 elif key == u'Qy': 295 self.current_dataset.yaxis("Q_y", unit) 296 self.current_dataset.qy_data = data_set.flatten() 297 elif key == u'Qydev': 298 self.current_dataset.dqy_data = data_set.flatten() 299 elif key == u'Qx': 300 self.current_dataset.xaxis("Q_x", unit) 301 self.current_dataset.qx_data = data_set.flatten() 302 elif key == u'Qxdev': 303 self.current_dataset.dqx_data = data_set.flatten() 304 305 def process_trans_spectrum(self, data_set, key): 306 """ 307 SAStransmission_spectrum processor 308 :param data_set: data from HDF5 file 309 :param key: canSAS_class attribute 310 """ 311 if key == u'T': 312 self.trans_spectrum.transmission = data_set.flatten() 313 elif key == u'Tdev': 314 self.trans_spectrum.transmission_deviation = data_set.flatten() 315 elif key == u'lambda': 316 self.trans_spectrum.wavelength = data_set.flatten() 317 318 def process_sample(self, data_point, key): 319 """ 320 SASsample processor 321 :param data_point: Single point from an HDF5 data file 322 :param key: class name data_point was taken from 323 """ 324 if key == u'Title': 325 self.current_datainfo.sample.name = data_point 326 elif key == u'name': 327 self.current_datainfo.sample.name = data_point 328 elif key == u'ID': 329 self.current_datainfo.sample.name = data_point 330 elif key == u'thickness': 331 self.current_datainfo.sample.thickness = data_point 332 elif key == u'temperature': 333 self.current_datainfo.sample.temperature = data_point 334 elif key == u'transmission': 335 self.current_datainfo.sample.transmission = data_point 336 elif key == u'x_position': 337 self.current_datainfo.sample.position.x = data_point 338 elif key == u'y_position': 339 self.current_datainfo.sample.position.y = data_point 340 elif key == u'pitch': 341 self.current_datainfo.sample.orientation.x = data_point 342 elif key == u'yaw': 343 self.current_datainfo.sample.orientation.y = data_point 344 elif key == u'roll': 345 self.current_datainfo.sample.orientation.z = data_point 346 elif key == u'details': 347 self.current_datainfo.sample.details.append(data_point) 348 349 def process_detector(self, data_point, key, unit): 350 """ 351 SASdetector processor 352 :param data_point: Single point from an HDF5 data file 353 :param key: class name data_point was taken from 354 :param unit: unit attribute from data set 355 """ 356 if key == u'name': 357 self.detector.name = data_point 358 elif key == u'SDD': 359 self.detector.distance = float(data_point) 360 self.detector.distance_unit = unit 361 elif key == u'slit_length': 362 self.detector.slit_length = float(data_point) 363 self.detector.slit_length_unit = unit 364 elif key == u'x_position': 365 self.detector.offset.x = float(data_point) 366 self.detector.offset_unit = unit 367 elif key == u'y_position': 368 self.detector.offset.y = float(data_point) 369 self.detector.offset_unit = unit 370 elif key == u'pitch': 371 self.detector.orientation.x = float(data_point) 372 self.detector.orientation_unit = unit 373 elif key == u'roll': 374 self.detector.orientation.z = float(data_point) 375 self.detector.orientation_unit = unit 376 elif key == u'yaw': 377 self.detector.orientation.y = float(data_point) 378 self.detector.orientation_unit = unit 379 elif key == u'beam_center_x': 380 self.detector.beam_center.x = float(data_point) 381 self.detector.beam_center_unit = unit 382 elif key == u'beam_center_y': 383 self.detector.beam_center.y = float(data_point) 384 self.detector.beam_center_unit = unit 385 elif key == u'x_pixel_size': 386 self.detector.pixel_size.x = float(data_point) 387 self.detector.pixel_size_unit = unit 388 elif key == u'y_pixel_size': 389 self.detector.pixel_size.y = float(data_point) 390 self.detector.pixel_size_unit = unit 391 392 def process_collimation(self, data_point, key, unit): 393 """ 394 SAScollimation processor 395 :param data_point: Single point from an HDF5 data file 396 :param key: class name data_point was taken from 397 :param unit: unit attribute from data set 398 """ 399 if key == u'distance': 400 self.collimation.length = data_point 401 self.collimation.length_unit = unit 402 elif key == u'name': 403 self.collimation.name = data_point 404 405 def process_aperture(self, data_point, key): 406 """ 407 SASaperture processor 408 :param data_point: Single point from an HDF5 data file 409 :param key: class name data_point was taken from 410 """ 411 if key == u'shape': 412 self.aperture.shape = data_point 413 elif key == u'x_gap': 414 self.aperture.size.x = data_point 415 elif key == u'y_gap': 416 self.aperture.size.y = data_point 417 418 def process_source(self, data_point, key, unit): 419 """ 420 SASsource processor 421 :param data_point: Single point from an HDF5 data file 422 :param key: class name data_point was taken from 423 :param unit: unit attribute from data set 424 """ 425 if key == u'incident_wavelength': 426 self.current_datainfo.source.wavelength = data_point 427 self.current_datainfo.source.wavelength_unit = unit 428 elif key == u'wavelength_max': 429 self.current_datainfo.source.wavelength_max = data_point 430 self.current_datainfo.source.wavelength_max_unit = unit 431 elif key == u'wavelength_min': 432 self.current_datainfo.source.wavelength_min = data_point 433 self.current_datainfo.source.wavelength_min_unit = unit 434 elif key == u'incident_wavelength_spread': 435 self.current_datainfo.source.wavelength_spread = data_point 436 self.current_datainfo.source.wavelength_spread_unit = unit 437 elif key == u'beam_size_x': 438 self.current_datainfo.source.beam_size.x = data_point 439 self.current_datainfo.source.beam_size_unit = unit 440 elif key == u'beam_size_y': 441 self.current_datainfo.source.beam_size.y = data_point 442 self.current_datainfo.source.beam_size_unit = unit 443 elif key == u'beam_shape': 444 self.current_datainfo.source.beam_shape = data_point 445 elif key == u'radiation': 446 self.current_datainfo.source.radiation = data_point 447 448 def process_process(self, data_point, key): 449 """ 450 SASprocess processor 451 :param data_point: Single point from an HDF5 data file 452 :param key: class name data_point was taken from 453 """ 454 term_match = re.compile(u'^term[0-9]+$') 455 if key == u'Title': # CanSAS 2.0 456 self.process.name = data_point 457 elif key == u'name': # NXcanSAS 458 self.process.name = data_point 459 elif key == u'description': 460 self.process.description = data_point 461 elif key == u'date': 462 self.process.date = data_point 463 elif term_match.match(key): 464 self.process.term.append(data_point) 465 else: 466 self.process.notes.append(data_point) 413 467 414 468 def add_intermediate(self): … … 452 506 spectrum_list = [] 453 507 for spectrum in self.current_datainfo.trans_spectrum: 454 spectrum.transmission = np.delete(spectrum.transmission, [0])455 508 spectrum.transmission = spectrum.transmission.astype(np.float64) 456 spectrum.transmission_deviation = np.delete(457 spectrum.transmission_deviation, [0])458 509 spectrum.transmission_deviation = \ 459 510 spectrum.transmission_deviation.astype(np.float64) 460 spectrum.wavelength = np.delete(spectrum.wavelength, [0])461 511 spectrum.wavelength = spectrum.wavelength.astype(np.float64) 462 512 if len(spectrum.transmission) > 0: … … 490 540 if dataset.data.ndim == 2: 491 541 (n_rows, n_cols) = dataset.data.shape 492 dataset.y_bins = dataset.qy_data[0::n_cols] 493 dataset.x_bins = dataset.qx_data[:n_cols] 542 flat_qy = dataset.qy_data[0::n_cols].flatten() 543 if flat_qy[0] == flat_qy[1]: 544 flat_qy = np.transpose(dataset.qy_data)[0::n_cols].flatten() 545 dataset.y_bins = np.unique(flat_qy) 546 flat_qx = dataset.qx_data[0::n_rows].flatten() 547 if flat_qx[0] == flat_qx[1]: 548 flat_qx = np.transpose(dataset.qx_data)[0::n_rows].flatten() 549 dataset.x_bins = np.unique(flat_qx) 494 550 dataset.data = dataset.data.flatten() 551 dataset.qx_data = dataset.qx_data.flatten() 552 dataset.qy_data = dataset.qy_data.flatten() 495 553 self.current_dataset = dataset 496 554 self.send_to_output() … … 515 573 self.current_datainfo = DataInfo() 516 574 517 518 def _initialize_new_data_set(self, parent_list=None): 575 def _initialize_new_data_set(self, value=None): 519 576 """ 520 577 A private class method to generate a new 1D or 2D data object based on … … 524 581 :param parent_list: List of names of parent elements 525 582 """ 526 527 if parent_list is None: 528 parent_list = [] 529 if self._find_intermediate(parent_list, "Qx"): 583 if self._is2d(value): 530 584 self.current_dataset = plottable_2D() 531 585 else: … … 534 588 self.current_dataset = plottable_1D(x, y) 535 589 self.current_datainfo.filename = self.raw_data.filename 536 537 def _find_intermediate(self, parent_list, basename=""): 538 """ 539 A private class used to find an entry by either using a direct key or 540 knowing the approximate basename. 590 self.mask_name = "" 591 self.i_name = "" 592 self.i_node = "" 593 self.q_name = [] 594 self.q_uncertainties = [] 595 self.q_resolutions = [] 596 self.i_uncertainties = "" 597 598 @staticmethod 599 def check_is_list_or_array(iterable): 600 try: 601 iter(iterable) 602 if (not isinstance(iterable, np.ndarray) and not isinstance( 603 iterable, list)) or (isinstance(iterable, str) or 604 isinstance(iterable, unicode)): 605 raise TypeError 606 except TypeError: 607 iterable = iterable.split(",") 608 return iterable 609 610 def _find_data_attributes(self, value): 611 """ 612 A class to find the indices for Q, the name of the Qdev and Idev, and 613 the name of the mask. 614 :param value: SASdata/NXdata HDF5 Group 615 """ 616 attrs = value.attrs 617 signal = attrs.get("signal", "I") 618 i_axes = attrs.get("I_axes", ["Q"]) 619 q_indices = attrs.get("Q_indices", [0]) 620 q_indices = map(int, self.check_is_list_or_array(q_indices)) 621 i_axes = self.check_is_list_or_array(i_axes) 622 keys = value.keys() 623 self.mask_name = attrs.get("mask") 624 for val in q_indices: 625 self.q_name.append(i_axes[val]) 626 self.i_name = signal 627 self.i_node = value.get(self.i_name) 628 for item in self.q_name: 629 if item in keys: 630 q_vals = value.get(item) 631 if q_vals.attrs.get("uncertainties") is not None: 632 self.q_uncertainties = q_vals.attrs.get("uncertainties") 633 elif q_vals.attrs.get("uncertainty") is not None: 634 self.q_uncertainties = q_vals.attrs.get("uncertainty") 635 if isinstance(self.q_uncertainties, str): 636 self.q_uncertainties = self.q_uncertainties.split(",") 637 if q_vals.attrs.get("resolutions") is not None: 638 self.q_resolutions = q_vals.attrs.get("resolutions") 639 if isinstance(self.q_resolutions, (str, unicode)): 640 self.q_resolutions = self.q_resolutions.split(",") 641 if self.i_name in keys: 642 i_vals = value.get(self.i_name) 643 self.i_uncertainties = i_vals.attrs.get("uncertainties") 644 if self.i_uncertainties is None: 645 self.i_uncertainties = i_vals.attrs.get("uncertainty") 646 647 def _is2d(self, value, basename="I"): 648 """ 649 A private class to determine if the data set is 1d or 2d. 541 650 542 651 :param parent_list: List of parents nodes in the HDF5 file 543 652 :param basename: Approximate name of an entry to search for 544 :return: 545 """ 546 547 entry = False 548 key_prog = re.compile(basename) 549 top = self.raw_data 550 for parent in parent_list: 551 top = top.get(parent) 552 for key in top.keys(): 553 if key_prog.match(key): 554 entry = True 555 break 556 return entry 653 :return: True if 2D, otherwise false 654 """ 655 656 vals = value.get(basename) 657 return (vals is not None and vals.shape is not None 658 and len(vals.shape) != 1) 557 659 558 660 def _create_unique_key(self, dictionary, name, numb=0): … … 583 685 if unit is None: 584 686 unit = h5attr(value, u'unit') 585 # Convert the unit formats586 if unit == "1/A":587 unit = "A^{-1}"588 elif unit == "1/cm":589 unit = "cm^{-1}"590 687 return unit -
src/sas/sascalc/dataloader/readers/danse_reader.py
r2469df7 rfc51d06 180 180 detector.beam_center.y = center_y * pixel 181 181 182 183 self.current_dataset.xaxis("\\rm{Q_{x}}", 'A^{-1}') 184 self.current_dataset.yaxis("\\rm{Q_{y}}", 'A^{-1}') 185 self.current_dataset.zaxis("\\rm{Intensity}", "cm^{-1}") 186 182 self.current_dataset = self.set_default_2d_units(self.current_dataset) 187 183 self.current_dataset.x_bins = x_vals 188 184 self.current_dataset.y_bins = y_vals -
src/sas/sascalc/dataloader/readers/red2d_reader.py
rc8321cfc r058f6c3 317 317 318 318 # Units of axes 319 self.current_dataset.xaxis(r"\rm{Q_{x}}", 'A^{-1}') 320 self.current_dataset.yaxis(r"\rm{Q_{y}}", 'A^{-1}') 321 self.current_dataset.zaxis(r"\rm{Intensity}", "cm^{-1}") 319 self.current_dataset = self.set_default_2d_units(self.current_dataset) 322 320 323 321 # Store loading process information -
src/sas/sascalc/file_converter/nxcansas_writer.py
r574adc7 r2ca5d57b 8 8 import os 9 9 10 from sas.sascalc.dataloader.readers.cansas_reader_HDF5 import Reader as Cansas2Reader10 from sas.sascalc.dataloader.readers.cansas_reader_HDF5 import Reader 11 11 from sas.sascalc.dataloader.data_info import Data1D, Data2D 12 12 13 class NXcanSASWriter( Cansas2Reader):13 class NXcanSASWriter(Reader): 14 14 """ 15 15 A class for writing in NXcanSAS data files. Any number of data sets may be … … 87 87 entry[names[2]].attrs['units'] = units 88 88 89 valid_data = all([issubclass(d.__class__, (Data1D, Data2D)) for d in dataset]) 89 valid_data = all([issubclass(d.__class__, (Data1D, Data2D)) for d in 90 dataset]) 90 91 if not valid_data: 91 raise ValueError("All entries of dataset must be Data1D or Data2D objects") 92 raise ValueError("All entries of dataset must be Data1D or Data2D" 93 "objects") 92 94 93 95 # Get run name and number from first Data object … … 109 111 sasentry.attrs['version'] = '1.0' 110 112 111 i = 1 112 113 for data_obj in dataset: 114 data_entry = sasentry.create_group("sasdata{0:0=2d}".format(i)) 113 for i, data_obj in enumerate(dataset): 114 data_entry = sasentry.create_group("sasdata{0:0=2d}".format(i+1)) 115 115 data_entry.attrs['canSAS_class'] = 'SASdata' 116 116 if isinstance(data_obj, Data1D): … … 118 118 elif isinstance(data_obj, Data2D): 119 119 self._write_2d_data(data_obj, data_entry) 120 i += 1121 120 122 121 data_info = dataset[0] … … 148 147 sample_entry.create_dataset('details', data=details) 149 148 150 # Instrum ment metadata149 # Instrument metadata 151 150 instrument_entry = sasentry.create_group('sasinstrument') 152 151 instrument_entry.attrs['canSAS_class'] = 'SASinstrument' … … 176 175 units=data_info.source.beam_size_unit, write_fn=_write_h5_float) 177 176 178 179 177 # Collimation metadata 180 178 if len(data_info.collimation) > 0: 181 i = 1 182 for coll_info in data_info.collimation: 179 for i, coll_info in enumerate(data_info.collimation): 183 180 collimation_entry = instrument_entry.create_group( 184 'sascollimation{0:0=2d}'.format(i ))181 'sascollimation{0:0=2d}'.format(i + 1)) 185 182 collimation_entry.attrs['canSAS_class'] = 'SAScollimation' 186 183 if coll_info.length is not None: 187 184 _write_h5_float(collimation_entry, coll_info.length, 'SDD') 188 collimation_entry['SDD'].attrs['units'] = coll_info.length_unit 185 collimation_entry['SDD'].attrs['units'] =\ 186 coll_info.length_unit 189 187 if coll_info.name is not None: 190 188 collimation_entry['name'] = _h5_string(coll_info.name) 191 189 else: 192 # Create a blank one - at least 1 set of collimation metadata 193 # required by format 194 collimation_entry = instrument_entry.create_group('sascollimation01') 190 # Create a blank one - at least 1 collimation required by format 191 instrument_entry.create_group('sascollimation01') 195 192 196 193 # Detector metadata 197 194 if len(data_info.detector) > 0: 198 195 i = 1 199 for det_info in data_info.detector:196 for i, det_info in enumerate(data_info.detector): 200 197 detector_entry = instrument_entry.create_group( 201 'sasdetector{0:0=2d}'.format(i ))198 'sasdetector{0:0=2d}'.format(i + 1)) 202 199 detector_entry.attrs['canSAS_class'] = 'SASdetector' 203 200 if det_info.distance is not None: 204 201 _write_h5_float(detector_entry, det_info.distance, 'SDD') 205 detector_entry['SDD'].attrs['units'] = det_info.distance_unit 202 detector_entry['SDD'].attrs['units'] =\ 203 det_info.distance_unit 206 204 if det_info.name is not None: 207 205 detector_entry['name'] = _h5_string(det_info.name) … … 209 207 detector_entry['name'] = _h5_string('') 210 208 if det_info.slit_length is not None: 211 _write_h5_float(detector_entry, det_info.slit_length, 'slit_length') 212 detector_entry['slit_length'].attrs['units'] = det_info.slit_length_unit 209 _write_h5_float(detector_entry, det_info.slit_length, 210 'slit_length') 211 detector_entry['slit_length'].attrs['units'] =\ 212 det_info.slit_length_unit 213 213 _write_h5_vector(detector_entry, det_info.offset) 214 214 # NXcanSAS doesn't save information about pitch, only roll … … 224 224 names=['x_pixel_size', 'y_pixel_size'], 225 225 write_fn=_write_h5_float, units=det_info.pixel_size_unit) 226 227 i += 1228 226 else: 229 227 # Create a blank one - at least 1 detector required by format … … 231 229 detector_entry.attrs['canSAS_class'] = 'SASdetector' 232 230 detector_entry.attrs['name'] = '' 231 232 # Process meta data 233 for i, process in enumerate(data_info.process): 234 process_entry = sasentry.create_group('sasprocess{0:0=2d}'.format( 235 i + 1)) 236 process_entry.attrs['canSAS_class'] = 'SASprocess' 237 if process.name: 238 name = _h5_string(process.name) 239 process_entry.create_dataset('name', data=name) 240 if process.date: 241 date = _h5_string(process.date) 242 process_entry.create_dataset('date', data=date) 243 if process.description: 244 desc = _h5_string(process.description) 245 process_entry.create_dataset('description', data=desc) 246 for j, term in enumerate(process.term): 247 # Don't save empty terms 248 if term: 249 h5_term = _h5_string(term) 250 process_entry.create_dataset('term{0:0=2d}'.format( 251 j + 1), data=h5_term) 252 for j, note in enumerate(process.notes): 253 # Don't save empty notes 254 if note: 255 h5_note = _h5_string(note) 256 process_entry.create_dataset('note{0:0=2d}'.format( 257 j + 1), data=h5_note) 258 259 # Transmission Spectrum 260 for i, trans in enumerate(data_info.trans_spectrum): 261 trans_entry = sasentry.create_group( 262 'sastransmission_spectrum{0:0=2d}'.format(i + 1)) 263 trans_entry.attrs['canSAS_class'] = 'SAStransmission_spectrum' 264 trans_entry.attrs['signal'] = 'T' 265 trans_entry.attrs['T_axes'] = 'T' 266 trans_entry.attrs['name'] = trans.name 267 if trans.timestamp is not '': 268 trans_entry.attrs['timestamp'] = trans.timestamp 269 transmission = trans_entry.create_dataset('T', 270 data=trans.transmission) 271 transmission.attrs['unertainties'] = 'Tdev' 272 trans_entry.create_dataset('Tdev', 273 data=trans.transmission_deviation) 274 trans_entry.create_dataset('lambda', data=trans.wavelength) 233 275 234 276 note_entry = sasentry.create_group('sasnote'.format(i)) … … 254 296 data_entry.attrs['signal'] = 'I' 255 297 data_entry.attrs['I_axes'] = 'Q' 256 data_entry.attrs['I_uncertainties'] = 'Idev' 257 data_entry.attrs['Q_indicies'] = 0 258 259 dI = data_obj.dy 260 if dI is None: 261 dI = np.zeros((data_obj.y.shape)) 262 263 data_entry.create_dataset('Q', data=data_obj.x) 264 data_entry.create_dataset('I', data=data_obj.y) 265 data_entry.create_dataset('Idev', data=dI) 298 data_entry.attrs['Q_indices'] = [0] 299 q_entry = data_entry.create_dataset('Q', data=data_obj.x) 300 q_entry.attrs['units'] = data_obj.x_unit 301 i_entry = data_entry.create_dataset('I', data=data_obj.y) 302 i_entry.attrs['units'] = data_obj.y_unit 303 if data_obj.dy is not None: 304 i_entry.attrs['uncertainties'] = 'Idev' 305 i_dev_entry = data_entry.create_dataset('Idev', data=data_obj.dy) 306 i_dev_entry.attrs['units'] = data_obj.y_unit 307 if data_obj.dx is not None: 308 q_entry.attrs['resolutions'] = 'dQ' 309 dq_entry = data_entry.create_dataset('dQ', data=data_obj.dx) 310 dq_entry.attrs['units'] = data_obj.x_unit 311 elif data_obj.dxl is not None: 312 q_entry.attrs['resolutions'] = ['dQl','dQw'] 313 dql_entry = data_entry.create_dataset('dQl', data=data_obj.dxl) 314 dql_entry.attrs['units'] = data_obj.x_unit 315 dqw_entry = data_entry.create_dataset('dQw', data=data_obj.dxw) 316 dqw_entry.attrs['units'] = data_obj.x_unit 266 317 267 318 def _write_2d_data(self, data, data_entry): … … 273 324 """ 274 325 data_entry.attrs['signal'] = 'I' 275 data_entry.attrs['I_axes'] = 'Q,Q' 276 data_entry.attrs['I_uncertainties'] = 'Idev' 277 data_entry.attrs['Q_indicies'] = [0,1] 326 data_entry.attrs['I_axes'] = 'Qx,Qy' 327 data_entry.attrs['Q_indices'] = [0,1] 278 328 279 329 (n_rows, n_cols) = (len(data.y_bins), len(data.x_bins)) … … 288 338 raise ValueError("Unable to calculate dimensions of 2D data") 289 339 290 I = np.reshape(data.data, (n_rows, n_cols)) 291 dI = np.zeros((n_rows, n_cols)) 292 if not all(data.err_data == [None]): 293 dI = np.reshape(data.err_data, (n_rows, n_cols)) 294 qx = np.reshape(data.qx_data, (n_rows, n_cols)) 340 intensity = np.reshape(data.data, (n_rows, n_cols)) 341 qx = np.reshape(data.qx_data, (n_rows, n_cols)) 295 342 qy = np.reshape(data.qy_data, (n_rows, n_cols)) 296 343 297 I_entry = data_entry.create_dataset('I', data=I) 298 I_entry.attrs['units'] = data.I_unit 299 Qx_entry = data_entry.create_dataset('Qx', data=qx) 300 Qx_entry.attrs['units'] = data.Q_unit 301 Qy_entry = data_entry.create_dataset('Qy', data=qy) 302 Qy_entry.attrs['units'] = data.Q_unit 303 Idev_entry = data_entry.create_dataset('Idev', data=dI) 304 Idev_entry.attrs['units'] = data.I_unit 344 i_entry = data_entry.create_dataset('I', data=intensity) 345 i_entry.attrs['units'] = data.I_unit 346 qx_entry = data_entry.create_dataset('Qx', data=qx) 347 qx_entry.attrs['units'] = data.Q_unit 348 qy_entry = data_entry.create_dataset('Qy', data=qy) 349 qy_entry.attrs['units'] = data.Q_unit 350 if data.err_data is not None and not all(data.err_data == [None]): 351 d_i = np.reshape(data.err_data, (n_rows, n_cols)) 352 i_entry.attrs['uncertainties'] = 'Idev' 353 i_dev_entry = data_entry.create_dataset('Idev', data=d_i) 354 i_dev_entry.attrs['units'] = data.I_unit 355 if data.dqx_data is not None and not all(data.dqx_data == [None]): 356 qx_entry.attrs['resolutions'] = 'dQx' 357 dqx_entry = data_entry.create_dataset('dQx', data=data.dqx_data) 358 dqx_entry.attrs['units'] = data.Q_unit 359 if data.dqy_data is not None and not all(data.dqy_data == [None]): 360 qy_entry.attrs['resolutions'] = 'dQy' 361 dqy_entry = data_entry.create_dataset('dQy', data=data.dqy_data) 362 dqy_entry.attrs['units'] = data.Q_unit -
src/sas/sasgui/guiframe/gui_manager.py
rb963b20 rfeec1cb 46 46 from sas.sasgui.guiframe.CategoryManager import CategoryManager 47 47 from sas.sascalc.dataloader.loader import Loader 48 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 48 49 from sas.sasgui.guiframe.proxy import Connection 49 50 … … 2422 2423 default_name = fname 2423 2424 wildcard = "Text files (*.txt)|*.txt|"\ 2424 "CanSAS 1D files(*.xml)|*.xml" 2425 path = None 2425 "CanSAS 1D files (*.xml)|*.xml|"\ 2426 "NXcanSAS files (*.h5)|*.h5|" 2427 options = {0: ".txt", 2428 1: ".xml", 2429 2: ".h5"} 2426 2430 dlg = wx.FileDialog(self, "Choose a file", 2427 2431 self._default_save_location, … … 2433 2437 # This is MAC Fix 2434 2438 ext_num = dlg.GetFilterIndex() 2435 if ext_num == 0: 2436 ext_format = '.txt' 2437 else: 2438 ext_format = '.xml' 2439 2440 ext_format = options[ext_num] 2439 2441 path = os.path.splitext(path)[0] + ext_format 2440 2442 mypath = os.path.basename(path) 2441 2442 # Instantiate a loader 2443 loader = Loader() 2444 ext_format = ".txt" 2445 if os.path.splitext(mypath)[1].lower() == ext_format: 2443 fName = os.path.splitext(path)[0] + ext_format 2444 2445 if os.path.splitext(mypath)[1].lower() == options[0]: 2446 2446 # Make sure the ext included in the file name 2447 2447 # especially on MAC 2448 fName = os.path.splitext(path)[0] + ext_format2449 2448 self._onsaveTXT(data, fName) 2450 ext_format = ".xml" 2451 if os.path.splitext(mypath)[1].lower() == ext_format: 2449 elif os.path.splitext(mypath)[1].lower() == options[1]: 2452 2450 # Make sure the ext included in the file name 2453 2451 # especially on MAC 2454 fName = os.path.splitext(path)[0] + ext_format 2452 # Instantiate a loader 2453 loader = Loader() 2455 2454 loader.save(fName, data, ext_format) 2455 elif os.path.splitext(mypath)[1].lower() == options[2]: 2456 nxcansaswriter = NXcanSASWriter() 2457 nxcansaswriter.write([data], fName) 2456 2458 try: 2457 2459 self._default_save_location = os.path.dirname(path) … … 2528 2530 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2529 2531 text += '\nData Points:\n' 2530 x_st = "X" 2532 text += "<index> \t<X> \t<Y> \t<dY> \t<dX" 2533 if data.dxl is not None and data.dxw is not None: 2534 text += "l> \t<dxw" 2535 text += ">\n" 2531 2536 for index in range(len(data.x)): 2532 2537 if data.dy is not None and len(data.dy) > index: … … 2539 2544 dx_val = 0.0 2540 2545 if data.dxl is not None and len(data.dxl) > index: 2541 if index == 0:2542 x_st = "Xl"2543 2546 dx_val = data.dxl[index] 2544 elif data.dxw is not None and len(data.dxw) > index: 2545 if index == 0: 2546 x_st = "Xw" 2547 dx_val = data.dxw[index] 2548 2549 if index == 0: 2550 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2547 if data.dxw is not None and len(data.dxw) > index: 2548 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2549 2551 2550 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2552 2551 data.x[index], … … 2565 2564 """ 2566 2565 default_name = fname 2567 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2566 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2567 "NXcanSAS files (*.h5)|*.h5|" 2568 2568 dlg = wx.FileDialog(self, "Choose a file", 2569 2569 self._default_save_location, … … 2577 2577 if ext_num == 0: 2578 2578 ext_format = '.dat' 2579 elif ext_num == 1: 2580 ext_format = '.h5' 2579 2581 else: 2580 2582 ext_format = '' … … 2584 2586 # Instantiate a loader 2585 2587 loader = Loader() 2586 2587 ext_format = ".dat" 2588 if os.path.splitext(mypath)[1].lower() == ext_format: 2588 if os.path.splitext(mypath)[1].lower() == '.dat': 2589 2589 # Make sure the ext included in the file name 2590 2590 # especially on MAC 2591 2591 fileName = os.path.splitext(path)[0] + ext_format 2592 2592 loader.save(fileName, data, ext_format) 2593 elif os.path.splitext(mypath)[1].lower() == '.h5': 2594 # Make sure the ext included in the file name 2595 # especially on MAC 2596 fileName = os.path.splitext(path)[0] + ext_format 2597 nxcansaswriter = NXcanSASWriter() 2598 nxcansaswriter.write([data], fileName) 2593 2599 try: 2594 2600 self._default_save_location = os.path.dirname(path) -
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r2924532 r02c1608e 239 239 self.load_complete(output=output, message="Loading data complete!", 240 240 info="info") 241 else:242 self.load_complete(output=None, message=error_message, info="error")243 241 244 242 def load_update(self, message="", info="warning"): -
test/sasdataloader/test/utest_abs_reader.py
rbd5c3b1 rbd5c3b1 118 118 self.assertEqual(self.data.detector[0].beam_center.y, center_y) 119 119 120 self.assertEqual(self.data.I_unit, ' 1/cm')120 self.assertEqual(self.data.I_unit, 'cm^{-1}') 121 121 self.assertEqual(self.data.data[0], 1.57831) 122 122 self.assertEqual(self.data.data[1], 2.70983) -
test/sasdataloader/test/utest_averaging.py
rf53d684 r7fd5e2a 106 106 107 107 def setUp(self): 108 filepath = find(' MAR07232_rest.h5')108 filepath = find('test_data//MAR07232_rest.h5') 109 109 self.data_list = Loader().load(filepath) 110 110 self.data = self.data_list[0] … … 121 121 122 122 o = r(self.data) 123 filepath = find(' ring_testdata.txt')123 filepath = find('test_data//ring_testdata.txt') 124 124 answer_list = Loader().load(filepath) 125 125 answer = answer_list[0] … … 142 142 o = r(self.data) 143 143 144 filepath = find(' avg_testdata.txt')144 filepath = find('test_data//avg_testdata.txt') 145 145 answer = Loader().load(filepath)[0] 146 146 for i in range(r.nbins_phi): … … 158 158 s, ds, npoints = r(self.data) 159 159 self.assertAlmostEqual(s, 34.278990899999997, 4) 160 self.assertAlmostEqual(ds, 7.8007981835194293, 4)160 self.assertAlmostEqual(ds, 8.237259999538685, 4) 161 161 self.assertAlmostEqual(npoints, 324.0000, 4) 162 162 … … 164 164 s, ds = r(self.data) 165 165 self.assertAlmostEqual(s, 0.10579935462962962, 4) 166 self.assertAlmostEqual(ds, 0.02 4076537603455028, 4)166 self.assertAlmostEqual(ds, 0.02542364197388483, 4) 167 167 168 168 def test_slabX(self): … … 177 177 o = r(self.data) 178 178 179 filepath = find(' slabx_testdata.txt')179 filepath = find('test_data//slabx_testdata.txt') 180 180 answer = Loader().load(filepath)[0] 181 181 for i in range(len(o.x)): … … 195 195 o = r(self.data) 196 196 197 filepath = find(' slaby_testdata.txt')197 filepath = find('test_data//slaby_testdata.txt') 198 198 answer = Loader().load(filepath)[0] 199 199 for i in range(len(o.x)): … … 221 221 o = r(self.data) 222 222 223 filepath = find(' ring_testdata.txt')223 filepath = find('test_data//ring_testdata.txt') 224 224 answer = Loader().load(filepath)[0] 225 225 for i in range(len(o.x)): … … 238 238 o = r(self.data) 239 239 240 filepath = find(' sectorphi_testdata.txt')240 filepath = find('test_data//sectorphi_testdata.txt') 241 241 answer = Loader().load(filepath)[0] 242 242 for i in range(len(o.x)): … … 255 255 o = r(self.data) 256 256 257 filepath = find(' sectorq_testdata.txt')257 filepath = find('test_data//sectorq_testdata.txt') 258 258 answer = Loader().load(filepath)[0] 259 259 for i in range(len(o.x)): -
test/sasdataloader/test/utest_cansas.py
rf53d684 r2ca5d57b 91 91 reader = XMLreader(self.xml_valid, self.schema_1_0) 92 92 valid = reader.validate_xml() 93 if valid: 94 self.assertTrue(valid) 95 else: 96 self.assertFalse(valid) 93 self.assertTrue(valid) 97 94 98 95 def _check_data(self, data): … … 193 190 def test_save_cansas_v1_0(self): 194 191 xmlreader = XMLreader(self.isis_1_0, self.schema_1_0) 195 valid = xmlreader.validate_xml() 196 self.assertTrue(valid) 192 self.assertTrue(xmlreader.validate_xml()) 197 193 reader_generic = Loader() 198 194 dataloader = reader_generic.load(self.isis_1_0) … … 207 203 return_data = reader2.read(self.write_1_0_filename) 208 204 written_data = return_data[0] 209 XMLreader(self.write_1_0_filename, self.schema_1_0) 210 valid = xmlreader.validate_xml() 211 self.assertTrue(valid) 205 xmlreader = XMLreader(self.write_1_0_filename, self.schema_1_0) 206 self.assertTrue(xmlreader.validate_xml()) 212 207 self._check_data(written_data) 213 208 if os.path.isfile(self.write_1_0_filename): … … 260 255 self.loader = Loader() 261 256 self.datafile_basic = find("simpleexamplefile.h5") 262 self.datafile_multiplesasentry = find("cansas_1Dand2D_samedatafile.h5") 263 self.datafile_multiplesasdata = find("cansas_1Dand2D_samesasentry.h5") 264 self.datafile_multiplesasdata_multiplesasentry = find("cansas_1Dand2D_multiplesasentry_multiplesasdata.h5") 257 self.datafile_multiplesasentry = find( 258 "test_data//nxcansas_1Dand2D_multisasentry.h5") 259 self.datafile_multiplesasdata = find( 260 "test_data//nxcansas_1Dand2D_multisasdata.h5") 261 self.datafile_multiplesasdata_multiplesasentry = find( 262 "test_data//nxcansas_1Dand2D_multisasentry_multisasdata.h5") 265 263 266 264 def test_real_data(self): … … 273 271 self._check_multiple_data(self.data[0]) 274 272 self._check_multiple_data(self.data[1]) 275 self._check_1d_data(self.data[0]) 273 if isinstance(self.data[0], Data1D): 274 self._check_1d_data(self.data[0]) 275 self._check_2d_data(self.data[1]) 276 else: 277 self._check_1d_data(self.data[1]) 278 self._check_2d_data(self.data[0]) 279 280 def test_multiple_sasdatas(self): 281 self.data = self.loader.load(self.datafile_multiplesasdata) 282 self.assertTrue(len(self.data) == 2) 283 self._check_multiple_data(self.data[0]) 284 self._check_multiple_data(self.data[1]) 285 if isinstance(self.data[0], Data1D): 286 self._check_1d_data(self.data[0]) 287 self._check_2d_data(self.data[1]) 288 else: 289 self._check_1d_data(self.data[1]) 290 self._check_2d_data(self.data[0]) 291 292 def test_multiple_sasentries_multiplesasdatas(self): 293 self.data = self.loader.load( 294 self.datafile_multiplesasdata_multiplesasentry) 295 self.assertTrue(len(self.data) == 4) 296 self._check_multiple_data(self.data[0]) 297 self._check_multiple_data(self.data[1]) 298 self._check_multiple_data(self.data[2]) 299 self._check_multiple_data(self.data[3]) 300 for data in self.data: 301 if isinstance(data, Data1D): 302 self._check_1d_data(data) 303 else: 304 self._check_2d_data(data) 276 305 277 306 def _check_multiple_data(self, data): … … 281 310 self.assertTrue(data.instrument == "SANS2D") 282 311 self.assertTrue(data.source.radiation == "Spallation Neutron Source") 283 self.assertTrue(len(data.detector) == 1) 284 self.assertTrue(data.detector[0].name == "rear-detector") 285 self.assertTrue(data.detector[0].distance == 4.385281) 286 self.assertTrue(data.detector[0].distance_unit == 'm') 312 self.assertTrue(len(data.detector) == 2) 313 self.assertTrue(data.detector[0].name == "rear-detector" 314 or data.detector[1].name == "rear-detector") 315 self.assertTrue(data.detector[0].name == "front-detector" 316 or data.detector[1].name == "front-detector") 317 self.assertAlmostEqual(data.detector[0].distance + 318 data.detector[1].distance, 7230.54, 2) 319 self.assertTrue(data.detector[0].distance_unit == 'mm') 287 320 self.assertTrue(len(data.trans_spectrum) == 1) 288 321 289 322 def _check_1d_data(self, data): 290 self.assertTrue(isinstance(data, Data1D))291 323 self.assertTrue(len(data.x) == 66) 292 324 self.assertTrue(len(data.x) == len(data.y)) 293 self.assertTrue(data.dy[10] == 0.20721 350111248701)294 self.assertTrue(data.y[10] == 24.193 889608153476)295 self.assertTrue(data.x[10] == 0.0089811 27988654792)325 self.assertTrue(data.dy[10] == 0.207214) 326 self.assertTrue(data.y[10] == 24.1939) 327 self.assertTrue(data.x[10] == 0.00898113) 296 328 297 329 def _check_2d_data(self, data): 298 330 self.assertTrue(isinstance(data, Data2D)) 299 self.assertTrue(len(data.x) == 66) 300 self.assertTrue(len(data.x) == len(data.y)) 301 self.assertTrue(data.dy[10] == 0.20721350111248701) 302 self.assertTrue(data.y[10] == 24.193889608153476) 303 self.assertTrue(data.x[10] == 0.008981127988654792) 331 self.assertTrue(len(data.q_data) == 150*150) 332 self.assertTrue(len(data.q_data) == len(data.data)) 333 self.assertAlmostEqual(data.err_data[10], 0.186723989418) 334 self.assertAlmostEqual(data.data[10], 0.465181) 335 self.assertAlmostEqual(data.qx_data[10], -0.129) 336 self.assertAlmostEqual(data.qy_data[10], -0.149) 304 337 305 338 def _check_example_data(self, data): -
test/sasdataloader/test/utest_red2d_reader.py
rf53d684 rfc51d06 31 31 self.assertEqual(f.qx_data[0],-0.03573497) 32 32 self.assertEqual(f.qx_data[36863],0.2908819) 33 self.assertEqual(f.Q_unit, ' 1/A')34 self.assertEqual(f.I_unit, ' 1/cm')33 self.assertEqual(f.Q_unit, 'A^{-1}') 34 self.assertEqual(f.I_unit, 'cm^{-1}') 35 35 36 36 self.assertEqual(f.meta_data['loader'],"IGOR/DAT 2D Q_map")
Note: See TracChangeset
for help on using the changeset viewer.