- Timestamp:
- Sep 23, 2017 10:24:21 AM (7 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f00072f
- Parents:
- a50da82
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/red2d_reader.py
r8641070 rc8321cfc 10 10 ###################################################################### 11 11 import os 12 import math 13 import time 14 12 15 import numpy as np 13 import math 14 from sas.sascalc.dataloader.data_info import plottable_2D, DataInfo, Detector 15 from sas.sascalc.dataloader.file_reader_base_class import FileReader 16 from sas.sascalc.dataloader.loader_exceptions import FileContentsException 17 18 # Look for unit converter 19 has_converter = True 20 try: 21 from sas.sascalc.data_util.nxsunit import Converter 22 except: 23 has_converter = False 16 17 from sas.sascalc.data_util.nxsunit import Converter 18 19 from ..data_info import plottable_2D, DataInfo, Detector 20 from ..file_reader_base_class import FileReader 21 from ..loader_exceptions import FileContentsException 24 22 25 23 … … 31 29 try: 32 30 return float(x_point) 33 except :31 except Exception: 34 32 return 0 35 33 … … 51 49 :param data: data2D 52 50 """ 53 import time54 51 # Write the file 55 52 try: … … 119 116 try: 120 117 wavelength = float(line_toks[1]) 121 # Units 122 if has_converter == True and \ 123 self.current_datainfo.source.wavelength_unit != 'A': 118 # Wavelength is stored in angstroms; convert if necessary 119 if self.current_datainfo.source.wavelength_unit != 'A': 124 120 conv = Converter('A') 125 121 wavelength = conv(wavelength, 126 122 units=self.current_datainfo.source.wavelength_unit) 127 except: 128 #Not required 129 pass 130 # Distance in mm 123 except Exception: 124 pass # Not required 131 125 try: 132 126 distance = float(line_toks[3]) 133 # Units134 if has_converter == True andself.current_datainfo.detector[0].distance_unit != 'm':127 # Distance is stored in meters; convert if necessary 128 if self.current_datainfo.detector[0].distance_unit != 'm': 135 129 conv = Converter('m') 136 130 distance = conv(distance, 137 131 units=self.current_datainfo.detector[0].distance_unit) 138 except: 139 #Not required 140 pass 141 142 # Distance in meters 132 except Exception: 133 pass # Not required 134 143 135 try: 144 136 transmission = float(line_toks[4]) 145 except: 146 #Not required 147 pass 137 except Exception: 138 pass # Not required 148 139 149 140 if line.count("LAMBDA") > 0: … … 170 161 171 162 ## Read and get data. 172 if data_started == True:163 if data_started: 173 164 line_toks = line.split() 174 165 if len(line_toks) == 0: … … 178 169 col_num = len(line_toks) 179 170 break 171 180 172 # Make numpy array to remove header lines using index 181 173 lines_array = np.array(lines) … … 203 195 # Change it(string) into float 204 196 #data_list = map(float,data_list) 205 data_list1 = map(check_point, data_list)197 data_list1 = list(map(check_point, data_list)) 206 198 207 199 # numpy array form … … 211 203 try: 212 204 data_point = data_array.reshape(row_num, col_num).transpose() 213 except :205 except Exception: 214 206 msg = "red2d_reader can't read this file: Incorrect number of data points provided." 215 207 raise FileContentsException(msg) … … 325 317 326 318 # Units of axes 327 self.current_dataset.xaxis( "\\rm{Q_{x}}", 'A^{-1}')328 self.current_dataset.yaxis( "\\rm{Q_{y}}", 'A^{-1}')329 self.current_dataset.zaxis( "\\rm{Intensity}", "cm^{-1}")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}") 330 322 331 323 # Store loading process information
Note: See TracChangeset
for help on using the changeset viewer.