22 * Diffraction Functions *
33 ******************************************************************************
44 * Purpose: *
5- * This file contains functions used for computing the Fresnel Inverse *
6- * Transform on a set of diffraction limited data. There are several *
7- * Methods of performing this: *
8- * Fresnel Quadratic Approximation: *
9- * Classic quadratic approximation from Fourier Optics. *
10- * Legendre Expansions: *
11- * Uses Legendre polynomials to approximate the Fresnel kernel. *
12- * Newton-Raphon Method: *
13- * Uses Newton-Raphson root finding method to compute the *
14- * stationary value of the Fresnel kernel. *
15- ******************************************************************************
16- * The Inverse Fresnel Transform: *
17- * *
18- * W/2 *
19- * - *
20- * | | *
21- * T(rho) = | T_hat(r_0)w(r-r_0)exp(-i psi(r,r_0)) dr_0 *
22- * | | *
23- * - *
24- * -W/2 *
25- * *
26- * Where T_hat is the diffracted data, w is the window function, r is *
27- * the ring intercept point, and r_0 is a dummy variable of integration. *
28- * psi is the Fresnel Kernel, and exp is simply the exponential function. *
29- ******************************************************************************
30- * The Normalization Scheme: *
31- * As the resolution get's too high, say 10 km or greater, the window *
32- * width quickly shrinks to zero. Thus the integral will be close to *
33- * zero. To account for this the option to normalize the integral by the *
34- * window width is offered. The normalization is defined as follows: *
35- * *
36- * | _ +infinity | *
37- * | | | | *
38- * | | exp(-i psi(x)) dx | *
39- * | | | | *
40- * | - -infinity | *
41- * Norm = __________________________________ *
42- * | - +W/2 | *
43- * | | | | *
44- * | | w(x) exp(-i psi(x)) dx | *
45- * | | | | *
46- * | - -W/2 | *
47- * *
48- * This has the effect of making the free-space regions, or regions which*
49- * were not affected by diffraction, evaluate to approximately one, *
50- * regardless of what resolution was chosen. *
51- ******************************************************************************
52- * DEFINED FUNCTIONS *
53- ******************************************************************************
54- * complex_double_fresnel_transform_quadratic: *
55- * Computes the Fresnel Inverse Transform using Fresnel's approximation. *
56- * This is the fastest, but can be inaccurate for certain geometries. *
57- ******************************************************************************
58- * complex_double_fresnel_legendre_transform: *
59- * Approximates the transform using Legendre polynomials. This is very *
60- * fast and accurate. It is the default method called from Python. *
61- ******************************************************************************
62- * complex_double_fresnel_transform_newton: *
63- * Uses Newton-Raphson to compute the stationary value of the Fresnel *
64- * Kernel. This is the most accurate, but also the slowest. *
5+ * This file contains wrappers for the routines found in *
6+ * __diffraction_functions.c to allow use with the Python interpreter. *
657 ******************************************************************************
668 * A FRIENDY WARNING *
679 ******************************************************************************
@@ -101,10 +43,10 @@ static void complex_double_fresnel_transform(char **args, npy_intp *dimensions,
10143 dlp .w_km_vals = (double * )args [7 ];
10244 dlp .start = * (long * )args [8 ];
10345 dlp .n_used = * (long * )args [9 ];
104- dlp .wtype = * (int * )args [10 ];
105- dlp .use_norm = * (int * )args [11 ];
106- dlp .use_fwd = * (int * )args [12 ];
107- dlp .order = * (int * )args [13 ];
46+ dlp .wtype = * (unsigned char * )args [10 ];
47+ dlp .use_norm = * (unsigned char * )args [11 ];
48+ dlp .use_fwd = * (unsigned char * )args [12 ];
49+ dlp .order = * (unsigned char * )args [13 ];
10850 dlp .T_out = (complex double * )args [14 ];
10951
11052 if (dlp .order == 0 ){
@@ -118,19 +60,12 @@ static void complex_double_fresnel_transform(char **args, npy_intp *dimensions,
11860 }
11961}
12062
121- /******************************************************************************
122- *----------------------------C Python API Stuff------------------------------*
123- ******************************************************************************/
124-
12563static PyMethodDef _diffraction_functions_methods [] = {{NULL , NULL , 0 , NULL }};
12664
12765/* Define pointers to the C functions. */
128- PyUFuncGenericFunction funcs [1 ] = {
129- & complex_double_fresnel_transform
130- };
66+ PyUFuncGenericFunction funcs [1 ] = {& complex_double_fresnel_transform };
13167
132-
133- /* Input and return types for Quartic Fresnel Transform */
68+ /* Input and return types for the Fresnel Transform */
13469static char data_types [15 ] = {
13570 NPY_CDOUBLE ,
13671 NPY_DOUBLE ,
@@ -142,24 +77,23 @@ static char data_types[15] = {
14277 NPY_DOUBLE ,
14378 NPY_LONG ,
14479 NPY_LONG ,
145- NPY_LONG ,
146- NPY_LONG ,
147- NPY_LONG ,
148- NPY_LONG ,
80+ NPY_UBYTE ,
81+ NPY_UBYTE ,
82+ NPY_UBYTE ,
83+ NPY_UBYTE ,
14984 NPY_CDOUBLE
15085};
15186
15287static void * PyuFunc_data [1 ] = {NULL };
15388
15489#if PY_VERSION_HEX >= 0x03000000
155- static struct PyModuleDef moduledef = {PyModuleDef_HEAD_INIT ,
156- "_diffraction_functions" ,
157- NULL ,
158- -1 ,
159- _diffraction_functions_methods ,
160- NULL , NULL , NULL , NULL };
161-
162- PyMODINIT_FUNC PyInit__diffraction_functions (void ){
90+ static struct PyModuleDef moduledef = {
91+ PyModuleDef_HEAD_INIT , "_diffraction_functions" , NULL , -1 ,
92+ _diffraction_functions_methods , NULL , NULL , NULL , NULL
93+ };
94+
95+ PyMODINIT_FUNC PyInit__diffraction_functions (void )
96+ {
16397 PyObject * fresnel_transform ;
16498 PyObject * m , * d ;
16599
@@ -183,7 +117,8 @@ PyMODINIT_FUNC PyInit__diffraction_functions(void){
183117 return m ;
184118}
185119#else
186- PyMODINIT_FUNC init__diffraction_functions (void ){
120+ PyMODINIT_FUNC init__diffraction_functions (void )
121+ {
187122 PyObject * fresnel_transform ;
188123 PyObject * m , * d ;
189124
@@ -197,7 +132,7 @@ PyMODINIT_FUNC init__diffraction_functions(void){
197132
198133 fresnel_transform = PyUFunc_FromFuncAndData (
199134 funcs , PyuFunc_data , data_types , 1 , 14 , 1 , PyUFunc_None ,
200- "fresnel_transform_" , "fresnel_transform " , 0
135+ "fresnel_transform_" , "fresnel_transform_docstring " , 0
201136 );
202137
203138 d = PyModule_GetDict (m );
@@ -206,4 +141,4 @@ PyMODINIT_FUNC init__diffraction_functions(void){
206141 Py_DECREF (fresnel_transform );
207142 return m ;
208143}
209- #endif
144+ #endif
0 commit comments