Changeset d6513cd in sasview for DataLoader/test/utest_abs_reader.py


Ignore:
Timestamp:
Aug 22, 2008 5:13:34 PM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
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
Message:

Data loader update (still working)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/test/utest_abs_reader.py

    rb99ac227 rd6513cd  
    134134        self.data = Loader().load("cansas1d.xml") 
    135135  
    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             
    137209         
    138210         
Note: See TracChangeset for help on using the changeset viewer.