Changeset bb03739 in sasview for DataLoader/readers
- Timestamp:
- Jul 1, 2008 7:01:30 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:
- cbe6dbe
- Parents:
- 2a92852
- Location:
- DataLoader/readers
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/readers/DataReader.py
r11a0319 rbb03739 3 3 from copy import deepcopy 4 4 import math 5 class DataReader:5 class Reader: 6 6 """ Simple data reader for Igor data files """ 7 7 -
DataLoader/readers/TXT3_Reader.py
r11a0319 rbb03739 15 15 self.filename = filename 16 16 17 17 18 def read(self,path, format=None): 18 19 """ Store the values loaded from file in local variables 19 20 can read 3 columns of data 20 21 """ 22 21 23 if not path == None: 22 input_f = open(path,'r') 23 buff = input_f.read() 24 lines = buff.split('\n') 25 self.x=[] 26 self.y=[] 27 self.dx = [] 28 self.dy=[] 29 value="can't read" 30 for line in lines: 31 toks = line.split() 32 try: 33 x = float(toks[0]) 34 y = float(toks[1]) 35 dy = float(toks[2]) 36 37 self.x.append(x) 38 self.y.append(y) 39 self.dy.append(dy) 40 41 except: 42 print "READ ERROR", line 43 44 self.dx = numpy.zeros(len(self.x)) 45 # Sanity check 46 if not len(self.x) == len(self.dx): 47 raise ValueError, "x and dx have different length" 48 if not len(self.y) == len(self.dy): 49 raise ValueError, "y and dy have different length" 50 51 if (self.x==[] or self.y==[])and (self.dy==[]): 24 read_it = False 25 ext=['.txt','.dat'] 26 for item in ext: 27 if path.lower().find(item)>=0: 28 read_it = True 29 print "this is the flag",read_it, path.lower() 30 if read_it==False: 52 31 raise ValueError, "txtReader can't read" 53 32 else: 54 #msg="txtReader Reading:\n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n" 55 #return msg 56 print "TXT3_Reader reading: \n" 57 return self.x,self.y,self.dy 33 input_f = open(path,'r') 34 buff = input_f.read() 35 lines = buff.split('\n') 36 self.x=[] 37 self.y=[] 38 self.dx = [] 39 self.dy=[] 40 value="can't read" 41 for line in lines: 42 toks = line.split() 43 try: 44 x = float(toks[0]) 45 y = float(toks[1]) 46 dy = float(toks[2]) 47 48 self.x.append(x) 49 self.y.append(y) 50 self.dy.append(dy) 51 52 except: 53 print "READ ERROR", line 54 55 self.dx = numpy.zeros(len(self.x)) 56 # Sanity check 57 if not len(self.x) == len(self.dx): 58 raise ValueError, "x and dx have different length" 59 if not len(self.y) == len(self.dy): 60 raise ValueError, "y and dy have different length" 61 62 if (self.x==[] or self.y==[])and (self.dy==[]): 63 raise ValueError, "txtReader can't read" 64 else: 65 #msg="txtReader Reading:\n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n" 66 #return msg 67 print "TXT3_Reader reading: \n" 68 return self.x,self.y,self.dy 58 69 59 70 -
DataLoader/readers/danse_reader.py
r11a0319 rbb03739 40 40 ## Error on each pixel 41 41 error = None 42 class DataReader:42 class Reader: 43 43 """ 44 44 Example data manipulation -
DataLoader/readers/tiff_reader.py
r11a0319 rbb03739 36 36 error = None 37 37 38 class DataReader:38 class Reader: 39 39 """ 40 40 Example data manipulation
Note: See TracChangeset
for help on using the changeset viewer.