Changeset 28caa03 in sasview
- Timestamp:
- Apr 4, 2009 3:17:43 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:
- 07f8d9a
- Parents:
- 0f5fe6b
- Location:
- DataLoader/readers
- Files:
-
- 2 added
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/readers/IgorReader.py
r0e2aa40 r28caa03 32 32 """ Simple data reader for Igor data files """ 33 33 ## File type 34 type_name = "IGOR 2D" 35 ## Wildcards 34 36 type = ["IGOR 2D files (*.ASC)|*.ASC"] 35 37 ## Extension -
DataLoader/readers/__init__.py
rbbc8013 r28caa03 1 import abs_reader 2 import cansas_reader 3 import ascii_reader 4 import cansas_reader 5 import danse_reader 6 import hfir1d_reader 7 import IgorReader 8 import tiff_reader 1 # Backward compatibility with the previous implementation of the default readers 2 from associations import register_readers 9 3 10 def register_readers(registry_function): 11 """ 12 Function called by the registry/loader object to register 13 all default readers using a call back function. 14 15 @param registry_function: function to be called to register each reader 16 """ 17 registry_function(abs_reader) 18 registry_function(cansas_reader) 19 registry_function(ascii_reader) 20 registry_function(cansas_reader) 21 registry_function(danse_reader) 22 registry_function(hfir1d_reader) 23 registry_function(IgorReader) 24 registry_function(tiff_reader) 25 4 # Method to associate extensions to default readers 5 from associations import read_associations -
DataLoader/readers/abs_reader.py
r0e2aa40 r28caa03 24 24 """ 25 25 ## File type 26 type_name = "IGOR 1D" 27 ## Wildcards 26 28 type = ["IGOR 1D files (*.abs)|*.abs"] 27 29 ## List of allowed extensions -
DataLoader/readers/ascii_reader.py
r0e2aa40 r28caa03 25 25 """ 26 26 ## File type 27 type_name = "ASCII" 28 29 ## Wildcards 27 30 type = ["ASCII files (*.txt)|*.txt", 28 31 "ASCII files (*.dat)|*.dat", -
DataLoader/readers/cansas_reader.py
r0e2aa40 r28caa03 196 196 version = '1.0' 197 197 ## File type 198 type_name = "CanSAS 1D" 199 ## Wildcards 198 200 type = ["CanSAS 1D files (*.xml)|*.xml"] 199 201 ## List of allowed extensions -
DataLoader/readers/danse_reader.py
r0e2aa40 r28caa03 36 36 """ 37 37 ## File type 38 type_name = "DANSE" 39 ## Wildcards 38 40 type = ["DANSE files (*.sans)|*.sans"] 39 41 ## Extension -
DataLoader/readers/hfir1d_reader.py
r0e2aa40 r28caa03 25 25 """ 26 26 ## File type 27 type_name = "HFIR 1D" 28 ## Wildcards 27 29 type = ["HFIR 1D files (*.d1d)|*.d1d"] 28 30 ## List of allowed extensions -
DataLoader/readers/tiff_reader.py
r9d4e502 r28caa03 23 23 """ 24 24 ## File type 25 type_name = "TIF" 26 ## Wildcards 25 27 type = ["TIF files (*.tif)|*.tif", 26 "JPG files (*.jpg)|*.jpg",27 "JPEG files (*.jpeg)|*.jpeg",28 "PNG files (*.png)|*.png",29 28 "TIFF files (*.tiff)|*.tiff", 30 "BMP files (*.bmp)|*.bmp",31 "GIF files (*.gif)|*.gif",32 29 ] 33 30 ## Extension 34 ext = ['.tif','.TIF', 35 '.jpg','.JPG', 36 '.png','.PNG', 37 '.jpeg','.JPEG', 38 '.tiff','.TIFF', 39 '.gif','.GIF', 40 '.bmp', '.BMP'] 31 ext = ['.tif', '.tiff'] 41 32 42 33 def read(self, filename=None): … … 59 50 except : 60 51 raise RuntimeError,"cannot open %s"%(filename) 61 predata = im.load()52 data = im.getdata() 62 53 63 x_range = im.size[0] 64 y_range = im.size[1] 54 # Initiazed the output data object 55 output.data = numpy.zeros([im.size[0],im.size[1]]) 56 output.err_data = numpy.zeros([im.size[0],im.size[1]]) 65 57 66 # Initiazed the output data object67 output.data = numpy.zeros([y_range,x_range])68 output.err_data = numpy.zeros([y_range,x_range])69 58 # Initialize 70 59 x_vals = [] … … 72 61 73 62 # x and y vectors 74 for i_x in range( x_range):63 for i_x in range(im.size[0]): 75 64 x_vals.append(i_x) 76 65 77 78 for i_y in range( y_range):66 itot = 0 67 for i_y in range(im.size[1]): 79 68 y_vals.append(i_y) 80 81 for i_x in range(x_range): 82 for i_y in range(y_range): 69 70 for val in data: 71 try: 72 value = float(val) 73 except: 74 logging.error("tiff_reader: had to skip a non-float point") 75 continue 83 76 84 try: 85 if predata[i_x,i_y].__class__.__name__=="tuple": 86 87 if len(predata[i_x,i_y]) == 3: 88 R,G,B= predata[i_x,i_y] 89 elif len(predata[i_x,i_y]) == 4: 90 R,G,B,I = predata[i_x,i_y] 91 #Converting to L Mode: uses the ITU-R 601-2 luma transform. 92 value = float(R * 299/1000 + G * 587/1000 + B * 114/1000) 93 94 else: 95 #Take it as Intensity 96 value = float(predata[i_x,i_y]) 97 except: 98 logging.error("tiff_reader: had to skip a non-float point") 99 continue 77 # Get bin number 78 if math.fmod(itot, im.size[0])==0: 79 i_x = 0 80 i_y += 1 81 else: 82 i_x += 1 100 83 101 102 output.data[y_range-i_y-1,i_x] = value 103 104 output.xbins = x_range 105 output.ybins = y_range 84 output.data[im.size[1]-1-i_y][i_x] = value 85 86 itot += 1 87 88 output.xbins = im.size[0] 89 output.ybins = im.size[1] 106 90 output.x_bins = x_vals 107 91 output.y_bins = y_vals 108 92 output.xmin = 0 109 output.xmax = x_range-193 output.xmax = im.size[0]-1 110 94 output.ymin = 0 111 output.ymax = y_range-195 output.ymax = im.size[0]-1 112 96 113 97 return output 114 98 99 100 if __name__ == "__main__": 101 reader = Reader() 102 print reader.read("../test/MP_New.sans") 103 104
Note: See TracChangeset
for help on using the changeset viewer.