Skip to content

Commit b77a5c6

Browse files
committed
removed pynfft dependency in favor of jvdps shiny new python implementation of nfft
1 parent c779cf0 commit b77a5c6

File tree

4 files changed

+21
-29
lines changed

4 files changed

+21
-29
lines changed

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ env:
1212
global:
1313
- TEST_DIR=/tmp/ftperiodogram
1414
- CONDA_DEPS="numpy scipy pytest pip"
15-
- PIP_DEPS="astroML gatspy coverage codecov pytest-cov"
16-
- CONDA_FORGE_DEPS="pynfft"
15+
- PIP_DEPS="coverage codecov pytest-cov"
1716

1817
before_install:
1918
- export MINICONDA=$HOME/miniconda
@@ -28,7 +27,6 @@ before_install:
2827
install:
2928
- conda create -q -n test-env python=$TRAVIS_PYTHON_VERSION $CONDA_DEPS
3029
- source activate test-env
31-
- conda install -c conda-forge $CONDA_FORGE_DEPS
3230
- pip install $PIP_DEPS
3331
- python setup.py install
3432

ftperiodogram/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.9.1"
1+
__version__ = "0.9.2"
22

33
from .modeler import FastTemplatePeriodogram, FastMultiTemplatePeriodogram
44
from .template import Template

ftperiodogram/cuda_utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#import pycuda.autoinit
2+
#import pycuda.driver as drv
3+
#import numpy as np
4+

ftperiodogram/summations.py

+15-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from pynfft.nfft import NFFT
1+
#from future import __division__
2+
from nfft import nfft_adjoint
23
from .utils import Summations
34
import numpy as np
45
from math import floor
@@ -67,20 +68,24 @@ def direct_summations(t, y, w, freqs, nh):
6768

6869

6970

70-
def fast_summations(t, y, w, freqs, nh, eps=1E-5):
71+
def fast_summations(t, y, w, freqs, nh, sigma=2, tol=1E-7, m=None,
72+
kernel='gaussian', use_fft=True, truncated=True):
7173
"""
7274
Computes C, S, YC, YS, CC, CS, SS using
73-
pyNFFT
75+
nfft Python implementation by Jake Vanderplas
7476
"""
77+
nfft_kwargs = dict(sigma=sigma, tol=tol, m=m,
78+
kernel=kernel, use_fft=use_fft,
79+
truncated=truncated)
80+
7581
nf, df, dnf = inspect_freqs(freqs)
7682
tmin = min(t)
7783

7884
# infer samples per peak
7985
baseline = max(t) - tmin
8086
samples_per_peak = 1./(baseline * df)
8187

82-
eps = 1E-5
83-
a = 0.5 - eps
88+
a = 0.5 - 1E-8
8489
r = 2 * a / df
8590

8691
tshift = a * (2 * (t - tmin) / r - 1)
@@ -90,38 +95,23 @@ def fast_summations(t, y, w, freqs, nh, eps=1E-5):
9095
# nf_nfft_w / 2 - 1 = 2H * (nf - 1 + dnf)
9196
nf_nfft_u = 2 * ( nh * (nf + dnf - 1) + 1)
9297
nf_nfft_w = 2 * ( 2 * nh * (nf + dnf - 1) + 1)
93-
n_w0 = int(floor(nf_nfft_w/2))
94-
n_u0 = int(floor(nf_nfft_u/2))
9598

9699
# transform y -> w_i * y_i - ybar
97100
ybar = np.dot(w, y)
98101
u = np.multiply(w, y - ybar)
99102

100-
# plan NFFT's and precompute
101-
plan = NFFT(nf_nfft_w, len(tshift))
102-
plan.x = tshift
103-
plan.precompute()
104-
105-
plan2 = NFFT(nf_nfft_u, len(tshift))
106-
plan2.x = tshift
107-
plan2.precompute()
108-
109-
# NFFT(weights)
110-
plan.f = w
111-
112-
f_hat_w = plan.adjoint()[n_w0:]
113-
114-
# NFFT(y - ybar)
115-
plan2.f = u
116-
f_hat_u = plan2.adjoint()[n_u0:]
103+
104+
n_w0 = int(floor(nf_nfft_w/2))
105+
n_u0 = int(floor(nf_nfft_u/2))
106+
f_hat_u = nfft_adjoint(tshift, u, nf_nfft_u, **nfft_kwargs )[n_u0:]
107+
f_hat_w = nfft_adjoint(tshift, w, nf_nfft_w, **nfft_kwargs )[n_w0:]
117108

118109
# now correct for phase shift induced by transforming t -> (-1/2, 1/2)
119110
beta = -a * (2 * tmin / r + 1)
120111
I = 0. + 1j
121112
twiddles = np.exp(- I * 2 * np.pi * np.arange(0, n_w0) * beta)
122113
f_hat_u *= twiddles[:len(f_hat_u)]
123114
f_hat_w *= twiddles[:len(f_hat_w)]
124-
125115
all_computed_sums = []
126116

127117
# Now compute the summation values at each frequency

0 commit comments

Comments
 (0)