Ignore:
Timestamp:
Oct 30, 2017 3:39:15 PM (5 years ago)
Author:
vondreele
Message:

fix MAR345 & CBF importers to work for python 3.6 as well as python 2.7; revised importers & new fortran decompression routines for py3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/imports/G2img_CBF.py

    r3141 r3144  
    1717import GSASIIobj as G2obj
    1818import GSASIIpath
     19import struct as st
     20import numpy as np
    1921import unpack_cbf as cbf
    2022GSASIIpath.SetVersionNumber("$Revision: 2133 $")
     
    4850    'Read cif binarydetector data cbf file'
    4951   
    50     import numpy as np
    5152    if GSASIIpath.GetConfigValue('debug'):
    5253        print ('Read cif binary detector data cbf file: '+filename)
     
    9596    img = File.read()[imageBeg:imageBeg+compImageSize]
    9697    nimg = len(img)
    97     if 'bytes' in str(type(img)):
    98         img = np.array(img,dtype='a')
    9998    image = np.zeros(nxy,dtype=np.int32)
    10099    time0 = time.time()
    101 #    GSASIIpath.IPyBreak()
    102     image = cbf.unpack_cbf(nimg,img,nxy,image)
     100    if 'bytes' in str(type(img)):
     101        img = np.frombuffer(img,dtype=np.uint8)
     102        image = cbf.unpack_cbf3(nimg,img,nxy,image)
     103    else:
     104        image = cbf.unpack_cbf(nimg,img,nxy,image)
    103105    image = np.reshape(image,(sizexy[1],sizexy[0]))
    104106    print ('import time: %.3f'%(time.time()-time0))
Note: See TracChangeset for help on using the changeset viewer.