Changeset d508be9 in sasview for DataLoader/readers
- Timestamp:
- Apr 10, 2009 3:44:31 PM (16 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:
- d0fd4c9
- Parents:
- 88e289c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/readers/ascii_reader.py
r892f246 rd508be9 94 94 #Initialize counters for data lines and header lines. 95 95 is_data = False #Has more than 3 lines 96 mum_data_lines = 3 # More than "3" lines of data is considered as actual data unless there is only less lines of data 97 98 i=-1 # To count # of current data candidate lines 99 i1=-1 # To count total # of previous data candidate lines 100 j=-1 # To count # of header lines 101 j1=-1 # Helps to count # of header lines 96 mum_data_lines = 3 # More than "3" lines of data is considered as actual data unless that is the only data 97 98 i=-1 # To count # of current data candidate lines 99 i1=-1 # To count total # of previous data candidate lines 100 j=-1 # To count # of header lines 101 j1=-1 # Helps to count # of header lines 102 lentoks = 2 # minimum required number of columns of data; ( <= 4). 102 103 103 104 for line in lines: … … 109 110 _y = float(toks[1]) 110 111 112 #To reject the line when reader meets less columns of data 113 if lentoks == 3: 114 _dy = float(toks[2]) 115 elif lentoks == 4: 116 _dx = float(toks[3]) 117 111 118 #Reset the header line counters 112 119 if j == j1: … … 116 123 if i > 1: 117 124 is_data = True 118 125 119 126 if data_conv_q is not None: 120 127 _x = data_conv_q(_x, units=output.x_unit) … … 161 168 has_error_dx = False if _dx == None else True 162 169 170 #After talked with PB, we decided to take care of only 4 columns of data for now. 171 #number of columns in the current line 172 if len(toks)>= 4: 173 new_lentoks = 4 174 else: 175 new_lentoks = len(toks) 176 177 #If the previous columns are less than the current, mark the previous as non-data and reset the dependents. 178 if lentoks < new_lentoks : 179 if is_data == False: 180 i = -1 181 i1 = 0 182 j = -1 183 j1 = -1 184 163 185 #Delete the previously stored lines of data candidates if is not data. 164 186 if i < 0 and -1< i1 < mum_data_lines and is_data == False: … … 219 241 pass 220 242 tdx = numpy.append(tdx, _dx) 243 244 #reset i1 and flag lentoks for the next 245 if lentoks < new_lentoks : 246 if is_data == False: 247 i1 = -1 248 if len(toks)>= 4: 249 lentoks = 4 250 else: 251 lentoks = len(toks) 221 252 222 253 #Reset # of header lines and counts # of data candidate lines … … 230 261 if is_data == True: 231 262 break 263 lentoks = 2 232 264 #Counting # of header lines 233 265 j+=1 … … 265 297 dx[i] = tdx[ind[i]] 266 298 299 267 300 #Data 268 301 output.x = x … … 279 312 else: 280 313 output.yaxis("\\rm{Intensity}","cm^{-1}") 281 314 print "output",output 282 315 return output 283 316
Note: See TracChangeset
for help on using the changeset viewer.