Changeset 3136 for trunk/imports/G2img_MAR.py
- Timestamp:
- Oct 23, 2017 11:39:16 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/imports/G2img_MAR.py
r2817 r3136 12 12 ''' 13 13 14 from __future__ import division, print_function 15 import platform 16 import sys 17 import struct as st 14 18 import GSASIIobj as G2obj 15 19 import GSASIIpath … … 27 31 ) 28 32 29 def ContentsValidator(self, file pointer):33 def ContentsValidator(self, filename): 30 34 '''no test at this time 31 35 ''' 32 36 return True 33 37 34 def Reader(self,filename, filepointer,ParentFrame=None, **unused):38 def Reader(self,filename, ParentFrame=None, **unused): 35 39 self.Comments,self.Data,self.Npix,self.Image = GetMAR345Data(filename) 36 40 if self.Npix == 0 or not self.Comments: … … 44 48 import pack_f as pf 45 49 except: 46 print '**** ERROR - Unable to load the GSAS MAR image decompression, pack_f'50 print ('**** ERROR - Unable to load the GSAS MAR image decompression, pack_f') 47 51 return None,None,None,None 48 52 49 53 if not imageOnly: 50 print 'Read Mar345 file: ',filename54 print ('Read Mar345 file: '+filename) 51 55 File = open(filename,'rb') 52 head = File.read(4095) 56 head = File.read(4095).decode(encoding='latin-1') 53 57 lines = head[128:].split('\n') 54 58 head = [] … … 79 83 data['size'] = [sizex,sizey] 80 84 File.seek(pos) 81 line = File.read(8) 85 line = File.read(8).decode(encoding='latin-1') 82 86 while 'CCP4' not in line: #get past overflow list for now 83 line = File.read(8) 87 line = File.read(8).decode(encoding='latin-1') 84 88 pos += 8 85 89 pos += 37 86 90 File.seek(pos) 87 raw = File.read() 91 if '2' in platform.python_version_tuple()[0]: 92 raw = File.read() 93 else: 94 raw = File.read() 95 print (type(raw),sys.getsizeof(raw),raw[:10]) 96 image = np.zeros(shape=(sizex,sizey),dtype=np.int32) 97 image = np.flipud(pf.pack_f(len(raw),raw,sizex,sizey,image).T) #transpose to get it right way around & flip 88 98 File.close() 89 image = np.zeros(shape=(sizex,sizey),dtype=np.int32)90 91 image = np.flipud(pf.pack_f(len(raw),raw,sizex,sizey,image).T) #transpose to get it right way around & flip92 99 if imageOnly: 93 100 return image
Note: See TracChangeset
for help on using the changeset viewer.