22
33from __future__ import division , print_function
44
5- __all__ = ["nufft1freqs " , "nufft1 " , "nufft2 " , "nufft3 " ]
5+ __all__ = ["nufft1d1freqs " , "nufft1d1 " , "nufft1d2 " , "nufft1d3" , "nufft2d1 " ]
66
77import numpy as np
88from ._nufft import (
99 dirft1d1 , nufft1d1f90 ,
1010 dirft1d2 , nufft1d2f90 ,
1111 dirft1d3 , nufft1d3f90 ,
12+ dirft2d1 , nufft2d1f90 ,
1213)
1314
1415
15- def nufft1freqs (ms , df = 1.0 ):
16+ def nufft1d1freqs (ms , df = 1.0 ):
1617 return df * (np .arange (- ms // 2 , ms // 2 ) + ms % 2 )
1718
1819
19- def nufft1 (x , y , ms , df = 1.0 , eps = 1e-15 , iflag = 1 , direct = False ):
20+ def nufft1d1 (x , y , ms , df = 1.0 , eps = 1e-15 , iflag = 1 , direct = False ):
2021 # Make sure that the data are properly formatted.
2122 x = np .ascontiguousarray (x , dtype = np .float64 )
2223 y = np .ascontiguousarray (y , dtype = np .complex128 )
@@ -34,7 +35,7 @@ def nufft1(x, y, ms, df=1.0, eps=1e-15, iflag=1, direct=False):
3435 return p
3536
3637
37- def nufft2 (x , p , df = 1.0 , eps = 1e-15 , iflag = 1 , direct = False ):
38+ def nufft1d2 (x , p , df = 1.0 , eps = 1e-15 , iflag = 1 , direct = False ):
3839 # Make sure that the data are properly formatted.
3940 x = np .ascontiguousarray (x , dtype = np .float64 )
4041 p = np .ascontiguousarray (p , dtype = np .complex128 )
@@ -50,7 +51,7 @@ def nufft2(x, p, df=1.0, eps=1e-15, iflag=1, direct=False):
5051 return y
5152
5253
53- def nufft3 (x , y , f , eps = 1e-15 , iflag = 1 , direct = False ):
54+ def nufft1d3 (x , y , f , eps = 1e-15 , iflag = 1 , direct = False ):
5455 # Make sure that the data are properly formatted.
5556 x = np .ascontiguousarray (x , dtype = np .float64 )
5657 y = np .ascontiguousarray (y , dtype = np .complex128 )
@@ -69,3 +70,22 @@ def nufft3(x, y, f, eps=1e-15, iflag=1, direct=False):
6970 if flag :
7071 raise RuntimeError ("nufft1d3 failed with code {0}" .format (flag ))
7172 return p / len (x )
73+
74+
75+ def nufft2d1 (x , y , z , ms , mt , df = 1.0 , eps = 1e-15 , iflag = 1 , direct = False ):
76+ # Make sure that the data are properly formatted.
77+ x = np .ascontiguousarray (x , dtype = np .float64 )
78+ y = np .ascontiguousarray (x , dtype = np .float64 )
79+ z = np .ascontiguousarray (y , dtype = np .complex128 )
80+ if len (x ) != len (y ) or len (y ) != len (z ):
81+ raise ValueError ("Dimension mismatch" )
82+
83+ # Run the Fortran code.
84+ if direct :
85+ p = dirft2d1 (x * df , y * df , z , iflag , ms , mt )
86+ else :
87+ p , flag = nufft2d1f90 (x * df , y * df , z , iflag , eps , ms , mt )
88+ # Check the output and return.
89+ if flag :
90+ raise RuntimeError ("nufft2d1 failed with code {0}" .format (flag ))
91+ return p
0 commit comments