Moved code. Reorganized more OO like
This commit is contained in:
parent
8258bd0fe9
commit
688e4e20de
6 changed files with 192 additions and 140 deletions
18
python_sample/icgen/borgadaptor.py
Normal file
18
python_sample/icgen/borgadaptor.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import numpy as np
|
||||
|
||||
def fourier_analysis(borg_vol):
|
||||
L = (borg_vol.ranges[1]-borg_vol.ranges[0])
|
||||
N = borg_vol.density.shape[0]
|
||||
|
||||
return np.fft.rfftn(borg_vol.density)*(L/N)**3, L, N
|
||||
|
||||
def half_pixel_shift(borg):
|
||||
|
||||
dhat,L,N = fourier_analysis(borg)
|
||||
|
||||
ik = np.fft.fftfreq(N,d=L/N)*2*np.pi
|
||||
phi = 0.5*L/N*(ik[:,None,None]+ik[None,:,None]+ik[None,None,:(N/2+1)])
|
||||
phase = np.cos(phi)+1j*np.sin(phi)
|
||||
|
||||
return dhat*phase, L
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue