Changeset d6513cd in sasview
- Timestamp:
- Aug 22, 2008 5:13:34 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:
- 48882d1
- Parents:
- 533550c
- Location:
- DataLoader
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/data_info.py
rb99ac227 rd6513cd 104 104 distance_unit = 'mm' 105 105 ## Offset of this detector position in X, Y, (and Z if necessary) [Vector] [mm] 106 offset = Vector()106 offset = None 107 107 offset_unit = 'm' 108 108 ## Orientation (rotation) of this detector in roll, pitch, and yaw [Vector] [degrees] 109 orientation = Vector()109 orientation = None 110 110 orientation_unit = 'degree' 111 111 ## Center of the beam on the detector in X and Y (and Z if necessary) [Vector] [mm] 112 beam_center = Vector()112 beam_center = None 113 113 beam_center_unit = 'mm' 114 114 ## Pixel size in X, Y, (and Z if necessary) [Vector] [mm] 115 pixel_size = Vector()115 pixel_size = None 116 116 pixel_size_unit = 'mm' 117 117 ## Slit length of the instrument for this detector.[float] [mm] 118 118 slit_length = None 119 119 slit_length_unit = 'mm' 120 121 def __init__(self): 122 """ 123 Initialize class attribute that are objects... 124 """ 125 self.offset = Vector() 126 self.orientation = Vector() 127 self.beam_center = Vector() 128 self.pixel_size = Vector() 129 120 130 121 131 def __str__(self): … … 136 146 return _str 137 147 148 class Aperture: 149 # Aperture size [Vector] 150 size = None 151 size_unit = 'mm' 152 # Aperture distance [float] 153 distance = None 154 distance_unit = 'mm' 155 156 def __init__(self): 157 self.size = Vector() 158 138 159 class Collimation: 139 160 """ 140 161 Class to hold collimation information 141 162 """ 142 class Aperture:143 # Aperture size [Vector]144 size = Vector()145 size_unit = 'mm'146 # Aperture distance [float]147 distance = None148 distance_unit = 'mm'149 163 150 164 ## Length [float] [mm] … … 152 166 length_unit = 'mm' 153 167 ## Aperture 154 aperture = [] 168 aperture = None 169 170 def __init__(self): 171 self.aperture = [] 155 172 156 173 def __str__(self): … … 172 189 radiation = '' 173 190 ## Beam size [Vector] [mm] 174 beam_size = Vector()191 beam_size = None 175 192 beam_size_unit = 'mm' 176 193 ## Beam shape [string] … … 189 206 wavelength_spread_unit = 'percent' 190 207 208 def __init__(self): 209 self.beam_size = Vector() 210 211 191 212 def __str__(self): 192 213 _str = "Source:\n" … … 229 250 temperature_unit = 'C' 230 251 ## Position [Vector] [mm] 231 position = Vector()252 position = None 232 253 position_unit = 'mm' 233 254 ## Orientation [Vector] [degrees] 234 orientation = Vector()255 orientation = None 235 256 orientation_unit = 'degree' 236 257 ## Details 237 details = [] 258 details = None 259 260 def __init__(self): 261 self.position = Vector() 262 self.orientation = Vector() 263 self.details = [] 238 264 239 265 def __str__(self): … … 264 290 date = '' 265 291 description= '' 266 term = [] 267 notes = [] 292 term = None 293 notes = None 294 295 def __init__(self): 296 self.term = [] 297 self.notes = [] 268 298 269 299 def __str__(self): … … 293 323 filename = '' 294 324 ## Notes 295 notes = []325 notes = None 296 326 ## Processes (Action on the data) 297 process = []327 process = None 298 328 ## Instrument name 299 329 instrument = '' 300 330 ## Detector information 301 detector = []331 detector = None 302 332 ## Sample information 303 sample = Sample()333 sample = None 304 334 ## Source information 305 source = Source()335 source = None 306 336 ## Collimation information 307 collimation = []337 collimation = None 308 338 ## Additional meta-data 309 meta_data = {}339 meta_data = None 310 340 ## Loading errors 311 errors = []341 errors = None 312 342 313 343 def __init__(self): … … 583 613 584 614 ## Vector of Q-values at the center of each bin in x 585 x_bins = []615 x_bins = None 586 616 587 617 ## Vector of Q-values at the center of each bin in y 588 y_bins = []618 y_bins = None 589 619 590 620 591 621 def __init__(self, data=None, err_data=None): 622 self.y_bins = [] 623 self.x_bins = [] 592 624 DataInfo.__init__(self) 593 625 plottable_2D.__init__(self, data, err_data) -
DataLoader/readers/cansas_reader.py
r99d1af6 rd6513cd 20 20 import numpy 21 21 import os, sys 22 from DataLoader.data_info import Data1D, Collimation, Detector, Process 22 from DataLoader.data_info import Data1D, Collimation, Detector, Process, Aperture 23 23 from xml import xpath 24 24 … … 70 70 break 71 71 72 73 74 75 72 if nodes[0].hasAttributes(): 73 for i in range(nodes[0].attributes.length): 74 attr[nodes[0].attributes.item(i).nodeName] \ 75 = nodes[0].attributes.item(i).nodeValue 76 76 except: 77 77 # problem reading the node. Skip it and return that … … 317 317 apert_list = xpath.Evaluate('aperture', item) 318 318 for apert in apert_list: 319 aperture = collim.Aperture() 320 319 aperture = Aperture() 321 320 _store_float('distance', apert, 'distance', aperture) 322 321 _store_float('size/x', apert, 'size.x', aperture) … … 426 425 data_info.dx = dx 427 426 data_info.dy = dy 427 428 data_conv_q = None 429 data_conv_i = None 430 431 if has_converter == True and data_info.x_unit != '1/A': 432 data_conv_q = Converter('1/A') 433 # Test it 434 data_conv_q(1.0, output.Q_unit) 435 436 if has_converter == True and data_info.y_unit != '1/cm': 437 data_conv_i = Converter('1/cm') 438 # Test it 439 data_conv_i(1.0, output.I_unit) 440 441 428 442 if data_conv_q is not None: 429 data_info.xaxis("\\rm{Q}", output.x_unit)443 data_info.xaxis("\\rm{Q}", data_info.x_unit) 430 444 else: 431 445 data_info.xaxis("\\rm{Q}", 'A^{-1}') 432 446 if data_conv_i is not None: 433 data_info.yaxis("\\{I(Q)}", output.y_unit)447 data_info.yaxis("\\{I(Q)}", data_info.y_unit) 434 448 else: 435 449 data_info.yaxis("\\rm{I(Q)}","cm^{-1}") -
DataLoader/test/cansas1d.xml
r8780e9a rd6513cd 66 66 </SASsource> 67 67 <SAScollimation> 68 <length unit='mm'> 123.0</length> 68 69 <aperture name="source" type="radius"> 69 70 <size> -
DataLoader/test/utest_abs_reader.py
rb99ac227 rd6513cd 134 134 self.data = Loader().load("cansas1d.xml") 135 135 136 136 def test_checkdata(self): 137 """ 138 Check the data content to see whether 139 it matches the specific file we loaded. 140 Check the units too to see whether the 141 Data1D defaults changed. Otherwise the 142 tests won't pass 143 """ 144 self.assertEqual(self.data.filename, "cansas1d.xml") 145 self.assertEqual(self.data.run, "1234") 146 147 # Sample info 148 self.assertEqual(self.data.sample.ID, "SI600-new-long") 149 self.assertEqual(self.data.sample.thickness_unit, 'mm') 150 self.assertEqual(self.data.sample.thickness, 1.03) 151 152 self.assertEqual(self.data.sample.transmission, 0.327) 153 154 self.assertEqual(self.data.sample.temperature_unit, 'C') 155 self.assertEqual(self.data.sample.temperature, 0) 156 157 self.assertEqual(self.data.sample.position_unit, 'mm') 158 self.assertEqual(self.data.sample.position.x, 10) 159 self.assertEqual(self.data.sample.position.y, 0) 160 161 self.assertEqual(self.data.sample.orientation_unit, 'degree') 162 self.assertEqual(self.data.sample.orientation.x, 22.5) 163 self.assertEqual(self.data.sample.orientation.y, 0.02) 164 165 self.assertEqual(self.data.sample.details[0], "http://chemtools.chem.soton.ac.uk/projects/blog/blogs.php/bit_id/2720") 166 self.assertEqual(self.data.sample.details[1], "Some text here") 167 168 # Instrument info 169 self.assertEqual(self.data.instrument, "TEST instrument") 170 171 # Source 172 self.assertEqual(self.data.source.radiation, "neutron") 173 174 self.assertEqual(self.data.source.beam_size_unit, "mm") 175 self.assertEqual(self.data.source.beam_size.x, 12) 176 self.assertEqual(self.data.source.beam_size.y, 12) 177 178 self.assertEqual(self.data.source.beam_shape, "disc") 179 180 self.assertEqual(self.data.source.wavelength_unit, "A") 181 self.assertEqual(self.data.source.wavelength, 6) 182 183 self.assertEqual(self.data.source.wavelength_max_unit, "nm") 184 self.assertEqual(self.data.source.wavelength_max, 1.0) 185 self.assertEqual(self.data.source.wavelength_min_unit, "nm") 186 self.assertEqual(self.data.source.wavelength_min, 0.22) 187 self.assertEqual(self.data.source.wavelength_spread_unit, "percent") 188 self.assertEqual(self.data.source.wavelength_spread, 14.3) 189 190 # Collimation 191 _found1 = False 192 _found2 = False 193 self.assertEqual(self.data.collimation[0].length, 123.) 194 195 for item in self.data.collimation[0].aperture: 196 self.assertEqual(item.size_unit,'mm') 197 self.assertEqual(item.distance_unit,'mm') 198 199 if item.size.x==50 \ 200 and item.distance==11000.: 201 _found1 = True 202 elif item.size.x==1.0: 203 _found2 = True 204 205 if _found1==False or _found2==False: 206 print item.distance 207 raise RuntimeError, "Could not find all data %s %s" % (_found1, _found2) 208 137 209 138 210
Note: See TracChangeset
for help on using the changeset viewer.