Changeset 579ba85 in sasview for DataLoader
- Timestamp:
- Aug 29, 2008 3:56:50 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:
- 442f42f
- Parents:
- 4c00964
- Location:
- DataLoader
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/data_info.py
r4c00964 r579ba85 24 24 25 25 #TODO: Keep track of data manipulation in the 'process' data structure. 26 27 from sans.guitools.plottables import Data1D as plottable_1D 26 #TODO: This module should be independent of plottables. We should write 27 # an adapter class for plottables when needed. 28 29 #from sans.guitools.plottables import Data1D as plottable_1D 28 30 from data_util.uncertainty import Uncertainty 29 31 import numpy 30 32 import math 31 33 34 class plottable_1D: 35 """ 36 Data1D is a place holder for 1D plottables. 37 """ 38 x = None 39 y = None 40 dx = None 41 dy = None 42 43 # Units 44 _xaxis = '' 45 _xunit = '' 46 _yaxis = '' 47 _yunit = '' 48 49 def __init__(self,x,y,dx=None,dy=None): 50 self.x = x 51 self.y = y 52 self.dx = dx 53 self.dy = dy 54 55 def xaxis(self, label, unit): 56 self._xaxis = label 57 self._xunit = unit 58 59 def yaxis(self, label, unit): 60 self._yaxis = label 61 self._yunit = unit 62 32 63 class plottable_2D: 33 64 """ 34 Data2D is a place holder for 2D plottables, which are 35 not yet implemented. 65 Data2D is a place holder for 2D plottables. 36 66 """ 37 67 xmin = None … … 148 178 class Aperture: 149 179 ## Name 150 name = ''180 name = None 151 181 ## Type 152 type = '' 182 type = None 183 ## Size name 184 size_name = None 153 185 ## Aperture size [Vector] 154 186 size = None … … 192 224 """ 193 225 ## Name 194 name = ''226 name = None 195 227 ## Radiation type [string] 196 radiation = '' 228 radiation = None 229 ## Beam size name 230 beam_size_name = None 197 231 ## Beam size [Vector] [mm] 198 232 beam_size = None 199 233 beam_size_unit = 'mm' 200 234 ## Beam shape [string] 201 beam_shape = ''235 beam_shape = None 202 236 ## Wavelength [float] [Angstrom] 203 237 wavelength = None … … 246 280 Class to hold the sample description 247 281 """ 282 ## Short name for sample 283 name = '' 248 284 ## ID 249 285 ID = '' … … 327 363 ## Run number 328 364 run = None 365 ## Run name 366 run_name = None 329 367 ## File name 330 368 filename = '' … … 355 393 self.title = '' 356 394 ## Run number 357 self.run = None 395 self.run = [] 396 self.run_name = {} 358 397 ## File name 359 398 self.filename = '' -
DataLoader/loader.py
r77c1c29d r579ba85 71 71 self.readers = {} 72 72 #Load all readers in plugins 73 self.__setitem__() 73 74 #TODO: misuse of __setitem__ 75 #TODO: this bad call is done twice: here, and in Loader.__init__ 76 #self.__setitem__() 74 77 75 78 … … 94 97 if dir==None: 95 98 dir = 'readers' 99 100 #TODO Probably name the new path something else... 101 102 #TODO: The whole concept of plug-ins was missed here. 103 # First we want to always load the reader we have (in 'readers') 104 # and THEN we want to add any additional readers found in 105 # a pre-defined plug-in path (that path should be a variable). 96 106 dir=os.path.join(os.path.dirname(os.path.abspath(__file__)),dir) 97 107 … … 100 110 if os.path.isdir(dir): 101 111 plugReader=_findReaders(dir)# import all module in plugins 112 113 #TODO The following just doesn't make sense 114 # ../C:\Python25\lib... ???? 102 115 if os.path.isdir('../'+dir): 103 116 plugReader=_findReaders('../'+dir) … … 107 120 list=[] 108 121 for preader in plugReader:# for each modules takes list of extensions 122 #TODO should use hasattr rather than a try/except block 109 123 try: 110 124 list=preader.ext -
DataLoader/readers/cansas_reader.py
r4c00964 r579ba85 8 8 copyright 2008, University of Tennessee 9 9 """ 10 11 # TODO: Unit conversion12 #TODO: missing aperture type: go through all entries and check for additional attributes 10 # Known issue: reader not compatible with multiple SASdata entries 11 # within a single SASentry. Will raise a runtime error. 12 13 13 #TODO: check that all vectors are written only if they have at least one non-empty value 14 #TODO: multiple SASEntrys14 #TODO: Writing only allows one SASentry per file. Would be best to allow multiple entries. 15 15 #TODO: Store error list 16 #TODO: convert from pixel to mm for beam center...17 16 #TODO: Allow for additional meta data for each section 18 17 #TODO: Notes need to be implemented. They can be any XML structure in version 1.0 … … 258 257 # Look up title 259 258 _store_content('Title', dom, 'title', data_info) 260 # Look up run number 261 _store_content('Run', dom, 'run', data_info) 259 # Look up run number 260 nodes = xpath.Evaluate('Run', dom) 261 for item in nodes: 262 value, attr = get_node_text(item) 263 if value is not None: 264 data_info.run.append(value) 265 if attr.has_key('name'): 266 data_info.run_name[value] = attr['name'] 267 262 268 # Look up instrument name 263 value, attr = get_content('SASinstrument', dom) 264 if attr.has_key('name'): 265 data_info.instrument = attr['name'] 269 _store_content('SASinstrument/name', dom, 'instrument', data_info) 270 #value, attr = get_content('SASinstrument', dom) 271 #if attr.has_key('name'): 272 # data_info.instrument = attr['name'] 266 273 267 274 note_list = xpath.Evaluate('SASnote', dom) … … 276 283 277 284 # Sample info ################### 285 value, attr = get_content('SASsample', dom) 286 if attr.has_key('name'): 287 data_info.sample.name = attr['name'] 288 278 289 _store_content('SASsample/ID', 279 290 dom, 'ID', data_info.sample) … … 327 338 dom, 'wavelength_spread', data_info.source) 328 339 329 # Beam size (as a vector) 340 # Beam size (as a vector) 341 value, attr = get_content('SASinstrument/SASsource/beam_size', dom) 342 if attr.has_key('name'): 343 data_info.source.beam_size_name = attr['name'] 344 330 345 _store_float('SASinstrument/SASsource/beam_size/x', 331 346 dom, 'beam_size.x', data_info.source) … … 350 365 351 366 # Get the name and type of the aperture 352 ap_value, ap_attr = get_node_text( item)367 ap_value, ap_attr = get_node_text(apert) 353 368 if ap_attr.has_key('name'): 354 369 aperture.name = ap_attr['name'] … … 357 372 358 373 _store_float('distance', apert, 'distance', aperture) 374 375 value, attr = get_content('size', apert) 376 if attr.has_key('name'): 377 aperture.size_name = attr['name'] 378 359 379 _store_float('size/x', apert, 'size.x', aperture) 360 380 _store_float('size/y', apert, 'size.y', aperture) … … 380 400 381 401 # Detector orientation (as a vector) 382 _store_float('orientation/ pitch',item, 'orientation.x', detector)383 _store_float('orientation/ yaw',item, 'orientation.y', detector)384 _store_float('orientation/ roll',item, 'orientation.z', detector)402 _store_float('orientation/roll', item, 'orientation.x', detector) 403 _store_float('orientation/pitch', item, 'orientation.y', detector) 404 _store_float('orientation/yaw', item, 'orientation.z', detector) 385 405 386 406 # Beam center (as a vector) … … 430 450 431 451 # Data info ###################### 452 nodes = xpath.Evaluate('SASdata', dom) 453 if len(nodes)>1: 454 raise RuntimeError, "CanSAS reader is not compatible with multiple SASdata entries" 455 432 456 nodes = xpath.Evaluate('SASdata/Idata', dom) 433 457 x = numpy.zeros(0) … … 455 479 if _x is not None and _y is not None: 456 480 x = numpy.append(x, _x) 457 y = numpy.append( x, _y)458 dx = numpy.append( x, _dx)459 dy = numpy.append( x, _dy)481 y = numpy.append(y, _y) 482 dx = numpy.append(dx, _dx) 483 dy = numpy.append(dy, _dy) 460 484 461 485 data_info.x = x … … 508 532 main_node.appendChild(entry_node) 509 533 510 write_node(doc, entry_node, "title", datainfo.title) 511 write_node(doc, entry_node, "run", datainfo.run) 534 write_node(doc, entry_node, "Title", datainfo.title) 535 536 for item in datainfo.run: 537 runname = {} 538 if datainfo.run_name.has_key(item) and len(str(datainfo.run_name[item]))>1: 539 runname = {'name': datainfo.run_name[item] } 540 write_node(doc, entry_node, "Run", item, runname) 512 541 513 542 # Data info … … 515 544 entry_node.appendChild(node) 516 545 546 for i in range(len(datainfo.x)): 547 pt = doc.createElement("Idata") 548 node.appendChild(pt) 549 write_node(doc, pt, "Q", datainfo.x[i], {'unit':datainfo.x_unit}) 550 if len(datainfo.y)>=i: 551 write_node(doc, pt, "I", datainfo.y[i], {'unit':datainfo.y_unit}) 552 if len(datainfo.dx)>=i: 553 write_node(doc, pt, "Qdev", datainfo.dx[i], {'unit':datainfo.x_unit}) 554 if len(datainfo.dy)>=i: 555 write_node(doc, pt, "Idev", datainfo.dy[i], {'unit':datainfo.y_unit}) 556 557 517 558 # Sample info 518 559 sample = doc.createElement("SASsample") 560 if datainfo.sample.name is not None: 561 sample.setAttribute("name", str(datainfo.sample.name)) 519 562 entry_node.appendChild(sample) 520 write_node(doc, sample, "ID", datainfo.sample.ID)563 write_node(doc, sample, "ID", str(datainfo.sample.ID)) 521 564 write_node(doc, sample, "thickness", datainfo.sample.thickness, {"unit":datainfo.sample.thickness_unit}) 522 565 write_node(doc, sample, "transmission", datainfo.sample.transmission) … … 527 570 528 571 pos = doc.createElement("position") 529 written = False 530 written = written or write_node(doc, pos, "x", datainfo.sample.position.x, {"unit":datainfo.sample.position_unit}) 531 written = written or write_node(doc, pos, "y", datainfo.sample.position.y, {"unit":datainfo.sample.position_unit}) 532 written = written or write_node(doc, pos, "z", datainfo.sample.position.z, {"unit":datainfo.sample.position_unit}) 572 written = write_node(doc, pos, "x", datainfo.sample.position.x, {"unit":datainfo.sample.position_unit}) 573 written = written | write_node(doc, pos, "y", datainfo.sample.position.y, {"unit":datainfo.sample.position_unit}) 574 written = written | write_node(doc, pos, "z", datainfo.sample.position.z, {"unit":datainfo.sample.position_unit}) 533 575 if written == True: 534 576 sample.appendChild(pos) 535 577 536 578 ori = doc.createElement("orientation") 537 written = False 538 written = written or write_node(doc, ori, "roll", datainfo.sample.orientation.x, {"unit":datainfo.sample.orientation_unit}) 539 written = written or write_node(doc, ori, "pitch", datainfo.sample.orientation.y, {"unit":datainfo.sample.orientation_unit}) 540 written = written or write_node(doc, ori, "yaw", datainfo.sample.orientation.z, {"unit":datainfo.sample.orientation_unit}) 579 written = write_node(doc, ori, "roll", datainfo.sample.orientation.x, {"unit":datainfo.sample.orientation_unit}) 580 written = written | write_node(doc, ori, "pitch", datainfo.sample.orientation.y, {"unit":datainfo.sample.orientation_unit}) 581 written = written | write_node(doc, ori, "yaw", datainfo.sample.orientation.z, {"unit":datainfo.sample.orientation_unit}) 541 582 if written == True: 542 583 sample.appendChild(ori) … … 550 591 # Source 551 592 source = doc.createElement("SASsource") 552 source.setAttribute("name", str(datainfo.source.name)) 593 if datainfo.source.name is not None: 594 source.setAttribute("name", str(datainfo.source.name)) 553 595 instr.appendChild(source) 554 596 555 597 write_node(doc, source, "radiation", datainfo.source.radiation) 556 598 write_node(doc, source, "beam_shape", datainfo.source.beam_shape) 599 size = doc.createElement("beam_size") 600 if datainfo.source.beam_size_name is not None: 601 size.setAttribute("name", str(datainfo.source.beam_size_name)) 602 written = write_node(doc, size, "x", datainfo.source.beam_size.x, {"unit":datainfo.source.beam_size_unit}) 603 written = written | write_node(doc, size, "y", datainfo.source.beam_size.y, {"unit":datainfo.source.beam_size_unit}) 604 written = written | write_node(doc, size, "z", datainfo.source.beam_size.z, {"unit":datainfo.source.beam_size_unit}) 605 if written == True: 606 source.appendChild(size) 607 557 608 write_node(doc, source, "wavelength", datainfo.source.wavelength, {"unit":datainfo.source.wavelength_unit}) 558 609 write_node(doc, source, "wavelength_min", datainfo.source.wavelength_min, {"unit":datainfo.source.wavelength_min_unit}) … … 563 614 for item in datainfo.collimation: 564 615 coll = doc.createElement("SAScollimation") 565 coll.setAttribute("name", item.name) 616 if item.name is not None: 617 coll.setAttribute("name", str(item.name)) 566 618 instr.appendChild(coll) 567 619 … … 569 621 570 622 for apert in item.aperture: 571 ap = doc.createElement("SAScollimation") 572 ap.setAttribute("name", apert.name) 573 ap.setAttribute("type", apert.type) 574 instr.appendChild(ap) 623 ap = doc.createElement("aperture") 624 if apert.name is not None: 625 ap.setAttribute("name", str(apert.name)) 626 if apert.type is not None: 627 ap.setAttribute("type", str(apert.type)) 628 coll.appendChild(ap) 575 629 576 630 write_node(doc, ap, "distance", apert.distance, {"unit":apert.distance_unit}) 577 631 578 632 size = doc.createElement("size") 579 ap.appendChild(size) 580 write_node(doc, size, "x", apert.size.x, {"unit":apert.size_unit}) 581 write_node(doc, size, "y", apert.size.y, {"unit":apert.size_unit}) 582 write_node(doc, size, "z", apert.size.z, {"unit":apert.size_unit}) 583 633 if apert.size_name is not None: 634 size.setAttribute("name", str(apert.size_name)) 635 written = write_node(doc, size, "x", apert.size.x, {"unit":apert.size_unit}) 636 written = written | write_node(doc, size, "y", apert.size.y, {"unit":apert.size_unit}) 637 written = written | write_node(doc, size, "z", apert.size.z, {"unit":apert.size_unit}) 638 if written == True: 639 ap.appendChild(size) 584 640 585 641 # Detectors 586 642 for item in datainfo.detector: 587 643 det = doc.createElement("SASdetector") 588 instr.appendChild(det)589 590 writ e_node(doc, det, "name", item.name)591 write_node(doc, det, "SDD", item.distance, {"unit":item.distance_unit})592 write_node(doc, det, "slit_length", item.slit_length, {"unit":item.slit_length_unit})644 written = write_node(doc, det, "name", item.name) 645 written = written | write_node(doc, det, "SDD", item.distance, {"unit":item.distance_unit}) 646 written = written | write_node(doc, det, "slit_length", item.slit_length, {"unit":item.slit_length_unit}) 647 if written == True: 648 instr.appendChild(det) 593 649 594 650 off = doc.createElement("offset") 595 det.appendChild(off)596 writ e_node(doc, off, "x", item.offset.x, {"unit":item.offset_unit})597 writ e_node(doc, off, "y", item.offset.y, {"unit":item.offset_unit})598 write_node(doc, off, "z", item.offset.z, {"unit":item.offset_unit})599 651 written = write_node(doc, off, "x", item.offset.x, {"unit":item.offset_unit}) 652 written = written | write_node(doc, off, "y", item.offset.y, {"unit":item.offset_unit}) 653 written = written | write_node(doc, off, "z", item.offset.z, {"unit":item.offset_unit}) 654 if written == True: 655 det.appendChild(off) 600 656 601 657 center = doc.createElement("beam_center") 602 det.appendChild(center) 603 write_node(doc, center, "x", item.beam_center.x, {"unit":item.beam_center_unit}) 604 write_node(doc, center, "y", item.beam_center.y, {"unit":item.beam_center_unit}) 605 write_node(doc, center, "z", item.beam_center.z, {"unit":item.beam_center_unit}) 606 658 written = write_node(doc, center, "x", item.beam_center.x, {"unit":item.beam_center_unit}) 659 written = written | write_node(doc, center, "y", item.beam_center.y, {"unit":item.beam_center_unit}) 660 written = written | write_node(doc, center, "z", item.beam_center.z, {"unit":item.beam_center_unit}) 661 if written == True: 662 det.appendChild(center) 663 607 664 pix = doc.createElement("pixel_size") 608 det.appendChild(pix) 609 write_node(doc, pix, "x", item.pixel_size.x, {"unit":item.pixel_size_unit}) 610 write_node(doc, pix, "y", item.pixel_size.y, {"unit":item.pixel_size_unit}) 611 write_node(doc, pix, "z", item.pixel_size.z, {"unit":item.pixel_size_unit}) 612 613 614 # Sample info 665 written = write_node(doc, pix, "x", item.pixel_size.x, {"unit":item.pixel_size_unit}) 666 written = written | write_node(doc, pix, "y", item.pixel_size.y, {"unit":item.pixel_size_unit}) 667 written = written | write_node(doc, pix, "z", item.pixel_size.z, {"unit":item.pixel_size_unit}) 668 if written == True: 669 det.appendChild(pix) 670 671 ori = doc.createElement("orientation") 672 written = write_node(doc, ori, "roll", item.orientation.x, {"unit":item.orientation_unit}) 673 written = written | write_node(doc, ori, "pitch", item.orientation.y, {"unit":item.orientation_unit}) 674 written = written | write_node(doc, ori, "yaw", item.orientation.z, {"unit":item.orientation_unit}) 675 if written == True: 676 det.appendChild(ori) 677 678 679 # Processes info 615 680 for item in datainfo.process: 616 681 node = doc.createElement("SASprocess") 617 682 entry_node.appendChild(node) 618 683 619 write_node(doc, entry_node, "run", item.name) 684 write_node(doc, node, "name", item.name) 685 write_node(doc, node, "date", item.date) 686 write_node(doc, node, "description", item.description) 687 for term in item.term: 688 value = term['value'] 689 del term['value'] 690 write_node(doc, node, "term", value, term) 691 for note in item.notes: 692 write_node(doc, node, "SASprocessnote", note) 620 693 621 694 -
DataLoader/release_notes.txt
r4c00964 r579ba85 4 4 Package name: DataLoader 0.2 5 5 6 1- Version 0. 16 1- Version 0.2 7 7 - Release date: ? 8 - First version of CanSAS reader/writer 9 - 1D data manipulations available 10 11 Version 0.1 8 12 - First version of SANS data loader 9 13 - Formats: IGOR 1D, IGOR 2D, CanSAS 1D, 2- or 3-column ascii … … 25 29 26 30 3.1- All systems: 27 - None 31 - CanSAS format only allows a single SASdata section per SASentry. 32 - CanSAS format only allows one SASentry per file, for a single DataInfo object. 28 33 29 34 3.2- Windows: -
DataLoader/test/cansas1d.xml
r4c00964 r579ba85 8 8 <SASentry> 9 9 <Title>Test title</Title> 10 <Run >1234</Run>10 <Run name='run name'>1234</Run> 11 11 <SASdata> 12 12 <Idata> … … 19 19 </Idata> 20 20 <Idata> 21 <Q unit="1/A">0.0 2</Q>22 <I unit="1/cm">100 0</I>23 <Idev unit="1/cm"> 3</Idev>24 <Qdev unit="1/A">0.0 1</Qdev>21 <Q unit="1/A">0.03</Q> 22 <I unit="1/cm">1001</I> 23 <Idev unit="1/cm">4</Idev> 24 <Qdev unit="1/A">0.02</Qdev> 25 25 <Qmean unit="1/A"><!-- Qmean is optional --></Qmean> 26 26 <Shadowfactor><!-- Shadowfactor is optional --></Shadowfactor> 27 27 </Idata> 28 28 </SASdata> 29 <SASsample >29 <SASsample name='my sample'> 30 30 <ID>SI600-new-long</ID> 31 31 <thickness unit="mm">1.03</thickness> … … 53 53 <SASsource name="source name"> 54 54 <radiation>neutron</radiation> 55 <beam_size >55 <beam_size name='bm'> 56 56 <x unit="mm">12.00</x> 57 <y unit="mm">1 2.00</y>57 <y unit="mm">13.00</y> 58 58 </beam_size> 59 59 <beam_shape>disc</beam_shape> … … 74 74 </aperture> 75 75 <aperture name="sample" type="radius"> 76 <size >76 <size name='size name'> 77 77 <x unit="mm">1</x> 78 78 </size> -
DataLoader/test/utest_abs_reader.py
r4c00964 r579ba85 135 135 136 136 def test_checkdata(self): 137 self.assertEqual(self.data.filename, "cansas1d.xml") 138 self._checkdata() 139 140 def _checkdata(self): 137 141 """ 138 142 Check the data content to see whether … … 142 146 tests won't pass 143 147 """ 144 self.assertEqual(self.data.filename, "cansas1d.xml") 145 self.assertEqual(self.data.run, "1234") 148 149 self.assertEqual(self.data.run[0], "1234") 150 151 # Data 152 self.assertEqual(len(self.data.x), 2) 153 self.assertEqual(self.data.x_unit, '1/A') 154 self.assertEqual(self.data.y_unit, '1/cm') 155 self.assertEqual(self.data.x[0], 0.02) 156 self.assertEqual(self.data.y[0], 1000) 157 self.assertEqual(self.data.dx[0], 0.01) 158 self.assertEqual(self.data.dy[0], 3) 159 self.assertEqual(self.data.x[1], 0.03) 160 self.assertEqual(self.data.y[1], 1001) 161 self.assertEqual(self.data.dx[1], 0.02) 162 self.assertEqual(self.data.dy[1], 4) 163 self.assertEqual(self.data.run_name['1234'], 'run name') 164 self.assertEqual(self.data.title, "Test title") 146 165 147 166 # Sample info 148 167 self.assertEqual(self.data.sample.ID, "SI600-new-long") 168 self.assertEqual(self.data.sample.name, "my sample") 149 169 self.assertEqual(self.data.sample.thickness_unit, 'mm') 150 170 self.assertEqual(self.data.sample.thickness, 1.03) … … 167 187 168 188 # Instrument info 169 self.assertEqual(self.data.instrument, " TESTinstrument")189 self.assertEqual(self.data.instrument, "canSAS instrument") 170 190 171 191 # Source … … 173 193 174 194 self.assertEqual(self.data.source.beam_size_unit, "mm") 195 self.assertEqual(self.data.source.beam_size_name, "bm") 175 196 self.assertEqual(self.data.source.beam_size.x, 12) 176 self.assertEqual(self.data.source.beam_size.y, 1 2)197 self.assertEqual(self.data.source.beam_size.y, 13) 177 198 178 199 self.assertEqual(self.data.source.beam_shape, "disc") … … 192 213 _found2 = False 193 214 self.assertEqual(self.data.collimation[0].length, 123.) 215 self.assertEqual(self.data.collimation[0].name, 'test coll name') 194 216 195 217 for item in self.data.collimation[0].aperture: … … 198 220 199 221 if item.size.x==50 \ 200 and item.distance==11000.: 222 and item.distance==11000.0 \ 223 and item.name=='source' \ 224 and item.type=='radius': 201 225 _found1 = True 202 elif item.size.x==1.0: 226 elif item.size.x==1.0 \ 227 and item.name=='sample' \ 228 and item.type=='radius': 203 229 _found2 = True 204 230 … … 209 235 # Detector 210 236 self.assertEqual(self.data.detector[0].name, "fictional hybrid") 211 self.assertEqual(self.data.detector[0].distance_unit, "m ")212 self.assertEqual(self.data.detector[0].distance, 4 .150)237 self.assertEqual(self.data.detector[0].distance_unit, "mm") 238 self.assertEqual(self.data.detector[0].distance, 4150) 213 239 214 240 self.assertEqual(self.data.detector[0].orientation_unit, "degree") … … 218 244 219 245 self.assertEqual(self.data.detector[0].offset_unit, "m") 220 self.assertEqual(self.data.detector[0].offset.x, .0 1)221 self.assertEqual(self.data.detector[0].offset.y, .0 2)246 self.assertEqual(self.data.detector[0].offset.x, .001) 247 self.assertEqual(self.data.detector[0].offset.y, .002) 222 248 self.assertEqual(self.data.detector[0].offset.z, None) 223 249 … … 233 259 234 260 # Process 261 _found_term1 = False 262 _found_term2 = False 263 for item in self.data.process: 264 self.assertTrue(item.name in ['NCNR-IGOR', 'spol']) 265 self.assertTrue(item.date in ['04-Sep-2007 18:35:02', 266 '03-SEP-2006 11:42:47']) 267 for t in item.term: 268 if t['name']=="ABS:DSTAND" \ 269 and t['unit']=='mm' \ 270 and float(t['value'])==1.0: 271 _found_term2 = True 272 elif t['name']=="radialstep" \ 273 and t['unit']=='mm' \ 274 and float(t['value'])==10.0: 275 _found_term1 = True 276 277 if _found_term1==False or _found_term2==False: 278 raise RuntimeError, "Could not find all process terms %s %s" % (_found_term1, _found_term2) 279 235 280 236 281 … … 243 288 dy = numpy.ones(5) 244 289 245 d = Loader().load("jan08002.ABS") 246 #d = Data1D(x, y, dy) 247 r.write("write_test.xml", d) 290 filename = "write_test.xml" 291 r.write(filename, self.data) 292 self.data = Loader().load(filename) 293 self.assertEqual(self.data.filename, filename) 294 self._checkdata() 295 248 296 249 297
Note: See TracChangeset
for help on using the changeset viewer.