Changeset 892f246 in sasview
- Timestamp:
- Apr 9, 2009 9:23:01 AM (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:
- b570686
- Parents:
- 7c845cb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/readers/ascii_reader.py
r28caa03 r892f246 54 54 lines = buff.split('\n') 55 55 56 #Jae could not find python universal line spliter: keep the below for now 56 57 # some ascii data has \r line separator, try it when it has only one line 57 58 if len(lines) < 2 : … … 91 92 has_error_dy = None 92 93 94 #Initialize counters for data lines and header lines. 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 102 93 103 for line in lines: 94 104 toks = line.split() 105 95 106 try: 107 96 108 _x = float(toks[0]) 97 109 _y = float(toks[1]) 98 110 111 #Reset the header line counters 112 if j == j1: 113 j = 0 114 j1 = 0 115 116 if i > 1: 117 is_data = True 118 99 119 if data_conv_q is not None: 100 120 _x = data_conv_q(_x, units=output.x_unit) … … 140 160 if has_error_dx == None: 141 161 has_error_dx = False if _dx == None else True 142 162 163 #Delete the previously stored lines of data candidates if is not data. 164 if i < 0 and -1< i1 < mum_data_lines and is_data == False: 165 try: 166 x= numpy.zeros(0) 167 y= numpy.zeros(0) 168 169 except: 170 pass 171 143 172 x = numpy.append(x, _x) 144 173 y = numpy.append(y, _y) 174 145 175 if has_error_dy == True: 176 #Delete the previously stored lines of data candidates if is not data. 177 if i < 0 and -1< i1 < mum_data_lines and is_data== False: 178 try: 179 dy = numpy.zeros(0) 180 except: 181 pass 146 182 dy = numpy.append(dy, _dy) 183 147 184 if has_error_dx == True: 185 #Delete the previously stored lines of data candidates if is not data. 186 if i < 0 and -1< i1 < mum_data_lines and is_data== False: 187 try: 188 dx = numpy.zeros(0) 189 except: 190 pass 148 191 dx = numpy.append(dx, _dx) 149 192 150 193 #Same for temp. 194 #Delete the previously stored lines of data candidates if is not data. 195 if i < 0 and -1< i1 < mum_data_lines and is_data== False: 196 try: 197 tx = numpy.zeros(0) 198 ty = numpy.zeros(0) 199 except: 200 pass 201 151 202 tx = numpy.append(tx, _x) 152 203 ty = numpy.append(ty, _y) 204 153 205 if has_error_dy == True: 206 #Delete the previously stored lines of data candidates if is not data. 207 if i < 0 and -1<i1 < mum_data_lines and is_data== False: 208 try: 209 tdy = numpy.zeros(0) 210 except: 211 pass 154 212 tdy = numpy.append(tdy, _dy) 155 213 if has_error_dx == True: 214 #Delete the previously stored lines of data candidates if is not data. 215 if i < 0 and -1< i1 < mum_data_lines and is_data== False: 216 try: 217 tdx = numpy.zeros(0) 218 except: 219 pass 156 220 tdx = numpy.append(tdx, _dx) 157 221 222 #Reset # of header lines and counts # of data candidate lines 223 if j == 0 and j1 ==0: 224 i1 = i + 1 225 i+=1 226 158 227 except: 228 229 # It is data and meet non - number, then stop reading 230 if is_data == True: 231 break 232 #Counting # of header lines 233 j+=1 234 if j == j1+1: 235 j1 = j 236 else: 237 j = -1 238 #Reset # of lines of data candidates 239 i = -1 240 159 241 # Couldn't parse this line, skip it 160 242 pass 161 243 244 162 245 163 246 # Sanity check … … 181 264 if has_error_dx == True: 182 265 dx[i] = tdx[ind[i]] 183 266 267 #Data 184 268 output.x = x 185 269 output.y = y … … 197 281 198 282 return output 283 199 284 else: 200 285 raise RuntimeError, "%s is not a file" % path
Note: See TracChangeset
for help on using the changeset viewer.