Package fabio :: Module pilatusimage
[hide private]
[frames] | no frames]

Source Code for Module fabio.pilatusimage

 1  #!/usr/bin/env python 
 2  """ 
 3   
 4  Authors: Henning O. Sorensen & Erik Knudsen 
 5           Center for Fundamental Research: Metal Structures in Four Dimensions 
 6           Risoe National Laboratory 
 7           Frederiksborgvej 399 
 8           DK-4000 Roskilde 
 9           email:henning.sorensen@risoe.dk 
10   
11           + (mods for fabio) Jon Wright, ESRF 
12  marccdimage can read MarCCD and MarMosaic images including header info. 
13   
14  JPW : Use a parser in case of typos (sorry?) 
15   
16  """ 
17   
18   
19  # Base this on the tifimage (as Pilatus is tiff with a  
20  # tiff header  
21   
22  from fabio.tifimage import tifimage 
23   
24   
25 -class pilatusimage(tifimage):
26 """ Read in Pilatus format, also 27 pilatus images, including header info """ 28 29
30 - def _readheader(self, infile):
31 """ 32 Parser based approach 33 Gets all entries 34 """ 35 # infile = open(infile) 36 hstr = infile.read(4096) 37 # well not very pretty - but seems to find start of 38 # header information 39 hstr = hstr[hstr.index('# '):] 40 hstr = hstr[:hstr.index('\x00')] 41 hstr = hstr.split('#') 42 go_on = True 43 while go_on: 44 try: 45 hstr.remove('') 46 except: 47 go_on = False 48 49 50 self.header = {} 51 52 for line in hstr: 53 line = line[1:line.index('\r\n')] 54 if line.find(':') > -1: 55 dump = line.split(':') 56 self.header[dump[0]] = dump[1] 57 elif line.find('=') > -1: 58 dump = line.split('=') 59 self.header[dump[0]] = dump[1] 60 elif line.find(' ') > -1: 61 i = line.find(' ') 62 self.header[line[:i]] = line[i:] 63 elif line.find(',') > -1: 64 dump = line.split(',') 65 self.header[dump[0]] = dump[1] 66 67 return self.header
68 69 70
71 - def _read(self, fname):
72 """ 73 inherited from tifimage 74 ... a Pilatus image *is a* tif image 75 just with a header 76 """ 77 return tifimage.read(self, fname)
78