Changeset 2441


Ignore:
Timestamp:
Aug 21, 2016 2:58:27 PM (7 years ago)
Author:
vondreele
Message:

fix bug in unpack_cbf.for, cleanup G2img_CF.py & reload win32 & win64 binaries

Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/fsource/unpack_cbf.for

    r2437 r2441  
    1919      INTEGER*2 ITWOBYTES
    2020      INTEGER*4 IFOURBYTES
    21      
     21
    2222      E1 = CHAR(128)
    2323      E2 = CHAR(0)//CHAR(128)
    2424      E4 = CHAR(0)//CHAR(0)//CHAR(0)//CHAR(128)
    2525
    26       I = 1
     26      I = 0
    2727      J = 0
     28      BASEPIXEL = 0
    2829      DO WHILE ( I.LT.N )
    2930        C1 = CMPR(I)
     
    4344           END IF
    4445        END IF
    45 c        BASEPIXEL = 0
    4646        IF ( ISIZE .EQ. 1 ) THEN
    4747           IONEBYTE = ICHAR(CMPR(I))
     
    6161           BASEPIXEL = BASEPIXEL+IFOURBYTES
    6262        END IF
     63c        IF ( MOD(J,100000).EQ.0 ) PRINT *,I,J,BASEPIXEL
    6364        IMG(J) = BASEPIXEL
    6465        J = J+1
  • trunk/imports/G2img_CBF.py

    r2440 r2441  
    5050   
    5151    import numpy as np
    52     import cPickle
    53    
    54     def analyse(stream):
    55         """
    56         Analyze a stream of char with any length of exception (2,4, or 8 bytes integers)
    57 
    58         @return list of NParrays
    59         """
    60         listnpa = []
    61         key16 = "\x80"
    62         key32 = "\x00\x80"
    63         key64 = "\x00\x00\x00\x80"
    64         idx = 0
    65         shift = 1
    66         position = 0
    67         while True:
    68             lns = len(stream)
    69             idx = stream.find(key16)
    70             if idx == -1:
    71                 listnpa.append(np.fromstring(stream, dtype="int8"))
    72                 break
    73             listnpa.append(np.fromstring(stream[:idx], dtype="int8"))
    74             position += listnpa[-1].size
    75 
    76             if stream[idx + 1:idx + 3] == key32:
    77                 if stream[idx + 3:idx + 7] == key64:
    78                     listnpa.append(np.fromstring(stream[idx + 7:idx + 15], dtype="int64"))
    79                     position += 1
    80 #                    print "loop64 x=%4i y=%4i in idx %4i lns %4i value=%s" % ((position % 2463), (position // 2463), idx, lns, listnpa[-1])
    81                     shift = 15
    82                 else: #32 bit int
    83                     listnpa.append(np.fromstring(stream[idx + 3:idx + 7], dtype="int32"))
    84                     position += 1
    85 #                    print "loop32 x=%4i y=%4i in idx %4i lns %4i value=%s" % ((position % 2463), (position // 2463), idx, lns, listnpa[-1])
    86                     shift = 7
    87             else: #int16
    88                 listnpa.append(np.fromstring(stream[idx + 1:idx + 3], dtype="int16"))
    89                 position += 1
    90 #                print "loop16 x=%4i y=%4i in idx %4i lns %4i value=%s" % ((position % 2463), (position // 2463), idx, lns, listnpa[-1])
    91                 shift = 3
    92             stream = stream[idx + shift:]
    93         return  listnpa
    94    
    95    
    9652    if GSASIIpath.GetConfigValue('debug'):
    9753        print 'Read cif binary detector data cbf file: ',filename
     
    13490        elif 'Number-of-Elements' in line:
    13591            Npix = int(fields[1])
     92    nxy = sizexy[0]*sizexy[1]
     93    image = np.zeros(nxy,dtype=np.int32)
    13694    cent = [cent[0]*pixSize[0]/1000.,cent[1]*pixSize[1]/1000.]
    13795    compImage = stream[imageBeg:imageBeg+compImageSize]
    13896#    GSASIIpath.IPyBreak()
    13997    time0 = time.time()
    140     nxy = sizexy[0]*sizexy[1]
    14198    nimg = len(compImage)
    142     image = np.zeros(nxy,dtype=np.float32)
    14399    image = cbf.unpack_cbf(nimg,compImage,nxy,image)
    144 #    image = np.hstack(analyse(compImage)).cumsum()
    145100    image = np.reshape(image,(sizexy[1],sizexy[0]))
    146 #    print 'import time:',time.time()-time0
     101    print 'import time:',time.time()-time0
    147102    data = {'pixelSize':pixSize,'wavelength':wave,'distance':dist,'center':cent,'size':sizexy}
    148103    Npix = sizexy[0]*sizexy[1]
Note: See TracChangeset for help on using the changeset viewer.