Changeset 16d8e5f in sasview
- Timestamp:
- Jul 10, 2008 4:41:18 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:
- 83ca047
- Parents:
- 93f0a586
- Location:
- DataLoader
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/loader.py
rd3619421 r16d8e5f 94 94 dir = 'readers' 95 95 dir=os.path.join(os.path.dirname(os.path.abspath(__file__)),dir) 96 96 97 97 if (reader==None and ext==None) or dir:#1st load 98 98 plugReader=None … … 202 202 os.path.isfile( os.path.abspath(path)) 203 203 except: 204 raise ValueError," file 204 raise ValueError," file path unknown" 205 205 206 206 if format is None: -
DataLoader/plugins/TXT2_Reader.py
r8d6440f r16d8e5f 3 3 import string,numpy 4 4 import logging 5 class ReaderInfo: 6 """ 7 This class is a container of data. It stores values read from files 8 """ 9 ## Wavelength [A] 10 wavelength = 0.0 11 ## Number of x bins 12 xbins = 128 13 ## Number of y bins 14 ybins = 128 15 ## Beam center X [pixel number] 16 center_x = 65 17 ## Beam center Y [pixel number] 18 center_y = 65 19 ## Distance from sample to detector [m] 20 distance = 11.0 21 ## Qx values [A-1] 22 x_vals = [] 23 ## Qy xalues [A-1] 24 y_vals = [] 25 ## Qx min 26 xmin = 0.0 27 ## Qx max 28 xmax = 1.0 29 ## Qy min 30 ymin = 0.0 31 ## Qy max 32 ymax = 1.0 33 ## Image 34 image = None 35 ## Pixel size 36 pixel_size = 0.5 37 ## x coordinate 38 x=[] 39 ##y coordinate 40 y=[] 41 ##dx error on y 42 dx=None 43 ## dy error on y 44 dy=None 45 ## Error on each pixel 46 error = None 47 ##type of data 48 type="" 49 ##z 50 Z=None 51 5 52 class Reader: 6 53 """ … … 68 115 #return msg 69 116 logging.info("TXT2_Reader reading %s\n" %path) 70 return self.x,self.y,self.dy 117 output = ReaderInfo() 118 output.x = self.x 119 output.y = self.y 120 output.type = "1D" 121 122 return output 71 123 return None 72 124 -
DataLoader/plugins/TXT3_Reader.py
r8d6440f r16d8e5f 3 3 import string,numpy 4 4 import logging 5 class ReaderInfo: 6 """ 7 This class is a container of data. It stores values read from files 8 """ 9 ## Wavelength [A] 10 wavelength = 0.0 11 ## Number of x bins 12 xbins = 128 13 ## Number of y bins 14 ybins = 128 15 ## Beam center X [pixel number] 16 center_x = 65 17 ## Beam center Y [pixel number] 18 center_y = 65 19 ## Distance from sample to detector [m] 20 distance = 11.0 21 ## Qx values [A-1] 22 x_vals = [] 23 ## Qy xalues [A-1] 24 y_vals = [] 25 ## Qx min 26 xmin = 0.0 27 ## Qx max 28 xmax = 1.0 29 ## Qy min 30 ymin = 0.0 31 ## Qy max 32 ymax = 1.0 33 ## Image 34 image = None 35 ## Pixel size 36 pixel_size = 0.5 37 ## x coordinate 38 x=[] 39 ##y coordinate 40 y=[] 41 ##dx error on y 42 dx=None 43 ## dy error on y 44 dy=None 45 ## Error on each pixel 46 error = None 47 ##type of data 48 type="" 49 ##z 50 Z=None 5 51 class Reader: 6 52 """ … … 67 113 raise ValueError, "TXT3_Reader can't read %s"%path 68 114 else: 69 #msg="txtReader Reading:\n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n" 70 #return msg 115 71 116 logging.info ("TXT3_Reader reading %s \n" %(path)) 72 return self.x,self.y,self.dy 117 118 output = ReaderInfo() 119 output.x = self.x 120 output.y = self.y 121 output.dy = self.dy 122 output.type = "1D" 123 124 return output 73 125 74 126 return None -
DataLoader/plugins/tiff_reader.py
r3dd7cce r16d8e5f 4 4 class ReaderInfo: 5 5 """ 6 This class is a container of data. It stores values read from files 6 7 """ 7 8 ## Wavelength [A] … … 33 34 ## Pixel size 34 35 pixel_size = 0.5 36 ## x coordinate 37 x=[] 38 ##y coordinate 39 y=[] 40 ##dx error on y 41 dx=None 42 ## dy error on y 43 dy=None 35 44 ## Error on each pixel 36 45 error = None 37 46 ##type of data 47 type="" 48 ##z 49 Z=None 50 38 51 class Reader: 39 52 """ … … 144 157 output.image = Z 145 158 output.pixel_size = pixel 146 159 output.type ="2D" 160 147 161 return output 148 162 -
DataLoader/readers/IgorReader.py
r8d6440f r16d8e5f 165 165 self.center_x = center_x 166 166 self.center_y = center_y 167 168 from readInfo import ReaderInfo 169 output = ReaderInfo() 170 output.Z=Z 171 output.xmin =xmin-xstep/2.0 172 output.xmax = xmax+xstep/2.0 173 output.ymin =ymin-ystep/2.0 174 output.ymax =ymax+ystep/2.0 175 output.type ="2D" 176 167 177 logging.info("IgorReader reading %s"%self.file) 168 return Z, xmin-xstep/2.0, xmax+xstep/2.0, ymin-ystep/2.0, ymax+ystep/2.0178 return output 169 179 -
DataLoader/readers/TXT2_Reader.py
r8d6440f r16d8e5f 66 66 #msg="R1 reading: \n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n" 67 67 #return msg 68 from readInfo import ReaderInfo 69 output = ReaderInfo() 70 output.x=self.x 71 output.y=self.y 72 68 73 logging.info("TXT2_Reader reading %s\n" %path) 69 return self.x,self.y,self.dy74 return output 70 75 return None 71 76 -
DataLoader/readers/TXT3_Reader.py
r8d6440f r16d8e5f 69 69 #return msg 70 70 logging.info("TXT3_Reader reading %s \n" %path) 71 return self.x,self.y,self.dy 71 from readInfo import ReaderInfo 72 output = ReaderInfo() 73 output.x = self.x 74 output.y = self.y 75 output.dy = self.dy 76 output.type = "1D" 77 78 return output 72 79 73 80 return None -
DataLoader/readers/danse_reader.py
r8d6440f r16d8e5f 8 8 import numpy 9 9 import logging 10 class ReaderInfo: 11 """ 12 """ 13 ## Wavelength [A] 14 wavelength = 0.0 15 ## Number of x bins 16 xbins = 128 17 ## Number of y bins 18 ybins = 128 19 ## Beam center X [pixel number] 20 center_x = 65 21 ## Beam center Y [pixel number] 22 center_y = 65 23 ## Distance from sample to detector [m] 24 distance = 11.0 25 ## Qx values [A-1] 26 x_vals = [] 27 ## Qy xalues [A-1] 28 y_vals = [] 29 ## Qx min 30 xmin = 0.0 31 ## Qx max 32 xmax = 1.0 33 ## Qy min 34 ymin = 0.0 35 ## Qy max 36 ymax = 1.0 37 ## Image 38 image = None 39 ## Pixel size 40 pixel_size = 0.5 41 ## Error on each pixel 42 error = None 10 43 11 class Reader: 44 12 """ … … 193 161 194 162 itot += 1 195 163 from readInfo import ReaderInfo 196 164 output = ReaderInfo() 197 165 output.wavelength = wavelength … … 210 178 output.pixel_size = pixel 211 179 output.image = Z 212 if not fversion==1.1: 180 output.type = "2D " 181 182 if not fversion>=1.0: 213 183 #output.error = E 214 184 raise ValueError,"Danse_reader can't read this file %s"%filename -
DataLoader/readers/tiff_reader.py
r8d6440f r16d8e5f 2 2 import Image 3 3 import math,logging 4 class ReaderInfo: 5 """ 6 """ 7 ## Wavelength [A] 8 wavelength = 0.0 9 ## Number of x bins 10 xbins = 128 11 ## Number of y bins 12 ybins = 128 13 ## Beam center X [pixel number] 14 center_x = 65 15 ## Beam center Y [pixel number] 16 center_y = 65 17 ## Distance from sample to detector [m] 18 distance = 11.0 19 ## Qx values [A-1] 20 x_vals = [] 21 ## Qy xalues [A-1] 22 y_vals = [] 23 ## Qx min 24 xmin = 0.0 25 ## Qx max 26 xmax = 1.0 27 ## Qy min 28 ymin = 0.0 29 ## Qy max 30 ymax = 1.0 31 ## Image 32 image = None 33 ## Pixel size 34 pixel_size = 0.5 35 ## Error on each pixel 36 error = None 4 37 5 38 6 class Reader: … … 129 97 130 98 itot += 1 131 99 from readInfo import ReaderInfo 132 100 output = ReaderInfo() 133 101 output.wavelength = wavelength … … 145 113 output.image = Z 146 114 output.pixel_size = pixel 115 output.type ="2D" 147 116 logging.info("tiff_reader reading %s"%(filename)) 148 117 -
DataLoader/test/testLoad.py
rd3619421 r16d8e5f 19 19 from DataLoader.readers import TXT3_Reader,TXT2_Reader 20 20 from DataLoader.readers import IgorReader,danse_reader,tiff_reader 21 21 22 import os.path 22 23 class testLoader(unittest.TestCase): … … 56 57 57 58 #Testing loading a txt file of 2 columns, the only reader should be read1 58 xload,yload,dyload=self.L.load('test_2_columns.txt')59 output=self.L.load('test_2_columns.txt') 59 60 x=[2.83954,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449,1.42857,1.63265] 60 61 y=[0.6,3.44938, 5.82026,5.27591,5.2781,5.22531,7.47487,7.85852,10.2278] 61 62 dx=[] 62 63 dy=[] 63 self.assertEqual(len( xload),len(x))64 self.assertEqual(len( yload),len(y))65 self.assertEqual(len(dyload),0)64 self.assertEqual(len(output.x),len(x)) 65 self.assertEqual(len(output.y),len(y)) 66 66 67 for i in range(len(x)): 67 self.assertEqual( xload[i],x[i])68 self.assertEqual( yload[i],y[i])68 self.assertEqual(output.x[i],x[i]) 69 self.assertEqual(output.y[i],y[i]) 69 70 70 71 71 72 def testLoad2(self): 72 73 """Testing loading a txt file of 3 columns""" 73 xload,yload,dyload= self.L.load('test_3_columns.txt')74 output= self.L.load('test_3_columns.txt') 74 75 x=[0,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449] 75 76 y=[2.83954,3.44938,5.82026,5.27591,5.2781,5.22531,7.47487] 76 77 dx=[] 77 78 dy=[0.6,0.676531,0.753061,0.829592,0.906122,0.982653,1.05918] 78 self.assertEqual(len( xload),len(x))79 self.assertEqual(len( yload),len(y))80 self.assertEqual(len( dyload),len(dy))79 self.assertEqual(len(output.x),len(x)) 80 self.assertEqual(len(output.y),len(y)) 81 self.assertEqual(len(output.dy),len(dy)) 81 82 for i in range(len(x)): 82 self.assertEqual( xload[i],x[i])83 self.assertEqual( yload[i],y[i])84 self.assertEqual( dyload[i],dy[i])83 self.assertEqual(output.x[i],x[i]) 84 self.assertEqual(output.y[i],y[i]) 85 self.assertEqual(output.dy[i],dy[i]) 85 86 86 87 … … 88 89 """ Testing loading Igor data""" 89 90 #tested good file.asc 90 Z,xmin, xmax, ymin, ymax= self.L.load('MAR07232_rest.ASC')91 self.assertEqual( xmin,-0.018558945804750416)92 self.assertEqual( xmax, 0.016234058202440633,)93 self.assertEqual( ymin,-0.01684257151702391)94 self.assertEqual( ymax,0.017950440578015116)91 output= self.L.load('MAR07232_rest.ASC') 92 self.assertEqual(output.xmin,-0.018558945804750416) 93 self.assertEqual(output.xmax, 0.016234058202440633,) 94 self.assertEqual(output.ymin,-0.01684257151702391) 95 self.assertEqual(output.ymax,0.017950440578015116) 95 96 96 97 #tested corrupted file.asc … … 102 103 """ Testing loading danse file""" 103 104 #tested good file.sans 104 data=self.L.load('MP_New.sans')105 output=self.L.load('MP_New.sans') 105 106 106 self.assertEqual( data.wavelength,7.5)107 self.assertEqual(output.wavelength,7.5) 107 108 108 109 #tested corrupted file.sans … … 115 116 def testload5(self): 116 117 """ Testing loading image file""" 117 data=self.L.load('angles_flat.png')118 self.assertEqual( data.xbins ,200)118 output=self.L.load('angles_flat.png') 119 self.assertEqual(output.xbins ,200) 119 120 120 121 def testload6(self): -
DataLoader/test/testplugings.py
rd3619421 r16d8e5f 39 39 self.assertEqual(self.L.__contains__('.ASC'),True) 40 40 #Testing loading a txt file of 2 columns, the only reader should be read1 41 xload,yload,dyload=self.L.load('test_2_columns.txt')41 output=self.L.load('test_2_columns.txt') 42 42 x=[2.83954,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449,1.42857,1.63265] 43 43 y=[0.6,3.44938, 5.82026,5.27591,5.2781,5.22531,7.47487,7.85852,10.2278] 44 44 dx=[] 45 45 dy=[] 46 self.assertEqual(len( xload),len(x))47 self.assertEqual(len( yload),len(y))48 self.assertEqual(len(dyload),0)46 self.assertEqual(len(output.x),len(x)) 47 self.assertEqual(len(output.y),len(y)) 48 49 49 for i in range(len(x)): 50 self.assertEqual( xload[i],x[i])51 self.assertEqual( yload[i],y[i])50 self.assertEqual(output.x[i],x[i]) 51 self.assertEqual(output.y[i],y[i])
Note: See TracChangeset
for help on using the changeset viewer.