tt.py 643 Bytes
Newer Older
Fang Yuedong's avatar
Fang Yuedong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
import ctypes

libPCA = ctypes.CDLL('../libPCA.so')  # CDLL加载库
print('load libPCA')

npsf = 2
npix = 3

libPCA.psfPCA.argtypes = [ctypes.POINTER(ctypes.c_float), ctypes.c_int, ctypes.c_int, ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double)]

Nstar = npsf
Mp    = npix*npix
NM    = Nstar*Mp
NN    = Nstar*Nstar
arr   = (ctypes.c_float*NM)()
basef = (ctypes.c_double*NM)()
coeff = (ctypes.c_double*NN)()

#psf1 = np.random.random([npix, npix])
#psf2 = np.random.random([npix, npix])
psfT  = np.random.random(Nstar*Mp)
arr[:] = psfT
libPCA.psfPCA(arr, Nstar, Mp, basef, coeff)

print('haha')
print(arr[:])