The requested changes are too big and content was truncated. Show full diff
@@ -0,0 +1,37 | |||
|
1 | C -*- fortran -*- | |
|
2 | C This file is autogenerated with f2py (version:2) | |
|
3 | C It contains Fortran 77 wrappers to fortran functions. | |
|
4 | ||
|
5 | subroutine f2pywrapspect1 (spect1f2pywrap, omega) | |
|
6 | external spect1 | |
|
7 | real omega | |
|
8 | real spect1f2pywrap, spect1 | |
|
9 | spect1f2pywrap = spect1(omega) | |
|
10 | end | |
|
11 | ||
|
12 | ||
|
13 | subroutine f2pyinitspec(setupfunc) | |
|
14 | external setupfunc | |
|
15 | real te | |
|
16 | real ti(10) | |
|
17 | real fi(10) | |
|
18 | real ven | |
|
19 | real vin(10) | |
|
20 | real alpha | |
|
21 | real dens | |
|
22 | real bfld | |
|
23 | integer nion | |
|
24 | integer wi(10) | |
|
25 | real ak | |
|
26 | common /spec/ te,ti,fi,ven,vin,alpha,dens,bfld,nion,wi,ak | |
|
27 | call setupfunc(te,ti,fi,ven,vin,alpha,dens,bfld,nion,wi,ak) | |
|
28 | end | |
|
29 | ||
|
30 | subroutine f2pyinitmode(setupfunc) | |
|
31 | external setupfunc | |
|
32 | integer imode | |
|
33 | common /mode/ imode | |
|
34 | call setupfunc(imode) | |
|
35 | end | |
|
36 | ||
|
37 |
This diff has been collapsed as it changes many lines, (797 lines changed) Show them Hide them | |||
@@ -0,0 +1,797 | |||
|
1 | /* File: fitacf_acf2module.c | |
|
2 | * This file is auto-generated with f2py (version:2). | |
|
3 | * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition, | |
|
4 | * written by Pearu Peterson <pearu@cens.ioc.ee>. | |
|
5 | * Generation date: Wed Jan 8 13:23:37 2025 | |
|
6 | * Do not edit this file directly unless you know what you are doing!!! | |
|
7 | */ | |
|
8 | ||
|
9 | #ifdef __cplusplus | |
|
10 | extern "C" { | |
|
11 | #endif | |
|
12 | ||
|
13 | /*********************** See f2py2e/cfuncs.py: includes ***********************/ | |
|
14 | #include "Python.h" | |
|
15 | #include <stdarg.h> | |
|
16 | #include "fortranobject.h" | |
|
17 | #include <math.h> | |
|
18 | ||
|
19 | /**************** See f2py2e/rules.py: mod_rules['modulebody'] ****************/ | |
|
20 | static PyObject *fitacf_acf2_error; | |
|
21 | static PyObject *fitacf_acf2_module; | |
|
22 | ||
|
23 | /*********************** See f2py2e/cfuncs.py: typedefs ***********************/ | |
|
24 | /*need_typedefs*/ | |
|
25 | ||
|
26 | /****************** See f2py2e/cfuncs.py: typedefs_generated ******************/ | |
|
27 | /*need_typedefs_generated*/ | |
|
28 | ||
|
29 | /********************** See f2py2e/cfuncs.py: cppmacros **********************/ | |
|
30 | #if defined(PREPEND_FORTRAN) | |
|
31 | #if defined(NO_APPEND_FORTRAN) | |
|
32 | #if defined(UPPERCASE_FORTRAN) | |
|
33 | #define F_FUNC(f,F) _##F | |
|
34 | #else | |
|
35 | #define F_FUNC(f,F) _##f | |
|
36 | #endif | |
|
37 | #else | |
|
38 | #if defined(UPPERCASE_FORTRAN) | |
|
39 | #define F_FUNC(f,F) _##F##_ | |
|
40 | #else | |
|
41 | #define F_FUNC(f,F) _##f##_ | |
|
42 | #endif | |
|
43 | #endif | |
|
44 | #else | |
|
45 | #if defined(NO_APPEND_FORTRAN) | |
|
46 | #if defined(UPPERCASE_FORTRAN) | |
|
47 | #define F_FUNC(f,F) F | |
|
48 | #else | |
|
49 | #define F_FUNC(f,F) f | |
|
50 | #endif | |
|
51 | #else | |
|
52 | #if defined(UPPERCASE_FORTRAN) | |
|
53 | #define F_FUNC(f,F) F##_ | |
|
54 | #else | |
|
55 | #define F_FUNC(f,F) f##_ | |
|
56 | #endif | |
|
57 | #endif | |
|
58 | #endif | |
|
59 | #if defined(UNDERSCORE_G77) | |
|
60 | #define F_FUNC_US(f,F) F_FUNC(f##_,F##_) | |
|
61 | #else | |
|
62 | #define F_FUNC_US(f,F) F_FUNC(f,F) | |
|
63 | #endif | |
|
64 | ||
|
65 | #define rank(var) var ## _Rank | |
|
66 | #define shape(var,dim) var ## _Dims[dim] | |
|
67 | #define old_rank(var) (PyArray_NDIM((PyArrayObject *)(capi_ ## var ## _tmp))) | |
|
68 | #define old_shape(var,dim) PyArray_DIM(((PyArrayObject *)(capi_ ## var ## _tmp)),dim) | |
|
69 | #define fshape(var,dim) shape(var,rank(var)-dim-1) | |
|
70 | #define len(var) shape(var,0) | |
|
71 | #define flen(var) fshape(var,0) | |
|
72 | #define old_size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp)) | |
|
73 | /* #define index(i) capi_i ## i */ | |
|
74 | #define slen(var) capi_ ## var ## _len | |
|
75 | #define size(var, ...) f2py_size((PyArrayObject *)(capi_ ## var ## _tmp), ## __VA_ARGS__, -1) | |
|
76 | ||
|
77 | #define CHECKSCALAR(check,tcheck,name,show,var)\ | |
|
78 | if (!(check)) {\ | |
|
79 | char errstring[256];\ | |
|
80 | sprintf(errstring, "%s: "show, "("tcheck") failed for "name, var);\ | |
|
81 | PyErr_SetString(fitacf_acf2_error,errstring);\ | |
|
82 | /*goto capi_fail;*/\ | |
|
83 | } else | |
|
84 | #ifdef DEBUGCFUNCS | |
|
85 | #define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess); | |
|
86 | #define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \ | |
|
87 | PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\ | |
|
88 | fprintf(stderr,"\n"); | |
|
89 | #else | |
|
90 | #define CFUNCSMESS(mess) | |
|
91 | #define CFUNCSMESSPY(mess,obj) | |
|
92 | #endif | |
|
93 | ||
|
94 | #ifndef max | |
|
95 | #define max(a,b) ((a > b) ? (a) : (b)) | |
|
96 | #endif | |
|
97 | #ifndef min | |
|
98 | #define min(a,b) ((a < b) ? (a) : (b)) | |
|
99 | #endif | |
|
100 | #ifndef MAX | |
|
101 | #define MAX(a,b) ((a > b) ? (a) : (b)) | |
|
102 | #endif | |
|
103 | #ifndef MIN | |
|
104 | #define MIN(a,b) ((a < b) ? (a) : (b)) | |
|
105 | #endif | |
|
106 | ||
|
107 | #if defined(PREPEND_FORTRAN) | |
|
108 | #if defined(NO_APPEND_FORTRAN) | |
|
109 | #if defined(UPPERCASE_FORTRAN) | |
|
110 | #define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F | |
|
111 | #else | |
|
112 | #define F_WRAPPEDFUNC(f,F) _f2pywrap##f | |
|
113 | #endif | |
|
114 | #else | |
|
115 | #if defined(UPPERCASE_FORTRAN) | |
|
116 | #define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_ | |
|
117 | #else | |
|
118 | #define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_ | |
|
119 | #endif | |
|
120 | #endif | |
|
121 | #else | |
|
122 | #if defined(NO_APPEND_FORTRAN) | |
|
123 | #if defined(UPPERCASE_FORTRAN) | |
|
124 | #define F_WRAPPEDFUNC(f,F) F2PYWRAP##F | |
|
125 | #else | |
|
126 | #define F_WRAPPEDFUNC(f,F) f2pywrap##f | |
|
127 | #endif | |
|
128 | #else | |
|
129 | #if defined(UPPERCASE_FORTRAN) | |
|
130 | #define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_ | |
|
131 | #else | |
|
132 | #define F_WRAPPEDFUNC(f,F) f2pywrap##f##_ | |
|
133 | #endif | |
|
134 | #endif | |
|
135 | #endif | |
|
136 | #if defined(UNDERSCORE_G77) | |
|
137 | #define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_) | |
|
138 | #else | |
|
139 | #define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F) | |
|
140 | #endif | |
|
141 | ||
|
142 | ||
|
143 | /************************ See f2py2e/cfuncs.py: cfuncs ************************/ | |
|
144 | static int double_from_pyobj(double* v,PyObject *obj,const char *errmess) { | |
|
145 | PyObject* tmp = NULL; | |
|
146 | if (PyFloat_Check(obj)) { | |
|
147 | #ifdef __sgi | |
|
148 | *v = PyFloat_AsDouble(obj); | |
|
149 | #else | |
|
150 | *v = PyFloat_AS_DOUBLE(obj); | |
|
151 | #endif | |
|
152 | return 1; | |
|
153 | } | |
|
154 | tmp = PyNumber_Float(obj); | |
|
155 | if (tmp) { | |
|
156 | #ifdef __sgi | |
|
157 | *v = PyFloat_AsDouble(tmp); | |
|
158 | #else | |
|
159 | *v = PyFloat_AS_DOUBLE(tmp); | |
|
160 | #endif | |
|
161 | Py_DECREF(tmp); | |
|
162 | return 1; | |
|
163 | } | |
|
164 | if (PyComplex_Check(obj)) | |
|
165 | tmp = PyObject_GetAttrString(obj,"real"); | |
|
166 | else if (PyString_Check(obj) || PyUnicode_Check(obj)) | |
|
167 | /*pass*/; | |
|
168 | else if (PySequence_Check(obj)) | |
|
169 | tmp = PySequence_GetItem(obj,0); | |
|
170 | if (tmp) { | |
|
171 | PyErr_Clear(); | |
|
172 | if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} | |
|
173 | Py_DECREF(tmp); | |
|
174 | } | |
|
175 | { | |
|
176 | PyObject* err = PyErr_Occurred(); | |
|
177 | if (err==NULL) err = fitacf_acf2_error; | |
|
178 | PyErr_SetString(err,errmess); | |
|
179 | } | |
|
180 | return 0; | |
|
181 | } | |
|
182 | ||
|
183 | static int f2py_size(PyArrayObject* var, ...) | |
|
184 | { | |
|
185 | npy_int sz = 0; | |
|
186 | npy_int dim; | |
|
187 | npy_int rank; | |
|
188 | va_list argp; | |
|
189 | va_start(argp, var); | |
|
190 | dim = va_arg(argp, npy_int); | |
|
191 | if (dim==-1) | |
|
192 | { | |
|
193 | sz = PyArray_SIZE(var); | |
|
194 | } | |
|
195 | else | |
|
196 | { | |
|
197 | rank = PyArray_NDIM(var); | |
|
198 | if (dim>=1 && dim<=rank) | |
|
199 | sz = PyArray_DIM(var, dim-1); | |
|
200 | else | |
|
201 | fprintf(stderr, "f2py_size: 2nd argument value=%d fails to satisfy 1<=value<=%d. Result will be 0.\n", dim, rank); | |
|
202 | } | |
|
203 | va_end(argp); | |
|
204 | return sz; | |
|
205 | } | |
|
206 | ||
|
207 | static int float_from_pyobj(float* v,PyObject *obj,const char *errmess) { | |
|
208 | double d=0.0; | |
|
209 | if (double_from_pyobj(&d,obj,errmess)) { | |
|
210 | *v = (float)d; | |
|
211 | return 1; | |
|
212 | } | |
|
213 | return 0; | |
|
214 | } | |
|
215 | ||
|
216 | static int int_from_pyobj(int* v,PyObject *obj,const char *errmess) { | |
|
217 | PyObject* tmp = NULL; | |
|
218 | if (PyInt_Check(obj)) { | |
|
219 | *v = (int)PyInt_AS_LONG(obj); | |
|
220 | return 1; | |
|
221 | } | |
|
222 | tmp = PyNumber_Int(obj); | |
|
223 | if (tmp) { | |
|
224 | *v = PyInt_AS_LONG(tmp); | |
|
225 | Py_DECREF(tmp); | |
|
226 | return 1; | |
|
227 | } | |
|
228 | if (PyComplex_Check(obj)) | |
|
229 | tmp = PyObject_GetAttrString(obj,"real"); | |
|
230 | else if (PyString_Check(obj) || PyUnicode_Check(obj)) | |
|
231 | /*pass*/; | |
|
232 | else if (PySequence_Check(obj)) | |
|
233 | tmp = PySequence_GetItem(obj,0); | |
|
234 | if (tmp) { | |
|
235 | PyErr_Clear(); | |
|
236 | if (int_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} | |
|
237 | Py_DECREF(tmp); | |
|
238 | } | |
|
239 | { | |
|
240 | PyObject* err = PyErr_Occurred(); | |
|
241 | if (err==NULL) err = fitacf_acf2_error; | |
|
242 | PyErr_SetString(err,errmess); | |
|
243 | } | |
|
244 | return 0; | |
|
245 | } | |
|
246 | ||
|
247 | ||
|
248 | /********************* See f2py2e/cfuncs.py: userincludes *********************/ | |
|
249 | /*need_userincludes*/ | |
|
250 | ||
|
251 | /********************* See f2py2e/capi_rules.py: usercode *********************/ | |
|
252 | ||
|
253 | ||
|
254 | /* See f2py2e/rules.py */ | |
|
255 | extern void F_FUNC(acf2,ACF2)(float*,float*,float*,float*,float*,float*,float*,int*,int*,float*,float*,float*,float*); | |
|
256 | extern void F_WRAPPEDFUNC(spect1,SPECT1)(float*,float*); | |
|
257 | extern void F_FUNC(gaussq,GAUSSQ)(float*,float*); | |
|
258 | /*eof externroutines*/ | |
|
259 | ||
|
260 | /******************** See f2py2e/capi_rules.py: usercode1 ********************/ | |
|
261 | ||
|
262 | ||
|
263 | /******************* See f2py2e/cb_rules.py: buildcallback *******************/ | |
|
264 | /*need_callbacks*/ | |
|
265 | ||
|
266 | /*********************** See f2py2e/rules.py: buildapi ***********************/ | |
|
267 | ||
|
268 | /************************************ acf2 ************************************/ | |
|
269 | static char doc_f2py_rout_fitacf_acf2_acf2[] = "\ | |
|
270 | acf = acf2(wl,tau,te1,ti1,fi1,ven1,vin1,wi1,alpha1,dens1,bfld1,acf,[nion1])\n\nWrapper for ``acf2``.\ | |
|
271 | \n\nParameters\n----------\n" | |
|
272 | "wl : input float\n" | |
|
273 | "tau : input float\n" | |
|
274 | "te1 : input float\n" | |
|
275 | "ti1 : input rank-1 array('f') with bounds (nion1)\n" | |
|
276 | "fi1 : input rank-1 array('f') with bounds (nion1)\n" | |
|
277 | "ven1 : input float\n" | |
|
278 | "vin1 : input rank-1 array('f') with bounds (nion1)\n" | |
|
279 | "wi1 : input rank-1 array('i') with bounds (nion1)\n" | |
|
280 | "alpha1 : input float\n" | |
|
281 | "dens1 : input float\n" | |
|
282 | "bfld1 : input float\n" | |
|
283 | "acf : input float\n" | |
|
284 | "\nOther Parameters\n----------------\n" | |
|
285 | "nion1 : input int, optional\n Default: len(ti1)\n" | |
|
286 | "\nReturns\n-------\n" | |
|
287 | "acf : float"; | |
|
288 | /* extern void F_FUNC(acf2,ACF2)(float*,float*,float*,float*,float*,float*,float*,int*,int*,float*,float*,float*,float*); */ | |
|
289 | static PyObject *f2py_rout_fitacf_acf2_acf2(const PyObject *capi_self, | |
|
290 | PyObject *capi_args, | |
|
291 | PyObject *capi_keywds, | |
|
292 | void (*f2py_func)(float*,float*,float*,float*,float*,float*,float*,int*,int*,float*,float*,float*,float*)) { | |
|
293 | PyObject * volatile capi_buildvalue = NULL; | |
|
294 | volatile int f2py_success = 1; | |
|
295 | /*decl*/ | |
|
296 | ||
|
297 | float wl = 0; | |
|
298 | PyObject *wl_capi = Py_None; | |
|
299 | float tau = 0; | |
|
300 | PyObject *tau_capi = Py_None; | |
|
301 | float te1 = 0; | |
|
302 | PyObject *te1_capi = Py_None; | |
|
303 | float *ti1 = NULL; | |
|
304 | npy_intp ti1_Dims[1] = {-1}; | |
|
305 | const int ti1_Rank = 1; | |
|
306 | PyArrayObject *capi_ti1_tmp = NULL; | |
|
307 | int capi_ti1_intent = 0; | |
|
308 | PyObject *ti1_capi = Py_None; | |
|
309 | float *fi1 = NULL; | |
|
310 | npy_intp fi1_Dims[1] = {-1}; | |
|
311 | const int fi1_Rank = 1; | |
|
312 | PyArrayObject *capi_fi1_tmp = NULL; | |
|
313 | int capi_fi1_intent = 0; | |
|
314 | PyObject *fi1_capi = Py_None; | |
|
315 | float ven1 = 0; | |
|
316 | PyObject *ven1_capi = Py_None; | |
|
317 | float *vin1 = NULL; | |
|
318 | npy_intp vin1_Dims[1] = {-1}; | |
|
319 | const int vin1_Rank = 1; | |
|
320 | PyArrayObject *capi_vin1_tmp = NULL; | |
|
321 | int capi_vin1_intent = 0; | |
|
322 | PyObject *vin1_capi = Py_None; | |
|
323 | int *wi1 = NULL; | |
|
324 | npy_intp wi1_Dims[1] = {-1}; | |
|
325 | const int wi1_Rank = 1; | |
|
326 | PyArrayObject *capi_wi1_tmp = NULL; | |
|
327 | int capi_wi1_intent = 0; | |
|
328 | PyObject *wi1_capi = Py_None; | |
|
329 | int nion1 = 0; | |
|
330 | PyObject *nion1_capi = Py_None; | |
|
331 | float alpha1 = 0; | |
|
332 | PyObject *alpha1_capi = Py_None; | |
|
333 | float dens1 = 0; | |
|
334 | PyObject *dens1_capi = Py_None; | |
|
335 | float bfld1 = 0; | |
|
336 | PyObject *bfld1_capi = Py_None; | |
|
337 | float acf = 0; | |
|
338 | PyObject *acf_capi = Py_None; | |
|
339 | static char *capi_kwlist[] = {"wl","tau","te1","ti1","fi1","ven1","vin1","wi1","alpha1","dens1","bfld1","acf","nion1",NULL}; | |
|
340 | ||
|
341 | /*routdebugenter*/ | |
|
342 | #ifdef F2PY_REPORT_ATEXIT | |
|
343 | f2py_start_clock(); | |
|
344 | #endif | |
|
345 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
346 | "OOOOOOOOOOOO|O:fitacf_acf2.acf2",\ | |
|
347 | capi_kwlist,&wl_capi,&tau_capi,&te1_capi,&ti1_capi,&fi1_capi,&ven1_capi,&vin1_capi,&wi1_capi,&alpha1_capi,&dens1_capi,&bfld1_capi,&acf_capi,&nion1_capi)) | |
|
348 | return NULL; | |
|
349 | /*frompyobj*/ | |
|
350 | /* Processing variable wl */ | |
|
351 | f2py_success = float_from_pyobj(&wl,wl_capi,"fitacf_acf2.acf2() 1st argument (wl) can't be converted to float"); | |
|
352 | if (f2py_success) { | |
|
353 | /* Processing variable tau */ | |
|
354 | f2py_success = float_from_pyobj(&tau,tau_capi,"fitacf_acf2.acf2() 2nd argument (tau) can't be converted to float"); | |
|
355 | if (f2py_success) { | |
|
356 | /* Processing variable te1 */ | |
|
357 | f2py_success = float_from_pyobj(&te1,te1_capi,"fitacf_acf2.acf2() 3rd argument (te1) can't be converted to float"); | |
|
358 | if (f2py_success) { | |
|
359 | /* Processing variable ti1 */ | |
|
360 | ; | |
|
361 | capi_ti1_intent |= F2PY_INTENT_IN; | |
|
362 | capi_ti1_tmp = array_from_pyobj(NPY_FLOAT,ti1_Dims,ti1_Rank,capi_ti1_intent,ti1_capi); | |
|
363 | if (capi_ti1_tmp == NULL) { | |
|
364 | PyObject *exc, *val, *tb; | |
|
365 | PyErr_Fetch(&exc, &val, &tb); | |
|
366 | PyErr_SetString(exc ? exc : fitacf_acf2_error,"failed in converting 4th argument `ti1' of fitacf_acf2.acf2 to C/Fortran array" ); | |
|
367 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
368 | } else { | |
|
369 | ti1 = (float *)(PyArray_DATA(capi_ti1_tmp)); | |
|
370 | ||
|
371 | /* Processing variable ven1 */ | |
|
372 | f2py_success = float_from_pyobj(&ven1,ven1_capi,"fitacf_acf2.acf2() 6th argument (ven1) can't be converted to float"); | |
|
373 | if (f2py_success) { | |
|
374 | /* Processing variable alpha1 */ | |
|
375 | f2py_success = float_from_pyobj(&alpha1,alpha1_capi,"fitacf_acf2.acf2() 9th argument (alpha1) can't be converted to float"); | |
|
376 | if (f2py_success) { | |
|
377 | /* Processing variable dens1 */ | |
|
378 | f2py_success = float_from_pyobj(&dens1,dens1_capi,"fitacf_acf2.acf2() 10th argument (dens1) can't be converted to float"); | |
|
379 | if (f2py_success) { | |
|
380 | /* Processing variable bfld1 */ | |
|
381 | f2py_success = float_from_pyobj(&bfld1,bfld1_capi,"fitacf_acf2.acf2() 11st argument (bfld1) can't be converted to float"); | |
|
382 | if (f2py_success) { | |
|
383 | /* Processing variable acf */ | |
|
384 | f2py_success = float_from_pyobj(&acf,acf_capi,"fitacf_acf2.acf2() 12nd argument (acf) can't be converted to float"); | |
|
385 | if (f2py_success) { | |
|
386 | /* Processing variable nion1 */ | |
|
387 | if (nion1_capi == Py_None) nion1 = len(ti1); else | |
|
388 | f2py_success = int_from_pyobj(&nion1,nion1_capi,"fitacf_acf2.acf2() 1st keyword (nion1) can't be converted to int"); | |
|
389 | if (f2py_success) { | |
|
390 | CHECKSCALAR(len(ti1)>=nion1,"len(ti1)>=nion1","1st keyword nion1","acf2:nion1=%d",nion1) { | |
|
391 | /* Processing variable fi1 */ | |
|
392 | fi1_Dims[0]=nion1; | |
|
393 | capi_fi1_intent |= F2PY_INTENT_IN; | |
|
394 | capi_fi1_tmp = array_from_pyobj(NPY_FLOAT,fi1_Dims,fi1_Rank,capi_fi1_intent,fi1_capi); | |
|
395 | if (capi_fi1_tmp == NULL) { | |
|
396 | PyObject *exc, *val, *tb; | |
|
397 | PyErr_Fetch(&exc, &val, &tb); | |
|
398 | PyErr_SetString(exc ? exc : fitacf_acf2_error,"failed in converting 5th argument `fi1' of fitacf_acf2.acf2 to C/Fortran array" ); | |
|
399 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
400 | } else { | |
|
401 | fi1 = (float *)(PyArray_DATA(capi_fi1_tmp)); | |
|
402 | ||
|
403 | /* Processing variable vin1 */ | |
|
404 | vin1_Dims[0]=nion1; | |
|
405 | capi_vin1_intent |= F2PY_INTENT_IN; | |
|
406 | capi_vin1_tmp = array_from_pyobj(NPY_FLOAT,vin1_Dims,vin1_Rank,capi_vin1_intent,vin1_capi); | |
|
407 | if (capi_vin1_tmp == NULL) { | |
|
408 | PyObject *exc, *val, *tb; | |
|
409 | PyErr_Fetch(&exc, &val, &tb); | |
|
410 | PyErr_SetString(exc ? exc : fitacf_acf2_error,"failed in converting 7th argument `vin1' of fitacf_acf2.acf2 to C/Fortran array" ); | |
|
411 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
412 | } else { | |
|
413 | vin1 = (float *)(PyArray_DATA(capi_vin1_tmp)); | |
|
414 | ||
|
415 | /* Processing variable wi1 */ | |
|
416 | wi1_Dims[0]=nion1; | |
|
417 | capi_wi1_intent |= F2PY_INTENT_IN; | |
|
418 | capi_wi1_tmp = array_from_pyobj(NPY_INT,wi1_Dims,wi1_Rank,capi_wi1_intent,wi1_capi); | |
|
419 | if (capi_wi1_tmp == NULL) { | |
|
420 | PyObject *exc, *val, *tb; | |
|
421 | PyErr_Fetch(&exc, &val, &tb); | |
|
422 | PyErr_SetString(exc ? exc : fitacf_acf2_error,"failed in converting 8th argument `wi1' of fitacf_acf2.acf2 to C/Fortran array" ); | |
|
423 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
424 | } else { | |
|
425 | wi1 = (int *)(PyArray_DATA(capi_wi1_tmp)); | |
|
426 | ||
|
427 | /*end of frompyobj*/ | |
|
428 | #ifdef F2PY_REPORT_ATEXIT | |
|
429 | f2py_start_call_clock(); | |
|
430 | #endif | |
|
431 | /*callfortranroutine*/ | |
|
432 | (*f2py_func)(&wl,&tau,&te1,ti1,fi1,&ven1,vin1,wi1,&nion1,&alpha1,&dens1,&bfld1,&acf); | |
|
433 | if (PyErr_Occurred()) | |
|
434 | f2py_success = 0; | |
|
435 | #ifdef F2PY_REPORT_ATEXIT | |
|
436 | f2py_stop_call_clock(); | |
|
437 | #endif | |
|
438 | /*end of callfortranroutine*/ | |
|
439 | if (f2py_success) { | |
|
440 | /*pyobjfrom*/ | |
|
441 | /*end of pyobjfrom*/ | |
|
442 | CFUNCSMESS("Building return value.\n"); | |
|
443 | capi_buildvalue = Py_BuildValue("f",acf); | |
|
444 | /*closepyobjfrom*/ | |
|
445 | /*end of closepyobjfrom*/ | |
|
446 | } /*if (f2py_success) after callfortranroutine*/ | |
|
447 | /*cleanupfrompyobj*/ | |
|
448 | if((PyObject *)capi_wi1_tmp!=wi1_capi) { | |
|
449 | Py_XDECREF(capi_wi1_tmp); } | |
|
450 | } /*if (capi_wi1_tmp == NULL) ... else of wi1*/ | |
|
451 | /* End of cleaning variable wi1 */ | |
|
452 | if((PyObject *)capi_vin1_tmp!=vin1_capi) { | |
|
453 | Py_XDECREF(capi_vin1_tmp); } | |
|
454 | } /*if (capi_vin1_tmp == NULL) ... else of vin1*/ | |
|
455 | /* End of cleaning variable vin1 */ | |
|
456 | if((PyObject *)capi_fi1_tmp!=fi1_capi) { | |
|
457 | Py_XDECREF(capi_fi1_tmp); } | |
|
458 | } /*if (capi_fi1_tmp == NULL) ... else of fi1*/ | |
|
459 | /* End of cleaning variable fi1 */ | |
|
460 | } /*CHECKSCALAR(len(ti1)>=nion1)*/ | |
|
461 | } /*if (f2py_success) of nion1*/ | |
|
462 | /* End of cleaning variable nion1 */ | |
|
463 | } /*if (f2py_success) of acf*/ | |
|
464 | /* End of cleaning variable acf */ | |
|
465 | } /*if (f2py_success) of bfld1*/ | |
|
466 | /* End of cleaning variable bfld1 */ | |
|
467 | } /*if (f2py_success) of dens1*/ | |
|
468 | /* End of cleaning variable dens1 */ | |
|
469 | } /*if (f2py_success) of alpha1*/ | |
|
470 | /* End of cleaning variable alpha1 */ | |
|
471 | } /*if (f2py_success) of ven1*/ | |
|
472 | /* End of cleaning variable ven1 */ | |
|
473 | if((PyObject *)capi_ti1_tmp!=ti1_capi) { | |
|
474 | Py_XDECREF(capi_ti1_tmp); } | |
|
475 | } /*if (capi_ti1_tmp == NULL) ... else of ti1*/ | |
|
476 | /* End of cleaning variable ti1 */ | |
|
477 | } /*if (f2py_success) of te1*/ | |
|
478 | /* End of cleaning variable te1 */ | |
|
479 | } /*if (f2py_success) of tau*/ | |
|
480 | /* End of cleaning variable tau */ | |
|
481 | } /*if (f2py_success) of wl*/ | |
|
482 | /* End of cleaning variable wl */ | |
|
483 | /*end of cleanupfrompyobj*/ | |
|
484 | if (capi_buildvalue == NULL) { | |
|
485 | /*routdebugfailure*/ | |
|
486 | } else { | |
|
487 | /*routdebugleave*/ | |
|
488 | } | |
|
489 | CFUNCSMESS("Freeing memory.\n"); | |
|
490 | /*freemem*/ | |
|
491 | #ifdef F2PY_REPORT_ATEXIT | |
|
492 | f2py_stop_clock(); | |
|
493 | #endif | |
|
494 | return capi_buildvalue; | |
|
495 | } | |
|
496 | /******************************** end of acf2 ********************************/ | |
|
497 | ||
|
498 | /*********************************** spect1 ***********************************/ | |
|
499 | static char doc_f2py_rout_fitacf_acf2_spect1[] = "\ | |
|
500 | spect1 = spect1(omega)\n\nWrapper for ``spect1``.\ | |
|
501 | \n\nParameters\n----------\n" | |
|
502 | "omega : input float\n" | |
|
503 | "\nReturns\n-------\n" | |
|
504 | "spect1 : float"; | |
|
505 | /* extern void F_WRAPPEDFUNC(spect1,SPECT1)(float*,float*); */ | |
|
506 | static PyObject *f2py_rout_fitacf_acf2_spect1(const PyObject *capi_self, | |
|
507 | PyObject *capi_args, | |
|
508 | PyObject *capi_keywds, | |
|
509 | void (*f2py_func)(float*,float*)) { | |
|
510 | PyObject * volatile capi_buildvalue = NULL; | |
|
511 | volatile int f2py_success = 1; | |
|
512 | /*decl*/ | |
|
513 | ||
|
514 | float spect1 = 0; | |
|
515 | float omega = 0; | |
|
516 | PyObject *omega_capi = Py_None; | |
|
517 | static char *capi_kwlist[] = {"omega",NULL}; | |
|
518 | ||
|
519 | /*routdebugenter*/ | |
|
520 | #ifdef F2PY_REPORT_ATEXIT | |
|
521 | f2py_start_clock(); | |
|
522 | #endif | |
|
523 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
524 | "O|:fitacf_acf2.spect1",\ | |
|
525 | capi_kwlist,&omega_capi)) | |
|
526 | return NULL; | |
|
527 | /*frompyobj*/ | |
|
528 | /* Processing variable omega */ | |
|
529 | f2py_success = float_from_pyobj(&omega,omega_capi,"fitacf_acf2.spect1() 1st argument (omega) can't be converted to float"); | |
|
530 | if (f2py_success) { | |
|
531 | /* Processing variable spect1 */ | |
|
532 | /*end of frompyobj*/ | |
|
533 | #ifdef F2PY_REPORT_ATEXIT | |
|
534 | f2py_start_call_clock(); | |
|
535 | #endif | |
|
536 | /*callfortranroutine*/ | |
|
537 | (*f2py_func)(&spect1,&omega); | |
|
538 | if (PyErr_Occurred()) | |
|
539 | f2py_success = 0; | |
|
540 | #ifdef F2PY_REPORT_ATEXIT | |
|
541 | f2py_stop_call_clock(); | |
|
542 | #endif | |
|
543 | /*end of callfortranroutine*/ | |
|
544 | if (f2py_success) { | |
|
545 | /*pyobjfrom*/ | |
|
546 | /*end of pyobjfrom*/ | |
|
547 | CFUNCSMESS("Building return value.\n"); | |
|
548 | capi_buildvalue = Py_BuildValue("f",spect1); | |
|
549 | /*closepyobjfrom*/ | |
|
550 | /*end of closepyobjfrom*/ | |
|
551 | } /*if (f2py_success) after callfortranroutine*/ | |
|
552 | /*cleanupfrompyobj*/ | |
|
553 | /* End of cleaning variable spect1 */ | |
|
554 | } /*if (f2py_success) of omega*/ | |
|
555 | /* End of cleaning variable omega */ | |
|
556 | /*end of cleanupfrompyobj*/ | |
|
557 | if (capi_buildvalue == NULL) { | |
|
558 | /*routdebugfailure*/ | |
|
559 | } else { | |
|
560 | /*routdebugleave*/ | |
|
561 | } | |
|
562 | CFUNCSMESS("Freeing memory.\n"); | |
|
563 | /*freemem*/ | |
|
564 | #ifdef F2PY_REPORT_ATEXIT | |
|
565 | f2py_stop_clock(); | |
|
566 | #endif | |
|
567 | return capi_buildvalue; | |
|
568 | } | |
|
569 | /******************************* end of spect1 *******************************/ | |
|
570 | ||
|
571 | /*********************************** gaussq ***********************************/ | |
|
572 | static char doc_f2py_rout_fitacf_acf2_gaussq[] = "\ | |
|
573 | gaussq(tau,acf)\n\nWrapper for ``gaussq``.\ | |
|
574 | \n\nParameters\n----------\n" | |
|
575 | "tau : input float\n" | |
|
576 | "acf : input float"; | |
|
577 | /* extern void F_FUNC(gaussq,GAUSSQ)(float*,float*); */ | |
|
578 | static PyObject *f2py_rout_fitacf_acf2_gaussq(const PyObject *capi_self, | |
|
579 | PyObject *capi_args, | |
|
580 | PyObject *capi_keywds, | |
|
581 | void (*f2py_func)(float*,float*)) { | |
|
582 | PyObject * volatile capi_buildvalue = NULL; | |
|
583 | volatile int f2py_success = 1; | |
|
584 | /*decl*/ | |
|
585 | ||
|
586 | float tau = 0; | |
|
587 | PyObject *tau_capi = Py_None; | |
|
588 | float acf = 0; | |
|
589 | PyObject *acf_capi = Py_None; | |
|
590 | static char *capi_kwlist[] = {"tau","acf",NULL}; | |
|
591 | ||
|
592 | /*routdebugenter*/ | |
|
593 | #ifdef F2PY_REPORT_ATEXIT | |
|
594 | f2py_start_clock(); | |
|
595 | #endif | |
|
596 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
597 | "OO|:fitacf_acf2.gaussq",\ | |
|
598 | capi_kwlist,&tau_capi,&acf_capi)) | |
|
599 | return NULL; | |
|
600 | /*frompyobj*/ | |
|
601 | /* Processing variable tau */ | |
|
602 | f2py_success = float_from_pyobj(&tau,tau_capi,"fitacf_acf2.gaussq() 1st argument (tau) can't be converted to float"); | |
|
603 | if (f2py_success) { | |
|
604 | /* Processing variable acf */ | |
|
605 | f2py_success = float_from_pyobj(&acf,acf_capi,"fitacf_acf2.gaussq() 2nd argument (acf) can't be converted to float"); | |
|
606 | if (f2py_success) { | |
|
607 | /*end of frompyobj*/ | |
|
608 | #ifdef F2PY_REPORT_ATEXIT | |
|
609 | f2py_start_call_clock(); | |
|
610 | #endif | |
|
611 | /*callfortranroutine*/ | |
|
612 | (*f2py_func)(&tau,&acf); | |
|
613 | if (PyErr_Occurred()) | |
|
614 | f2py_success = 0; | |
|
615 | #ifdef F2PY_REPORT_ATEXIT | |
|
616 | f2py_stop_call_clock(); | |
|
617 | #endif | |
|
618 | /*end of callfortranroutine*/ | |
|
619 | if (f2py_success) { | |
|
620 | /*pyobjfrom*/ | |
|
621 | /*end of pyobjfrom*/ | |
|
622 | CFUNCSMESS("Building return value.\n"); | |
|
623 | capi_buildvalue = Py_BuildValue(""); | |
|
624 | /*closepyobjfrom*/ | |
|
625 | /*end of closepyobjfrom*/ | |
|
626 | } /*if (f2py_success) after callfortranroutine*/ | |
|
627 | /*cleanupfrompyobj*/ | |
|
628 | } /*if (f2py_success) of acf*/ | |
|
629 | /* End of cleaning variable acf */ | |
|
630 | } /*if (f2py_success) of tau*/ | |
|
631 | /* End of cleaning variable tau */ | |
|
632 | /*end of cleanupfrompyobj*/ | |
|
633 | if (capi_buildvalue == NULL) { | |
|
634 | /*routdebugfailure*/ | |
|
635 | } else { | |
|
636 | /*routdebugleave*/ | |
|
637 | } | |
|
638 | CFUNCSMESS("Freeing memory.\n"); | |
|
639 | /*freemem*/ | |
|
640 | #ifdef F2PY_REPORT_ATEXIT | |
|
641 | f2py_stop_clock(); | |
|
642 | #endif | |
|
643 | return capi_buildvalue; | |
|
644 | } | |
|
645 | /******************************* end of gaussq *******************************/ | |
|
646 | /*eof body*/ | |
|
647 | ||
|
648 | /******************* See f2py2e/f90mod_rules.py: buildhooks *******************/ | |
|
649 | /*need_f90modhooks*/ | |
|
650 | ||
|
651 | /************** See f2py2e/rules.py: module_rules['modulebody'] **************/ | |
|
652 | ||
|
653 | /******************* See f2py2e/common_rules.py: buildhooks *******************/ | |
|
654 | ||
|
655 | static FortranDataDef f2py_spec_def[] = { | |
|
656 | {"te",0,{{-1}},NPY_FLOAT}, | |
|
657 | {"ti",1,{{10}},NPY_FLOAT}, | |
|
658 | {"fi",1,{{10}},NPY_FLOAT}, | |
|
659 | {"ven",0,{{-1}},NPY_FLOAT}, | |
|
660 | {"vin",1,{{10}},NPY_FLOAT}, | |
|
661 | {"alpha",0,{{-1}},NPY_FLOAT}, | |
|
662 | {"dens",0,{{-1}},NPY_FLOAT}, | |
|
663 | {"bfld",0,{{-1}},NPY_FLOAT}, | |
|
664 | {"nion",0,{{-1}},NPY_INT}, | |
|
665 | {"wi",1,{{10}},NPY_INT}, | |
|
666 | {"ak",0,{{-1}},NPY_FLOAT}, | |
|
667 | {NULL} | |
|
668 | }; | |
|
669 | static void f2py_setup_spec(char *te,char *ti,char *fi,char *ven,char *vin,char *alpha,char *dens,char *bfld,char *nion,char *wi,char *ak) { | |
|
670 | int i_f2py=0; | |
|
671 | f2py_spec_def[i_f2py++].data = te; | |
|
672 | f2py_spec_def[i_f2py++].data = ti; | |
|
673 | f2py_spec_def[i_f2py++].data = fi; | |
|
674 | f2py_spec_def[i_f2py++].data = ven; | |
|
675 | f2py_spec_def[i_f2py++].data = vin; | |
|
676 | f2py_spec_def[i_f2py++].data = alpha; | |
|
677 | f2py_spec_def[i_f2py++].data = dens; | |
|
678 | f2py_spec_def[i_f2py++].data = bfld; | |
|
679 | f2py_spec_def[i_f2py++].data = nion; | |
|
680 | f2py_spec_def[i_f2py++].data = wi; | |
|
681 | f2py_spec_def[i_f2py++].data = ak; | |
|
682 | } | |
|
683 | extern void F_FUNC(f2pyinitspec,F2PYINITSPEC)(void(*)(char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*)); | |
|
684 | static void f2py_init_spec(void) { | |
|
685 | F_FUNC(f2pyinitspec,F2PYINITSPEC)(f2py_setup_spec); | |
|
686 | } | |
|
687 | ||
|
688 | static FortranDataDef f2py_mode_def[] = { | |
|
689 | {"imode",0,{{-1}},NPY_INT}, | |
|
690 | {NULL} | |
|
691 | }; | |
|
692 | static void f2py_setup_mode(char *imode) { | |
|
693 | int i_f2py=0; | |
|
694 | f2py_mode_def[i_f2py++].data = imode; | |
|
695 | } | |
|
696 | extern void F_FUNC(f2pyinitmode,F2PYINITMODE)(void(*)(char*)); | |
|
697 | static void f2py_init_mode(void) { | |
|
698 | F_FUNC(f2pyinitmode,F2PYINITMODE)(f2py_setup_mode); | |
|
699 | } | |
|
700 | ||
|
701 | /*need_commonhooks*/ | |
|
702 | ||
|
703 | /**************************** See f2py2e/rules.py ****************************/ | |
|
704 | ||
|
705 | static FortranDataDef f2py_routine_defs[] = { | |
|
706 | {"acf2",-1,{{-1}},0,(char *)F_FUNC(acf2,ACF2),(f2py_init_func)f2py_rout_fitacf_acf2_acf2,doc_f2py_rout_fitacf_acf2_acf2}, | |
|
707 | {"spect1",-1,{{-1}},0,(char *)F_WRAPPEDFUNC(spect1,SPECT1),(f2py_init_func)f2py_rout_fitacf_acf2_spect1,doc_f2py_rout_fitacf_acf2_spect1}, | |
|
708 | {"gaussq",-1,{{-1}},0,(char *)F_FUNC(gaussq,GAUSSQ),(f2py_init_func)f2py_rout_fitacf_acf2_gaussq,doc_f2py_rout_fitacf_acf2_gaussq}, | |
|
709 | ||
|
710 | /*eof routine_defs*/ | |
|
711 | {NULL} | |
|
712 | }; | |
|
713 | ||
|
714 | static PyMethodDef f2py_module_methods[] = { | |
|
715 | ||
|
716 | {NULL,NULL} | |
|
717 | }; | |
|
718 | ||
|
719 | static struct PyModuleDef moduledef = { | |
|
720 | PyModuleDef_HEAD_INIT, | |
|
721 | "fitacf_acf2", | |
|
722 | NULL, | |
|
723 | -1, | |
|
724 | f2py_module_methods, | |
|
725 | NULL, | |
|
726 | NULL, | |
|
727 | NULL, | |
|
728 | NULL | |
|
729 | }; | |
|
730 | ||
|
731 | PyMODINIT_FUNC PyInit_fitacf_acf2(void) { | |
|
732 | int i; | |
|
733 | PyObject *m,*d, *s, *tmp; | |
|
734 | m = fitacf_acf2_module = PyModule_Create(&moduledef); | |
|
735 | Py_SET_TYPE(&PyFortran_Type, &PyType_Type); | |
|
736 | import_array(); | |
|
737 | if (PyErr_Occurred()) | |
|
738 | {PyErr_SetString(PyExc_ImportError, "can't initialize module fitacf_acf2 (failed to import numpy)"); return m;} | |
|
739 | d = PyModule_GetDict(m); | |
|
740 | s = PyString_FromString("$Revision: $"); | |
|
741 | PyDict_SetItemString(d, "__version__", s); | |
|
742 | Py_DECREF(s); | |
|
743 | s = PyUnicode_FromString( | |
|
744 | "This module 'fitacf_acf2' is auto-generated with f2py (version:2).\nFunctions:\n" | |
|
745 | " acf = acf2(wl,tau,te1,ti1,fi1,ven1,vin1,wi1,alpha1,dens1,bfld1,acf,nion1=len(ti1))\n" | |
|
746 | " spect1 = spect1(omega)\n" | |
|
747 | " gaussq(tau,acf)\n" | |
|
748 | "COMMON blocks:\n"" /spec/ te,ti(10),fi(10),ven,vin(10),alpha,dens,bfld,nion,wi(10),ak\n"" /mode/ imode\n""."); | |
|
749 | PyDict_SetItemString(d, "__doc__", s); | |
|
750 | Py_DECREF(s); | |
|
751 | fitacf_acf2_error = PyErr_NewException ("fitacf_acf2.error", NULL, NULL); | |
|
752 | /* | |
|
753 | * Store the error object inside the dict, so that it could get deallocated. | |
|
754 | * (in practice, this is a module, so it likely will not and cannot.) | |
|
755 | */ | |
|
756 | PyDict_SetItemString(d, "_fitacf_acf2_error", fitacf_acf2_error); | |
|
757 | Py_DECREF(fitacf_acf2_error); | |
|
758 | for(i=0;f2py_routine_defs[i].name!=NULL;i++) { | |
|
759 | tmp = PyFortranObject_NewAsAttr(&f2py_routine_defs[i]); | |
|
760 | PyDict_SetItemString(d, f2py_routine_defs[i].name, tmp); | |
|
761 | Py_DECREF(tmp); | |
|
762 | } | |
|
763 | ||
|
764 | ||
|
765 | { | |
|
766 | extern float F_FUNC(spect1,SPECT1)(void); | |
|
767 | PyObject* o = PyDict_GetItemString(d,"spect1"); | |
|
768 | tmp = F2PyCapsule_FromVoidPtr((void*)F_FUNC(spect1,SPECT1),NULL); | |
|
769 | PyObject_SetAttrString(o,"_cpointer", tmp); | |
|
770 | Py_DECREF(tmp); | |
|
771 | s = PyUnicode_FromString("spect1"); | |
|
772 | PyObject_SetAttrString(o,"__name__", s); | |
|
773 | Py_DECREF(s); | |
|
774 | } | |
|
775 | ||
|
776 | ||
|
777 | /*eof initf2pywraphooks*/ | |
|
778 | /*eof initf90modhooks*/ | |
|
779 | ||
|
780 | tmp = PyFortranObject_New(f2py_spec_def,f2py_init_spec); | |
|
781 | F2PyDict_SetItemString(d, "spec", tmp); | |
|
782 | Py_DECREF(tmp); | |
|
783 | tmp = PyFortranObject_New(f2py_mode_def,f2py_init_mode); | |
|
784 | F2PyDict_SetItemString(d, "mode", tmp); | |
|
785 | Py_DECREF(tmp); | |
|
786 | /*eof initcommonhooks*/ | |
|
787 | ||
|
788 | ||
|
789 | #ifdef F2PY_REPORT_ATEXIT | |
|
790 | if (! PyErr_Occurred()) | |
|
791 | on_exit(f2py_report_on_exit,(void*)"fitacf_acf2"); | |
|
792 | #endif | |
|
793 | return m; | |
|
794 | } | |
|
795 | #ifdef __cplusplus | |
|
796 | } | |
|
797 | #endif |
@@ -0,0 +1,63 | |||
|
1 | C -*- fortran -*- | |
|
2 | C This file is autogenerated with f2py (version:2) | |
|
3 | C It contains Fortran 77 wrappers to fortran functions. | |
|
4 | ||
|
5 | subroutine f2pywrapspect1 (spect1f2pywrap, omega) | |
|
6 | external spect1 | |
|
7 | real omega | |
|
8 | real spect1f2pywrap, spect1 | |
|
9 | spect1f2pywrap = spect1(omega) | |
|
10 | end | |
|
11 | ||
|
12 | ||
|
13 | subroutine f2pywrapspmpar (spmparf2pywrap, i) | |
|
14 | external spmpar | |
|
15 | integer i | |
|
16 | real spmparf2pywrap, spmpar | |
|
17 | spmparf2pywrap = spmpar(i) | |
|
18 | end | |
|
19 | ||
|
20 | ||
|
21 | subroutine f2pyinitspec(setupfunc) | |
|
22 | external setupfunc | |
|
23 | real te | |
|
24 | real ti(10) | |
|
25 | real fi(10) | |
|
26 | real ven | |
|
27 | real vin(10) | |
|
28 | real alpha | |
|
29 | real dens | |
|
30 | real bfld | |
|
31 | integer nion | |
|
32 | integer wi(10) | |
|
33 | real ak | |
|
34 | common /spec/ te,ti,fi,ven,vin,alpha,dens,bfld,nion,wi,ak | |
|
35 | call setupfunc(te,ti,fi,ven,vin,alpha,dens,bfld,nion,wi,ak) | |
|
36 | end | |
|
37 | ||
|
38 | subroutine f2pyinitmode(setupfunc) | |
|
39 | external setupfunc | |
|
40 | integer imode | |
|
41 | common /mode/ imode | |
|
42 | call setupfunc(imode) | |
|
43 | end | |
|
44 | ||
|
45 | subroutine f2pyinitfitter(setupfunc) | |
|
46 | external setupfunc | |
|
47 | real tau(100) | |
|
48 | real rho(100) | |
|
49 | real sigma2(100) | |
|
50 | real params(10) | |
|
51 | integer ifit(10) | |
|
52 | common /fitter/ tau,rho,sigma2,params,ifit | |
|
53 | call setupfunc(tau,rho,sigma2,params,ifit) | |
|
54 | end | |
|
55 | ||
|
56 | subroutine f2pyinittrans(setupfunc) | |
|
57 | external setupfunc | |
|
58 | real ev(10000) | |
|
59 | common /trans/ ev | |
|
60 | call setupfunc(ev) | |
|
61 | end | |
|
62 | ||
|
63 |
This diff has been collapsed as it changes many lines, (1986 lines changed) Show them Hide them | |||
@@ -0,0 +1,1986 | |||
|
1 | /* File: fitacf_fit_shortmodule.c | |
|
2 | * This file is auto-generated with f2py (version:2). | |
|
3 | * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition, | |
|
4 | * written by Pearu Peterson <pearu@cens.ioc.ee>. | |
|
5 | * Generation date: Wed Jan 8 13:23:37 2025 | |
|
6 | * Do not edit this file directly unless you know what you are doing!!! | |
|
7 | */ | |
|
8 | ||
|
9 | #ifdef __cplusplus | |
|
10 | extern "C" { | |
|
11 | #endif | |
|
12 | ||
|
13 | /*********************** See f2py2e/cfuncs.py: includes ***********************/ | |
|
14 | #include "Python.h" | |
|
15 | #include <stdarg.h> | |
|
16 | #include "fortranobject.h" | |
|
17 | #include <string.h> | |
|
18 | #include <setjmp.h> | |
|
19 | #include <math.h> | |
|
20 | ||
|
21 | /**************** See f2py2e/rules.py: mod_rules['modulebody'] ****************/ | |
|
22 | static PyObject *fitacf_fit_short_error; | |
|
23 | static PyObject *fitacf_fit_short_module; | |
|
24 | ||
|
25 | /*********************** See f2py2e/cfuncs.py: typedefs ***********************/ | |
|
26 | typedef signed char signed_char; | |
|
27 | typedef struct {float r,i;} complex_float; | |
|
28 | ||
|
29 | /****************** See f2py2e/cfuncs.py: typedefs_generated ******************/ | |
|
30 | typedef void(*cb_fcn_in_lmdif__user__routines_typedef)(int *,int *,float *,float *,int *); | |
|
31 | ||
|
32 | /********************** See f2py2e/cfuncs.py: cppmacros **********************/ | |
|
33 | #define PRINTPYOBJERR(obj)\ | |
|
34 | fprintf(stderr,"fitacf_fit_short.error is related to ");\ | |
|
35 | PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\ | |
|
36 | fprintf(stderr,"\n"); | |
|
37 | ||
|
38 | \ | |
|
39 | #define FAILNULL(p) do { \ | |
|
40 | if ((p) == NULL) { \ | |
|
41 | PyErr_SetString(PyExc_MemoryError, "NULL pointer found"); \ | |
|
42 | goto capi_fail; \ | |
|
43 | } \ | |
|
44 | } while (0) | |
|
45 | ||
|
46 | #define MEMCOPY(to,from,n)\ | |
|
47 | do { FAILNULL(to); FAILNULL(from); (void)memcpy(to,from,n); } while (0) | |
|
48 | ||
|
49 | #ifdef DEBUGCFUNCS | |
|
50 | #define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess); | |
|
51 | #define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \ | |
|
52 | PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\ | |
|
53 | fprintf(stderr,"\n"); | |
|
54 | #else | |
|
55 | #define CFUNCSMESS(mess) | |
|
56 | #define CFUNCSMESSPY(mess,obj) | |
|
57 | #endif | |
|
58 | ||
|
59 | #define pyobj_from_int1(v) (PyInt_FromLong(v)) | |
|
60 | #if defined(PREPEND_FORTRAN) | |
|
61 | #if defined(NO_APPEND_FORTRAN) | |
|
62 | #if defined(UPPERCASE_FORTRAN) | |
|
63 | #define F_FUNC(f,F) _##F | |
|
64 | #else | |
|
65 | #define F_FUNC(f,F) _##f | |
|
66 | #endif | |
|
67 | #else | |
|
68 | #if defined(UPPERCASE_FORTRAN) | |
|
69 | #define F_FUNC(f,F) _##F##_ | |
|
70 | #else | |
|
71 | #define F_FUNC(f,F) _##f##_ | |
|
72 | #endif | |
|
73 | #endif | |
|
74 | #else | |
|
75 | #if defined(NO_APPEND_FORTRAN) | |
|
76 | #if defined(UPPERCASE_FORTRAN) | |
|
77 | #define F_FUNC(f,F) F | |
|
78 | #else | |
|
79 | #define F_FUNC(f,F) f | |
|
80 | #endif | |
|
81 | #else | |
|
82 | #if defined(UPPERCASE_FORTRAN) | |
|
83 | #define F_FUNC(f,F) F##_ | |
|
84 | #else | |
|
85 | #define F_FUNC(f,F) f##_ | |
|
86 | #endif | |
|
87 | #endif | |
|
88 | #endif | |
|
89 | #if defined(UNDERSCORE_G77) | |
|
90 | #define F_FUNC_US(f,F) F_FUNC(f##_,F##_) | |
|
91 | #else | |
|
92 | #define F_FUNC_US(f,F) F_FUNC(f,F) | |
|
93 | #endif | |
|
94 | ||
|
95 | #define rank(var) var ## _Rank | |
|
96 | #define shape(var,dim) var ## _Dims[dim] | |
|
97 | #define old_rank(var) (PyArray_NDIM((PyArrayObject *)(capi_ ## var ## _tmp))) | |
|
98 | #define old_shape(var,dim) PyArray_DIM(((PyArrayObject *)(capi_ ## var ## _tmp)),dim) | |
|
99 | #define fshape(var,dim) shape(var,rank(var)-dim-1) | |
|
100 | #define len(var) shape(var,0) | |
|
101 | #define flen(var) fshape(var,0) | |
|
102 | #define old_size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp)) | |
|
103 | /* #define index(i) capi_i ## i */ | |
|
104 | #define slen(var) capi_ ## var ## _len | |
|
105 | #define size(var, ...) f2py_size((PyArrayObject *)(capi_ ## var ## _tmp), ## __VA_ARGS__, -1) | |
|
106 | ||
|
107 | #define CHECKSCALAR(check,tcheck,name,show,var)\ | |
|
108 | if (!(check)) {\ | |
|
109 | char errstring[256];\ | |
|
110 | sprintf(errstring, "%s: "show, "("tcheck") failed for "name, var);\ | |
|
111 | PyErr_SetString(fitacf_fit_short_error,errstring);\ | |
|
112 | /*goto capi_fail;*/\ | |
|
113 | } else | |
|
114 | #ifndef max | |
|
115 | #define max(a,b) ((a > b) ? (a) : (b)) | |
|
116 | #endif | |
|
117 | #ifndef min | |
|
118 | #define min(a,b) ((a < b) ? (a) : (b)) | |
|
119 | #endif | |
|
120 | #ifndef MAX | |
|
121 | #define MAX(a,b) ((a > b) ? (a) : (b)) | |
|
122 | #endif | |
|
123 | #ifndef MIN | |
|
124 | #define MIN(a,b) ((a < b) ? (a) : (b)) | |
|
125 | #endif | |
|
126 | ||
|
127 | #if defined(PREPEND_FORTRAN) | |
|
128 | #if defined(NO_APPEND_FORTRAN) | |
|
129 | #if defined(UPPERCASE_FORTRAN) | |
|
130 | #define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F | |
|
131 | #else | |
|
132 | #define F_WRAPPEDFUNC(f,F) _f2pywrap##f | |
|
133 | #endif | |
|
134 | #else | |
|
135 | #if defined(UPPERCASE_FORTRAN) | |
|
136 | #define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_ | |
|
137 | #else | |
|
138 | #define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_ | |
|
139 | #endif | |
|
140 | #endif | |
|
141 | #else | |
|
142 | #if defined(NO_APPEND_FORTRAN) | |
|
143 | #if defined(UPPERCASE_FORTRAN) | |
|
144 | #define F_WRAPPEDFUNC(f,F) F2PYWRAP##F | |
|
145 | #else | |
|
146 | #define F_WRAPPEDFUNC(f,F) f2pywrap##f | |
|
147 | #endif | |
|
148 | #else | |
|
149 | #if defined(UPPERCASE_FORTRAN) | |
|
150 | #define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_ | |
|
151 | #else | |
|
152 | #define F_WRAPPEDFUNC(f,F) f2pywrap##f##_ | |
|
153 | #endif | |
|
154 | #endif | |
|
155 | #endif | |
|
156 | #if defined(UNDERSCORE_G77) | |
|
157 | #define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_) | |
|
158 | #else | |
|
159 | #define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F) | |
|
160 | #endif | |
|
161 | ||
|
162 | #define SWAP(a,b,t) {\ | |
|
163 | t *c;\ | |
|
164 | c = a;\ | |
|
165 | a = b;\ | |
|
166 | b = c;} | |
|
167 | ||
|
168 | ||
|
169 | /************************ See f2py2e/cfuncs.py: cfuncs ************************/ | |
|
170 | static int double_from_pyobj(double* v,PyObject *obj,const char *errmess) { | |
|
171 | PyObject* tmp = NULL; | |
|
172 | if (PyFloat_Check(obj)) { | |
|
173 | #ifdef __sgi | |
|
174 | *v = PyFloat_AsDouble(obj); | |
|
175 | #else | |
|
176 | *v = PyFloat_AS_DOUBLE(obj); | |
|
177 | #endif | |
|
178 | return 1; | |
|
179 | } | |
|
180 | tmp = PyNumber_Float(obj); | |
|
181 | if (tmp) { | |
|
182 | #ifdef __sgi | |
|
183 | *v = PyFloat_AsDouble(tmp); | |
|
184 | #else | |
|
185 | *v = PyFloat_AS_DOUBLE(tmp); | |
|
186 | #endif | |
|
187 | Py_DECREF(tmp); | |
|
188 | return 1; | |
|
189 | } | |
|
190 | if (PyComplex_Check(obj)) | |
|
191 | tmp = PyObject_GetAttrString(obj,"real"); | |
|
192 | else if (PyString_Check(obj) || PyUnicode_Check(obj)) | |
|
193 | /*pass*/; | |
|
194 | else if (PySequence_Check(obj)) | |
|
195 | tmp = PySequence_GetItem(obj,0); | |
|
196 | if (tmp) { | |
|
197 | PyErr_Clear(); | |
|
198 | if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} | |
|
199 | Py_DECREF(tmp); | |
|
200 | } | |
|
201 | { | |
|
202 | PyObject* err = PyErr_Occurred(); | |
|
203 | if (err==NULL) err = fitacf_fit_short_error; | |
|
204 | PyErr_SetString(err,errmess); | |
|
205 | } | |
|
206 | return 0; | |
|
207 | } | |
|
208 | ||
|
209 | static int f2py_size(PyArrayObject* var, ...) | |
|
210 | { | |
|
211 | npy_int sz = 0; | |
|
212 | npy_int dim; | |
|
213 | npy_int rank; | |
|
214 | va_list argp; | |
|
215 | va_start(argp, var); | |
|
216 | dim = va_arg(argp, npy_int); | |
|
217 | if (dim==-1) | |
|
218 | { | |
|
219 | sz = PyArray_SIZE(var); | |
|
220 | } | |
|
221 | else | |
|
222 | { | |
|
223 | rank = PyArray_NDIM(var); | |
|
224 | if (dim>=1 && dim<=rank) | |
|
225 | sz = PyArray_DIM(var, dim-1); | |
|
226 | else | |
|
227 | fprintf(stderr, "f2py_size: 2nd argument value=%d fails to satisfy 1<=value<=%d. Result will be 0.\n", dim, rank); | |
|
228 | } | |
|
229 | va_end(argp); | |
|
230 | return sz; | |
|
231 | } | |
|
232 | ||
|
233 | static int float_from_pyobj(float* v,PyObject *obj,const char *errmess) { | |
|
234 | double d=0.0; | |
|
235 | if (double_from_pyobj(&d,obj,errmess)) { | |
|
236 | *v = (float)d; | |
|
237 | return 1; | |
|
238 | } | |
|
239 | return 0; | |
|
240 | } | |
|
241 | ||
|
242 | static int int_from_pyobj(int* v,PyObject *obj,const char *errmess) { | |
|
243 | PyObject* tmp = NULL; | |
|
244 | if (PyInt_Check(obj)) { | |
|
245 | *v = (int)PyInt_AS_LONG(obj); | |
|
246 | return 1; | |
|
247 | } | |
|
248 | tmp = PyNumber_Int(obj); | |
|
249 | if (tmp) { | |
|
250 | *v = PyInt_AS_LONG(tmp); | |
|
251 | Py_DECREF(tmp); | |
|
252 | return 1; | |
|
253 | } | |
|
254 | if (PyComplex_Check(obj)) | |
|
255 | tmp = PyObject_GetAttrString(obj,"real"); | |
|
256 | else if (PyString_Check(obj) || PyUnicode_Check(obj)) | |
|
257 | /*pass*/; | |
|
258 | else if (PySequence_Check(obj)) | |
|
259 | tmp = PySequence_GetItem(obj,0); | |
|
260 | if (tmp) { | |
|
261 | PyErr_Clear(); | |
|
262 | if (int_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} | |
|
263 | Py_DECREF(tmp); | |
|
264 | } | |
|
265 | { | |
|
266 | PyObject* err = PyErr_Occurred(); | |
|
267 | if (err==NULL) err = fitacf_fit_short_error; | |
|
268 | PyErr_SetString(err,errmess); | |
|
269 | } | |
|
270 | return 0; | |
|
271 | } | |
|
272 | ||
|
273 | static int create_cb_arglist(PyObject* fun,PyTupleObject* xa,const int maxnofargs,const int nofoptargs,int *nofargs,PyTupleObject **args,const char *errmess) { | |
|
274 | PyObject *tmp = NULL; | |
|
275 | PyObject *tmp_fun = NULL; | |
|
276 | int tot,opt,ext,siz,i,di=0; | |
|
277 | CFUNCSMESS("create_cb_arglist\n"); | |
|
278 | tot=opt=ext=siz=0; | |
|
279 | /* Get the total number of arguments */ | |
|
280 | if (PyFunction_Check(fun)) { | |
|
281 | tmp_fun = fun; | |
|
282 | Py_INCREF(tmp_fun); | |
|
283 | } | |
|
284 | else { | |
|
285 | di = 1; | |
|
286 | if (PyObject_HasAttrString(fun,"im_func")) { | |
|
287 | tmp_fun = PyObject_GetAttrString(fun,"im_func"); | |
|
288 | } | |
|
289 | else if (PyObject_HasAttrString(fun,"__call__")) { | |
|
290 | tmp = PyObject_GetAttrString(fun,"__call__"); | |
|
291 | if (PyObject_HasAttrString(tmp,"im_func")) | |
|
292 | tmp_fun = PyObject_GetAttrString(tmp,"im_func"); | |
|
293 | else { | |
|
294 | tmp_fun = fun; /* built-in function */ | |
|
295 | Py_INCREF(tmp_fun); | |
|
296 | tot = maxnofargs; | |
|
297 | if (PyCFunction_Check(fun)) { | |
|
298 | /* In case the function has a co_argcount (like on PyPy) */ | |
|
299 | di = 0; | |
|
300 | } | |
|
301 | if (xa != NULL) | |
|
302 | tot += PyTuple_Size((PyObject *)xa); | |
|
303 | } | |
|
304 | Py_XDECREF(tmp); | |
|
305 | } | |
|
306 | else if (PyFortran_Check(fun) || PyFortran_Check1(fun)) { | |
|
307 | tot = maxnofargs; | |
|
308 | if (xa != NULL) | |
|
309 | tot += PyTuple_Size((PyObject *)xa); | |
|
310 | tmp_fun = fun; | |
|
311 | Py_INCREF(tmp_fun); | |
|
312 | } | |
|
313 | else if (F2PyCapsule_Check(fun)) { | |
|
314 | tot = maxnofargs; | |
|
315 | if (xa != NULL) | |
|
316 | ext = PyTuple_Size((PyObject *)xa); | |
|
317 | if(ext>0) { | |
|
318 | fprintf(stderr,"extra arguments tuple cannot be used with CObject call-back\n"); | |
|
319 | goto capi_fail; | |
|
320 | } | |
|
321 | tmp_fun = fun; | |
|
322 | Py_INCREF(tmp_fun); | |
|
323 | } | |
|
324 | } | |
|
325 | if (tmp_fun==NULL) { | |
|
326 | fprintf(stderr,"Call-back argument must be function|instance|instance.__call__|f2py-function but got %s.\n",(fun==NULL?"NULL":Py_TYPE(fun)->tp_name)); | |
|
327 | goto capi_fail; | |
|
328 | } | |
|
329 | if (PyObject_HasAttrString(tmp_fun,"__code__")) { | |
|
330 | if (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,"__code__"),"co_argcount")) { | |
|
331 | PyObject *tmp_argcount = PyObject_GetAttrString(tmp,"co_argcount"); | |
|
332 | Py_DECREF(tmp); | |
|
333 | if (tmp_argcount == NULL) { | |
|
334 | goto capi_fail; | |
|
335 | } | |
|
336 | tot = PyInt_AsLong(tmp_argcount) - di; | |
|
337 | Py_DECREF(tmp_argcount); | |
|
338 | } | |
|
339 | } | |
|
340 | /* Get the number of optional arguments */ | |
|
341 | if (PyObject_HasAttrString(tmp_fun,"__defaults__")) { | |
|
342 | if (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,"__defaults__"))) | |
|
343 | opt = PyTuple_Size(tmp); | |
|
344 | Py_XDECREF(tmp); | |
|
345 | } | |
|
346 | /* Get the number of extra arguments */ | |
|
347 | if (xa != NULL) | |
|
348 | ext = PyTuple_Size((PyObject *)xa); | |
|
349 | /* Calculate the size of call-backs argument list */ | |
|
350 | siz = MIN(maxnofargs+ext,tot); | |
|
351 | *nofargs = MAX(0,siz-ext); | |
|
352 | #ifdef DEBUGCFUNCS | |
|
353 | fprintf(stderr,"debug-capi:create_cb_arglist:maxnofargs(-nofoptargs),tot,opt,ext,siz,nofargs=%d(-%d),%d,%d,%d,%d,%d\n",maxnofargs,nofoptargs,tot,opt,ext,siz,*nofargs); | |
|
354 | #endif | |
|
355 | if (siz<tot-opt) { | |
|
356 | fprintf(stderr,"create_cb_arglist: Failed to build argument list (siz) with enough arguments (tot-opt) required by user-supplied function (siz,tot,opt=%d,%d,%d).\n",siz,tot,opt); | |
|
357 | goto capi_fail; | |
|
358 | } | |
|
359 | /* Initialize argument list */ | |
|
360 | *args = (PyTupleObject *)PyTuple_New(siz); | |
|
361 | for (i=0;i<*nofargs;i++) { | |
|
362 | Py_INCREF(Py_None); | |
|
363 | PyTuple_SET_ITEM((PyObject *)(*args),i,Py_None); | |
|
364 | } | |
|
365 | if (xa != NULL) | |
|
366 | for (i=(*nofargs);i<siz;i++) { | |
|
367 | tmp = PyTuple_GetItem((PyObject *)xa,i-(*nofargs)); | |
|
368 | Py_INCREF(tmp); | |
|
369 | PyTuple_SET_ITEM(*args,i,tmp); | |
|
370 | } | |
|
371 | CFUNCSMESS("create_cb_arglist-end\n"); | |
|
372 | Py_DECREF(tmp_fun); | |
|
373 | return 1; | |
|
374 | capi_fail: | |
|
375 | if ((PyErr_Occurred())==NULL) | |
|
376 | PyErr_SetString(fitacf_fit_short_error,errmess); | |
|
377 | Py_XDECREF(tmp_fun); | |
|
378 | return 0; | |
|
379 | } | |
|
380 | ||
|
381 | ||
|
382 | /********************* See f2py2e/cfuncs.py: userincludes *********************/ | |
|
383 | /*need_userincludes*/ | |
|
384 | ||
|
385 | /********************* See f2py2e/capi_rules.py: usercode *********************/ | |
|
386 | ||
|
387 | ||
|
388 | /* See f2py2e/rules.py */ | |
|
389 | extern void F_FUNC(fit,FIT)(float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,int*,int*,int*); | |
|
390 | extern void F_WRAPPEDFUNC(spect1,SPECT1)(float*,float*); | |
|
391 | extern void F_FUNC(gaussq,GAUSSQ)(float*,float*); | |
|
392 | extern void F_FUNC(lmdif1,LMDIF1)(cb_fcn_in_lmdif__user__routines_typedef,int*,int*,float*,float*,float*,int*,int*,float*,int*); | |
|
393 | extern void F_FUNC(lmdif,LMDIF)(cb_fcn_in_lmdif__user__routines_typedef,int*,int*,float*,float*,float*,float*,float*,int*,float*,float*,int*,float*,int*,int*,int*,float*,int*,int*,float*,float*,float*,float*,float*); | |
|
394 | extern void F_WRAPPEDFUNC(spmpar,SPMPAR)(float*,int*); | |
|
395 | /*eof externroutines*/ | |
|
396 | ||
|
397 | /******************** See f2py2e/capi_rules.py: usercode1 ********************/ | |
|
398 | ||
|
399 | ||
|
400 | /******************* See f2py2e/cb_rules.py: buildcallback *******************/ | |
|
401 | ||
|
402 | /********************** cb_fcn_in_lmdif__user__routines **********************/ | |
|
403 | PyObject *cb_fcn_in_lmdif__user__routines_capi = NULL;/*was Py_None*/ | |
|
404 | PyTupleObject *cb_fcn_in_lmdif__user__routines_args_capi = NULL; | |
|
405 | int cb_fcn_in_lmdif__user__routines_nofargs = 0; | |
|
406 | jmp_buf cb_fcn_in_lmdif__user__routines_jmpbuf; | |
|
407 | /*typedef void(*cb_fcn_in_lmdif__user__routines_typedef)(int *,int *,float *,float *,int *);*/ | |
|
408 | static void cb_fcn_in_lmdif__user__routines (int *m_cb_capi,int *n_cb_capi,float *x,float *fvec,int *iflag_cb_capi) { | |
|
409 | PyTupleObject *capi_arglist = cb_fcn_in_lmdif__user__routines_args_capi; | |
|
410 | PyObject *capi_return = NULL; | |
|
411 | PyObject *capi_tmp = NULL; | |
|
412 | PyObject *capi_arglist_list = NULL; | |
|
413 | int capi_j,capi_i = 0; | |
|
414 | int capi_longjmp_ok = 1; | |
|
415 | /*decl*/ | |
|
416 | int m=(*m_cb_capi); | |
|
417 | int n=(*n_cb_capi); | |
|
418 | int iflag=(*iflag_cb_capi); | |
|
419 | npy_intp x_Dims[1] = {-1}; | |
|
420 | npy_intp fvec_Dims[1] = {-1}; | |
|
421 | #ifdef F2PY_REPORT_ATEXIT | |
|
422 | f2py_cb_start_clock(); | |
|
423 | #endif | |
|
424 | CFUNCSMESS("cb:Call-back function cb_fcn_in_lmdif__user__routines (maxnofargs=5(-2))\n"); | |
|
425 | CFUNCSMESSPY("cb:cb_fcn_in_lmdif__user__routines_capi=",cb_fcn_in_lmdif__user__routines_capi); | |
|
426 | if (cb_fcn_in_lmdif__user__routines_capi==NULL) { | |
|
427 | capi_longjmp_ok = 0; | |
|
428 | cb_fcn_in_lmdif__user__routines_capi = PyObject_GetAttrString(fitacf_fit_short_module,"fcn"); | |
|
429 | } | |
|
430 | if (cb_fcn_in_lmdif__user__routines_capi==NULL) { | |
|
431 | PyErr_SetString(fitacf_fit_short_error,"cb: Callback fcn not defined (as an argument or module fitacf_fit_short attribute).\n"); | |
|
432 | goto capi_fail; | |
|
433 | } | |
|
434 | if (F2PyCapsule_Check(cb_fcn_in_lmdif__user__routines_capi)) { | |
|
435 | cb_fcn_in_lmdif__user__routines_typedef cb_fcn_in_lmdif__user__routines_cptr; | |
|
436 | cb_fcn_in_lmdif__user__routines_cptr = F2PyCapsule_AsVoidPtr(cb_fcn_in_lmdif__user__routines_capi); | |
|
437 | (*cb_fcn_in_lmdif__user__routines_cptr)(m_cb_capi,n_cb_capi,x,fvec,iflag_cb_capi); | |
|
438 | return; | |
|
439 | } | |
|
440 | if (capi_arglist==NULL) { | |
|
441 | capi_longjmp_ok = 0; | |
|
442 | capi_tmp = PyObject_GetAttrString(fitacf_fit_short_module,"fcn_extra_args"); | |
|
443 | if (capi_tmp) { | |
|
444 | capi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp); | |
|
445 | if (capi_arglist==NULL) { | |
|
446 | PyErr_SetString(fitacf_fit_short_error,"Failed to convert fitacf_fit_short.fcn_extra_args to tuple.\n"); | |
|
447 | goto capi_fail; | |
|
448 | } | |
|
449 | } else { | |
|
450 | PyErr_Clear(); | |
|
451 | capi_arglist = (PyTupleObject *)Py_BuildValue("()"); | |
|
452 | } | |
|
453 | } | |
|
454 | if (capi_arglist == NULL) { | |
|
455 | PyErr_SetString(fitacf_fit_short_error,"Callback fcn argument list is not set.\n"); | |
|
456 | goto capi_fail; | |
|
457 | } | |
|
458 | /*setdims*/ | |
|
459 | x_Dims[0]=n; | |
|
460 | fvec_Dims[0]=m; | |
|
461 | #ifdef PYPY_VERSION | |
|
462 | #define CAPI_ARGLIST_SETITEM(idx, value) PyList_SetItem((PyObject *)capi_arglist_list, idx, value) | |
|
463 | capi_arglist_list = PySequence_List(capi_arglist); | |
|
464 | if (capi_arglist_list == NULL) goto capi_fail; | |
|
465 | #else | |
|
466 | #define CAPI_ARGLIST_SETITEM(idx, value) PyTuple_SetItem((PyObject *)capi_arglist, idx, value) | |
|
467 | #endif | |
|
468 | /*pyobjfrom*/ | |
|
469 | if (cb_fcn_in_lmdif__user__routines_nofargs>capi_i) { | |
|
470 | int itemsize_ = NPY_FLOAT == NPY_STRING ? 1 : 0; | |
|
471 | /*XXX: Hmm, what will destroy this array??? */ | |
|
472 | PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,x_Dims,NPY_FLOAT,NULL,(char*)x,itemsize_,NPY_ARRAY_FARRAY,NULL); | |
|
473 | ||
|
474 | ||
|
475 | if (tmp_arr==NULL) | |
|
476 | goto capi_fail; | |
|
477 | if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr)) | |
|
478 | goto capi_fail; | |
|
479 | } | |
|
480 | if (cb_fcn_in_lmdif__user__routines_nofargs>capi_i) { | |
|
481 | int itemsize_ = NPY_FLOAT == NPY_STRING ? 1 : 0; | |
|
482 | /*XXX: Hmm, what will destroy this array??? */ | |
|
483 | PyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,1,fvec_Dims,NPY_FLOAT,NULL,(char*)fvec,itemsize_,NPY_ARRAY_FARRAY,NULL); | |
|
484 | ||
|
485 | ||
|
486 | if (tmp_arr==NULL) | |
|
487 | goto capi_fail; | |
|
488 | if (CAPI_ARGLIST_SETITEM(capi_i++,(PyObject *)tmp_arr)) | |
|
489 | goto capi_fail; | |
|
490 | } | |
|
491 | if (cb_fcn_in_lmdif__user__routines_nofargs>capi_i) | |
|
492 | if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(iflag))) | |
|
493 | goto capi_fail; | |
|
494 | if (cb_fcn_in_lmdif__user__routines_nofargs>capi_i) | |
|
495 | if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(m))) | |
|
496 | goto capi_fail; | |
|
497 | if (cb_fcn_in_lmdif__user__routines_nofargs>capi_i) | |
|
498 | if (CAPI_ARGLIST_SETITEM(capi_i++,pyobj_from_int1(n))) | |
|
499 | goto capi_fail; | |
|
500 | #undef CAPI_ARGLIST_SETITEM | |
|
501 | #ifdef PYPY_VERSION | |
|
502 | CFUNCSMESSPY("cb:capi_arglist=",capi_arglist_list); | |
|
503 | #else | |
|
504 | CFUNCSMESSPY("cb:capi_arglist=",capi_arglist); | |
|
505 | #endif | |
|
506 | CFUNCSMESS("cb:Call-back calling Python function fcn.\n"); | |
|
507 | #ifdef F2PY_REPORT_ATEXIT | |
|
508 | f2py_cb_start_call_clock(); | |
|
509 | #endif | |
|
510 | #ifdef PYPY_VERSION | |
|
511 | capi_return = PyObject_CallObject(cb_fcn_in_lmdif__user__routines_capi,(PyObject *)capi_arglist_list); | |
|
512 | Py_DECREF(capi_arglist_list); | |
|
513 | capi_arglist_list = NULL; | |
|
514 | #else | |
|
515 | capi_return = PyObject_CallObject(cb_fcn_in_lmdif__user__routines_capi,(PyObject *)capi_arglist); | |
|
516 | #endif | |
|
517 | #ifdef F2PY_REPORT_ATEXIT | |
|
518 | f2py_cb_stop_call_clock(); | |
|
519 | #endif | |
|
520 | CFUNCSMESSPY("cb:capi_return=",capi_return); | |
|
521 | if (capi_return == NULL) { | |
|
522 | fprintf(stderr,"capi_return is NULL\n"); | |
|
523 | goto capi_fail; | |
|
524 | } | |
|
525 | if (capi_return == Py_None) { | |
|
526 | Py_DECREF(capi_return); | |
|
527 | capi_return = Py_BuildValue("()"); | |
|
528 | } | |
|
529 | else if (!PyTuple_Check(capi_return)) { | |
|
530 | capi_return = Py_BuildValue("(N)",capi_return); | |
|
531 | } | |
|
532 | capi_j = PyTuple_Size(capi_return); | |
|
533 | capi_i = 0; | |
|
534 | /*frompyobj*/ | |
|
535 | CFUNCSMESS("cb:cb_fcn_in_lmdif__user__routines:successful\n"); | |
|
536 | Py_DECREF(capi_return); | |
|
537 | #ifdef F2PY_REPORT_ATEXIT | |
|
538 | f2py_cb_stop_clock(); | |
|
539 | #endif | |
|
540 | goto capi_return_pt; | |
|
541 | capi_fail: | |
|
542 | fprintf(stderr,"Call-back cb_fcn_in_lmdif__user__routines failed.\n"); | |
|
543 | Py_XDECREF(capi_return); | |
|
544 | Py_XDECREF(capi_arglist_list); | |
|
545 | if (capi_longjmp_ok) | |
|
546 | longjmp(cb_fcn_in_lmdif__user__routines_jmpbuf,-1); | |
|
547 | capi_return_pt: | |
|
548 | ; | |
|
549 | return; | |
|
550 | } | |
|
551 | /******************* end of cb_fcn_in_lmdif__user__routines *******************/ | |
|
552 | ||
|
553 | ||
|
554 | /*********************** See f2py2e/rules.py: buildapi ***********************/ | |
|
555 | ||
|
556 | /************************************ fit ************************************/ | |
|
557 | static char doc_f2py_rout_fitacf_fit_short_fit[] = "\ | |
|
558 | cinv,sigma2p,paramp,ebp,ist = fit(wl,taup,rhop,covar,cinv,sigma2p,paramp,bfldp,alphap,densp,alt,time,ifitp,ist,[nl])\n\nWrapper for ``fit``.\ | |
|
559 | \n\nParameters\n----------\n" | |
|
560 | "wl : input float\n" | |
|
561 | "taup : input rank-1 array('f') with bounds (nl)\n" | |
|
562 | "rhop : input rank-1 array('f') with bounds (nl)\n" | |
|
563 | "covar : input rank-2 array('f') with bounds (nl,nl)\n" | |
|
564 | "cinv : input rank-2 array('f') with bounds (nl,nl)\n" | |
|
565 | "sigma2p : input rank-1 array('f') with bounds (nl)\n" | |
|
566 | "paramp : input rank-1 array('f') with bounds (10)\n" | |
|
567 | "bfldp : input float\n" | |
|
568 | "alphap : input float\n" | |
|
569 | "densp : input float\n" | |
|
570 | "alt : input float\n" | |
|
571 | "time : input float\n" | |
|
572 | "ifitp : input rank-1 array('i') with bounds (10)\n" | |
|
573 | "ist : input int\n" | |
|
574 | "\nOther Parameters\n----------------\n" | |
|
575 | "nl : input int, optional\n Default: len(taup)\n" | |
|
576 | "\nReturns\n-------\n" | |
|
577 | "cinv : rank-2 array('f') with bounds (nl,nl)\n" | |
|
578 | "sigma2p : rank-1 array('f') with bounds (nl)\n" | |
|
579 | "paramp : rank-1 array('f') with bounds (10)\n" | |
|
580 | "ebp : rank-1 array('f') with bounds (10)\n" | |
|
581 | "ist : int"; | |
|
582 | /* extern void F_FUNC(fit,FIT)(float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,int*,int*,int*); */ | |
|
583 | static PyObject *f2py_rout_fitacf_fit_short_fit(const PyObject *capi_self, | |
|
584 | PyObject *capi_args, | |
|
585 | PyObject *capi_keywds, | |
|
586 | void (*f2py_func)(float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,float*,int*,int*,int*)) { | |
|
587 | PyObject * volatile capi_buildvalue = NULL; | |
|
588 | volatile int f2py_success = 1; | |
|
589 | /*decl*/ | |
|
590 | ||
|
591 | float wl = 0; | |
|
592 | PyObject *wl_capi = Py_None; | |
|
593 | float *taup = NULL; | |
|
594 | npy_intp taup_Dims[1] = {-1}; | |
|
595 | const int taup_Rank = 1; | |
|
596 | PyArrayObject *capi_taup_tmp = NULL; | |
|
597 | int capi_taup_intent = 0; | |
|
598 | PyObject *taup_capi = Py_None; | |
|
599 | float *rhop = NULL; | |
|
600 | npy_intp rhop_Dims[1] = {-1}; | |
|
601 | const int rhop_Rank = 1; | |
|
602 | PyArrayObject *capi_rhop_tmp = NULL; | |
|
603 | int capi_rhop_intent = 0; | |
|
604 | PyObject *rhop_capi = Py_None; | |
|
605 | float *covar = NULL; | |
|
606 | npy_intp covar_Dims[2] = {-1, -1}; | |
|
607 | const int covar_Rank = 2; | |
|
608 | PyArrayObject *capi_covar_tmp = NULL; | |
|
609 | int capi_covar_intent = 0; | |
|
610 | PyObject *covar_capi = Py_None; | |
|
611 | float *cinv = NULL; | |
|
612 | npy_intp cinv_Dims[2] = {-1, -1}; | |
|
613 | const int cinv_Rank = 2; | |
|
614 | PyArrayObject *capi_cinv_tmp = NULL; | |
|
615 | int capi_cinv_intent = 0; | |
|
616 | PyObject *cinv_capi = Py_None; | |
|
617 | float *sigma2p = NULL; | |
|
618 | npy_intp sigma2p_Dims[1] = {-1}; | |
|
619 | const int sigma2p_Rank = 1; | |
|
620 | PyArrayObject *capi_sigma2p_tmp = NULL; | |
|
621 | int capi_sigma2p_intent = 0; | |
|
622 | PyObject *sigma2p_capi = Py_None; | |
|
623 | float *paramp = NULL; | |
|
624 | npy_intp paramp_Dims[1] = {-1}; | |
|
625 | const int paramp_Rank = 1; | |
|
626 | PyArrayObject *capi_paramp_tmp = NULL; | |
|
627 | int capi_paramp_intent = 0; | |
|
628 | PyObject *paramp_capi = Py_None; | |
|
629 | float *ebp = NULL; | |
|
630 | npy_intp ebp_Dims[1] = {-1}; | |
|
631 | const int ebp_Rank = 1; | |
|
632 | PyArrayObject *capi_ebp_tmp = NULL; | |
|
633 | int capi_ebp_intent = 0; | |
|
634 | float bfldp = 0; | |
|
635 | PyObject *bfldp_capi = Py_None; | |
|
636 | float alphap = 0; | |
|
637 | PyObject *alphap_capi = Py_None; | |
|
638 | float densp = 0; | |
|
639 | PyObject *densp_capi = Py_None; | |
|
640 | float alt = 0; | |
|
641 | PyObject *alt_capi = Py_None; | |
|
642 | float time = 0; | |
|
643 | PyObject *time_capi = Py_None; | |
|
644 | int *ifitp = NULL; | |
|
645 | npy_intp ifitp_Dims[1] = {-1}; | |
|
646 | const int ifitp_Rank = 1; | |
|
647 | PyArrayObject *capi_ifitp_tmp = NULL; | |
|
648 | int capi_ifitp_intent = 0; | |
|
649 | PyObject *ifitp_capi = Py_None; | |
|
650 | int ist = 0; | |
|
651 | PyObject *ist_capi = Py_None; | |
|
652 | int nl = 0; | |
|
653 | PyObject *nl_capi = Py_None; | |
|
654 | static char *capi_kwlist[] = {"wl","taup","rhop","covar","cinv","sigma2p","paramp","bfldp","alphap","densp","alt","time","ifitp","ist","nl",NULL}; | |
|
655 | ||
|
656 | /*routdebugenter*/ | |
|
657 | #ifdef F2PY_REPORT_ATEXIT | |
|
658 | f2py_start_clock(); | |
|
659 | #endif | |
|
660 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
661 | "OOOOOOOOOOOOOO|O:fitacf_fit_short.fit",\ | |
|
662 | capi_kwlist,&wl_capi,&taup_capi,&rhop_capi,&covar_capi,&cinv_capi,&sigma2p_capi,¶mp_capi,&bfldp_capi,&alphap_capi,&densp_capi,&alt_capi,&time_capi,&ifitp_capi,&ist_capi,&nl_capi)) | |
|
663 | return NULL; | |
|
664 | /*frompyobj*/ | |
|
665 | /* Processing variable wl */ | |
|
666 | f2py_success = float_from_pyobj(&wl,wl_capi,"fitacf_fit_short.fit() 1st argument (wl) can't be converted to float"); | |
|
667 | if (f2py_success) { | |
|
668 | /* Processing variable taup */ | |
|
669 | ; | |
|
670 | capi_taup_intent |= F2PY_INTENT_IN; | |
|
671 | capi_taup_tmp = array_from_pyobj(NPY_FLOAT,taup_Dims,taup_Rank,capi_taup_intent,taup_capi); | |
|
672 | if (capi_taup_tmp == NULL) { | |
|
673 | PyObject *exc, *val, *tb; | |
|
674 | PyErr_Fetch(&exc, &val, &tb); | |
|
675 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 2nd argument `taup' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
676 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
677 | } else { | |
|
678 | taup = (float *)(PyArray_DATA(capi_taup_tmp)); | |
|
679 | ||
|
680 | /* Processing variable paramp */ | |
|
681 | paramp_Dims[0]=10; | |
|
682 | capi_paramp_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; | |
|
683 | capi_paramp_tmp = array_from_pyobj(NPY_FLOAT,paramp_Dims,paramp_Rank,capi_paramp_intent,paramp_capi); | |
|
684 | if (capi_paramp_tmp == NULL) { | |
|
685 | PyObject *exc, *val, *tb; | |
|
686 | PyErr_Fetch(&exc, &val, &tb); | |
|
687 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 7th argument `paramp' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
688 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
689 | } else { | |
|
690 | paramp = (float *)(PyArray_DATA(capi_paramp_tmp)); | |
|
691 | ||
|
692 | /* Processing variable ebp */ | |
|
693 | ebp_Dims[0]=10; | |
|
694 | capi_ebp_intent |= F2PY_INTENT_OUT|F2PY_INTENT_HIDE; | |
|
695 | capi_ebp_tmp = array_from_pyobj(NPY_FLOAT,ebp_Dims,ebp_Rank,capi_ebp_intent,Py_None); | |
|
696 | if (capi_ebp_tmp == NULL) { | |
|
697 | PyObject *exc, *val, *tb; | |
|
698 | PyErr_Fetch(&exc, &val, &tb); | |
|
699 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting hidden `ebp' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
700 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
701 | } else { | |
|
702 | ebp = (float *)(PyArray_DATA(capi_ebp_tmp)); | |
|
703 | ||
|
704 | /* Processing variable bfldp */ | |
|
705 | f2py_success = float_from_pyobj(&bfldp,bfldp_capi,"fitacf_fit_short.fit() 8th argument (bfldp) can't be converted to float"); | |
|
706 | if (f2py_success) { | |
|
707 | /* Processing variable alphap */ | |
|
708 | f2py_success = float_from_pyobj(&alphap,alphap_capi,"fitacf_fit_short.fit() 9th argument (alphap) can't be converted to float"); | |
|
709 | if (f2py_success) { | |
|
710 | /* Processing variable densp */ | |
|
711 | f2py_success = float_from_pyobj(&densp,densp_capi,"fitacf_fit_short.fit() 10th argument (densp) can't be converted to float"); | |
|
712 | if (f2py_success) { | |
|
713 | /* Processing variable alt */ | |
|
714 | f2py_success = float_from_pyobj(&alt,alt_capi,"fitacf_fit_short.fit() 11st argument (alt) can't be converted to float"); | |
|
715 | if (f2py_success) { | |
|
716 | /* Processing variable time */ | |
|
717 | f2py_success = float_from_pyobj(&time,time_capi,"fitacf_fit_short.fit() 12nd argument (time) can't be converted to float"); | |
|
718 | if (f2py_success) { | |
|
719 | /* Processing variable ifitp */ | |
|
720 | ifitp_Dims[0]=10; | |
|
721 | capi_ifitp_intent |= F2PY_INTENT_IN; | |
|
722 | capi_ifitp_tmp = array_from_pyobj(NPY_INT,ifitp_Dims,ifitp_Rank,capi_ifitp_intent,ifitp_capi); | |
|
723 | if (capi_ifitp_tmp == NULL) { | |
|
724 | PyObject *exc, *val, *tb; | |
|
725 | PyErr_Fetch(&exc, &val, &tb); | |
|
726 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 13rd argument `ifitp' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
727 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
728 | } else { | |
|
729 | ifitp = (int *)(PyArray_DATA(capi_ifitp_tmp)); | |
|
730 | ||
|
731 | /* Processing variable ist */ | |
|
732 | f2py_success = int_from_pyobj(&ist,ist_capi,"fitacf_fit_short.fit() 14th argument (ist) can't be converted to int"); | |
|
733 | if (f2py_success) { | |
|
734 | /* Processing variable nl */ | |
|
735 | if (nl_capi == Py_None) nl = len(taup); else | |
|
736 | f2py_success = int_from_pyobj(&nl,nl_capi,"fitacf_fit_short.fit() 1st keyword (nl) can't be converted to int"); | |
|
737 | if (f2py_success) { | |
|
738 | CHECKSCALAR(len(taup)>=nl,"len(taup)>=nl","1st keyword nl","fit:nl=%d",nl) { | |
|
739 | /* Processing variable rhop */ | |
|
740 | rhop_Dims[0]=nl; | |
|
741 | capi_rhop_intent |= F2PY_INTENT_IN; | |
|
742 | capi_rhop_tmp = array_from_pyobj(NPY_FLOAT,rhop_Dims,rhop_Rank,capi_rhop_intent,rhop_capi); | |
|
743 | if (capi_rhop_tmp == NULL) { | |
|
744 | PyObject *exc, *val, *tb; | |
|
745 | PyErr_Fetch(&exc, &val, &tb); | |
|
746 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 3rd argument `rhop' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
747 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
748 | } else { | |
|
749 | rhop = (float *)(PyArray_DATA(capi_rhop_tmp)); | |
|
750 | ||
|
751 | /* Processing variable covar */ | |
|
752 | covar_Dims[0]=nl,covar_Dims[1]=nl; | |
|
753 | capi_covar_intent |= F2PY_INTENT_IN; | |
|
754 | capi_covar_tmp = array_from_pyobj(NPY_FLOAT,covar_Dims,covar_Rank,capi_covar_intent,covar_capi); | |
|
755 | if (capi_covar_tmp == NULL) { | |
|
756 | PyObject *exc, *val, *tb; | |
|
757 | PyErr_Fetch(&exc, &val, &tb); | |
|
758 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 4th argument `covar' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
759 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
760 | } else { | |
|
761 | covar = (float *)(PyArray_DATA(capi_covar_tmp)); | |
|
762 | ||
|
763 | /* Processing variable cinv */ | |
|
764 | cinv_Dims[0]=nl,cinv_Dims[1]=nl; | |
|
765 | capi_cinv_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; | |
|
766 | capi_cinv_tmp = array_from_pyobj(NPY_FLOAT,cinv_Dims,cinv_Rank,capi_cinv_intent,cinv_capi); | |
|
767 | if (capi_cinv_tmp == NULL) { | |
|
768 | PyObject *exc, *val, *tb; | |
|
769 | PyErr_Fetch(&exc, &val, &tb); | |
|
770 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 5th argument `cinv' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
771 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
772 | } else { | |
|
773 | cinv = (float *)(PyArray_DATA(capi_cinv_tmp)); | |
|
774 | ||
|
775 | /* Processing variable sigma2p */ | |
|
776 | sigma2p_Dims[0]=nl; | |
|
777 | capi_sigma2p_intent |= F2PY_INTENT_IN|F2PY_INTENT_OUT; | |
|
778 | capi_sigma2p_tmp = array_from_pyobj(NPY_FLOAT,sigma2p_Dims,sigma2p_Rank,capi_sigma2p_intent,sigma2p_capi); | |
|
779 | if (capi_sigma2p_tmp == NULL) { | |
|
780 | PyObject *exc, *val, *tb; | |
|
781 | PyErr_Fetch(&exc, &val, &tb); | |
|
782 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 6th argument `sigma2p' of fitacf_fit_short.fit to C/Fortran array" ); | |
|
783 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
784 | } else { | |
|
785 | sigma2p = (float *)(PyArray_DATA(capi_sigma2p_tmp)); | |
|
786 | ||
|
787 | /*end of frompyobj*/ | |
|
788 | #ifdef F2PY_REPORT_ATEXIT | |
|
789 | f2py_start_call_clock(); | |
|
790 | #endif | |
|
791 | /*callfortranroutine*/ | |
|
792 | (*f2py_func)(&wl,taup,rhop,covar,cinv,sigma2p,paramp,ebp,&bfldp,&alphap,&densp,&alt,&time,ifitp,&ist,&nl); | |
|
793 | if (PyErr_Occurred()) | |
|
794 | f2py_success = 0; | |
|
795 | #ifdef F2PY_REPORT_ATEXIT | |
|
796 | f2py_stop_call_clock(); | |
|
797 | #endif | |
|
798 | /*end of callfortranroutine*/ | |
|
799 | if (f2py_success) { | |
|
800 | /*pyobjfrom*/ | |
|
801 | /*end of pyobjfrom*/ | |
|
802 | CFUNCSMESS("Building return value.\n"); | |
|
803 | capi_buildvalue = Py_BuildValue("NNNNi",capi_cinv_tmp,capi_sigma2p_tmp,capi_paramp_tmp,capi_ebp_tmp,ist); | |
|
804 | /*closepyobjfrom*/ | |
|
805 | /*end of closepyobjfrom*/ | |
|
806 | } /*if (f2py_success) after callfortranroutine*/ | |
|
807 | /*cleanupfrompyobj*/ | |
|
808 | } /*if (capi_sigma2p_tmp == NULL) ... else of sigma2p*/ | |
|
809 | /* End of cleaning variable sigma2p */ | |
|
810 | } /*if (capi_cinv_tmp == NULL) ... else of cinv*/ | |
|
811 | /* End of cleaning variable cinv */ | |
|
812 | if((PyObject *)capi_covar_tmp!=covar_capi) { | |
|
813 | Py_XDECREF(capi_covar_tmp); } | |
|
814 | } /*if (capi_covar_tmp == NULL) ... else of covar*/ | |
|
815 | /* End of cleaning variable covar */ | |
|
816 | if((PyObject *)capi_rhop_tmp!=rhop_capi) { | |
|
817 | Py_XDECREF(capi_rhop_tmp); } | |
|
818 | } /*if (capi_rhop_tmp == NULL) ... else of rhop*/ | |
|
819 | /* End of cleaning variable rhop */ | |
|
820 | } /*CHECKSCALAR(len(taup)>=nl)*/ | |
|
821 | } /*if (f2py_success) of nl*/ | |
|
822 | /* End of cleaning variable nl */ | |
|
823 | } /*if (f2py_success) of ist*/ | |
|
824 | /* End of cleaning variable ist */ | |
|
825 | if((PyObject *)capi_ifitp_tmp!=ifitp_capi) { | |
|
826 | Py_XDECREF(capi_ifitp_tmp); } | |
|
827 | } /*if (capi_ifitp_tmp == NULL) ... else of ifitp*/ | |
|
828 | /* End of cleaning variable ifitp */ | |
|
829 | } /*if (f2py_success) of time*/ | |
|
830 | /* End of cleaning variable time */ | |
|
831 | } /*if (f2py_success) of alt*/ | |
|
832 | /* End of cleaning variable alt */ | |
|
833 | } /*if (f2py_success) of densp*/ | |
|
834 | /* End of cleaning variable densp */ | |
|
835 | } /*if (f2py_success) of alphap*/ | |
|
836 | /* End of cleaning variable alphap */ | |
|
837 | } /*if (f2py_success) of bfldp*/ | |
|
838 | /* End of cleaning variable bfldp */ | |
|
839 | } /*if (capi_ebp_tmp == NULL) ... else of ebp*/ | |
|
840 | /* End of cleaning variable ebp */ | |
|
841 | } /*if (capi_paramp_tmp == NULL) ... else of paramp*/ | |
|
842 | /* End of cleaning variable paramp */ | |
|
843 | if((PyObject *)capi_taup_tmp!=taup_capi) { | |
|
844 | Py_XDECREF(capi_taup_tmp); } | |
|
845 | } /*if (capi_taup_tmp == NULL) ... else of taup*/ | |
|
846 | /* End of cleaning variable taup */ | |
|
847 | } /*if (f2py_success) of wl*/ | |
|
848 | /* End of cleaning variable wl */ | |
|
849 | /*end of cleanupfrompyobj*/ | |
|
850 | if (capi_buildvalue == NULL) { | |
|
851 | /*routdebugfailure*/ | |
|
852 | } else { | |
|
853 | /*routdebugleave*/ | |
|
854 | } | |
|
855 | CFUNCSMESS("Freeing memory.\n"); | |
|
856 | /*freemem*/ | |
|
857 | #ifdef F2PY_REPORT_ATEXIT | |
|
858 | f2py_stop_clock(); | |
|
859 | #endif | |
|
860 | return capi_buildvalue; | |
|
861 | } | |
|
862 | /********************************* end of fit *********************************/ | |
|
863 | ||
|
864 | /*********************************** spect1 ***********************************/ | |
|
865 | static char doc_f2py_rout_fitacf_fit_short_spect1[] = "\ | |
|
866 | spect1 = spect1(omega)\n\nWrapper for ``spect1``.\ | |
|
867 | \n\nParameters\n----------\n" | |
|
868 | "omega : input float\n" | |
|
869 | "\nReturns\n-------\n" | |
|
870 | "spect1 : float"; | |
|
871 | /* extern void F_WRAPPEDFUNC(spect1,SPECT1)(float*,float*); */ | |
|
872 | static PyObject *f2py_rout_fitacf_fit_short_spect1(const PyObject *capi_self, | |
|
873 | PyObject *capi_args, | |
|
874 | PyObject *capi_keywds, | |
|
875 | void (*f2py_func)(float*,float*)) { | |
|
876 | PyObject * volatile capi_buildvalue = NULL; | |
|
877 | volatile int f2py_success = 1; | |
|
878 | /*decl*/ | |
|
879 | ||
|
880 | float spect1 = 0; | |
|
881 | float omega = 0; | |
|
882 | PyObject *omega_capi = Py_None; | |
|
883 | static char *capi_kwlist[] = {"omega",NULL}; | |
|
884 | ||
|
885 | /*routdebugenter*/ | |
|
886 | #ifdef F2PY_REPORT_ATEXIT | |
|
887 | f2py_start_clock(); | |
|
888 | #endif | |
|
889 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
890 | "O|:fitacf_fit_short.spect1",\ | |
|
891 | capi_kwlist,&omega_capi)) | |
|
892 | return NULL; | |
|
893 | /*frompyobj*/ | |
|
894 | /* Processing variable omega */ | |
|
895 | f2py_success = float_from_pyobj(&omega,omega_capi,"fitacf_fit_short.spect1() 1st argument (omega) can't be converted to float"); | |
|
896 | if (f2py_success) { | |
|
897 | /* Processing variable spect1 */ | |
|
898 | /*end of frompyobj*/ | |
|
899 | #ifdef F2PY_REPORT_ATEXIT | |
|
900 | f2py_start_call_clock(); | |
|
901 | #endif | |
|
902 | /*callfortranroutine*/ | |
|
903 | (*f2py_func)(&spect1,&omega); | |
|
904 | if (PyErr_Occurred()) | |
|
905 | f2py_success = 0; | |
|
906 | #ifdef F2PY_REPORT_ATEXIT | |
|
907 | f2py_stop_call_clock(); | |
|
908 | #endif | |
|
909 | /*end of callfortranroutine*/ | |
|
910 | if (f2py_success) { | |
|
911 | /*pyobjfrom*/ | |
|
912 | /*end of pyobjfrom*/ | |
|
913 | CFUNCSMESS("Building return value.\n"); | |
|
914 | capi_buildvalue = Py_BuildValue("f",spect1); | |
|
915 | /*closepyobjfrom*/ | |
|
916 | /*end of closepyobjfrom*/ | |
|
917 | } /*if (f2py_success) after callfortranroutine*/ | |
|
918 | /*cleanupfrompyobj*/ | |
|
919 | /* End of cleaning variable spect1 */ | |
|
920 | } /*if (f2py_success) of omega*/ | |
|
921 | /* End of cleaning variable omega */ | |
|
922 | /*end of cleanupfrompyobj*/ | |
|
923 | if (capi_buildvalue == NULL) { | |
|
924 | /*routdebugfailure*/ | |
|
925 | } else { | |
|
926 | /*routdebugleave*/ | |
|
927 | } | |
|
928 | CFUNCSMESS("Freeing memory.\n"); | |
|
929 | /*freemem*/ | |
|
930 | #ifdef F2PY_REPORT_ATEXIT | |
|
931 | f2py_stop_clock(); | |
|
932 | #endif | |
|
933 | return capi_buildvalue; | |
|
934 | } | |
|
935 | /******************************* end of spect1 *******************************/ | |
|
936 | ||
|
937 | /*********************************** gaussq ***********************************/ | |
|
938 | static char doc_f2py_rout_fitacf_fit_short_gaussq[] = "\ | |
|
939 | gaussq(tau,acf)\n\nWrapper for ``gaussq``.\ | |
|
940 | \n\nParameters\n----------\n" | |
|
941 | "tau : input float\n" | |
|
942 | "acf : input float"; | |
|
943 | /* extern void F_FUNC(gaussq,GAUSSQ)(float*,float*); */ | |
|
944 | static PyObject *f2py_rout_fitacf_fit_short_gaussq(const PyObject *capi_self, | |
|
945 | PyObject *capi_args, | |
|
946 | PyObject *capi_keywds, | |
|
947 | void (*f2py_func)(float*,float*)) { | |
|
948 | PyObject * volatile capi_buildvalue = NULL; | |
|
949 | volatile int f2py_success = 1; | |
|
950 | /*decl*/ | |
|
951 | ||
|
952 | float tau = 0; | |
|
953 | PyObject *tau_capi = Py_None; | |
|
954 | float acf = 0; | |
|
955 | PyObject *acf_capi = Py_None; | |
|
956 | static char *capi_kwlist[] = {"tau","acf",NULL}; | |
|
957 | ||
|
958 | /*routdebugenter*/ | |
|
959 | #ifdef F2PY_REPORT_ATEXIT | |
|
960 | f2py_start_clock(); | |
|
961 | #endif | |
|
962 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
963 | "OO|:fitacf_fit_short.gaussq",\ | |
|
964 | capi_kwlist,&tau_capi,&acf_capi)) | |
|
965 | return NULL; | |
|
966 | /*frompyobj*/ | |
|
967 | /* Processing variable tau */ | |
|
968 | f2py_success = float_from_pyobj(&tau,tau_capi,"fitacf_fit_short.gaussq() 1st argument (tau) can't be converted to float"); | |
|
969 | if (f2py_success) { | |
|
970 | /* Processing variable acf */ | |
|
971 | f2py_success = float_from_pyobj(&acf,acf_capi,"fitacf_fit_short.gaussq() 2nd argument (acf) can't be converted to float"); | |
|
972 | if (f2py_success) { | |
|
973 | /*end of frompyobj*/ | |
|
974 | #ifdef F2PY_REPORT_ATEXIT | |
|
975 | f2py_start_call_clock(); | |
|
976 | #endif | |
|
977 | /*callfortranroutine*/ | |
|
978 | (*f2py_func)(&tau,&acf); | |
|
979 | if (PyErr_Occurred()) | |
|
980 | f2py_success = 0; | |
|
981 | #ifdef F2PY_REPORT_ATEXIT | |
|
982 | f2py_stop_call_clock(); | |
|
983 | #endif | |
|
984 | /*end of callfortranroutine*/ | |
|
985 | if (f2py_success) { | |
|
986 | /*pyobjfrom*/ | |
|
987 | /*end of pyobjfrom*/ | |
|
988 | CFUNCSMESS("Building return value.\n"); | |
|
989 | capi_buildvalue = Py_BuildValue(""); | |
|
990 | /*closepyobjfrom*/ | |
|
991 | /*end of closepyobjfrom*/ | |
|
992 | } /*if (f2py_success) after callfortranroutine*/ | |
|
993 | /*cleanupfrompyobj*/ | |
|
994 | } /*if (f2py_success) of acf*/ | |
|
995 | /* End of cleaning variable acf */ | |
|
996 | } /*if (f2py_success) of tau*/ | |
|
997 | /* End of cleaning variable tau */ | |
|
998 | /*end of cleanupfrompyobj*/ | |
|
999 | if (capi_buildvalue == NULL) { | |
|
1000 | /*routdebugfailure*/ | |
|
1001 | } else { | |
|
1002 | /*routdebugleave*/ | |
|
1003 | } | |
|
1004 | CFUNCSMESS("Freeing memory.\n"); | |
|
1005 | /*freemem*/ | |
|
1006 | #ifdef F2PY_REPORT_ATEXIT | |
|
1007 | f2py_stop_clock(); | |
|
1008 | #endif | |
|
1009 | return capi_buildvalue; | |
|
1010 | } | |
|
1011 | /******************************* end of gaussq *******************************/ | |
|
1012 | ||
|
1013 | /*********************************** lmdif1 ***********************************/ | |
|
1014 | static char doc_f2py_rout_fitacf_fit_short_lmdif1[] = "\ | |
|
1015 | lmdif1(fcn,x,fvec,tol,info,iwa,wa,[m,n,lwa,fcn_extra_args])\n\nWrapper for ``lmdif1``.\ | |
|
1016 | \n\nParameters\n----------\n" | |
|
1017 | "fcn : call-back function\n" | |
|
1018 | "x : input rank-1 array('f') with bounds (n)\n" | |
|
1019 | "fvec : input rank-1 array('f') with bounds (m)\n" | |
|
1020 | "tol : input float\n" | |
|
1021 | "info : input int\n" | |
|
1022 | "iwa : input rank-1 array('i') with bounds (n)\n" | |
|
1023 | "wa : input rank-1 array('f') with bounds (lwa)\n" | |
|
1024 | "\nOther Parameters\n----------------\n" | |
|
1025 | "fcn_extra_args : input tuple, optional\n Default: ()\n" | |
|
1026 | "m : input int, optional\n Default: len(fvec)\n" | |
|
1027 | "n : input int, optional\n Default: len(x)\n" | |
|
1028 | "lwa : input int, optional\n Default: len(wa)\n" | |
|
1029 | "\nNotes\n-----\nCall-back functions::\n\n" | |
|
1030 | " def fcn(x,fvec,iflag,[m,n]): return \n\ | |
|
1031 | Required arguments:\n" | |
|
1032 | " x : input rank-1 array('f') with bounds (n)\n" | |
|
1033 | " fvec : input rank-1 array('f') with bounds (m)\n" | |
|
1034 | " iflag : input int\n" | |
|
1035 | " Optional arguments:\n" | |
|
1036 | " m : input int, optional\n Default: len(fvec)\n" | |
|
1037 | " n : input int, optional\n Default: len(x)"; | |
|
1038 | /* extern void F_FUNC(lmdif1,LMDIF1)(cb_fcn_in_lmdif__user__routines_typedef,int*,int*,float*,float*,float*,int*,int*,float*,int*); */ | |
|
1039 | static PyObject *f2py_rout_fitacf_fit_short_lmdif1(const PyObject *capi_self, | |
|
1040 | PyObject *capi_args, | |
|
1041 | PyObject *capi_keywds, | |
|
1042 | void (*f2py_func)(cb_fcn_in_lmdif__user__routines_typedef,int*,int*,float*,float*,float*,int*,int*,float*,int*)) { | |
|
1043 | PyObject * volatile capi_buildvalue = NULL; | |
|
1044 | volatile int f2py_success = 1; | |
|
1045 | /*decl*/ | |
|
1046 | ||
|
1047 | PyObject *fcn_capi = Py_None; | |
|
1048 | PyTupleObject *fcn_xa_capi = NULL; | |
|
1049 | PyTupleObject *fcn_args_capi = NULL; | |
|
1050 | int fcn_nofargs_capi = 0; | |
|
1051 | cb_fcn_in_lmdif__user__routines_typedef fcn_cptr; | |
|
1052 | int m = 0; | |
|
1053 | PyObject *m_capi = Py_None; | |
|
1054 | int n = 0; | |
|
1055 | PyObject *n_capi = Py_None; | |
|
1056 | float *x = NULL; | |
|
1057 | npy_intp x_Dims[1] = {-1}; | |
|
1058 | const int x_Rank = 1; | |
|
1059 | PyArrayObject *capi_x_tmp = NULL; | |
|
1060 | int capi_x_intent = 0; | |
|
1061 | PyObject *x_capi = Py_None; | |
|
1062 | float *fvec = NULL; | |
|
1063 | npy_intp fvec_Dims[1] = {-1}; | |
|
1064 | const int fvec_Rank = 1; | |
|
1065 | PyArrayObject *capi_fvec_tmp = NULL; | |
|
1066 | int capi_fvec_intent = 0; | |
|
1067 | PyObject *fvec_capi = Py_None; | |
|
1068 | float tol = 0; | |
|
1069 | PyObject *tol_capi = Py_None; | |
|
1070 | int info = 0; | |
|
1071 | PyObject *info_capi = Py_None; | |
|
1072 | int *iwa = NULL; | |
|
1073 | npy_intp iwa_Dims[1] = {-1}; | |
|
1074 | const int iwa_Rank = 1; | |
|
1075 | PyArrayObject *capi_iwa_tmp = NULL; | |
|
1076 | int capi_iwa_intent = 0; | |
|
1077 | PyObject *iwa_capi = Py_None; | |
|
1078 | float *wa = NULL; | |
|
1079 | npy_intp wa_Dims[1] = {-1}; | |
|
1080 | const int wa_Rank = 1; | |
|
1081 | PyArrayObject *capi_wa_tmp = NULL; | |
|
1082 | int capi_wa_intent = 0; | |
|
1083 | PyObject *wa_capi = Py_None; | |
|
1084 | int lwa = 0; | |
|
1085 | PyObject *lwa_capi = Py_None; | |
|
1086 | static char *capi_kwlist[] = {"fcn","x","fvec","tol","info","iwa","wa","m","n","lwa","fcn_extra_args",NULL}; | |
|
1087 | ||
|
1088 | /*routdebugenter*/ | |
|
1089 | #ifdef F2PY_REPORT_ATEXIT | |
|
1090 | f2py_start_clock(); | |
|
1091 | #endif | |
|
1092 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
1093 | "OOOOOOO|OOOO!:fitacf_fit_short.lmdif1",\ | |
|
1094 | capi_kwlist,&fcn_capi,&x_capi,&fvec_capi,&tol_capi,&info_capi,&iwa_capi,&wa_capi,&m_capi,&n_capi,&lwa_capi,&PyTuple_Type,&fcn_xa_capi)) | |
|
1095 | return NULL; | |
|
1096 | /*frompyobj*/ | |
|
1097 | /* Processing variable fcn */ | |
|
1098 | if(F2PyCapsule_Check(fcn_capi)) { | |
|
1099 | fcn_cptr = F2PyCapsule_AsVoidPtr(fcn_capi); | |
|
1100 | } else { | |
|
1101 | fcn_cptr = cb_fcn_in_lmdif__user__routines; | |
|
1102 | } | |
|
1103 | ||
|
1104 | fcn_nofargs_capi = cb_fcn_in_lmdif__user__routines_nofargs; | |
|
1105 | if (create_cb_arglist(fcn_capi,fcn_xa_capi,5,2,&cb_fcn_in_lmdif__user__routines_nofargs,&fcn_args_capi,"failed in processing argument list for call-back fcn.")) { | |
|
1106 | jmp_buf fcn_jmpbuf; | |
|
1107 | CFUNCSMESS("Saving jmpbuf for `fcn`.\n"); | |
|
1108 | SWAP(fcn_capi,cb_fcn_in_lmdif__user__routines_capi,PyObject); | |
|
1109 | SWAP(fcn_args_capi,cb_fcn_in_lmdif__user__routines_args_capi,PyTupleObject); | |
|
1110 | memcpy(&fcn_jmpbuf,&cb_fcn_in_lmdif__user__routines_jmpbuf,sizeof(jmp_buf)); | |
|
1111 | /* Processing variable x */ | |
|
1112 | ; | |
|
1113 | capi_x_intent |= F2PY_INTENT_IN; | |
|
1114 | capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi); | |
|
1115 | if (capi_x_tmp == NULL) { | |
|
1116 | PyObject *exc, *val, *tb; | |
|
1117 | PyErr_Fetch(&exc, &val, &tb); | |
|
1118 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 2nd argument `x' of fitacf_fit_short.lmdif1 to C/Fortran array" ); | |
|
1119 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1120 | } else { | |
|
1121 | x = (float *)(PyArray_DATA(capi_x_tmp)); | |
|
1122 | ||
|
1123 | /* Processing variable fvec */ | |
|
1124 | ; | |
|
1125 | capi_fvec_intent |= F2PY_INTENT_IN; | |
|
1126 | capi_fvec_tmp = array_from_pyobj(NPY_FLOAT,fvec_Dims,fvec_Rank,capi_fvec_intent,fvec_capi); | |
|
1127 | if (capi_fvec_tmp == NULL) { | |
|
1128 | PyObject *exc, *val, *tb; | |
|
1129 | PyErr_Fetch(&exc, &val, &tb); | |
|
1130 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 3rd argument `fvec' of fitacf_fit_short.lmdif1 to C/Fortran array" ); | |
|
1131 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1132 | } else { | |
|
1133 | fvec = (float *)(PyArray_DATA(capi_fvec_tmp)); | |
|
1134 | ||
|
1135 | /* Processing variable tol */ | |
|
1136 | f2py_success = float_from_pyobj(&tol,tol_capi,"fitacf_fit_short.lmdif1() 4th argument (tol) can't be converted to float"); | |
|
1137 | if (f2py_success) { | |
|
1138 | /* Processing variable info */ | |
|
1139 | f2py_success = int_from_pyobj(&info,info_capi,"fitacf_fit_short.lmdif1() 5th argument (info) can't be converted to int"); | |
|
1140 | if (f2py_success) { | |
|
1141 | /* Processing variable wa */ | |
|
1142 | ; | |
|
1143 | capi_wa_intent |= F2PY_INTENT_IN; | |
|
1144 | capi_wa_tmp = array_from_pyobj(NPY_FLOAT,wa_Dims,wa_Rank,capi_wa_intent,wa_capi); | |
|
1145 | if (capi_wa_tmp == NULL) { | |
|
1146 | PyObject *exc, *val, *tb; | |
|
1147 | PyErr_Fetch(&exc, &val, &tb); | |
|
1148 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 7th argument `wa' of fitacf_fit_short.lmdif1 to C/Fortran array" ); | |
|
1149 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1150 | } else { | |
|
1151 | wa = (float *)(PyArray_DATA(capi_wa_tmp)); | |
|
1152 | ||
|
1153 | /* Processing variable m */ | |
|
1154 | if (m_capi == Py_None) m = len(fvec); else | |
|
1155 | f2py_success = int_from_pyobj(&m,m_capi,"fitacf_fit_short.lmdif1() 1st keyword (m) can't be converted to int"); | |
|
1156 | if (f2py_success) { | |
|
1157 | CHECKSCALAR(len(fvec)>=m,"len(fvec)>=m","1st keyword m","lmdif1:m=%d",m) { | |
|
1158 | /* Processing variable n */ | |
|
1159 | if (n_capi == Py_None) n = len(x); else | |
|
1160 | f2py_success = int_from_pyobj(&n,n_capi,"fitacf_fit_short.lmdif1() 2nd keyword (n) can't be converted to int"); | |
|
1161 | if (f2py_success) { | |
|
1162 | CHECKSCALAR(len(x)>=n,"len(x)>=n","2nd keyword n","lmdif1:n=%d",n) { | |
|
1163 | /* Processing variable iwa */ | |
|
1164 | iwa_Dims[0]=n; | |
|
1165 | capi_iwa_intent |= F2PY_INTENT_IN; | |
|
1166 | capi_iwa_tmp = array_from_pyobj(NPY_INT,iwa_Dims,iwa_Rank,capi_iwa_intent,iwa_capi); | |
|
1167 | if (capi_iwa_tmp == NULL) { | |
|
1168 | PyObject *exc, *val, *tb; | |
|
1169 | PyErr_Fetch(&exc, &val, &tb); | |
|
1170 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 6th argument `iwa' of fitacf_fit_short.lmdif1 to C/Fortran array" ); | |
|
1171 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1172 | } else { | |
|
1173 | iwa = (int *)(PyArray_DATA(capi_iwa_tmp)); | |
|
1174 | ||
|
1175 | /* Processing variable lwa */ | |
|
1176 | if (lwa_capi == Py_None) lwa = len(wa); else | |
|
1177 | f2py_success = int_from_pyobj(&lwa,lwa_capi,"fitacf_fit_short.lmdif1() 3rd keyword (lwa) can't be converted to int"); | |
|
1178 | if (f2py_success) { | |
|
1179 | CHECKSCALAR(len(wa)>=lwa,"len(wa)>=lwa","3rd keyword lwa","lmdif1:lwa=%d",lwa) { | |
|
1180 | /*end of frompyobj*/ | |
|
1181 | #ifdef F2PY_REPORT_ATEXIT | |
|
1182 | f2py_start_call_clock(); | |
|
1183 | #endif | |
|
1184 | /*callfortranroutine*/ | |
|
1185 | if ((setjmp(cb_fcn_in_lmdif__user__routines_jmpbuf))) { | |
|
1186 | f2py_success = 0; | |
|
1187 | } else { | |
|
1188 | (*f2py_func)(fcn_cptr,&m,&n,x,fvec,&tol,&info,iwa,wa,&lwa); | |
|
1189 | } | |
|
1190 | if (PyErr_Occurred()) | |
|
1191 | f2py_success = 0; | |
|
1192 | #ifdef F2PY_REPORT_ATEXIT | |
|
1193 | f2py_stop_call_clock(); | |
|
1194 | #endif | |
|
1195 | /*end of callfortranroutine*/ | |
|
1196 | if (f2py_success) { | |
|
1197 | /*pyobjfrom*/ | |
|
1198 | /*end of pyobjfrom*/ | |
|
1199 | CFUNCSMESS("Building return value.\n"); | |
|
1200 | capi_buildvalue = Py_BuildValue(""); | |
|
1201 | /*closepyobjfrom*/ | |
|
1202 | /*end of closepyobjfrom*/ | |
|
1203 | } /*if (f2py_success) after callfortranroutine*/ | |
|
1204 | /*cleanupfrompyobj*/ | |
|
1205 | } /*CHECKSCALAR(len(wa)>=lwa)*/ | |
|
1206 | } /*if (f2py_success) of lwa*/ | |
|
1207 | /* End of cleaning variable lwa */ | |
|
1208 | if((PyObject *)capi_iwa_tmp!=iwa_capi) { | |
|
1209 | Py_XDECREF(capi_iwa_tmp); } | |
|
1210 | } /*if (capi_iwa_tmp == NULL) ... else of iwa*/ | |
|
1211 | /* End of cleaning variable iwa */ | |
|
1212 | } /*CHECKSCALAR(len(x)>=n)*/ | |
|
1213 | } /*if (f2py_success) of n*/ | |
|
1214 | /* End of cleaning variable n */ | |
|
1215 | } /*CHECKSCALAR(len(fvec)>=m)*/ | |
|
1216 | } /*if (f2py_success) of m*/ | |
|
1217 | /* End of cleaning variable m */ | |
|
1218 | if((PyObject *)capi_wa_tmp!=wa_capi) { | |
|
1219 | Py_XDECREF(capi_wa_tmp); } | |
|
1220 | } /*if (capi_wa_tmp == NULL) ... else of wa*/ | |
|
1221 | /* End of cleaning variable wa */ | |
|
1222 | } /*if (f2py_success) of info*/ | |
|
1223 | /* End of cleaning variable info */ | |
|
1224 | } /*if (f2py_success) of tol*/ | |
|
1225 | /* End of cleaning variable tol */ | |
|
1226 | if((PyObject *)capi_fvec_tmp!=fvec_capi) { | |
|
1227 | Py_XDECREF(capi_fvec_tmp); } | |
|
1228 | } /*if (capi_fvec_tmp == NULL) ... else of fvec*/ | |
|
1229 | /* End of cleaning variable fvec */ | |
|
1230 | if((PyObject *)capi_x_tmp!=x_capi) { | |
|
1231 | Py_XDECREF(capi_x_tmp); } | |
|
1232 | } /*if (capi_x_tmp == NULL) ... else of x*/ | |
|
1233 | /* End of cleaning variable x */ | |
|
1234 | CFUNCSMESS("Restoring jmpbuf for `fcn`.\n"); | |
|
1235 | cb_fcn_in_lmdif__user__routines_capi = fcn_capi; | |
|
1236 | Py_DECREF(cb_fcn_in_lmdif__user__routines_args_capi); | |
|
1237 | cb_fcn_in_lmdif__user__routines_args_capi = fcn_args_capi; | |
|
1238 | cb_fcn_in_lmdif__user__routines_nofargs = fcn_nofargs_capi; | |
|
1239 | memcpy(&cb_fcn_in_lmdif__user__routines_jmpbuf,&fcn_jmpbuf,sizeof(jmp_buf)); | |
|
1240 | } | |
|
1241 | /* End of cleaning variable fcn */ | |
|
1242 | /*end of cleanupfrompyobj*/ | |
|
1243 | if (capi_buildvalue == NULL) { | |
|
1244 | /*routdebugfailure*/ | |
|
1245 | } else { | |
|
1246 | /*routdebugleave*/ | |
|
1247 | } | |
|
1248 | CFUNCSMESS("Freeing memory.\n"); | |
|
1249 | /*freemem*/ | |
|
1250 | #ifdef F2PY_REPORT_ATEXIT | |
|
1251 | f2py_stop_clock(); | |
|
1252 | #endif | |
|
1253 | return capi_buildvalue; | |
|
1254 | } | |
|
1255 | /******************************* end of lmdif1 *******************************/ | |
|
1256 | ||
|
1257 | /*********************************** lmdif ***********************************/ | |
|
1258 | static char doc_f2py_rout_fitacf_fit_short_lmdif[] = "\ | |
|
1259 | lmdif(fcn,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,diag,mode,factor,nprint,info,nfev,fjac,ipvt,qtf,wa1,wa2,wa3,wa4,[m,n,ldfjac,fcn_extra_args])\n\nWrapper for ``lmdif``.\ | |
|
1260 | \n\nParameters\n----------\n" | |
|
1261 | "fcn : call-back function\n" | |
|
1262 | "x : input rank-1 array('f') with bounds (n)\n" | |
|
1263 | "fvec : input rank-1 array('f') with bounds (m)\n" | |
|
1264 | "ftol : input float\n" | |
|
1265 | "xtol : input float\n" | |
|
1266 | "gtol : input float\n" | |
|
1267 | "maxfev : input int\n" | |
|
1268 | "epsfcn : input float\n" | |
|
1269 | "diag : input rank-1 array('f') with bounds (n)\n" | |
|
1270 | "mode : input int\n" | |
|
1271 | "factor : input float\n" | |
|
1272 | "nprint : input int\n" | |
|
1273 | "info : input int\n" | |
|
1274 | "nfev : input int\n" | |
|
1275 | "fjac : input rank-2 array('f') with bounds (ldfjac,n)\n" | |
|
1276 | "ipvt : input rank-1 array('i') with bounds (n)\n" | |
|
1277 | "qtf : input rank-1 array('f') with bounds (n)\n" | |
|
1278 | "wa1 : input rank-1 array('f') with bounds (n)\n" | |
|
1279 | "wa2 : input rank-1 array('f') with bounds (n)\n" | |
|
1280 | "wa3 : input rank-1 array('f') with bounds (n)\n" | |
|
1281 | "wa4 : input rank-1 array('f') with bounds (m)\n" | |
|
1282 | "\nOther Parameters\n----------------\n" | |
|
1283 | "fcn_extra_args : input tuple, optional\n Default: ()\n" | |
|
1284 | "m : input int, optional\n Default: len(fvec)\n" | |
|
1285 | "n : input int, optional\n Default: len(x)\n" | |
|
1286 | "ldfjac : input int, optional\n Default: shape(fjac,0)\n" | |
|
1287 | "\nNotes\n-----\nCall-back functions::\n\n" | |
|
1288 | " def fcn(x,fvec,iflag,[m,n]): return \n\ | |
|
1289 | Required arguments:\n" | |
|
1290 | " x : input rank-1 array('f') with bounds (n)\n" | |
|
1291 | " fvec : input rank-1 array('f') with bounds (m)\n" | |
|
1292 | " iflag : input int\n" | |
|
1293 | " Optional arguments:\n" | |
|
1294 | " m : input int, optional\n Default: len(fvec)\n" | |
|
1295 | " n : input int, optional\n Default: len(x)"; | |
|
1296 | /* extern void F_FUNC(lmdif,LMDIF)(cb_fcn_in_lmdif__user__routines_typedef,int*,int*,float*,float*,float*,float*,float*,int*,float*,float*,int*,float*,int*,int*,int*,float*,int*,int*,float*,float*,float*,float*,float*); */ | |
|
1297 | static PyObject *f2py_rout_fitacf_fit_short_lmdif(const PyObject *capi_self, | |
|
1298 | PyObject *capi_args, | |
|
1299 | PyObject *capi_keywds, | |
|
1300 | void (*f2py_func)(cb_fcn_in_lmdif__user__routines_typedef,int*,int*,float*,float*,float*,float*,float*,int*,float*,float*,int*,float*,int*,int*,int*,float*,int*,int*,float*,float*,float*,float*,float*)) { | |
|
1301 | PyObject * volatile capi_buildvalue = NULL; | |
|
1302 | volatile int f2py_success = 1; | |
|
1303 | /*decl*/ | |
|
1304 | ||
|
1305 | PyObject *fcn_capi = Py_None; | |
|
1306 | PyTupleObject *fcn_xa_capi = NULL; | |
|
1307 | PyTupleObject *fcn_args_capi = NULL; | |
|
1308 | int fcn_nofargs_capi = 0; | |
|
1309 | cb_fcn_in_lmdif__user__routines_typedef fcn_cptr; | |
|
1310 | int m = 0; | |
|
1311 | PyObject *m_capi = Py_None; | |
|
1312 | int n = 0; | |
|
1313 | PyObject *n_capi = Py_None; | |
|
1314 | float *x = NULL; | |
|
1315 | npy_intp x_Dims[1] = {-1}; | |
|
1316 | const int x_Rank = 1; | |
|
1317 | PyArrayObject *capi_x_tmp = NULL; | |
|
1318 | int capi_x_intent = 0; | |
|
1319 | PyObject *x_capi = Py_None; | |
|
1320 | float *fvec = NULL; | |
|
1321 | npy_intp fvec_Dims[1] = {-1}; | |
|
1322 | const int fvec_Rank = 1; | |
|
1323 | PyArrayObject *capi_fvec_tmp = NULL; | |
|
1324 | int capi_fvec_intent = 0; | |
|
1325 | PyObject *fvec_capi = Py_None; | |
|
1326 | float ftol = 0; | |
|
1327 | PyObject *ftol_capi = Py_None; | |
|
1328 | float xtol = 0; | |
|
1329 | PyObject *xtol_capi = Py_None; | |
|
1330 | float gtol = 0; | |
|
1331 | PyObject *gtol_capi = Py_None; | |
|
1332 | int maxfev = 0; | |
|
1333 | PyObject *maxfev_capi = Py_None; | |
|
1334 | float epsfcn = 0; | |
|
1335 | PyObject *epsfcn_capi = Py_None; | |
|
1336 | float *diag = NULL; | |
|
1337 | npy_intp diag_Dims[1] = {-1}; | |
|
1338 | const int diag_Rank = 1; | |
|
1339 | PyArrayObject *capi_diag_tmp = NULL; | |
|
1340 | int capi_diag_intent = 0; | |
|
1341 | PyObject *diag_capi = Py_None; | |
|
1342 | int mode = 0; | |
|
1343 | PyObject *mode_capi = Py_None; | |
|
1344 | float factor = 0; | |
|
1345 | PyObject *factor_capi = Py_None; | |
|
1346 | int nprint = 0; | |
|
1347 | PyObject *nprint_capi = Py_None; | |
|
1348 | int info = 0; | |
|
1349 | PyObject *info_capi = Py_None; | |
|
1350 | int nfev = 0; | |
|
1351 | PyObject *nfev_capi = Py_None; | |
|
1352 | float *fjac = NULL; | |
|
1353 | npy_intp fjac_Dims[2] = {-1, -1}; | |
|
1354 | const int fjac_Rank = 2; | |
|
1355 | PyArrayObject *capi_fjac_tmp = NULL; | |
|
1356 | int capi_fjac_intent = 0; | |
|
1357 | PyObject *fjac_capi = Py_None; | |
|
1358 | int ldfjac = 0; | |
|
1359 | PyObject *ldfjac_capi = Py_None; | |
|
1360 | int *ipvt = NULL; | |
|
1361 | npy_intp ipvt_Dims[1] = {-1}; | |
|
1362 | const int ipvt_Rank = 1; | |
|
1363 | PyArrayObject *capi_ipvt_tmp = NULL; | |
|
1364 | int capi_ipvt_intent = 0; | |
|
1365 | PyObject *ipvt_capi = Py_None; | |
|
1366 | float *qtf = NULL; | |
|
1367 | npy_intp qtf_Dims[1] = {-1}; | |
|
1368 | const int qtf_Rank = 1; | |
|
1369 | PyArrayObject *capi_qtf_tmp = NULL; | |
|
1370 | int capi_qtf_intent = 0; | |
|
1371 | PyObject *qtf_capi = Py_None; | |
|
1372 | float *wa1 = NULL; | |
|
1373 | npy_intp wa1_Dims[1] = {-1}; | |
|
1374 | const int wa1_Rank = 1; | |
|
1375 | PyArrayObject *capi_wa1_tmp = NULL; | |
|
1376 | int capi_wa1_intent = 0; | |
|
1377 | PyObject *wa1_capi = Py_None; | |
|
1378 | float *wa2 = NULL; | |
|
1379 | npy_intp wa2_Dims[1] = {-1}; | |
|
1380 | const int wa2_Rank = 1; | |
|
1381 | PyArrayObject *capi_wa2_tmp = NULL; | |
|
1382 | int capi_wa2_intent = 0; | |
|
1383 | PyObject *wa2_capi = Py_None; | |
|
1384 | float *wa3 = NULL; | |
|
1385 | npy_intp wa3_Dims[1] = {-1}; | |
|
1386 | const int wa3_Rank = 1; | |
|
1387 | PyArrayObject *capi_wa3_tmp = NULL; | |
|
1388 | int capi_wa3_intent = 0; | |
|
1389 | PyObject *wa3_capi = Py_None; | |
|
1390 | float *wa4 = NULL; | |
|
1391 | npy_intp wa4_Dims[1] = {-1}; | |
|
1392 | const int wa4_Rank = 1; | |
|
1393 | PyArrayObject *capi_wa4_tmp = NULL; | |
|
1394 | int capi_wa4_intent = 0; | |
|
1395 | PyObject *wa4_capi = Py_None; | |
|
1396 | static char *capi_kwlist[] = {"fcn","x","fvec","ftol","xtol","gtol","maxfev","epsfcn","diag","mode","factor","nprint","info","nfev","fjac","ipvt","qtf","wa1","wa2","wa3","wa4","m","n","ldfjac","fcn_extra_args",NULL}; | |
|
1397 | ||
|
1398 | /*routdebugenter*/ | |
|
1399 | #ifdef F2PY_REPORT_ATEXIT | |
|
1400 | f2py_start_clock(); | |
|
1401 | #endif | |
|
1402 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
1403 | "OOOOOOOOOOOOOOOOOOOOO|OOOO!:fitacf_fit_short.lmdif",\ | |
|
1404 | capi_kwlist,&fcn_capi,&x_capi,&fvec_capi,&ftol_capi,&xtol_capi,>ol_capi,&maxfev_capi,&epsfcn_capi,&diag_capi,&mode_capi,&factor_capi,&nprint_capi,&info_capi,&nfev_capi,&fjac_capi,&ipvt_capi,&qtf_capi,&wa1_capi,&wa2_capi,&wa3_capi,&wa4_capi,&m_capi,&n_capi,&ldfjac_capi,&PyTuple_Type,&fcn_xa_capi)) | |
|
1405 | return NULL; | |
|
1406 | /*frompyobj*/ | |
|
1407 | /* Processing variable fcn */ | |
|
1408 | if(F2PyCapsule_Check(fcn_capi)) { | |
|
1409 | fcn_cptr = F2PyCapsule_AsVoidPtr(fcn_capi); | |
|
1410 | } else { | |
|
1411 | fcn_cptr = cb_fcn_in_lmdif__user__routines; | |
|
1412 | } | |
|
1413 | ||
|
1414 | fcn_nofargs_capi = cb_fcn_in_lmdif__user__routines_nofargs; | |
|
1415 | if (create_cb_arglist(fcn_capi,fcn_xa_capi,5,2,&cb_fcn_in_lmdif__user__routines_nofargs,&fcn_args_capi,"failed in processing argument list for call-back fcn.")) { | |
|
1416 | jmp_buf fcn_jmpbuf; | |
|
1417 | CFUNCSMESS("Saving jmpbuf for `fcn`.\n"); | |
|
1418 | SWAP(fcn_capi,cb_fcn_in_lmdif__user__routines_capi,PyObject); | |
|
1419 | SWAP(fcn_args_capi,cb_fcn_in_lmdif__user__routines_args_capi,PyTupleObject); | |
|
1420 | memcpy(&fcn_jmpbuf,&cb_fcn_in_lmdif__user__routines_jmpbuf,sizeof(jmp_buf)); | |
|
1421 | /* Processing variable x */ | |
|
1422 | ; | |
|
1423 | capi_x_intent |= F2PY_INTENT_IN; | |
|
1424 | capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi); | |
|
1425 | if (capi_x_tmp == NULL) { | |
|
1426 | PyObject *exc, *val, *tb; | |
|
1427 | PyErr_Fetch(&exc, &val, &tb); | |
|
1428 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 2nd argument `x' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1429 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1430 | } else { | |
|
1431 | x = (float *)(PyArray_DATA(capi_x_tmp)); | |
|
1432 | ||
|
1433 | /* Processing variable fvec */ | |
|
1434 | ; | |
|
1435 | capi_fvec_intent |= F2PY_INTENT_IN; | |
|
1436 | capi_fvec_tmp = array_from_pyobj(NPY_FLOAT,fvec_Dims,fvec_Rank,capi_fvec_intent,fvec_capi); | |
|
1437 | if (capi_fvec_tmp == NULL) { | |
|
1438 | PyObject *exc, *val, *tb; | |
|
1439 | PyErr_Fetch(&exc, &val, &tb); | |
|
1440 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 3rd argument `fvec' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1441 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1442 | } else { | |
|
1443 | fvec = (float *)(PyArray_DATA(capi_fvec_tmp)); | |
|
1444 | ||
|
1445 | /* Processing variable ftol */ | |
|
1446 | f2py_success = float_from_pyobj(&ftol,ftol_capi,"fitacf_fit_short.lmdif() 4th argument (ftol) can't be converted to float"); | |
|
1447 | if (f2py_success) { | |
|
1448 | /* Processing variable xtol */ | |
|
1449 | f2py_success = float_from_pyobj(&xtol,xtol_capi,"fitacf_fit_short.lmdif() 5th argument (xtol) can't be converted to float"); | |
|
1450 | if (f2py_success) { | |
|
1451 | /* Processing variable gtol */ | |
|
1452 | f2py_success = float_from_pyobj(>ol,gtol_capi,"fitacf_fit_short.lmdif() 6th argument (gtol) can't be converted to float"); | |
|
1453 | if (f2py_success) { | |
|
1454 | /* Processing variable maxfev */ | |
|
1455 | f2py_success = int_from_pyobj(&maxfev,maxfev_capi,"fitacf_fit_short.lmdif() 7th argument (maxfev) can't be converted to int"); | |
|
1456 | if (f2py_success) { | |
|
1457 | /* Processing variable epsfcn */ | |
|
1458 | f2py_success = float_from_pyobj(&epsfcn,epsfcn_capi,"fitacf_fit_short.lmdif() 8th argument (epsfcn) can't be converted to float"); | |
|
1459 | if (f2py_success) { | |
|
1460 | /* Processing variable mode */ | |
|
1461 | f2py_success = int_from_pyobj(&mode,mode_capi,"fitacf_fit_short.lmdif() 10th argument (mode) can't be converted to int"); | |
|
1462 | if (f2py_success) { | |
|
1463 | /* Processing variable factor */ | |
|
1464 | f2py_success = float_from_pyobj(&factor,factor_capi,"fitacf_fit_short.lmdif() 11st argument (factor) can't be converted to float"); | |
|
1465 | if (f2py_success) { | |
|
1466 | /* Processing variable nprint */ | |
|
1467 | f2py_success = int_from_pyobj(&nprint,nprint_capi,"fitacf_fit_short.lmdif() 12nd argument (nprint) can't be converted to int"); | |
|
1468 | if (f2py_success) { | |
|
1469 | /* Processing variable info */ | |
|
1470 | f2py_success = int_from_pyobj(&info,info_capi,"fitacf_fit_short.lmdif() 13rd argument (info) can't be converted to int"); | |
|
1471 | if (f2py_success) { | |
|
1472 | /* Processing variable nfev */ | |
|
1473 | f2py_success = int_from_pyobj(&nfev,nfev_capi,"fitacf_fit_short.lmdif() 14th argument (nfev) can't be converted to int"); | |
|
1474 | if (f2py_success) { | |
|
1475 | /* Processing variable m */ | |
|
1476 | if (m_capi == Py_None) m = len(fvec); else | |
|
1477 | f2py_success = int_from_pyobj(&m,m_capi,"fitacf_fit_short.lmdif() 1st keyword (m) can't be converted to int"); | |
|
1478 | if (f2py_success) { | |
|
1479 | CHECKSCALAR(len(fvec)>=m,"len(fvec)>=m","1st keyword m","lmdif:m=%d",m) { | |
|
1480 | /* Processing variable n */ | |
|
1481 | if (n_capi == Py_None) n = len(x); else | |
|
1482 | f2py_success = int_from_pyobj(&n,n_capi,"fitacf_fit_short.lmdif() 2nd keyword (n) can't be converted to int"); | |
|
1483 | if (f2py_success) { | |
|
1484 | CHECKSCALAR(len(x)>=n,"len(x)>=n","2nd keyword n","lmdif:n=%d",n) { | |
|
1485 | /* Processing variable diag */ | |
|
1486 | diag_Dims[0]=n; | |
|
1487 | capi_diag_intent |= F2PY_INTENT_IN; | |
|
1488 | capi_diag_tmp = array_from_pyobj(NPY_FLOAT,diag_Dims,diag_Rank,capi_diag_intent,diag_capi); | |
|
1489 | if (capi_diag_tmp == NULL) { | |
|
1490 | PyObject *exc, *val, *tb; | |
|
1491 | PyErr_Fetch(&exc, &val, &tb); | |
|
1492 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 9th argument `diag' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1493 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1494 | } else { | |
|
1495 | diag = (float *)(PyArray_DATA(capi_diag_tmp)); | |
|
1496 | ||
|
1497 | /* Processing variable fjac */ | |
|
1498 | fjac_Dims[1]=n; | |
|
1499 | capi_fjac_intent |= F2PY_INTENT_IN; | |
|
1500 | capi_fjac_tmp = array_from_pyobj(NPY_FLOAT,fjac_Dims,fjac_Rank,capi_fjac_intent,fjac_capi); | |
|
1501 | if (capi_fjac_tmp == NULL) { | |
|
1502 | PyObject *exc, *val, *tb; | |
|
1503 | PyErr_Fetch(&exc, &val, &tb); | |
|
1504 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 15th argument `fjac' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1505 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1506 | } else { | |
|
1507 | fjac = (float *)(PyArray_DATA(capi_fjac_tmp)); | |
|
1508 | ||
|
1509 | /* Processing variable ldfjac */ | |
|
1510 | if (ldfjac_capi == Py_None) ldfjac = shape(fjac,0); else | |
|
1511 | f2py_success = int_from_pyobj(&ldfjac,ldfjac_capi,"fitacf_fit_short.lmdif() 3rd keyword (ldfjac) can't be converted to int"); | |
|
1512 | if (f2py_success) { | |
|
1513 | CHECKSCALAR(shape(fjac,0)==ldfjac,"shape(fjac,0)==ldfjac","3rd keyword ldfjac","lmdif:ldfjac=%d",ldfjac) { | |
|
1514 | /* Processing variable ipvt */ | |
|
1515 | ipvt_Dims[0]=n; | |
|
1516 | capi_ipvt_intent |= F2PY_INTENT_IN; | |
|
1517 | capi_ipvt_tmp = array_from_pyobj(NPY_INT,ipvt_Dims,ipvt_Rank,capi_ipvt_intent,ipvt_capi); | |
|
1518 | if (capi_ipvt_tmp == NULL) { | |
|
1519 | PyObject *exc, *val, *tb; | |
|
1520 | PyErr_Fetch(&exc, &val, &tb); | |
|
1521 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 16th argument `ipvt' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1522 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1523 | } else { | |
|
1524 | ipvt = (int *)(PyArray_DATA(capi_ipvt_tmp)); | |
|
1525 | ||
|
1526 | /* Processing variable qtf */ | |
|
1527 | qtf_Dims[0]=n; | |
|
1528 | capi_qtf_intent |= F2PY_INTENT_IN; | |
|
1529 | capi_qtf_tmp = array_from_pyobj(NPY_FLOAT,qtf_Dims,qtf_Rank,capi_qtf_intent,qtf_capi); | |
|
1530 | if (capi_qtf_tmp == NULL) { | |
|
1531 | PyObject *exc, *val, *tb; | |
|
1532 | PyErr_Fetch(&exc, &val, &tb); | |
|
1533 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 17th argument `qtf' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1534 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1535 | } else { | |
|
1536 | qtf = (float *)(PyArray_DATA(capi_qtf_tmp)); | |
|
1537 | ||
|
1538 | /* Processing variable wa1 */ | |
|
1539 | wa1_Dims[0]=n; | |
|
1540 | capi_wa1_intent |= F2PY_INTENT_IN; | |
|
1541 | capi_wa1_tmp = array_from_pyobj(NPY_FLOAT,wa1_Dims,wa1_Rank,capi_wa1_intent,wa1_capi); | |
|
1542 | if (capi_wa1_tmp == NULL) { | |
|
1543 | PyObject *exc, *val, *tb; | |
|
1544 | PyErr_Fetch(&exc, &val, &tb); | |
|
1545 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 18th argument `wa1' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1546 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1547 | } else { | |
|
1548 | wa1 = (float *)(PyArray_DATA(capi_wa1_tmp)); | |
|
1549 | ||
|
1550 | /* Processing variable wa2 */ | |
|
1551 | wa2_Dims[0]=n; | |
|
1552 | capi_wa2_intent |= F2PY_INTENT_IN; | |
|
1553 | capi_wa2_tmp = array_from_pyobj(NPY_FLOAT,wa2_Dims,wa2_Rank,capi_wa2_intent,wa2_capi); | |
|
1554 | if (capi_wa2_tmp == NULL) { | |
|
1555 | PyObject *exc, *val, *tb; | |
|
1556 | PyErr_Fetch(&exc, &val, &tb); | |
|
1557 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 19th argument `wa2' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1558 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1559 | } else { | |
|
1560 | wa2 = (float *)(PyArray_DATA(capi_wa2_tmp)); | |
|
1561 | ||
|
1562 | /* Processing variable wa3 */ | |
|
1563 | wa3_Dims[0]=n; | |
|
1564 | capi_wa3_intent |= F2PY_INTENT_IN; | |
|
1565 | capi_wa3_tmp = array_from_pyobj(NPY_FLOAT,wa3_Dims,wa3_Rank,capi_wa3_intent,wa3_capi); | |
|
1566 | if (capi_wa3_tmp == NULL) { | |
|
1567 | PyObject *exc, *val, *tb; | |
|
1568 | PyErr_Fetch(&exc, &val, &tb); | |
|
1569 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 20th argument `wa3' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1570 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1571 | } else { | |
|
1572 | wa3 = (float *)(PyArray_DATA(capi_wa3_tmp)); | |
|
1573 | ||
|
1574 | /* Processing variable wa4 */ | |
|
1575 | wa4_Dims[0]=m; | |
|
1576 | capi_wa4_intent |= F2PY_INTENT_IN; | |
|
1577 | capi_wa4_tmp = array_from_pyobj(NPY_FLOAT,wa4_Dims,wa4_Rank,capi_wa4_intent,wa4_capi); | |
|
1578 | if (capi_wa4_tmp == NULL) { | |
|
1579 | PyObject *exc, *val, *tb; | |
|
1580 | PyErr_Fetch(&exc, &val, &tb); | |
|
1581 | PyErr_SetString(exc ? exc : fitacf_fit_short_error,"failed in converting 21st argument `wa4' of fitacf_fit_short.lmdif to C/Fortran array" ); | |
|
1582 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
1583 | } else { | |
|
1584 | wa4 = (float *)(PyArray_DATA(capi_wa4_tmp)); | |
|
1585 | ||
|
1586 | /*end of frompyobj*/ | |
|
1587 | #ifdef F2PY_REPORT_ATEXIT | |
|
1588 | f2py_start_call_clock(); | |
|
1589 | #endif | |
|
1590 | /*callfortranroutine*/ | |
|
1591 | if ((setjmp(cb_fcn_in_lmdif__user__routines_jmpbuf))) { | |
|
1592 | f2py_success = 0; | |
|
1593 | } else { | |
|
1594 | (*f2py_func)(fcn_cptr,&m,&n,x,fvec,&ftol,&xtol,>ol,&maxfev,&epsfcn,diag,&mode,&factor,&nprint,&info,&nfev,fjac,&ldfjac,ipvt,qtf,wa1,wa2,wa3,wa4); | |
|
1595 | } | |
|
1596 | if (PyErr_Occurred()) | |
|
1597 | f2py_success = 0; | |
|
1598 | #ifdef F2PY_REPORT_ATEXIT | |
|
1599 | f2py_stop_call_clock(); | |
|
1600 | #endif | |
|
1601 | /*end of callfortranroutine*/ | |
|
1602 | if (f2py_success) { | |
|
1603 | /*pyobjfrom*/ | |
|
1604 | /*end of pyobjfrom*/ | |
|
1605 | CFUNCSMESS("Building return value.\n"); | |
|
1606 | capi_buildvalue = Py_BuildValue(""); | |
|
1607 | /*closepyobjfrom*/ | |
|
1608 | /*end of closepyobjfrom*/ | |
|
1609 | } /*if (f2py_success) after callfortranroutine*/ | |
|
1610 | /*cleanupfrompyobj*/ | |
|
1611 | if((PyObject *)capi_wa4_tmp!=wa4_capi) { | |
|
1612 | Py_XDECREF(capi_wa4_tmp); } | |
|
1613 | } /*if (capi_wa4_tmp == NULL) ... else of wa4*/ | |
|
1614 | /* End of cleaning variable wa4 */ | |
|
1615 | if((PyObject *)capi_wa3_tmp!=wa3_capi) { | |
|
1616 | Py_XDECREF(capi_wa3_tmp); } | |
|
1617 | } /*if (capi_wa3_tmp == NULL) ... else of wa3*/ | |
|
1618 | /* End of cleaning variable wa3 */ | |
|
1619 | if((PyObject *)capi_wa2_tmp!=wa2_capi) { | |
|
1620 | Py_XDECREF(capi_wa2_tmp); } | |
|
1621 | } /*if (capi_wa2_tmp == NULL) ... else of wa2*/ | |
|
1622 | /* End of cleaning variable wa2 */ | |
|
1623 | if((PyObject *)capi_wa1_tmp!=wa1_capi) { | |
|
1624 | Py_XDECREF(capi_wa1_tmp); } | |
|
1625 | } /*if (capi_wa1_tmp == NULL) ... else of wa1*/ | |
|
1626 | /* End of cleaning variable wa1 */ | |
|
1627 | if((PyObject *)capi_qtf_tmp!=qtf_capi) { | |
|
1628 | Py_XDECREF(capi_qtf_tmp); } | |
|
1629 | } /*if (capi_qtf_tmp == NULL) ... else of qtf*/ | |
|
1630 | /* End of cleaning variable qtf */ | |
|
1631 | if((PyObject *)capi_ipvt_tmp!=ipvt_capi) { | |
|
1632 | Py_XDECREF(capi_ipvt_tmp); } | |
|
1633 | } /*if (capi_ipvt_tmp == NULL) ... else of ipvt*/ | |
|
1634 | /* End of cleaning variable ipvt */ | |
|
1635 | } /*CHECKSCALAR(shape(fjac,0)==ldfjac)*/ | |
|
1636 | } /*if (f2py_success) of ldfjac*/ | |
|
1637 | /* End of cleaning variable ldfjac */ | |
|
1638 | if((PyObject *)capi_fjac_tmp!=fjac_capi) { | |
|
1639 | Py_XDECREF(capi_fjac_tmp); } | |
|
1640 | } /*if (capi_fjac_tmp == NULL) ... else of fjac*/ | |
|
1641 | /* End of cleaning variable fjac */ | |
|
1642 | if((PyObject *)capi_diag_tmp!=diag_capi) { | |
|
1643 | Py_XDECREF(capi_diag_tmp); } | |
|
1644 | } /*if (capi_diag_tmp == NULL) ... else of diag*/ | |
|
1645 | /* End of cleaning variable diag */ | |
|
1646 | } /*CHECKSCALAR(len(x)>=n)*/ | |
|
1647 | } /*if (f2py_success) of n*/ | |
|
1648 | /* End of cleaning variable n */ | |
|
1649 | } /*CHECKSCALAR(len(fvec)>=m)*/ | |
|
1650 | } /*if (f2py_success) of m*/ | |
|
1651 | /* End of cleaning variable m */ | |
|
1652 | } /*if (f2py_success) of nfev*/ | |
|
1653 | /* End of cleaning variable nfev */ | |
|
1654 | } /*if (f2py_success) of info*/ | |
|
1655 | /* End of cleaning variable info */ | |
|
1656 | } /*if (f2py_success) of nprint*/ | |
|
1657 | /* End of cleaning variable nprint */ | |
|
1658 | } /*if (f2py_success) of factor*/ | |
|
1659 | /* End of cleaning variable factor */ | |
|
1660 | } /*if (f2py_success) of mode*/ | |
|
1661 | /* End of cleaning variable mode */ | |
|
1662 | } /*if (f2py_success) of epsfcn*/ | |
|
1663 | /* End of cleaning variable epsfcn */ | |
|
1664 | } /*if (f2py_success) of maxfev*/ | |
|
1665 | /* End of cleaning variable maxfev */ | |
|
1666 | } /*if (f2py_success) of gtol*/ | |
|
1667 | /* End of cleaning variable gtol */ | |
|
1668 | } /*if (f2py_success) of xtol*/ | |
|
1669 | /* End of cleaning variable xtol */ | |
|
1670 | } /*if (f2py_success) of ftol*/ | |
|
1671 | /* End of cleaning variable ftol */ | |
|
1672 | if((PyObject *)capi_fvec_tmp!=fvec_capi) { | |
|
1673 | Py_XDECREF(capi_fvec_tmp); } | |
|
1674 | } /*if (capi_fvec_tmp == NULL) ... else of fvec*/ | |
|
1675 | /* End of cleaning variable fvec */ | |
|
1676 | if((PyObject *)capi_x_tmp!=x_capi) { | |
|
1677 | Py_XDECREF(capi_x_tmp); } | |
|
1678 | } /*if (capi_x_tmp == NULL) ... else of x*/ | |
|
1679 | /* End of cleaning variable x */ | |
|
1680 | CFUNCSMESS("Restoring jmpbuf for `fcn`.\n"); | |
|
1681 | cb_fcn_in_lmdif__user__routines_capi = fcn_capi; | |
|
1682 | Py_DECREF(cb_fcn_in_lmdif__user__routines_args_capi); | |
|
1683 | cb_fcn_in_lmdif__user__routines_args_capi = fcn_args_capi; | |
|
1684 | cb_fcn_in_lmdif__user__routines_nofargs = fcn_nofargs_capi; | |
|
1685 | memcpy(&cb_fcn_in_lmdif__user__routines_jmpbuf,&fcn_jmpbuf,sizeof(jmp_buf)); | |
|
1686 | } | |
|
1687 | /* End of cleaning variable fcn */ | |
|
1688 | /*end of cleanupfrompyobj*/ | |
|
1689 | if (capi_buildvalue == NULL) { | |
|
1690 | /*routdebugfailure*/ | |
|
1691 | } else { | |
|
1692 | /*routdebugleave*/ | |
|
1693 | } | |
|
1694 | CFUNCSMESS("Freeing memory.\n"); | |
|
1695 | /*freemem*/ | |
|
1696 | #ifdef F2PY_REPORT_ATEXIT | |
|
1697 | f2py_stop_clock(); | |
|
1698 | #endif | |
|
1699 | return capi_buildvalue; | |
|
1700 | } | |
|
1701 | /******************************** end of lmdif ********************************/ | |
|
1702 | ||
|
1703 | /*********************************** spmpar ***********************************/ | |
|
1704 | static char doc_f2py_rout_fitacf_fit_short_spmpar[] = "\ | |
|
1705 | spmpar = spmpar(i)\n\nWrapper for ``spmpar``.\ | |
|
1706 | \n\nParameters\n----------\n" | |
|
1707 | "i : input int\n" | |
|
1708 | "\nReturns\n-------\n" | |
|
1709 | "spmpar : float"; | |
|
1710 | /* extern void F_WRAPPEDFUNC(spmpar,SPMPAR)(float*,int*); */ | |
|
1711 | static PyObject *f2py_rout_fitacf_fit_short_spmpar(const PyObject *capi_self, | |
|
1712 | PyObject *capi_args, | |
|
1713 | PyObject *capi_keywds, | |
|
1714 | void (*f2py_func)(float*,int*)) { | |
|
1715 | PyObject * volatile capi_buildvalue = NULL; | |
|
1716 | volatile int f2py_success = 1; | |
|
1717 | /*decl*/ | |
|
1718 | ||
|
1719 | float spmpar = 0; | |
|
1720 | int i = 0; | |
|
1721 | PyObject *i_capi = Py_None; | |
|
1722 | static char *capi_kwlist[] = {"i",NULL}; | |
|
1723 | ||
|
1724 | /*routdebugenter*/ | |
|
1725 | #ifdef F2PY_REPORT_ATEXIT | |
|
1726 | f2py_start_clock(); | |
|
1727 | #endif | |
|
1728 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
1729 | "O|:fitacf_fit_short.spmpar",\ | |
|
1730 | capi_kwlist,&i_capi)) | |
|
1731 | return NULL; | |
|
1732 | /*frompyobj*/ | |
|
1733 | /* Processing variable i */ | |
|
1734 | f2py_success = int_from_pyobj(&i,i_capi,"fitacf_fit_short.spmpar() 1st argument (i) can't be converted to int"); | |
|
1735 | if (f2py_success) { | |
|
1736 | /* Processing variable spmpar */ | |
|
1737 | /*end of frompyobj*/ | |
|
1738 | #ifdef F2PY_REPORT_ATEXIT | |
|
1739 | f2py_start_call_clock(); | |
|
1740 | #endif | |
|
1741 | /*callfortranroutine*/ | |
|
1742 | (*f2py_func)(&spmpar,&i); | |
|
1743 | if (PyErr_Occurred()) | |
|
1744 | f2py_success = 0; | |
|
1745 | #ifdef F2PY_REPORT_ATEXIT | |
|
1746 | f2py_stop_call_clock(); | |
|
1747 | #endif | |
|
1748 | /*end of callfortranroutine*/ | |
|
1749 | if (f2py_success) { | |
|
1750 | /*pyobjfrom*/ | |
|
1751 | /*end of pyobjfrom*/ | |
|
1752 | CFUNCSMESS("Building return value.\n"); | |
|
1753 | capi_buildvalue = Py_BuildValue("f",spmpar); | |
|
1754 | /*closepyobjfrom*/ | |
|
1755 | /*end of closepyobjfrom*/ | |
|
1756 | } /*if (f2py_success) after callfortranroutine*/ | |
|
1757 | /*cleanupfrompyobj*/ | |
|
1758 | /* End of cleaning variable spmpar */ | |
|
1759 | } /*if (f2py_success) of i*/ | |
|
1760 | /* End of cleaning variable i */ | |
|
1761 | /*end of cleanupfrompyobj*/ | |
|
1762 | if (capi_buildvalue == NULL) { | |
|
1763 | /*routdebugfailure*/ | |
|
1764 | } else { | |
|
1765 | /*routdebugleave*/ | |
|
1766 | } | |
|
1767 | CFUNCSMESS("Freeing memory.\n"); | |
|
1768 | /*freemem*/ | |
|
1769 | #ifdef F2PY_REPORT_ATEXIT | |
|
1770 | f2py_stop_clock(); | |
|
1771 | #endif | |
|
1772 | return capi_buildvalue; | |
|
1773 | } | |
|
1774 | /******************************* end of spmpar *******************************/ | |
|
1775 | /*eof body*/ | |
|
1776 | ||
|
1777 | /******************* See f2py2e/f90mod_rules.py: buildhooks *******************/ | |
|
1778 | /*need_f90modhooks*/ | |
|
1779 | ||
|
1780 | /************** See f2py2e/rules.py: module_rules['modulebody'] **************/ | |
|
1781 | ||
|
1782 | /******************* See f2py2e/common_rules.py: buildhooks *******************/ | |
|
1783 | ||
|
1784 | static FortranDataDef f2py_spec_def[] = { | |
|
1785 | {"te",0,{{-1}},NPY_FLOAT}, | |
|
1786 | {"ti",1,{{10}},NPY_FLOAT}, | |
|
1787 | {"fi",1,{{10}},NPY_FLOAT}, | |
|
1788 | {"ven",0,{{-1}},NPY_FLOAT}, | |
|
1789 | {"vin",1,{{10}},NPY_FLOAT}, | |
|
1790 | {"alpha",0,{{-1}},NPY_FLOAT}, | |
|
1791 | {"dens",0,{{-1}},NPY_FLOAT}, | |
|
1792 | {"bfld",0,{{-1}},NPY_FLOAT}, | |
|
1793 | {"nion",0,{{-1}},NPY_INT}, | |
|
1794 | {"wi",1,{{10}},NPY_INT}, | |
|
1795 | {"ak",0,{{-1}},NPY_FLOAT}, | |
|
1796 | {NULL} | |
|
1797 | }; | |
|
1798 | static void f2py_setup_spec(char *te,char *ti,char *fi,char *ven,char *vin,char *alpha,char *dens,char *bfld,char *nion,char *wi,char *ak) { | |
|
1799 | int i_f2py=0; | |
|
1800 | f2py_spec_def[i_f2py++].data = te; | |
|
1801 | f2py_spec_def[i_f2py++].data = ti; | |
|
1802 | f2py_spec_def[i_f2py++].data = fi; | |
|
1803 | f2py_spec_def[i_f2py++].data = ven; | |
|
1804 | f2py_spec_def[i_f2py++].data = vin; | |
|
1805 | f2py_spec_def[i_f2py++].data = alpha; | |
|
1806 | f2py_spec_def[i_f2py++].data = dens; | |
|
1807 | f2py_spec_def[i_f2py++].data = bfld; | |
|
1808 | f2py_spec_def[i_f2py++].data = nion; | |
|
1809 | f2py_spec_def[i_f2py++].data = wi; | |
|
1810 | f2py_spec_def[i_f2py++].data = ak; | |
|
1811 | } | |
|
1812 | extern void F_FUNC(f2pyinitspec,F2PYINITSPEC)(void(*)(char*,char*,char*,char*,char*,char*,char*,char*,char*,char*,char*)); | |
|
1813 | static void f2py_init_spec(void) { | |
|
1814 | F_FUNC(f2pyinitspec,F2PYINITSPEC)(f2py_setup_spec); | |
|
1815 | } | |
|
1816 | ||
|
1817 | static FortranDataDef f2py_mode_def[] = { | |
|
1818 | {"imode",0,{{-1}},NPY_INT}, | |
|
1819 | {NULL} | |
|
1820 | }; | |
|
1821 | static void f2py_setup_mode(char *imode) { | |
|
1822 | int i_f2py=0; | |
|
1823 | f2py_mode_def[i_f2py++].data = imode; | |
|
1824 | } | |
|
1825 | extern void F_FUNC(f2pyinitmode,F2PYINITMODE)(void(*)(char*)); | |
|
1826 | static void f2py_init_mode(void) { | |
|
1827 | F_FUNC(f2pyinitmode,F2PYINITMODE)(f2py_setup_mode); | |
|
1828 | } | |
|
1829 | ||
|
1830 | static FortranDataDef f2py_fitter_def[] = { | |
|
1831 | {"tau",1,{{100}},NPY_FLOAT}, | |
|
1832 | {"rho",1,{{100}},NPY_FLOAT}, | |
|
1833 | {"sigma2",1,{{100}},NPY_FLOAT}, | |
|
1834 | {"params",1,{{10}},NPY_FLOAT}, | |
|
1835 | {"ifit",1,{{10}},NPY_INT}, | |
|
1836 | {NULL} | |
|
1837 | }; | |
|
1838 | static void f2py_setup_fitter(char *tau,char *rho,char *sigma2,char *params,char *ifit) { | |
|
1839 | int i_f2py=0; | |
|
1840 | f2py_fitter_def[i_f2py++].data = tau; | |
|
1841 | f2py_fitter_def[i_f2py++].data = rho; | |
|
1842 | f2py_fitter_def[i_f2py++].data = sigma2; | |
|
1843 | f2py_fitter_def[i_f2py++].data = params; | |
|
1844 | f2py_fitter_def[i_f2py++].data = ifit; | |
|
1845 | } | |
|
1846 | extern void F_FUNC(f2pyinitfitter,F2PYINITFITTER)(void(*)(char*,char*,char*,char*,char*)); | |
|
1847 | static void f2py_init_fitter(void) { | |
|
1848 | F_FUNC(f2pyinitfitter,F2PYINITFITTER)(f2py_setup_fitter); | |
|
1849 | } | |
|
1850 | ||
|
1851 | static FortranDataDef f2py_trans_def[] = { | |
|
1852 | {"ev",1,{{10000}},NPY_FLOAT}, | |
|
1853 | {NULL} | |
|
1854 | }; | |
|
1855 | static void f2py_setup_trans(char *ev) { | |
|
1856 | int i_f2py=0; | |
|
1857 | f2py_trans_def[i_f2py++].data = ev; | |
|
1858 | } | |
|
1859 | extern void F_FUNC(f2pyinittrans,F2PYINITTRANS)(void(*)(char*)); | |
|
1860 | static void f2py_init_trans(void) { | |
|
1861 | F_FUNC(f2pyinittrans,F2PYINITTRANS)(f2py_setup_trans); | |
|
1862 | } | |
|
1863 | ||
|
1864 | /*need_commonhooks*/ | |
|
1865 | ||
|
1866 | /**************************** See f2py2e/rules.py ****************************/ | |
|
1867 | ||
|
1868 | static FortranDataDef f2py_routine_defs[] = { | |
|
1869 | {"fit",-1,{{-1}},0,(char *)F_FUNC(fit,FIT),(f2py_init_func)f2py_rout_fitacf_fit_short_fit,doc_f2py_rout_fitacf_fit_short_fit}, | |
|
1870 | {"spect1",-1,{{-1}},0,(char *)F_WRAPPEDFUNC(spect1,SPECT1),(f2py_init_func)f2py_rout_fitacf_fit_short_spect1,doc_f2py_rout_fitacf_fit_short_spect1}, | |
|
1871 | {"gaussq",-1,{{-1}},0,(char *)F_FUNC(gaussq,GAUSSQ),(f2py_init_func)f2py_rout_fitacf_fit_short_gaussq,doc_f2py_rout_fitacf_fit_short_gaussq}, | |
|
1872 | {"lmdif1",-1,{{-1}},0,(char *)F_FUNC(lmdif1,LMDIF1),(f2py_init_func)f2py_rout_fitacf_fit_short_lmdif1,doc_f2py_rout_fitacf_fit_short_lmdif1}, | |
|
1873 | {"lmdif",-1,{{-1}},0,(char *)F_FUNC(lmdif,LMDIF),(f2py_init_func)f2py_rout_fitacf_fit_short_lmdif,doc_f2py_rout_fitacf_fit_short_lmdif}, | |
|
1874 | {"spmpar",-1,{{-1}},0,(char *)F_WRAPPEDFUNC(spmpar,SPMPAR),(f2py_init_func)f2py_rout_fitacf_fit_short_spmpar,doc_f2py_rout_fitacf_fit_short_spmpar}, | |
|
1875 | ||
|
1876 | /*eof routine_defs*/ | |
|
1877 | {NULL} | |
|
1878 | }; | |
|
1879 | ||
|
1880 | static PyMethodDef f2py_module_methods[] = { | |
|
1881 | ||
|
1882 | {NULL,NULL} | |
|
1883 | }; | |
|
1884 | ||
|
1885 | static struct PyModuleDef moduledef = { | |
|
1886 | PyModuleDef_HEAD_INIT, | |
|
1887 | "fitacf_fit_short", | |
|
1888 | NULL, | |
|
1889 | -1, | |
|
1890 | f2py_module_methods, | |
|
1891 | NULL, | |
|
1892 | NULL, | |
|
1893 | NULL, | |
|
1894 | NULL | |
|
1895 | }; | |
|
1896 | ||
|
1897 | PyMODINIT_FUNC PyInit_fitacf_fit_short(void) { | |
|
1898 | int i; | |
|
1899 | PyObject *m,*d, *s, *tmp; | |
|
1900 | m = fitacf_fit_short_module = PyModule_Create(&moduledef); | |
|
1901 | Py_SET_TYPE(&PyFortran_Type, &PyType_Type); | |
|
1902 | import_array(); | |
|
1903 | if (PyErr_Occurred()) | |
|
1904 | {PyErr_SetString(PyExc_ImportError, "can't initialize module fitacf_fit_short (failed to import numpy)"); return m;} | |
|
1905 | d = PyModule_GetDict(m); | |
|
1906 | s = PyString_FromString("$Revision: $"); | |
|
1907 | PyDict_SetItemString(d, "__version__", s); | |
|
1908 | Py_DECREF(s); | |
|
1909 | s = PyUnicode_FromString( | |
|
1910 | "This module 'fitacf_fit_short' is auto-generated with f2py (version:2).\nFunctions:\n" | |
|
1911 | " cinv,sigma2p,paramp,ebp,ist = fit(wl,taup,rhop,covar,cinv,sigma2p,paramp,bfldp,alphap,densp,alt,time,ifitp,ist,nl=len(taup))\n" | |
|
1912 | " spect1 = spect1(omega)\n" | |
|
1913 | " gaussq(tau,acf)\n" | |
|
1914 | " lmdif1(fcn,x,fvec,tol,info,iwa,wa,m=len(fvec),n=len(x),lwa=len(wa),fcn_extra_args=())\n" | |
|
1915 | " lmdif(fcn,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,diag,mode,factor,nprint,info,nfev,fjac,ipvt,qtf,wa1,wa2,wa3,wa4,m=len(fvec),n=len(x),ldfjac=shape(fjac,0),fcn_extra_args=())\n" | |
|
1916 | " spmpar = spmpar(i)\n" | |
|
1917 | "COMMON blocks:\n"" /spec/ te,ti(10),fi(10),ven,vin(10),alpha,dens,bfld,nion,wi(10),ak\n"" /mode/ imode\n"" /fitter/ tau(100),rho(100),sigma2(100),params(10),ifit(10)\n"" /trans/ ev(10000)\n""."); | |
|
1918 | PyDict_SetItemString(d, "__doc__", s); | |
|
1919 | Py_DECREF(s); | |
|
1920 | fitacf_fit_short_error = PyErr_NewException ("fitacf_fit_short.error", NULL, NULL); | |
|
1921 | /* | |
|
1922 | * Store the error object inside the dict, so that it could get deallocated. | |
|
1923 | * (in practice, this is a module, so it likely will not and cannot.) | |
|
1924 | */ | |
|
1925 | PyDict_SetItemString(d, "_fitacf_fit_short_error", fitacf_fit_short_error); | |
|
1926 | Py_DECREF(fitacf_fit_short_error); | |
|
1927 | for(i=0;f2py_routine_defs[i].name!=NULL;i++) { | |
|
1928 | tmp = PyFortranObject_NewAsAttr(&f2py_routine_defs[i]); | |
|
1929 | PyDict_SetItemString(d, f2py_routine_defs[i].name, tmp); | |
|
1930 | Py_DECREF(tmp); | |
|
1931 | } | |
|
1932 | ||
|
1933 | ||
|
1934 | { | |
|
1935 | extern float F_FUNC(spect1,SPECT1)(void); | |
|
1936 | PyObject* o = PyDict_GetItemString(d,"spect1"); | |
|
1937 | tmp = F2PyCapsule_FromVoidPtr((void*)F_FUNC(spect1,SPECT1),NULL); | |
|
1938 | PyObject_SetAttrString(o,"_cpointer", tmp); | |
|
1939 | Py_DECREF(tmp); | |
|
1940 | s = PyUnicode_FromString("spect1"); | |
|
1941 | PyObject_SetAttrString(o,"__name__", s); | |
|
1942 | Py_DECREF(s); | |
|
1943 | } | |
|
1944 | ||
|
1945 | ||
|
1946 | ||
|
1947 | ||
|
1948 | ||
|
1949 | { | |
|
1950 | extern float F_FUNC(spmpar,SPMPAR)(void); | |
|
1951 | PyObject* o = PyDict_GetItemString(d,"spmpar"); | |
|
1952 | tmp = F2PyCapsule_FromVoidPtr((void*)F_FUNC(spmpar,SPMPAR),NULL); | |
|
1953 | PyObject_SetAttrString(o,"_cpointer", tmp); | |
|
1954 | Py_DECREF(tmp); | |
|
1955 | s = PyUnicode_FromString("spmpar"); | |
|
1956 | PyObject_SetAttrString(o,"__name__", s); | |
|
1957 | Py_DECREF(s); | |
|
1958 | } | |
|
1959 | ||
|
1960 | /*eof initf2pywraphooks*/ | |
|
1961 | /*eof initf90modhooks*/ | |
|
1962 | ||
|
1963 | tmp = PyFortranObject_New(f2py_spec_def,f2py_init_spec); | |
|
1964 | F2PyDict_SetItemString(d, "spec", tmp); | |
|
1965 | Py_DECREF(tmp); | |
|
1966 | tmp = PyFortranObject_New(f2py_mode_def,f2py_init_mode); | |
|
1967 | F2PyDict_SetItemString(d, "mode", tmp); | |
|
1968 | Py_DECREF(tmp); | |
|
1969 | tmp = PyFortranObject_New(f2py_fitter_def,f2py_init_fitter); | |
|
1970 | F2PyDict_SetItemString(d, "fitter", tmp); | |
|
1971 | Py_DECREF(tmp); | |
|
1972 | tmp = PyFortranObject_New(f2py_trans_def,f2py_init_trans); | |
|
1973 | F2PyDict_SetItemString(d, "trans", tmp); | |
|
1974 | Py_DECREF(tmp); | |
|
1975 | /*eof initcommonhooks*/ | |
|
1976 | ||
|
1977 | ||
|
1978 | #ifdef F2PY_REPORT_ATEXIT | |
|
1979 | if (! PyErr_Occurred()) | |
|
1980 | on_exit(f2py_report_on_exit,(void*)"fitacf_fit_short"); | |
|
1981 | #endif | |
|
1982 | return m; | |
|
1983 | } | |
|
1984 | #ifdef __cplusplus | |
|
1985 | } | |
|
1986 | #endif |
@@ -0,0 +1,20 | |||
|
1 | C -*- fortran -*- | |
|
2 | C This file is autogenerated with f2py (version:2) | |
|
3 | C It contains Fortran 77 wrappers to fortran functions. | |
|
4 | ||
|
5 | subroutine f2pywrapcdtr1 (cdtr1f2pywrap, depth) | |
|
6 | external cdtr1 | |
|
7 | real depth | |
|
8 | real cdtr1f2pywrap, cdtr1 | |
|
9 | cdtr1f2pywrap = cdtr1(depth) | |
|
10 | end | |
|
11 | ||
|
12 | ||
|
13 | subroutine f2pywrapczte1 (czte1f2pywrap, zlag, tr) | |
|
14 | external czte1 | |
|
15 | real zlag | |
|
16 | real tr | |
|
17 | real czte1f2pywrap, czte1 | |
|
18 | czte1f2pywrap = czte1(zlag, tr) | |
|
19 | end | |
|
20 |
This diff has been collapsed as it changes many lines, (871 lines changed) Show them Hide them | |||
@@ -0,0 +1,871 | |||
|
1 | /* File: fitacf_guessmodule.c | |
|
2 | * This file is auto-generated with f2py (version:2). | |
|
3 | * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition, | |
|
4 | * written by Pearu Peterson <pearu@cens.ioc.ee>. | |
|
5 | * Generation date: Wed Jan 8 13:23:37 2025 | |
|
6 | * Do not edit this file directly unless you know what you are doing!!! | |
|
7 | */ | |
|
8 | ||
|
9 | #ifdef __cplusplus | |
|
10 | extern "C" { | |
|
11 | #endif | |
|
12 | ||
|
13 | /*********************** See f2py2e/cfuncs.py: includes ***********************/ | |
|
14 | #include "Python.h" | |
|
15 | #include <stdarg.h> | |
|
16 | #include "fortranobject.h" | |
|
17 | #include <math.h> | |
|
18 | ||
|
19 | /**************** See f2py2e/rules.py: mod_rules['modulebody'] ****************/ | |
|
20 | static PyObject *fitacf_guess_error; | |
|
21 | static PyObject *fitacf_guess_module; | |
|
22 | ||
|
23 | /*********************** See f2py2e/cfuncs.py: typedefs ***********************/ | |
|
24 | /*need_typedefs*/ | |
|
25 | ||
|
26 | /****************** See f2py2e/cfuncs.py: typedefs_generated ******************/ | |
|
27 | /*need_typedefs_generated*/ | |
|
28 | ||
|
29 | /********************** See f2py2e/cfuncs.py: cppmacros **********************/ | |
|
30 | #define PRINTPYOBJERR(obj)\ | |
|
31 | fprintf(stderr,"fitacf_guess.error is related to ");\ | |
|
32 | PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\ | |
|
33 | fprintf(stderr,"\n"); | |
|
34 | ||
|
35 | #define pyobj_from_float1(v) (PyFloat_FromDouble(v)) | |
|
36 | #if defined(PREPEND_FORTRAN) | |
|
37 | #if defined(NO_APPEND_FORTRAN) | |
|
38 | #if defined(UPPERCASE_FORTRAN) | |
|
39 | #define F_FUNC(f,F) _##F | |
|
40 | #else | |
|
41 | #define F_FUNC(f,F) _##f | |
|
42 | #endif | |
|
43 | #else | |
|
44 | #if defined(UPPERCASE_FORTRAN) | |
|
45 | #define F_FUNC(f,F) _##F##_ | |
|
46 | #else | |
|
47 | #define F_FUNC(f,F) _##f##_ | |
|
48 | #endif | |
|
49 | #endif | |
|
50 | #else | |
|
51 | #if defined(NO_APPEND_FORTRAN) | |
|
52 | #if defined(UPPERCASE_FORTRAN) | |
|
53 | #define F_FUNC(f,F) F | |
|
54 | #else | |
|
55 | #define F_FUNC(f,F) f | |
|
56 | #endif | |
|
57 | #else | |
|
58 | #if defined(UPPERCASE_FORTRAN) | |
|
59 | #define F_FUNC(f,F) F##_ | |
|
60 | #else | |
|
61 | #define F_FUNC(f,F) f##_ | |
|
62 | #endif | |
|
63 | #endif | |
|
64 | #endif | |
|
65 | #if defined(UNDERSCORE_G77) | |
|
66 | #define F_FUNC_US(f,F) F_FUNC(f##_,F##_) | |
|
67 | #else | |
|
68 | #define F_FUNC_US(f,F) F_FUNC(f,F) | |
|
69 | #endif | |
|
70 | ||
|
71 | #define rank(var) var ## _Rank | |
|
72 | #define shape(var,dim) var ## _Dims[dim] | |
|
73 | #define old_rank(var) (PyArray_NDIM((PyArrayObject *)(capi_ ## var ## _tmp))) | |
|
74 | #define old_shape(var,dim) PyArray_DIM(((PyArrayObject *)(capi_ ## var ## _tmp)),dim) | |
|
75 | #define fshape(var,dim) shape(var,rank(var)-dim-1) | |
|
76 | #define len(var) shape(var,0) | |
|
77 | #define flen(var) fshape(var,0) | |
|
78 | #define old_size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp)) | |
|
79 | /* #define index(i) capi_i ## i */ | |
|
80 | #define slen(var) capi_ ## var ## _len | |
|
81 | #define size(var, ...) f2py_size((PyArrayObject *)(capi_ ## var ## _tmp), ## __VA_ARGS__, -1) | |
|
82 | ||
|
83 | #define CHECKSCALAR(check,tcheck,name,show,var)\ | |
|
84 | if (!(check)) {\ | |
|
85 | char errstring[256];\ | |
|
86 | sprintf(errstring, "%s: "show, "("tcheck") failed for "name, var);\ | |
|
87 | PyErr_SetString(fitacf_guess_error,errstring);\ | |
|
88 | /*goto capi_fail;*/\ | |
|
89 | } else | |
|
90 | #ifdef DEBUGCFUNCS | |
|
91 | #define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess); | |
|
92 | #define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \ | |
|
93 | PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\ | |
|
94 | fprintf(stderr,"\n"); | |
|
95 | #else | |
|
96 | #define CFUNCSMESS(mess) | |
|
97 | #define CFUNCSMESSPY(mess,obj) | |
|
98 | #endif | |
|
99 | ||
|
100 | #ifndef max | |
|
101 | #define max(a,b) ((a > b) ? (a) : (b)) | |
|
102 | #endif | |
|
103 | #ifndef min | |
|
104 | #define min(a,b) ((a < b) ? (a) : (b)) | |
|
105 | #endif | |
|
106 | #ifndef MAX | |
|
107 | #define MAX(a,b) ((a > b) ? (a) : (b)) | |
|
108 | #endif | |
|
109 | #ifndef MIN | |
|
110 | #define MIN(a,b) ((a < b) ? (a) : (b)) | |
|
111 | #endif | |
|
112 | ||
|
113 | #if defined(PREPEND_FORTRAN) | |
|
114 | #if defined(NO_APPEND_FORTRAN) | |
|
115 | #if defined(UPPERCASE_FORTRAN) | |
|
116 | #define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F | |
|
117 | #else | |
|
118 | #define F_WRAPPEDFUNC(f,F) _f2pywrap##f | |
|
119 | #endif | |
|
120 | #else | |
|
121 | #if defined(UPPERCASE_FORTRAN) | |
|
122 | #define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_ | |
|
123 | #else | |
|
124 | #define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_ | |
|
125 | #endif | |
|
126 | #endif | |
|
127 | #else | |
|
128 | #if defined(NO_APPEND_FORTRAN) | |
|
129 | #if defined(UPPERCASE_FORTRAN) | |
|
130 | #define F_WRAPPEDFUNC(f,F) F2PYWRAP##F | |
|
131 | #else | |
|
132 | #define F_WRAPPEDFUNC(f,F) f2pywrap##f | |
|
133 | #endif | |
|
134 | #else | |
|
135 | #if defined(UPPERCASE_FORTRAN) | |
|
136 | #define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_ | |
|
137 | #else | |
|
138 | #define F_WRAPPEDFUNC(f,F) f2pywrap##f##_ | |
|
139 | #endif | |
|
140 | #endif | |
|
141 | #endif | |
|
142 | #if defined(UNDERSCORE_G77) | |
|
143 | #define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_) | |
|
144 | #else | |
|
145 | #define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F) | |
|
146 | #endif | |
|
147 | ||
|
148 | /* New SciPy */ | |
|
149 | #define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(PyArray_DATA(arr))=*v; break; | |
|
150 | #define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break; | |
|
151 | #define TRYPYARRAYTEMPLATEOBJECT case NPY_OBJECT: PyArray_SETITEM(arr,PyArray_DATA(arr),pyobj_from_ ## ctype ## 1(*v)); break; | |
|
152 | ||
|
153 | #define TRYPYARRAYTEMPLATE(ctype,typecode) \ | |
|
154 | PyArrayObject *arr = NULL;\ | |
|
155 | if (!obj) return -2;\ | |
|
156 | if (!PyArray_Check(obj)) return -1;\ | |
|
157 | if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,"TRYPYARRAYTEMPLATE:");PRINTPYOBJERR(obj);return 0;}\ | |
|
158 | if (PyArray_DESCR(arr)->type==typecode) {*(ctype *)(PyArray_DATA(arr))=*v; return 1;}\ | |
|
159 | switch (PyArray_TYPE(arr)) {\ | |
|
160 | case NPY_DOUBLE: *(double *)(PyArray_DATA(arr))=*v; break;\ | |
|
161 | case NPY_INT: *(int *)(PyArray_DATA(arr))=*v; break;\ | |
|
162 | case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;\ | |
|
163 | case NPY_FLOAT: *(float *)(PyArray_DATA(arr))=*v; break;\ | |
|
164 | case NPY_CDOUBLE: *(double *)(PyArray_DATA(arr))=*v; break;\ | |
|
165 | case NPY_CFLOAT: *(float *)(PyArray_DATA(arr))=*v; break;\ | |
|
166 | case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=(*v!=0); break;\ | |
|
167 | case NPY_UBYTE: *(unsigned char *)(PyArray_DATA(arr))=*v; break;\ | |
|
168 | case NPY_BYTE: *(signed char *)(PyArray_DATA(arr))=*v; break;\ | |
|
169 | case NPY_SHORT: *(short *)(PyArray_DATA(arr))=*v; break;\ | |
|
170 | case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=*v; break;\ | |
|
171 | case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=*v; break;\ | |
|
172 | case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=*v; break;\ | |
|
173 | case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=*v; break;\ | |
|
174 | case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=*v; break;\ | |
|
175 | case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\ | |
|
176 | case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\ | |
|
177 | case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_ ## ctype ## 1(*v)); break;\ | |
|
178 | default: return -2;\ | |
|
179 | };\ | |
|
180 | return 1 | |
|
181 | ||
|
182 | ||
|
183 | /************************ See f2py2e/cfuncs.py: cfuncs ************************/ | |
|
184 | static int double_from_pyobj(double* v,PyObject *obj,const char *errmess) { | |
|
185 | PyObject* tmp = NULL; | |
|
186 | if (PyFloat_Check(obj)) { | |
|
187 | #ifdef __sgi | |
|
188 | *v = PyFloat_AsDouble(obj); | |
|
189 | #else | |
|
190 | *v = PyFloat_AS_DOUBLE(obj); | |
|
191 | #endif | |
|
192 | return 1; | |
|
193 | } | |
|
194 | tmp = PyNumber_Float(obj); | |
|
195 | if (tmp) { | |
|
196 | #ifdef __sgi | |
|
197 | *v = PyFloat_AsDouble(tmp); | |
|
198 | #else | |
|
199 | *v = PyFloat_AS_DOUBLE(tmp); | |
|
200 | #endif | |
|
201 | Py_DECREF(tmp); | |
|
202 | return 1; | |
|
203 | } | |
|
204 | if (PyComplex_Check(obj)) | |
|
205 | tmp = PyObject_GetAttrString(obj,"real"); | |
|
206 | else if (PyString_Check(obj) || PyUnicode_Check(obj)) | |
|
207 | /*pass*/; | |
|
208 | else if (PySequence_Check(obj)) | |
|
209 | tmp = PySequence_GetItem(obj,0); | |
|
210 | if (tmp) { | |
|
211 | PyErr_Clear(); | |
|
212 | if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} | |
|
213 | Py_DECREF(tmp); | |
|
214 | } | |
|
215 | { | |
|
216 | PyObject* err = PyErr_Occurred(); | |
|
217 | if (err==NULL) err = fitacf_guess_error; | |
|
218 | PyErr_SetString(err,errmess); | |
|
219 | } | |
|
220 | return 0; | |
|
221 | } | |
|
222 | ||
|
223 | static int f2py_size(PyArrayObject* var, ...) | |
|
224 | { | |
|
225 | npy_int sz = 0; | |
|
226 | npy_int dim; | |
|
227 | npy_int rank; | |
|
228 | va_list argp; | |
|
229 | va_start(argp, var); | |
|
230 | dim = va_arg(argp, npy_int); | |
|
231 | if (dim==-1) | |
|
232 | { | |
|
233 | sz = PyArray_SIZE(var); | |
|
234 | } | |
|
235 | else | |
|
236 | { | |
|
237 | rank = PyArray_NDIM(var); | |
|
238 | if (dim>=1 && dim<=rank) | |
|
239 | sz = PyArray_DIM(var, dim-1); | |
|
240 | else | |
|
241 | fprintf(stderr, "f2py_size: 2nd argument value=%d fails to satisfy 1<=value<=%d. Result will be 0.\n", dim, rank); | |
|
242 | } | |
|
243 | va_end(argp); | |
|
244 | return sz; | |
|
245 | } | |
|
246 | ||
|
247 | static int try_pyarr_from_float(PyObject* obj,float* v) { | |
|
248 | TRYPYARRAYTEMPLATE(float,'f'); | |
|
249 | } | |
|
250 | ||
|
251 | static int float_from_pyobj(float* v,PyObject *obj,const char *errmess) { | |
|
252 | double d=0.0; | |
|
253 | if (double_from_pyobj(&d,obj,errmess)) { | |
|
254 | *v = (float)d; | |
|
255 | return 1; | |
|
256 | } | |
|
257 | return 0; | |
|
258 | } | |
|
259 | ||
|
260 | static int int_from_pyobj(int* v,PyObject *obj,const char *errmess) { | |
|
261 | PyObject* tmp = NULL; | |
|
262 | if (PyInt_Check(obj)) { | |
|
263 | *v = (int)PyInt_AS_LONG(obj); | |
|
264 | return 1; | |
|
265 | } | |
|
266 | tmp = PyNumber_Int(obj); | |
|
267 | if (tmp) { | |
|
268 | *v = PyInt_AS_LONG(tmp); | |
|
269 | Py_DECREF(tmp); | |
|
270 | return 1; | |
|
271 | } | |
|
272 | if (PyComplex_Check(obj)) | |
|
273 | tmp = PyObject_GetAttrString(obj,"real"); | |
|
274 | else if (PyString_Check(obj) || PyUnicode_Check(obj)) | |
|
275 | /*pass*/; | |
|
276 | else if (PySequence_Check(obj)) | |
|
277 | tmp = PySequence_GetItem(obj,0); | |
|
278 | if (tmp) { | |
|
279 | PyErr_Clear(); | |
|
280 | if (int_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;} | |
|
281 | Py_DECREF(tmp); | |
|
282 | } | |
|
283 | { | |
|
284 | PyObject* err = PyErr_Occurred(); | |
|
285 | if (err==NULL) err = fitacf_guess_error; | |
|
286 | PyErr_SetString(err,errmess); | |
|
287 | } | |
|
288 | return 0; | |
|
289 | } | |
|
290 | ||
|
291 | ||
|
292 | /********************* See f2py2e/cfuncs.py: userincludes *********************/ | |
|
293 | /*need_userincludes*/ | |
|
294 | ||
|
295 | /********************* See f2py2e/capi_rules.py: usercode *********************/ | |
|
296 | ||
|
297 | ||
|
298 | /* See f2py2e/rules.py */ | |
|
299 | extern void F_FUNC(guess,GUESS)(float*,float*,int*,float*,float*,float*,float*); | |
|
300 | extern void F_FUNC(parab1,PARAB1)(float*,float*,float*,float*,float*); | |
|
301 | extern void F_WRAPPEDFUNC(cdtr1,CDTR1)(float*,float*); | |
|
302 | extern void F_WRAPPEDFUNC(czte1,CZTE1)(float*,float*,float*); | |
|
303 | /*eof externroutines*/ | |
|
304 | ||
|
305 | /******************** See f2py2e/capi_rules.py: usercode1 ********************/ | |
|
306 | ||
|
307 | ||
|
308 | /******************* See f2py2e/cb_rules.py: buildcallback *******************/ | |
|
309 | /*need_callbacks*/ | |
|
310 | ||
|
311 | /*********************** See f2py2e/rules.py: buildapi ***********************/ | |
|
312 | ||
|
313 | /*********************************** guess ***********************************/ | |
|
314 | static char doc_f2py_rout_fitacf_guess_guess[] = "\ | |
|
315 | guess(acf,tau,zero,amin,te,tr,[npts])\n\nWrapper for ``guess``.\ | |
|
316 | \n\nParameters\n----------\n" | |
|
317 | "acf : input rank-1 array('f') with bounds (npts)\n" | |
|
318 | "tau : input rank-1 array('f') with bounds (npts)\n" | |
|
319 | "zero : in/output rank-0 array(float,'f')\n" | |
|
320 | "amin : in/output rank-0 array(float,'f')\n" | |
|
321 | "te : in/output rank-0 array(float,'f')\n" | |
|
322 | "tr : in/output rank-0 array(float,'f')\n" | |
|
323 | "\nOther Parameters\n----------------\n" | |
|
324 | "npts : input int, optional\n Default: len(acf)"; | |
|
325 | /* extern void F_FUNC(guess,GUESS)(float*,float*,int*,float*,float*,float*,float*); */ | |
|
326 | static PyObject *f2py_rout_fitacf_guess_guess(const PyObject *capi_self, | |
|
327 | PyObject *capi_args, | |
|
328 | PyObject *capi_keywds, | |
|
329 | void (*f2py_func)(float*,float*,int*,float*,float*,float*,float*)) { | |
|
330 | PyObject * volatile capi_buildvalue = NULL; | |
|
331 | volatile int f2py_success = 1; | |
|
332 | /*decl*/ | |
|
333 | ||
|
334 | float *acf = NULL; | |
|
335 | npy_intp acf_Dims[1] = {-1}; | |
|
336 | const int acf_Rank = 1; | |
|
337 | PyArrayObject *capi_acf_tmp = NULL; | |
|
338 | int capi_acf_intent = 0; | |
|
339 | PyObject *acf_capi = Py_None; | |
|
340 | float *tau = NULL; | |
|
341 | npy_intp tau_Dims[1] = {-1}; | |
|
342 | const int tau_Rank = 1; | |
|
343 | PyArrayObject *capi_tau_tmp = NULL; | |
|
344 | int capi_tau_intent = 0; | |
|
345 | PyObject *tau_capi = Py_None; | |
|
346 | int npts = 0; | |
|
347 | PyObject *npts_capi = Py_None; | |
|
348 | float zero = 0; | |
|
349 | PyObject *zero_capi = Py_None; | |
|
350 | float amin = 0; | |
|
351 | PyObject *amin_capi = Py_None; | |
|
352 | float te = 0; | |
|
353 | PyObject *te_capi = Py_None; | |
|
354 | float tr = 0; | |
|
355 | PyObject *tr_capi = Py_None; | |
|
356 | static char *capi_kwlist[] = {"acf","tau","zero","amin","te","tr","npts",NULL}; | |
|
357 | ||
|
358 | /*routdebugenter*/ | |
|
359 | #ifdef F2PY_REPORT_ATEXIT | |
|
360 | f2py_start_clock(); | |
|
361 | #endif | |
|
362 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
363 | "OOOOOO|O:fitacf_guess.guess",\ | |
|
364 | capi_kwlist,&acf_capi,&tau_capi,&zero_capi,&amin_capi,&te_capi,&tr_capi,&npts_capi)) | |
|
365 | return NULL; | |
|
366 | /*frompyobj*/ | |
|
367 | /* Processing variable acf */ | |
|
368 | ; | |
|
369 | capi_acf_intent |= F2PY_INTENT_IN; | |
|
370 | capi_acf_tmp = array_from_pyobj(NPY_FLOAT,acf_Dims,acf_Rank,capi_acf_intent,acf_capi); | |
|
371 | if (capi_acf_tmp == NULL) { | |
|
372 | PyObject *exc, *val, *tb; | |
|
373 | PyErr_Fetch(&exc, &val, &tb); | |
|
374 | PyErr_SetString(exc ? exc : fitacf_guess_error,"failed in converting 1st argument `acf' of fitacf_guess.guess to C/Fortran array" ); | |
|
375 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
376 | } else { | |
|
377 | acf = (float *)(PyArray_DATA(capi_acf_tmp)); | |
|
378 | ||
|
379 | /* Processing variable zero */ | |
|
380 | f2py_success = float_from_pyobj(&zero,zero_capi,"fitacf_guess.guess() 3rd argument (zero) can't be converted to float"); | |
|
381 | if (f2py_success) { | |
|
382 | /* Processing variable amin */ | |
|
383 | f2py_success = float_from_pyobj(&amin,amin_capi,"fitacf_guess.guess() 4th argument (amin) can't be converted to float"); | |
|
384 | if (f2py_success) { | |
|
385 | /* Processing variable te */ | |
|
386 | f2py_success = float_from_pyobj(&te,te_capi,"fitacf_guess.guess() 5th argument (te) can't be converted to float"); | |
|
387 | if (f2py_success) { | |
|
388 | /* Processing variable tr */ | |
|
389 | f2py_success = float_from_pyobj(&tr,tr_capi,"fitacf_guess.guess() 6th argument (tr) can't be converted to float"); | |
|
390 | if (f2py_success) { | |
|
391 | /* Processing variable npts */ | |
|
392 | if (npts_capi == Py_None) npts = len(acf); else | |
|
393 | f2py_success = int_from_pyobj(&npts,npts_capi,"fitacf_guess.guess() 1st keyword (npts) can't be converted to int"); | |
|
394 | if (f2py_success) { | |
|
395 | CHECKSCALAR(len(acf)>=npts,"len(acf)>=npts","1st keyword npts","guess:npts=%d",npts) { | |
|
396 | /* Processing variable tau */ | |
|
397 | tau_Dims[0]=npts; | |
|
398 | capi_tau_intent |= F2PY_INTENT_IN; | |
|
399 | capi_tau_tmp = array_from_pyobj(NPY_FLOAT,tau_Dims,tau_Rank,capi_tau_intent,tau_capi); | |
|
400 | if (capi_tau_tmp == NULL) { | |
|
401 | PyObject *exc, *val, *tb; | |
|
402 | PyErr_Fetch(&exc, &val, &tb); | |
|
403 | PyErr_SetString(exc ? exc : fitacf_guess_error,"failed in converting 2nd argument `tau' of fitacf_guess.guess to C/Fortran array" ); | |
|
404 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
405 | } else { | |
|
406 | tau = (float *)(PyArray_DATA(capi_tau_tmp)); | |
|
407 | ||
|
408 | /*end of frompyobj*/ | |
|
409 | #ifdef F2PY_REPORT_ATEXIT | |
|
410 | f2py_start_call_clock(); | |
|
411 | #endif | |
|
412 | /*callfortranroutine*/ | |
|
413 | (*f2py_func)(acf,tau,&npts,&zero,&amin,&te,&tr); | |
|
414 | if (PyErr_Occurred()) | |
|
415 | f2py_success = 0; | |
|
416 | #ifdef F2PY_REPORT_ATEXIT | |
|
417 | f2py_stop_call_clock(); | |
|
418 | #endif | |
|
419 | /*end of callfortranroutine*/ | |
|
420 | if (f2py_success) { | |
|
421 | /*pyobjfrom*/ | |
|
422 | f2py_success = try_pyarr_from_float(zero_capi,&zero); | |
|
423 | if (f2py_success) { | |
|
424 | f2py_success = try_pyarr_from_float(amin_capi,&amin); | |
|
425 | if (f2py_success) { | |
|
426 | f2py_success = try_pyarr_from_float(te_capi,&te); | |
|
427 | if (f2py_success) { | |
|
428 | f2py_success = try_pyarr_from_float(tr_capi,&tr); | |
|
429 | if (f2py_success) { | |
|
430 | /*end of pyobjfrom*/ | |
|
431 | CFUNCSMESS("Building return value.\n"); | |
|
432 | capi_buildvalue = Py_BuildValue(""); | |
|
433 | /*closepyobjfrom*/ | |
|
434 | } /*if (f2py_success) of tr pyobjfrom*/ | |
|
435 | } /*if (f2py_success) of te pyobjfrom*/ | |
|
436 | } /*if (f2py_success) of amin pyobjfrom*/ | |
|
437 | } /*if (f2py_success) of zero pyobjfrom*/ | |
|
438 | /*end of closepyobjfrom*/ | |
|
439 | } /*if (f2py_success) after callfortranroutine*/ | |
|
440 | /*cleanupfrompyobj*/ | |
|
441 | if((PyObject *)capi_tau_tmp!=tau_capi) { | |
|
442 | Py_XDECREF(capi_tau_tmp); } | |
|
443 | } /*if (capi_tau_tmp == NULL) ... else of tau*/ | |
|
444 | /* End of cleaning variable tau */ | |
|
445 | } /*CHECKSCALAR(len(acf)>=npts)*/ | |
|
446 | } /*if (f2py_success) of npts*/ | |
|
447 | /* End of cleaning variable npts */ | |
|
448 | } /*if (f2py_success) of tr*/ | |
|
449 | /* End of cleaning variable tr */ | |
|
450 | } /*if (f2py_success) of te*/ | |
|
451 | /* End of cleaning variable te */ | |
|
452 | } /*if (f2py_success) of amin*/ | |
|
453 | /* End of cleaning variable amin */ | |
|
454 | } /*if (f2py_success) of zero*/ | |
|
455 | /* End of cleaning variable zero */ | |
|
456 | if((PyObject *)capi_acf_tmp!=acf_capi) { | |
|
457 | Py_XDECREF(capi_acf_tmp); } | |
|
458 | } /*if (capi_acf_tmp == NULL) ... else of acf*/ | |
|
459 | /* End of cleaning variable acf */ | |
|
460 | /*end of cleanupfrompyobj*/ | |
|
461 | if (capi_buildvalue == NULL) { | |
|
462 | /*routdebugfailure*/ | |
|
463 | } else { | |
|
464 | /*routdebugleave*/ | |
|
465 | } | |
|
466 | CFUNCSMESS("Freeing memory.\n"); | |
|
467 | /*freemem*/ | |
|
468 | #ifdef F2PY_REPORT_ATEXIT | |
|
469 | f2py_stop_clock(); | |
|
470 | #endif | |
|
471 | return capi_buildvalue; | |
|
472 | } | |
|
473 | /******************************** end of guess ********************************/ | |
|
474 | ||
|
475 | /*********************************** parab1 ***********************************/ | |
|
476 | static char doc_f2py_rout_fitacf_guess_parab1[] = "\ | |
|
477 | parab1(x,y,a,b,c)\n\nWrapper for ``parab1``.\ | |
|
478 | \n\nParameters\n----------\n" | |
|
479 | "x : input rank-1 array('f') with bounds (3)\n" | |
|
480 | "y : input rank-1 array('f') with bounds (3)\n" | |
|
481 | "a : input float\n" | |
|
482 | "b : input float\n" | |
|
483 | "c : input float"; | |
|
484 | /* extern void F_FUNC(parab1,PARAB1)(float*,float*,float*,float*,float*); */ | |
|
485 | static PyObject *f2py_rout_fitacf_guess_parab1(const PyObject *capi_self, | |
|
486 | PyObject *capi_args, | |
|
487 | PyObject *capi_keywds, | |
|
488 | void (*f2py_func)(float*,float*,float*,float*,float*)) { | |
|
489 | PyObject * volatile capi_buildvalue = NULL; | |
|
490 | volatile int f2py_success = 1; | |
|
491 | /*decl*/ | |
|
492 | ||
|
493 | float *x = NULL; | |
|
494 | npy_intp x_Dims[1] = {-1}; | |
|
495 | const int x_Rank = 1; | |
|
496 | PyArrayObject *capi_x_tmp = NULL; | |
|
497 | int capi_x_intent = 0; | |
|
498 | PyObject *x_capi = Py_None; | |
|
499 | float *y = NULL; | |
|
500 | npy_intp y_Dims[1] = {-1}; | |
|
501 | const int y_Rank = 1; | |
|
502 | PyArrayObject *capi_y_tmp = NULL; | |
|
503 | int capi_y_intent = 0; | |
|
504 | PyObject *y_capi = Py_None; | |
|
505 | float a = 0; | |
|
506 | PyObject *a_capi = Py_None; | |
|
507 | float b = 0; | |
|
508 | PyObject *b_capi = Py_None; | |
|
509 | float c = 0; | |
|
510 | PyObject *c_capi = Py_None; | |
|
511 | static char *capi_kwlist[] = {"x","y","a","b","c",NULL}; | |
|
512 | ||
|
513 | /*routdebugenter*/ | |
|
514 | #ifdef F2PY_REPORT_ATEXIT | |
|
515 | f2py_start_clock(); | |
|
516 | #endif | |
|
517 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
518 | "OOOOO|:fitacf_guess.parab1",\ | |
|
519 | capi_kwlist,&x_capi,&y_capi,&a_capi,&b_capi,&c_capi)) | |
|
520 | return NULL; | |
|
521 | /*frompyobj*/ | |
|
522 | /* Processing variable x */ | |
|
523 | x_Dims[0]=3; | |
|
524 | capi_x_intent |= F2PY_INTENT_IN; | |
|
525 | capi_x_tmp = array_from_pyobj(NPY_FLOAT,x_Dims,x_Rank,capi_x_intent,x_capi); | |
|
526 | if (capi_x_tmp == NULL) { | |
|
527 | PyObject *exc, *val, *tb; | |
|
528 | PyErr_Fetch(&exc, &val, &tb); | |
|
529 | PyErr_SetString(exc ? exc : fitacf_guess_error,"failed in converting 1st argument `x' of fitacf_guess.parab1 to C/Fortran array" ); | |
|
530 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
531 | } else { | |
|
532 | x = (float *)(PyArray_DATA(capi_x_tmp)); | |
|
533 | ||
|
534 | /* Processing variable y */ | |
|
535 | y_Dims[0]=3; | |
|
536 | capi_y_intent |= F2PY_INTENT_IN; | |
|
537 | capi_y_tmp = array_from_pyobj(NPY_FLOAT,y_Dims,y_Rank,capi_y_intent,y_capi); | |
|
538 | if (capi_y_tmp == NULL) { | |
|
539 | PyObject *exc, *val, *tb; | |
|
540 | PyErr_Fetch(&exc, &val, &tb); | |
|
541 | PyErr_SetString(exc ? exc : fitacf_guess_error,"failed in converting 2nd argument `y' of fitacf_guess.parab1 to C/Fortran array" ); | |
|
542 | npy_PyErr_ChainExceptionsCause(exc, val, tb); | |
|
543 | } else { | |
|
544 | y = (float *)(PyArray_DATA(capi_y_tmp)); | |
|
545 | ||
|
546 | /* Processing variable a */ | |
|
547 | f2py_success = float_from_pyobj(&a,a_capi,"fitacf_guess.parab1() 3rd argument (a) can't be converted to float"); | |
|
548 | if (f2py_success) { | |
|
549 | /* Processing variable b */ | |
|
550 | f2py_success = float_from_pyobj(&b,b_capi,"fitacf_guess.parab1() 4th argument (b) can't be converted to float"); | |
|
551 | if (f2py_success) { | |
|
552 | /* Processing variable c */ | |
|
553 | f2py_success = float_from_pyobj(&c,c_capi,"fitacf_guess.parab1() 5th argument (c) can't be converted to float"); | |
|
554 | if (f2py_success) { | |
|
555 | /*end of frompyobj*/ | |
|
556 | #ifdef F2PY_REPORT_ATEXIT | |
|
557 | f2py_start_call_clock(); | |
|
558 | #endif | |
|
559 | /*callfortranroutine*/ | |
|
560 | (*f2py_func)(x,y,&a,&b,&c); | |
|
561 | if (PyErr_Occurred()) | |
|
562 | f2py_success = 0; | |
|
563 | #ifdef F2PY_REPORT_ATEXIT | |
|
564 | f2py_stop_call_clock(); | |
|
565 | #endif | |
|
566 | /*end of callfortranroutine*/ | |
|
567 | if (f2py_success) { | |
|
568 | /*pyobjfrom*/ | |
|
569 | /*end of pyobjfrom*/ | |
|
570 | CFUNCSMESS("Building return value.\n"); | |
|
571 | capi_buildvalue = Py_BuildValue(""); | |
|
572 | /*closepyobjfrom*/ | |
|
573 | /*end of closepyobjfrom*/ | |
|
574 | } /*if (f2py_success) after callfortranroutine*/ | |
|
575 | /*cleanupfrompyobj*/ | |
|
576 | } /*if (f2py_success) of c*/ | |
|
577 | /* End of cleaning variable c */ | |
|
578 | } /*if (f2py_success) of b*/ | |
|
579 | /* End of cleaning variable b */ | |
|
580 | } /*if (f2py_success) of a*/ | |
|
581 | /* End of cleaning variable a */ | |
|
582 | if((PyObject *)capi_y_tmp!=y_capi) { | |
|
583 | Py_XDECREF(capi_y_tmp); } | |
|
584 | } /*if (capi_y_tmp == NULL) ... else of y*/ | |
|
585 | /* End of cleaning variable y */ | |
|
586 | if((PyObject *)capi_x_tmp!=x_capi) { | |
|
587 | Py_XDECREF(capi_x_tmp); } | |
|
588 | } /*if (capi_x_tmp == NULL) ... else of x*/ | |
|
589 | /* End of cleaning variable x */ | |
|
590 | /*end of cleanupfrompyobj*/ | |
|
591 | if (capi_buildvalue == NULL) { | |
|
592 | /*routdebugfailure*/ | |
|
593 | } else { | |
|
594 | /*routdebugleave*/ | |
|
595 | } | |
|
596 | CFUNCSMESS("Freeing memory.\n"); | |
|
597 | /*freemem*/ | |
|
598 | #ifdef F2PY_REPORT_ATEXIT | |
|
599 | f2py_stop_clock(); | |
|
600 | #endif | |
|
601 | return capi_buildvalue; | |
|
602 | } | |
|
603 | /******************************* end of parab1 *******************************/ | |
|
604 | ||
|
605 | /*********************************** cdtr1 ***********************************/ | |
|
606 | static char doc_f2py_rout_fitacf_guess_cdtr1[] = "\ | |
|
607 | cdtr1 = cdtr1(depth)\n\nWrapper for ``cdtr1``.\ | |
|
608 | \n\nParameters\n----------\n" | |
|
609 | "depth : input float\n" | |
|
610 | "\nReturns\n-------\n" | |
|
611 | "cdtr1 : float"; | |
|
612 | /* extern void F_WRAPPEDFUNC(cdtr1,CDTR1)(float*,float*); */ | |
|
613 | static PyObject *f2py_rout_fitacf_guess_cdtr1(const PyObject *capi_self, | |
|
614 | PyObject *capi_args, | |
|
615 | PyObject *capi_keywds, | |
|
616 | void (*f2py_func)(float*,float*)) { | |
|
617 | PyObject * volatile capi_buildvalue = NULL; | |
|
618 | volatile int f2py_success = 1; | |
|
619 | /*decl*/ | |
|
620 | ||
|
621 | float cdtr1 = 0; | |
|
622 | float depth = 0; | |
|
623 | PyObject *depth_capi = Py_None; | |
|
624 | static char *capi_kwlist[] = {"depth",NULL}; | |
|
625 | ||
|
626 | /*routdebugenter*/ | |
|
627 | #ifdef F2PY_REPORT_ATEXIT | |
|
628 | f2py_start_clock(); | |
|
629 | #endif | |
|
630 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
631 | "O|:fitacf_guess.cdtr1",\ | |
|
632 | capi_kwlist,&depth_capi)) | |
|
633 | return NULL; | |
|
634 | /*frompyobj*/ | |
|
635 | /* Processing variable depth */ | |
|
636 | f2py_success = float_from_pyobj(&depth,depth_capi,"fitacf_guess.cdtr1() 1st argument (depth) can't be converted to float"); | |
|
637 | if (f2py_success) { | |
|
638 | /* Processing variable cdtr1 */ | |
|
639 | /*end of frompyobj*/ | |
|
640 | #ifdef F2PY_REPORT_ATEXIT | |
|
641 | f2py_start_call_clock(); | |
|
642 | #endif | |
|
643 | /*callfortranroutine*/ | |
|
644 | (*f2py_func)(&cdtr1,&depth); | |
|
645 | if (PyErr_Occurred()) | |
|
646 | f2py_success = 0; | |
|
647 | #ifdef F2PY_REPORT_ATEXIT | |
|
648 | f2py_stop_call_clock(); | |
|
649 | #endif | |
|
650 | /*end of callfortranroutine*/ | |
|
651 | if (f2py_success) { | |
|
652 | /*pyobjfrom*/ | |
|
653 | /*end of pyobjfrom*/ | |
|
654 | CFUNCSMESS("Building return value.\n"); | |
|
655 | capi_buildvalue = Py_BuildValue("f",cdtr1); | |
|
656 | /*closepyobjfrom*/ | |
|
657 | /*end of closepyobjfrom*/ | |
|
658 | } /*if (f2py_success) after callfortranroutine*/ | |
|
659 | /*cleanupfrompyobj*/ | |
|
660 | /* End of cleaning variable cdtr1 */ | |
|
661 | } /*if (f2py_success) of depth*/ | |
|
662 | /* End of cleaning variable depth */ | |
|
663 | /*end of cleanupfrompyobj*/ | |
|
664 | if (capi_buildvalue == NULL) { | |
|
665 | /*routdebugfailure*/ | |
|
666 | } else { | |
|
667 | /*routdebugleave*/ | |
|
668 | } | |
|
669 | CFUNCSMESS("Freeing memory.\n"); | |
|
670 | /*freemem*/ | |
|
671 | #ifdef F2PY_REPORT_ATEXIT | |
|
672 | f2py_stop_clock(); | |
|
673 | #endif | |
|
674 | return capi_buildvalue; | |
|
675 | } | |
|
676 | /******************************** end of cdtr1 ********************************/ | |
|
677 | ||
|
678 | /*********************************** czte1 ***********************************/ | |
|
679 | static char doc_f2py_rout_fitacf_guess_czte1[] = "\ | |
|
680 | czte1 = czte1(zlag,tr)\n\nWrapper for ``czte1``.\ | |
|
681 | \n\nParameters\n----------\n" | |
|
682 | "zlag : input float\n" | |
|
683 | "tr : input float\n" | |
|
684 | "\nReturns\n-------\n" | |
|
685 | "czte1 : float"; | |
|
686 | /* extern void F_WRAPPEDFUNC(czte1,CZTE1)(float*,float*,float*); */ | |
|
687 | static PyObject *f2py_rout_fitacf_guess_czte1(const PyObject *capi_self, | |
|
688 | PyObject *capi_args, | |
|
689 | PyObject *capi_keywds, | |
|
690 | void (*f2py_func)(float*,float*,float*)) { | |
|
691 | PyObject * volatile capi_buildvalue = NULL; | |
|
692 | volatile int f2py_success = 1; | |
|
693 | /*decl*/ | |
|
694 | ||
|
695 | float czte1 = 0; | |
|
696 | float zlag = 0; | |
|
697 | PyObject *zlag_capi = Py_None; | |
|
698 | float tr = 0; | |
|
699 | PyObject *tr_capi = Py_None; | |
|
700 | static char *capi_kwlist[] = {"zlag","tr",NULL}; | |
|
701 | ||
|
702 | /*routdebugenter*/ | |
|
703 | #ifdef F2PY_REPORT_ATEXIT | |
|
704 | f2py_start_clock(); | |
|
705 | #endif | |
|
706 | if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ | |
|
707 | "OO|:fitacf_guess.czte1",\ | |
|
708 | capi_kwlist,&zlag_capi,&tr_capi)) | |
|
709 | return NULL; | |
|
710 | /*frompyobj*/ | |
|
711 | /* Processing variable zlag */ | |
|
712 | f2py_success = float_from_pyobj(&zlag,zlag_capi,"fitacf_guess.czte1() 1st argument (zlag) can't be converted to float"); | |
|
713 | if (f2py_success) { | |
|
714 | /* Processing variable tr */ | |
|
715 | f2py_success = float_from_pyobj(&tr,tr_capi,"fitacf_guess.czte1() 2nd argument (tr) can't be converted to float"); | |
|
716 | if (f2py_success) { | |
|
717 | /* Processing variable czte1 */ | |
|
718 | /*end of frompyobj*/ | |
|
719 | #ifdef F2PY_REPORT_ATEXIT | |
|
720 | f2py_start_call_clock(); | |
|
721 | #endif | |
|
722 | /*callfortranroutine*/ | |
|
723 | (*f2py_func)(&czte1,&zlag,&tr); | |
|
724 | if (PyErr_Occurred()) | |
|
725 | f2py_success = 0; | |
|
726 | #ifdef F2PY_REPORT_ATEXIT | |
|
727 | f2py_stop_call_clock(); | |
|
728 | #endif | |
|
729 | /*end of callfortranroutine*/ | |
|
730 | if (f2py_success) { | |
|
731 | /*pyobjfrom*/ | |
|
732 | /*end of pyobjfrom*/ | |
|
733 | CFUNCSMESS("Building return value.\n"); | |
|
734 | capi_buildvalue = Py_BuildValue("f",czte1); | |
|
735 | /*closepyobjfrom*/ | |
|
736 | /*end of closepyobjfrom*/ | |
|
737 | } /*if (f2py_success) after callfortranroutine*/ | |
|
738 | /*cleanupfrompyobj*/ | |
|
739 | /* End of cleaning variable czte1 */ | |
|
740 | } /*if (f2py_success) of tr*/ | |
|
741 | /* End of cleaning variable tr */ | |
|
742 | } /*if (f2py_success) of zlag*/ | |
|
743 | /* End of cleaning variable zlag */ | |
|
744 | /*end of cleanupfrompyobj*/ | |
|
745 | if (capi_buildvalue == NULL) { | |
|
746 | /*routdebugfailure*/ | |
|
747 | } else { | |
|
748 | /*routdebugleave*/ | |
|
749 | } | |
|
750 | CFUNCSMESS("Freeing memory.\n"); | |
|
751 | /*freemem*/ | |
|
752 | #ifdef F2PY_REPORT_ATEXIT | |
|
753 | f2py_stop_clock(); | |
|
754 | #endif | |
|
755 | return capi_buildvalue; | |
|
756 | } | |
|
757 | /******************************** end of czte1 ********************************/ | |
|
758 | /*eof body*/ | |
|
759 | ||
|
760 | /******************* See f2py2e/f90mod_rules.py: buildhooks *******************/ | |
|
761 | /*need_f90modhooks*/ | |
|
762 | ||
|
763 | /************** See f2py2e/rules.py: module_rules['modulebody'] **************/ | |
|
764 | ||
|
765 | /******************* See f2py2e/common_rules.py: buildhooks *******************/ | |
|
766 | ||
|
767 | /*need_commonhooks*/ | |
|
768 | ||
|
769 | /**************************** See f2py2e/rules.py ****************************/ | |
|
770 | ||
|
771 | static FortranDataDef f2py_routine_defs[] = { | |
|
772 | {"guess",-1,{{-1}},0,(char *)F_FUNC(guess,GUESS),(f2py_init_func)f2py_rout_fitacf_guess_guess,doc_f2py_rout_fitacf_guess_guess}, | |
|
773 | {"parab1",-1,{{-1}},0,(char *)F_FUNC(parab1,PARAB1),(f2py_init_func)f2py_rout_fitacf_guess_parab1,doc_f2py_rout_fitacf_guess_parab1}, | |
|
774 | {"cdtr1",-1,{{-1}},0,(char *)F_WRAPPEDFUNC(cdtr1,CDTR1),(f2py_init_func)f2py_rout_fitacf_guess_cdtr1,doc_f2py_rout_fitacf_guess_cdtr1}, | |
|
775 | {"czte1",-1,{{-1}},0,(char *)F_WRAPPEDFUNC(czte1,CZTE1),(f2py_init_func)f2py_rout_fitacf_guess_czte1,doc_f2py_rout_fitacf_guess_czte1}, | |
|
776 | ||
|
777 | /*eof routine_defs*/ | |
|
778 | {NULL} | |
|
779 | }; | |
|
780 | ||
|
781 | static PyMethodDef f2py_module_methods[] = { | |
|
782 | ||
|
783 | {NULL,NULL} | |
|
784 | }; | |
|
785 | ||
|
786 | static struct PyModuleDef moduledef = { | |
|
787 | PyModuleDef_HEAD_INIT, | |
|
788 | "fitacf_guess", | |
|
789 | NULL, | |
|
790 | -1, | |
|
791 | f2py_module_methods, | |
|
792 | NULL, | |
|
793 | NULL, | |
|
794 | NULL, | |
|
795 | NULL | |
|
796 | }; | |
|
797 | ||
|
798 | PyMODINIT_FUNC PyInit_fitacf_guess(void) { | |
|
799 | int i; | |
|
800 | PyObject *m,*d, *s, *tmp; | |
|
801 | m = fitacf_guess_module = PyModule_Create(&moduledef); | |
|
802 | Py_SET_TYPE(&PyFortran_Type, &PyType_Type); | |
|
803 | import_array(); | |
|
804 | if (PyErr_Occurred()) | |
|
805 | {PyErr_SetString(PyExc_ImportError, "can't initialize module fitacf_guess (failed to import numpy)"); return m;} | |
|
806 | d = PyModule_GetDict(m); | |
|
807 | s = PyString_FromString("$Revision: $"); | |
|
808 | PyDict_SetItemString(d, "__version__", s); | |
|
809 | Py_DECREF(s); | |
|
810 | s = PyUnicode_FromString( | |
|
811 | "This module 'fitacf_guess' is auto-generated with f2py (version:2).\nFunctions:\n" | |
|
812 | " guess(acf,tau,zero,amin,te,tr,npts=len(acf))\n" | |
|
813 | " parab1(x,y,a,b,c)\n" | |
|
814 | " cdtr1 = cdtr1(depth)\n" | |
|
815 | " czte1 = czte1(zlag,tr)\n" | |
|
816 | "."); | |
|
817 | PyDict_SetItemString(d, "__doc__", s); | |
|
818 | Py_DECREF(s); | |
|
819 | fitacf_guess_error = PyErr_NewException ("fitacf_guess.error", NULL, NULL); | |
|
820 | /* | |
|
821 | * Store the error object inside the dict, so that it could get deallocated. | |
|
822 | * (in practice, this is a module, so it likely will not and cannot.) | |
|
823 | */ | |
|
824 | PyDict_SetItemString(d, "_fitacf_guess_error", fitacf_guess_error); | |
|
825 | Py_DECREF(fitacf_guess_error); | |
|
826 | for(i=0;f2py_routine_defs[i].name!=NULL;i++) { | |
|
827 | tmp = PyFortranObject_NewAsAttr(&f2py_routine_defs[i]); | |
|
828 | PyDict_SetItemString(d, f2py_routine_defs[i].name, tmp); | |
|
829 | Py_DECREF(tmp); | |
|
830 | } | |
|
831 | ||
|
832 | ||
|
833 | ||
|
834 | { | |
|
835 | extern float F_FUNC(cdtr1,CDTR1)(void); | |
|
836 | PyObject* o = PyDict_GetItemString(d,"cdtr1"); | |
|
837 | tmp = F2PyCapsule_FromVoidPtr((void*)F_FUNC(cdtr1,CDTR1),NULL); | |
|
838 | PyObject_SetAttrString(o,"_cpointer", tmp); | |
|
839 | Py_DECREF(tmp); | |
|
840 | s = PyUnicode_FromString("cdtr1"); | |
|
841 | PyObject_SetAttrString(o,"__name__", s); | |
|
842 | Py_DECREF(s); | |
|
843 | } | |
|
844 | ||
|
845 | ||
|
846 | { | |
|
847 | extern float F_FUNC(czte1,CZTE1)(void); | |
|
848 | PyObject* o = PyDict_GetItemString(d,"czte1"); | |
|
849 | tmp = F2PyCapsule_FromVoidPtr((void*)F_FUNC(czte1,CZTE1),NULL); | |
|
850 | PyObject_SetAttrString(o,"_cpointer", tmp); | |
|
851 | Py_DECREF(tmp); | |
|
852 | s = PyUnicode_FromString("czte1"); | |
|
853 | PyObject_SetAttrString(o,"__name__", s); | |
|
854 | Py_DECREF(s); | |
|
855 | } | |
|
856 | ||
|
857 | /*eof initf2pywraphooks*/ | |
|
858 | /*eof initf90modhooks*/ | |
|
859 | ||
|
860 | /*eof initcommonhooks*/ | |
|
861 | ||
|
862 | ||
|
863 | #ifdef F2PY_REPORT_ATEXIT | |
|
864 | if (! PyErr_Occurred()) | |
|
865 | on_exit(f2py_report_on_exit,(void*)"fitacf_guess"); | |
|
866 | #endif | |
|
867 | return m; | |
|
868 | } | |
|
869 | #ifdef __cplusplus | |
|
870 | } | |
|
871 | #endif |
@@ -0,0 +1,240 | |||
|
1 | C -*- fortran -*- | |
|
2 | C This file is autogenerated with f2py (version:2) | |
|
3 | C It contains Fortran 77 wrappers to fortran functions. | |
|
4 | ||
|
5 | subroutine f2pywrapenorm (enormf2pywrap, n, x) | |
|
6 | external enorm | |
|
7 | integer n | |
|
8 | real x(n) | |
|
9 | real enormf2pywrap, enorm | |
|
10 | enormf2pywrap = enorm(n, x) | |
|
11 | end | |
|
12 | ||
|
13 | ||
|
14 | subroutine f2pywrapspmpar (spmparf2pywrap, i) | |
|
15 | external spmpar | |
|
16 | integer i | |
|
17 | real spmparf2pywrap, spmpar | |
|
18 | spmparf2pywrap = spmpar(i) | |
|
19 | end | |
|
20 | ||
|
21 | ||
|
22 | subroutine f2pywrapcdtr1 (cdtr1f2pywrap, depth) | |
|
23 | external cdtr1 | |
|
24 | real depth | |
|
25 | real cdtr1f2pywrap, cdtr1 | |
|
26 | cdtr1f2pywrap = cdtr1(depth) | |
|
27 | end | |
|
28 | ||
|
29 | ||
|
30 | subroutine f2pywrapczte1 (czte1f2pywrap, zlag, tr) | |
|
31 | external czte1 | |
|
32 | real zlag | |
|
33 | real tr | |
|
34 | real czte1f2pywrap, czte1 | |
|
35 | czte1f2pywrap = czte1(zlag, tr) | |
|
36 | end | |
|
37 | ||
|
38 | ||
|
39 | subroutine f2pywrapcj_ion (cj_ionf2pywrap, theta, psi) | |
|
40 | external cj_ion | |
|
41 | real theta | |
|
42 | real psi | |
|
43 | complex cj_ionf2pywrap, cj_ion | |
|
44 | cj_ionf2pywrap = cj_ion(theta, psi) | |
|
45 | end | |
|
46 | ||
|
47 | ||
|
48 | subroutine f2pywrapcj_electron (cj_electronf2pywrap, theta, | |
|
49 | &phi, psi, alpha) | |
|
50 | external cj_electron | |
|
51 | real theta | |
|
52 | real phi | |
|
53 | real psi | |
|
54 | real alpha | |
|
55 | complex cj_electronf2pywrap, cj_electron | |
|
56 | cj_electronf2pywrap = cj_electron(theta, phi, psi, alpha) | |
|
57 | end | |
|
58 | ||
|
59 | ||
|
60 | subroutine f2pywrapy_ion (y_ionf2pywrap, theta, psi) | |
|
61 | external y_ion | |
|
62 | real theta | |
|
63 | real psi | |
|
64 | complex y_ionf2pywrap, y_ion | |
|
65 | y_ionf2pywrap = y_ion(theta, psi) | |
|
66 | end | |
|
67 | ||
|
68 | ||
|
69 | subroutine f2pywrapy_electron (y_electronf2pywrap, theta, ph | |
|
70 | &i, psi, alpha) | |
|
71 | external y_electron | |
|
72 | real theta | |
|
73 | real phi | |
|
74 | real psi | |
|
75 | real alpha | |
|
76 | complex y_electronf2pywrap, y_electron | |
|
77 | y_electronf2pywrap = y_electron(theta, phi, psi, alpha) | |
|
78 | end | |
|
79 | ||
|
80 | ||
|
81 | subroutine f2pywrapspect1 (spect1f2pywrap, omega) | |
|
82 | external spect1 | |
|
83 | real omega | |
|
84 | real spect1f2pywrap, spect1 | |
|
85 | spect1f2pywrap = spect1(omega) | |
|
86 | end | |
|
87 | ||
|
88 | ||
|
89 | subroutine f2pywrapatanh (atanhf2pywrap, x) | |
|
90 | external atanh | |
|
91 | real x | |
|
92 | real atanhf2pywrap, atanh | |
|
93 | atanhf2pywrap = atanh(x) | |
|
94 | end | |
|
95 | ||
|
96 | ||
|
97 | subroutine f2pywrapbvalue (bvaluef2pywrap, t, bcoef, n, k, x | |
|
98 | &, jderiv) | |
|
99 | external bvalue | |
|
100 | integer n | |
|
101 | integer k | |
|
102 | real x | |
|
103 | integer jderiv | |
|
104 | real t(n+k) | |
|
105 | real bcoef(n) | |
|
106 | real bvaluef2pywrap, bvalue | |
|
107 | bvaluef2pywrap = bvalue(t, bcoef, n, k, x, jderiv) | |
|
108 | end | |
|
109 | ||
|
110 | ||
|
111 | subroutine f2pywrapr1mach (r1machf2pywrap, i) | |
|
112 | external r1mach | |
|
113 | integer i | |
|
114 | real r1machf2pywrap, r1mach | |
|
115 | r1machf2pywrap = r1mach(i) | |
|
116 | end | |
|
117 | ||
|
118 | ||
|
119 | subroutine f2pyinitchisq(setupfunc) | |
|
120 | external setupfunc | |
|
121 | real chi2 | |
|
122 | common /chisq/ chi2 | |
|
123 | call setupfunc(chi2) | |
|
124 | end | |
|
125 | ||
|
126 | subroutine f2pyinitfpa(setupfunc) | |
|
127 | external setupfunc | |
|
128 | real densp(91) | |
|
129 | real tep(91) | |
|
130 | real trp(91) | |
|
131 | real tip(91) | |
|
132 | real hfp(91) | |
|
133 | real hefp(91) | |
|
134 | real altp(91) | |
|
135 | real r0 | |
|
136 | real dr | |
|
137 | real wl | |
|
138 | common /fpa/ densp,tep,trp,tip,hfp,hefp,altp,r0,dr,wl | |
|
139 | call setupfunc(densp,tep,trp,tip,hfp,hefp,altp,r0,dr,wl) | |
|
140 | end | |
|
141 | ||
|
142 | subroutine f2pyinitdata(setupfunc) | |
|
143 | external setupfunc | |
|
144 | real plag(16,91) | |
|
145 | real plag_errors(16,91) | |
|
146 | common /data/ plag,plag_errors | |
|
147 | call setupfunc(plag,plag_errors) | |
|
148 | end | |
|
149 | ||
|
150 | subroutine f2pyinitsys(setupfunc) | |
|
151 | external setupfunc | |
|
152 | real sconst | |
|
153 | common /sys/ sconst | |
|
154 | call setupfunc(sconst) | |
|
155 | end | |
|
156 | ||
|
157 | subroutine f2pyiniterrs(setupfunc) | |
|
158 | external setupfunc | |
|
159 | real edensp(91) | |
|
160 | real etep(91) | |
|
161 | real etip(91) | |
|
162 | real ehfp(91) | |
|
163 | real ehefp(91) | |
|
164 | common /errs/ edensp,etep,etip,ehfp,ehefp | |
|
165 | call setupfunc(edensp,etep,etip,ehfp,ehefp) | |
|
166 | end | |
|
167 | ||
|
168 | subroutine f2pyinitmag(setupfunc) | |
|
169 | external setupfunc | |
|
170 | real bfld_prof(85) | |
|
171 | real alpha_prof(85) | |
|
172 | common /mag/ bfld_prof,alpha_prof | |
|
173 | call setupfunc(bfld_prof,alpha_prof) | |
|
174 | end | |
|
175 | ||
|
176 | subroutine f2pyinitmode(setupfunc) | |
|
177 | external setupfunc | |
|
178 | integer imode | |
|
179 | common /mode/ imode | |
|
180 | call setupfunc(imode) | |
|
181 | end | |
|
182 | ||
|
183 | subroutine f2pyinitutime(setupfunc) | |
|
184 | external setupfunc | |
|
185 | real uttime | |
|
186 | common /utime/ uttime | |
|
187 | call setupfunc(uttime) | |
|
188 | end | |
|
189 | ||
|
190 | subroutine f2pyinitspline(setupfunc) | |
|
191 | external setupfunc | |
|
192 | real ta(34) | |
|
193 | real bcoef(30,5) | |
|
194 | common /spline/ ta,bcoef | |
|
195 | call setupfunc(ta,bcoef) | |
|
196 | end | |
|
197 | ||
|
198 | subroutine f2pyinitspec(setupfunc) | |
|
199 | external setupfunc | |
|
200 | real te | |
|
201 | real ti(10) | |
|
202 | real fi(10) | |
|
203 | real ven | |
|
204 | real vin(10) | |
|
205 | real alpha | |
|
206 | real dens | |
|
207 | real bfld | |
|
208 | integer nion | |
|
209 | integer wi(10) | |
|
210 | real ak | |
|
211 | common /spec/ te,ti,fi,ven,vin,alpha,dens,bfld,nion,wi,ak | |
|
212 | call setupfunc(te,ti,fi,ven,vin,alpha,dens,bfld,nion,wi,ak) | |
|
213 | end | |
|
214 | ||
|
215 | subroutine f2pyinitfitter(setupfunc) | |
|
216 | external setupfunc | |
|
217 | real tau(100) | |
|
218 | real rho(100) | |
|
219 | real sigma2(100) | |
|
220 | real params(10) | |
|
221 | integer ifit(10) | |
|
222 | common /fitter/ tau,rho,sigma2,params,ifit | |
|
223 | call setupfunc(tau,rho,sigma2,params,ifit) | |
|
224 | end | |
|
225 | ||
|
226 | subroutine f2pyinittrans(setupfunc) | |
|
227 | external setupfunc | |
|
228 | real ev(10000) | |
|
229 | common /trans/ ev | |
|
230 | call setupfunc(ev) | |
|
231 | end | |
|
232 | ||
|
233 | subroutine f2pyinitd8mach(setupfunc) | |
|
234 | external setupfunc | |
|
235 | integer cray1 | |
|
236 | common /d8mach/ cray1 | |
|
237 | call setupfunc(cray1) | |
|
238 | end | |
|
239 | ||
|
240 |
|
1 | NO CONTENT: new file 100644 | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -0,0 +1,17 | |||
|
1 | ||
|
2 | subroutine get_path(fqual_temp) | |
|
3 | c | |
|
4 | c create table of magnetic field components | |
|
5 | c | |
|
6 | c character*47 L | |
|
7 | ||
|
8 | character(1024) :: fqual_temp | |
|
9 | character(512) :: ppath | |
|
10 | character(512) :: cpath | |
|
11 | ppath = "/home/cportilla/DIR_MADRIGAL/schain" | |
|
12 | cpath = "/schainf/Ffiles/bfmodel/" | |
|
13 | c write(*,*) "Len:", L | |
|
14 | fqual_temp = TRIM(ppath)//TRIM(cpath) | |
|
15 | c write(*,*) "Len:", fqual_temp | |
|
16 | return | |
|
17 | end |
@@ -0,0 +1,36 | |||
|
1 | ||
|
2 | subroutine get_len(the_len,fqual_temp) | |
|
3 | c | |
|
4 | c create table of magnetic field components | |
|
5 | c | |
|
6 | c character*47 L | |
|
7 | ||
|
8 | character(1024) :: fqual_temp | |
|
9 | character(512) :: ppath | |
|
10 | character(512) :: cpath | |
|
11 | integer the_len | |
|
12 | ppath = "/home/cportilla/DIR_MADRIGAL/schain" | |
|
13 | cpath = "/schainf/Ffiles/jlib26feb2001" | |
|
14 | fqual_temp = TRIM(ppath)//TRIM(cpath) | |
|
15 | the_len = LEN_TRIM(fqual_temp) | |
|
16 | ||
|
17 | return | |
|
18 | end | |
|
19 | ||
|
20 | subroutine get_path_reader(fqual,the_len) | |
|
21 | c | |
|
22 | c create table of magnetic field components | |
|
23 | c | |
|
24 | c character*47 L | |
|
25 | ||
|
26 | integer the_len | |
|
27 | character(the_len) :: fqual | |
|
28 | character(1024) :: fqual_temp | |
|
29 | ||
|
30 | call get_len(the_len,fqual_temp) | |
|
31 | fqual = TRIM(fqual_temp) | |
|
32 | write(*,*) "Done" | |
|
33 | ||
|
34 | return | |
|
35 | end | |
|
36 |
@@ -0,0 +1,141 | |||
|
1 | {"conditions": [ | |
|
2 | ||
|
3 | {"year": 2024, "doy": 47, "initial_time": [5,32], "final_time": [6,42], "aux_index": [ null, 11]}, | |
|
4 | ||
|
5 | {"year": 2024, "doy": 247, "initial_time": [2,0], "final_time": [5,0], "aux_index": [ null, 11]}, | |
|
6 | {"year": 2024, "doy": 247, "initial_time": [1,40], "final_time": [2,0], "aux_index": [ null, 26]}, | |
|
7 | {"year": 2024, "doy": 247, "initial_time": [0,45], "final_time": [0,45], "aux_index": [ null, 28]}, | |
|
8 | {"year": 2024, "doy": 246, "initial_time": [23,15], "final_time": [23,59], "aux_index": [ null, 21]}, | |
|
9 | {"year": 2024, "doy": 246, "initial_time": [13,55], "final_time": [23,59], "aux_index": [ null, 11]}, | |
|
10 | {"year": 2024, "doy": 247, "initial_time": [0,0], "final_time": [2,25], "aux_index": [ null, 22]}, | |
|
11 | {"year": 2024, "doy": 247, "initial_time": [3,0], "final_time": [3,0], "aux_index": [ 34, null]}, | |
|
12 | ||
|
13 | {"year": 2024, "doy": 247, "initial_time": [5,0], "final_time": [23,59], "aux_index": [ null, 11]}, | |
|
14 | {"year": 2024, "doy": 247, "initial_time": [5,0], "final_time": [11,25], "aux_index": [ 11, 13]}, | |
|
15 | {"year": 2024, "doy": 247, "initial_time": [5,30], "final_time": [9,50], "aux_index": [ 13, 13]}, | |
|
16 | {"year": 2024, "doy": 247, "initial_time": [23,15], "final_time": [23,59], "aux_index": [ null, 15]}, | |
|
17 | {"year": 2024, "doy": 248, "initial_time": [0,0], "final_time": [4,59], "aux_index": [ null, 13]}, | |
|
18 | {"year": 2024, "doy": 248, "initial_time": [0,0], "final_time": [1,50], "aux_index": [ null, 21]}, | |
|
19 | {"year": 2024, "doy": 248, "initial_time": [0,0], "final_time": [2,50], "aux_index": [ null, 17]}, | |
|
20 | {"year": 2024, "doy": 247, "initial_time": [8,5], "final_time": [8,10], "aux_index": [ null, null]}, | |
|
21 | {"year": 2024, "doy": 248, "initial_time": [2,50], "final_time": [2,50], "aux_index": [ 30, null]}, | |
|
22 | {"year": 2024, "doy": 248, "initial_time": [3,55], "final_time": [4,0], "aux_index": [ 26, null]}, | |
|
23 | {"year": 2024, "doy": 247, "initial_time": [5,0], "final_time": [5,0], "aux_index": [ 18, 24]}, | |
|
24 | {"year": 2024, "doy": 247, "initial_time": [5,5], "final_time": [5,5], "aux_index": [ 21, 26]}, | |
|
25 | {"year": 2024, "doy": 247, "initial_time": [5,15], "final_time": [5,15], "aux_index": [ 19, 21]}, | |
|
26 | {"year": 2024, "doy": 247, "initial_time": [5,20], "final_time": [5,20], "aux_index": [ 21, 23]}, | |
|
27 | {"year": 2024, "doy": 247, "initial_time": [5,25], "final_time": [5,25], "aux_index": [ 21, 26]}, | |
|
28 | {"year": 2024, "doy": 247, "initial_time": [5,30], "final_time": [5,30], "aux_index": [ 20, 27]}, | |
|
29 | {"year": 2024, "doy": 247, "initial_time": [5,35], "final_time": [5,35], "aux_index": [ 22, 27]}, | |
|
30 | {"year": 2024, "doy": 247, "initial_time": [8,5], "final_time": [8,10], "aux_index": [ null, null]}, | |
|
31 | {"year": 2024, "doy": 247, "initial_time": [15,30], "final_time": [15,30], "aux_index": [ null, null]}, | |
|
32 | ||
|
33 | ||
|
34 | {"year": 2024, "doy": 248, "initial_time": [5,20], "final_time": [5,35], "aux_index": [ 20, null]}, | |
|
35 | {"year": 2024, "doy": 248, "initial_time": [5,40], "final_time": [5,55], "aux_index": [ 23, null]}, | |
|
36 | {"year": 2024, "doy": 248, "initial_time": [5,0], "final_time": [23,59], "aux_index": [ null, 11]}, | |
|
37 | {"year": 2024, "doy": 249, "initial_time": [0,0], "final_time": [4,59], "aux_index": [ null, 12]}, | |
|
38 | {"year": 2024, "doy": 248, "initial_time": [5,0], "final_time": [9,0], "aux_index": [ null, 13]}, | |
|
39 | {"year": 2024, "doy": 249, "initial_time": [2,0], "final_time": [2,20], "aux_index": [ null, 17]}, | |
|
40 | {"year": 2024, "doy": 249, "initial_time": [2,55], "final_time": [2,55], "aux_index": [ 27, null]}, | |
|
41 | {"year": 2024, "doy": 249, "initial_time": [3,0], "final_time": [3,5], "aux_index": [ 25, null]}, | |
|
42 | {"year": 2024, "doy": 249, "initial_time": [4,5], "final_time": [4,5], "aux_index": [ 23, null]}, | |
|
43 | {"year": 2024, "doy": 249, "initial_time": [4,10], "final_time": [4,10], "aux_index": [ 26, null]}, | |
|
44 | {"year": 2024, "doy": 249, "initial_time": [4,15], "final_time": [4,15], "aux_index": [ 30, null]}, | |
|
45 | {"year": 2024, "doy": 249, "initial_time": [0,30], "final_time": [0,40], "aux_index": [ null, null]}, | |
|
46 | ||
|
47 | {"year": 2024, "doy": 249, "initial_time": [5,20], "final_time": [5,20], "aux_index": [ 22, null]}, | |
|
48 | {"year": 2024, "doy": 249, "initial_time": [5,25], "final_time": [5,25], "aux_index": [ 23, null]}, | |
|
49 | {"year": 2024, "doy": 249, "initial_time": [5,30], "final_time": [5,30], "aux_index": [ 18, 37]}, | |
|
50 | {"year": 2024, "doy": 249, "initial_time": [5,35], "final_time": [5,40], "aux_index": [ 18, 34]}, | |
|
51 | {"year": 2024, "doy": 249, "initial_time": [5,45], "final_time": [5,45], "aux_index": [ 20, 30]}, | |
|
52 | {"year": 2024, "doy": 249, "initial_time": [6,5], "final_time": [6,5], "aux_index": [ 24, null]}, | |
|
53 | {"year": 2024, "doy": 249, "initial_time": [10,5], "final_time": [10,5], "aux_index": [ null, null]}, | |
|
54 | {"year": 2024, "doy": 249, "initial_time": [6,10], "final_time": [6,10], "aux_index": [ 29, null]}, | |
|
55 | {"year": 2024, "doy": 249, "initial_time": [6,45], "final_time": [6,45], "aux_index": [ 21, null]}, | |
|
56 | {"year": 2024, "doy": 249, "initial_time": [5,0], "final_time": [20,0], "aux_index": [ null, 11]}, | |
|
57 | {"year": 2024, "doy": 249, "initial_time": [23,10], "final_time": [23,59], "aux_index": [ null, 11]}, | |
|
58 | {"year": 2024, "doy": 250, "initial_time": [0,0], "final_time": [4,59], "aux_index": [ null, 13]}, | |
|
59 | {"year": 2024, "doy": 249, "initial_time": [5,0], "final_time": [8,50], "aux_index": [ null, 12]}, | |
|
60 | {"year": 2024, "doy": 250, "initial_time": [0,0], "final_time": [3,35], "aux_index": [ null, 23]}, | |
|
61 | {"year": 2024, "doy": 250, "initial_time": [0,0], "final_time": [0,55], "aux_index": [ null, null]}, | |
|
62 | {"year": 2024, "doy": 249, "initial_time": [7,15], "final_time": [7,15], "aux_index": [ null, 14]}, | |
|
63 | {"year": 2024, "doy": 250, "initial_time": [3,15], "final_time": [3,35], "aux_index": [ 46, null]}, | |
|
64 | {"year": 2024, "doy": 250, "initial_time": [3,25], "final_time": [3,25], "aux_index": [ null, 30]}, | |
|
65 | {"year": 2024, "doy": 250, "initial_time": [3,30], "final_time": [3,30], "aux_index": [ null, 32]}, | |
|
66 | {"year": 2024, "doy": 250, "initial_time": [3,35], "final_time": [3,35], "aux_index": [ null, 34]}, | |
|
67 | {"year": 2024, "doy": 250, "initial_time": [3,40], "final_time": [3,40], "aux_index": [ 21, 38]}, | |
|
68 | {"year": 2024, "doy": 250, "initial_time": [3,45], "final_time": [3,45], "aux_index": [ 22, 37]}, | |
|
69 | {"year": 2024, "doy": 250, "initial_time": [1,35], "final_time": [1,35], "aux_index": [ 36, null]}, | |
|
70 | {"year": 2024, "doy": 250, "initial_time": [1,40], "final_time": [1,40], "aux_index": [ 32, null]}, | |
|
71 | {"year": 2024, "doy": 250, "initial_time": [1,45], "final_time": [1,45], "aux_index": [ 31, null]}, | |
|
72 | {"year": 2024, "doy": 250, "initial_time": [2,30], "final_time": [2,30], "aux_index": [ 30, null]}, | |
|
73 | {"year": 2024, "doy": 250, "initial_time": [2,35], "final_time": [2,35], "aux_index": [ 33, null]}, | |
|
74 | {"year": 2024, "doy": 250, "initial_time": [2,40], "final_time": [2,40], "aux_index": [ 27, null]}, | |
|
75 | ||
|
76 | {"year": 2024, "doy": 251, "initial_time": [3,0], "final_time": [3,45], "aux_index": [ null, null]}, | |
|
77 | {"year": 2024, "doy": 251, "initial_time": [0,30], "final_time": [0,45], "aux_index": [ null, null]}, | |
|
78 | ||
|
79 | {"year": 2024, "doy": 250, "initial_time": [5,0], "final_time": [5,0], "aux_index": [ 20, 41]}, | |
|
80 | {"year": 2024, "doy": 250, "initial_time": [5,5], "final_time": [5,10], "aux_index": [ 24, 37]}, | |
|
81 | {"year": 2024, "doy": 250, "initial_time": [5,20], "final_time": [5,25], "aux_index": [ 23, 39]}, | |
|
82 | {"year": 2024, "doy": 250, "initial_time": [5,30], "final_time": [5,30], "aux_index": [ 19, null]}, | |
|
83 | {"year": 2024, "doy": 250, "initial_time": [6,5], "final_time": [6,5], "aux_index": [ 24, null]}, | |
|
84 | {"year": 2024, "doy": 250, "initial_time": [6,10], "final_time": [6,10], "aux_index": [ 20, 41]}, | |
|
85 | {"year": 2024, "doy": 250, "initial_time": [6,15], "final_time": [6,15], "aux_index": [ 20, 39]}, | |
|
86 | {"year": 2024, "doy": 250, "initial_time": [6,20], "final_time": [6,20], "aux_index": [ 20, 37]}, | |
|
87 | {"year": 2024, "doy": 250, "initial_time": [6,25], "final_time": [6,25], "aux_index": [ 21, 29]}, | |
|
88 | {"year": 2024, "doy": 250, "initial_time": [6,30], "final_time": [6,30], "aux_index": [ 22, 29]}, | |
|
89 | {"year": 2024, "doy": 250, "initial_time": [6,45], "final_time": [6,45], "aux_index": [ 20, null]}, | |
|
90 | {"year": 2024, "doy": 250, "initial_time": [6,50], "final_time": [6,50], "aux_index": [ 19, 38]}, | |
|
91 | {"year": 2024, "doy": 250, "initial_time": [6,55], "final_time": [6,55], "aux_index": [ 23, 42]}, | |
|
92 | {"year": 2024, "doy": 250, "initial_time": [7,0], "final_time": [7,0], "aux_index": [ 20, null]}, | |
|
93 | {"year": 2024, "doy": 250, "initial_time": [7,5], "final_time": [7,5], "aux_index": [ 23, 40]}, | |
|
94 | {"year": 2024, "doy": 250, "initial_time": [7,10], "final_time": [7,10], "aux_index": [ 23, 42]}, | |
|
95 | {"year": 2024, "doy": 250, "initial_time": [7,15], "final_time": [7,15], "aux_index": [ 25, 37]}, | |
|
96 | {"year": 2024, "doy": 250, "initial_time": [7,30], "final_time": [7,30], "aux_index": [ 25, 40]}, | |
|
97 | {"year": 2024, "doy": 250, "initial_time": [7,35], "final_time": [7,35], "aux_index": [ 25, 39]}, | |
|
98 | {"year": 2024, "doy": 250, "initial_time": [7,40], "final_time": [7,40], "aux_index": [ 23, 41]}, | |
|
99 | {"year": 2024, "doy": 250, "initial_time": [7,45], "final_time": [7,45], "aux_index": [ 27, 38]}, | |
|
100 | {"year": 2024, "doy": 250, "initial_time": [23,10], "final_time": [23,59], "aux_index": [ null, 12]}, | |
|
101 | {"year": 2024, "doy": 251, "initial_time": [0,0], "final_time": [4,59], "aux_index": [ null, 13]}, | |
|
102 | {"year": 2024, "doy": 250, "initial_time": [5,0], "final_time": [8,10], "aux_index": [ null, 12]}, | |
|
103 | {"year": 2024, "doy": 250, "initial_time": [9,10], "final_time": [10,50], "aux_index": [ null, 12]}, | |
|
104 | {"year": 2024, "doy": 251, "initial_time": [0,0], "final_time": [3,30], "aux_index": [ null, 27]}, | |
|
105 | {"year": 2024, "doy": 250, "initial_time": [19,30], "final_time": [19,30], "aux_index": [ 19, 26]}, | |
|
106 | {"year": 2024, "doy": 250, "initial_time": [10,50], "final_time": [13,20], "aux_index": [ null, 12]}, | |
|
107 | ||
|
108 | ||
|
109 | {"year": 2024, "doy": 251, "initial_time": [5,0], "final_time": [5,0], "aux_index": [ 23, 40]}, | |
|
110 | {"year": 2024, "doy": 251, "initial_time": [5,5], "final_time": [5,10], "aux_index": [ 25, 40]}, | |
|
111 | {"year": 2024, "doy": 251, "initial_time": [17,30], "final_time": [20,30], "aux_index": [ 56, null]}, | |
|
112 | {"year": 2024, "doy": 251, "initial_time": [5,0], "final_time": [8,10], "aux_index": [ null, 12]}, | |
|
113 | {"year": 2024, "doy": 251, "initial_time": [5,0], "final_time": [20,0], "aux_index": [ null, 11]}, | |
|
114 | {"year": 2024, "doy": 251, "initial_time": [19,50], "final_time": [19,50], "aux_index": [ null, null]}, | |
|
115 | {"year": 2024, "doy": 252, "initial_time": [0,30], "final_time": [0,55], "aux_index": [ null, null]}, | |
|
116 | {"year": 2024, "doy": 252, "initial_time": [0,55], "final_time": [1,0], "aux_index": [ null, 40]}, | |
|
117 | {"year": 2024, "doy": 252, "initial_time": [1,0], "final_time": [1,15], "aux_index": [ null, 34]}, | |
|
118 | {"year": 2024, "doy": 252, "initial_time": [0,30], "final_time": [0,55], "aux_index": [ null, null]}, | |
|
119 | {"year": 2024, "doy": 252, "initial_time": [1,35], "final_time": [1,55], "aux_index": [ null, null]}, | |
|
120 | {"year": 2024, "doy": 251, "initial_time": [23,10], "final_time": [23,59], "aux_index": [ null, 20]}, | |
|
121 | {"year": 2024, "doy": 252, "initial_time": [0,0], "final_time": [5,0], "aux_index": [ null, 12]}, | |
|
122 | {"year": 2024, "doy": 252, "initial_time": [0,0], "final_time": [1,50], "aux_index": [ null, 31]}, | |
|
123 | {"year": 2024, "doy": 252, "initial_time": [3,20], "final_time": [3,25], "aux_index": [ 22, null]}, | |
|
124 | {"year": 2024, "doy": 252, "initial_time": [3,30], "final_time": [3,35], "aux_index": [ 23, null]}, | |
|
125 | {"year": 2024, "doy": 252, "initial_time": [3,50], "final_time": [3,50], "aux_index": [ 22, null]}, | |
|
126 | {"year": 2024, "doy": 252, "initial_time": [3,55], "final_time": [4,5], "aux_index": [ 21, null]}, | |
|
127 | {"year": 2024, "doy": 252, "initial_time": [4,10], "final_time": [4,10], "aux_index": [ 21, 36]}, | |
|
128 | ||
|
129 | {"year": 2024, "doy": 252, "initial_time": [5,0], "final_time": [20,0], "aux_index": [ null, 12]}, | |
|
130 | {"year": 2024, "doy": 252, "initial_time": [13,0], "final_time": [13,0], "aux_index": [ null, null]}, | |
|
131 | {"year": 2024, "doy": 252, "initial_time": [5,15], "final_time": [5,20], "aux_index": [ 23, null]}, | |
|
132 | {"year": 2024, "doy": 252, "initial_time": [5,25], "final_time": [5,25], "aux_index": [ 27, 36]}, | |
|
133 | {"year": 2024, "doy": 252, "initial_time": [5,30], "final_time": [5,30], "aux_index": [ 27, null]}, | |
|
134 | {"year": 2024, "doy": 252, "initial_time": [5,35], "final_time": [5,35], "aux_index": [ 31, null]}, | |
|
135 | {"year": 2024, "doy": 252, "initial_time": [5,20], "final_time": [5,40], "aux_index": [ 33, null]}, | |
|
136 | {"year": 2024, "doy": 252, "initial_time": [7,5], "final_time": [7,5], "aux_index": [ 21, null]}, | |
|
137 | {"year": 2024, "doy": 252, "initial_time": [7,10], "final_time": [7,10], "aux_index": [ 23, null]} | |
|
138 | ||
|
139 | ||
|
140 | ]} | |
|
141 |
|
1 | NO CONTENT: new file 100644 | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -14,7 +14,7 from threading import Thread | |||
|
14 | 14 | from multiprocessing import Process, Queue |
|
15 | 15 | from schainpy.utils import log |
|
16 | 16 | |
|
17 | QUEUE_SIZE = int(os.environ.get('QUEUE_MAX_SIZE', '10')) | |
|
17 | QUEUE_SIZE = int(os.environ.get('QUEUE_MAX_SIZE', '100')) | |
|
18 | 18 | |
|
19 | 19 | class ProcessingUnit(object): |
|
20 | 20 | ''' |
@@ -1827,7 +1827,7 class Oblique_Gauss_Fit(Operation): | |||
|
1827 | 1827 | #print("After data_snr: ", dataOut.data_snr) |
|
1828 | 1828 | dataOut.mode = mode |
|
1829 | 1829 | dataOut.flagNoData = numpy.all(numpy.isnan(dataOut.Dop_EEJ_T1)) #Si todos los valores son NaN no se prosigue |
|
1830 |
|
|
|
1830 | dataOut.flagNoData = False #Descomentar solo para ploteo sino mantener comentado (para guardado) | |
|
1831 | 1831 | |
|
1832 | 1832 | return dataOut |
|
1833 | 1833 | |
@@ -7188,9 +7188,10 class IGRFModel(Operation): | |||
|
7188 | 7188 | log.warning('You should install "mkfact_short_2020" module to process IGRF Model') |
|
7189 | 7189 | |
|
7190 | 7190 | if self.aux==1: |
|
7191 | ||
|
7191 | ||
|
7192 | 7192 | #dataOut.TimeBlockSeconds_First_Time=time.mktime(time.strptime(dataOut.TimeBlockDate)) |
|
7193 | 7193 | #### we do not use dataOut.datatime.ctime() because it's the time of the second (next) block |
|
7194 | dataOut.TimeBlockSeconds = 1727848800.0 | |
|
7194 | 7195 | dataOut.TimeBlockSeconds_First_Time=dataOut.TimeBlockSeconds |
|
7195 | 7196 | dataOut.bd_time=time.gmtime(dataOut.TimeBlockSeconds_First_Time) |
|
7196 | 7197 | dataOut.year=dataOut.bd_time.tm_year+(dataOut.bd_time.tm_yday-1)/364.0 |
@@ -7199,6 +7200,7 class IGRFModel(Operation): | |||
|
7199 | 7200 | self.aux=0 |
|
7200 | 7201 | dh = dataOut.heightList[1]-dataOut.heightList[0] |
|
7201 | 7202 | #dataOut.h=numpy.arange(0.0,15.0*dataOut.MAXNRANGENDT,15.0,dtype='float32') |
|
7203 | dataOut.MAXNRANGENDT = dataOut.nHeights | |
|
7202 | 7204 | dataOut.h=numpy.arange(0.0,dh*dataOut.MAXNRANGENDT,dh,dtype='float32') |
|
7203 | 7205 | dataOut.bfm=numpy.zeros(dataOut.MAXNRANGENDT,dtype='float32') |
|
7204 | 7206 | dataOut.bfm=numpy.array(dataOut.bfm,order='F') |
@@ -7210,10 +7212,12 class IGRFModel(Operation): | |||
|
7210 | 7212 | #print("**** mkfact WRAPPER ***** ",mkfact_short_2020.mkfact.__doc__ ) |
|
7211 | 7213 | #print("IDs: ", id(dataOut.bki)) |
|
7212 | 7214 | #print("bki shape: ", numpy.shape(dataOut.bki),numpy.shape(dataOut.h),dataOut.year) |
|
7213 | ||
|
7215 | print(dataOut.year,dataOut.h,dataOut.bfm,dataOut.thb,dataOut.bki,dataOut.MAXNRANGENDT) | |
|
7214 | 7216 | mkfact_short_2020_2.mkfact(dataOut.year,dataOut.h,dataOut.bfm,dataOut.thb,dataOut.bki,dataOut.MAXNRANGENDT) |
|
7215 | 7217 | |
|
7216 | 7218 | #mkfact_short_2020.mkfact(dataOut.year,dataOut.h,dataOut.bfm,dataOut.thb,dataOut.bki,dataOut.MAXNRANGENDT) |
|
7219 | ||
|
7220 | print("bki: ", dataOut.bki) | |
|
7217 | 7221 | #print("bki: ", dataOut.bki[:10]) |
|
7218 | 7222 | #print("thb: ", dataOut.thb[:10]) |
|
7219 | 7223 | #print("bfm: ", dataOut.bfm[:10]) |
This diff has been collapsed as it changes many lines, (1918 lines changed) Show them Hide them | |||
@@ -12,6 +12,8 import time | |||
|
12 | 12 |
import itertools |
|
13 | 13 | |
|
14 | 14 |
import numpy |
|
15 | import matplotlib.pyplot as plt | |
|
16 | import datetime | |
|
15 | 17 | |
|
16 | 18 |
from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation |
|
17 | 19 |
from schainpy.model.data.jrodata import Spectra |
@@ -22,7 +24,7 from schainpy.model.data import _HS_algorithm | |||
|
22 | 24 |
from schainpy.model.proc.jroproc_voltage import CleanCohEchoes |
|
23 | 25 | |
|
24 | 26 |
from time import time, mktime, strptime, gmtime, ctime |
|
25 | ||
|
27 | from scipy.stats import norm | |
|
26 | 28 | |
|
27 | 29 |
class SpectraLagProc(ProcessingUnit): |
|
28 | 30 |
''' |
@@ -34,14 +36,23 class SpectraLagProc(ProcessingUnit): | |||
|
34 | 36 | |
|
35 | 37 |
self.buffer = None |
|
36 | 38 |
self.buffer_Lag = None |
|
37 |
self.firstdatatime = None |
|
|
38 |
self.profIndex = 0 |
|
|
39 | self.firstdatatime = None # Tracks the time of the first data entry. | |
|
40 | self.profIndex = 0 # Profile Index | |
|
39 | 41 |
self.dataOut = Spectra() |
|
40 | 42 |
self.id_min = None |
|
41 | 43 |
self.id_max = None |
|
42 |
self.setupReq = False #Agregar a todas las unidades de proc |
|
|
44 | self.setupReq = False #Agregar a todas las unidades de proc | |
|
45 | # DataIn: Voltage raw data | |
|
46 | # DataOut: Spectra data | |
|
43 | 47 | |
|
44 | 48 |
def __updateSpecFromVoltage(self): |
|
49 | ||
|
50 | ''' | |
|
51 | Assign all the metadata of dataIn (Voltage data) to dataOut (Spectra Data) | |
|
52 | ||
|
53 | Metadata dataIn -> Metadata dataOut | |
|
54 | ||
|
55 | ''' | |
|
45 | 56 | |
|
46 | 57 |
self.dataOut.timeZone = self.dataIn.timeZone |
|
47 | 58 |
self.dataOut.dstFlag = self.dataIn.dstFlag |
@@ -82,6 +93,9 class SpectraLagProc(ProcessingUnit): | |||
|
82 | 93 |
""" |
|
83 | 94 |
Convierte valores de Voltaje a Spectra |
|
84 | 95 | |
|
96 | Returns: | |
|
97 | Self-spectra, Cross-spectra, DC | |
|
98 | ||
|
85 | 99 |
Affected: |
|
86 | 100 |
self.dataOut.data_spc |
|
87 | 101 |
self.dataOut.data_cspc |
@@ -91,16 +105,15 class SpectraLagProc(ProcessingUnit): | |||
|
91 | 105 |
self.buffer |
|
92 | 106 |
self.dataOut.flagNoData |
|
93 | 107 |
""" |
|
94 | #print(self.buffer[1,:,0]) | |
|
95 | #exit(1) | |
|
96 | #print("buffer shape",self.buffer.shape) | |
|
108 | ||
|
97 | 109 |
fft_volt = numpy.fft.fft( |
|
98 | 110 |
self.buffer, n=self.dataOut.nFFTPoints, axis=1) |
|
99 | 111 |
fft_volt = fft_volt.astype(numpy.dtype('complex')) |
|
100 | 112 |
dc = fft_volt[:, 0, :] |
|
101 | 113 | |
|
102 |
# |
|
|
103 | fft_volt = numpy.fft.fftshift(fft_volt, axes=(1,)) | |
|
114 | ### Calculate self-spectra | |
|
115 | # Reorder the frequency distribution to set 0 at center | |
|
116 | fft_volt = numpy.fft.fftshift(fft_volt, axes = (1,)) | |
|
104 | 117 |
spc = fft_volt * numpy.conjugate(fft_volt) |
|
105 | 118 |
spc = spc.real |
|
106 | 119 | |
@@ -111,11 +124,11 class SpectraLagProc(ProcessingUnit): | |||
|
111 | 124 |
cspc = None |
|
112 | 125 |
pairIndex = 0 |
|
113 | 126 |
if self.dataOut.pairsList != None: |
|
114 |
# |
|
|
115 | #print("HERE") | |
|
127 | # Calculate cross-spectra | |
|
116 | 128 |
cspc = numpy.zeros( |
|
117 | 129 |
(self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') |
|
118 | 130 |
for pair in self.dataOut.pairsList: |
|
131 | # Check if channel of pairs are in the channellist | |
|
119 | 132 |
if pair[0] not in self.dataOut.channelList: |
|
120 | 133 |
raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" % ( |
|
121 | 134 |
str(pair), str(self.dataOut.channelList))) |
@@ -157,26 +170,30 class SpectraLagProc(ProcessingUnit): | |||
|
157 | 170 |
self.dataIn.nHeights), |
|
158 | 171 |
dtype='complex') |
|
159 | 172 | |
|
160 | if self.dataIn.flagDataAsBlock: | |
|
161 | nVoltProfiles = self.dataIn.data.shape[1] | |
|
173 | # Usually FFTPoints should be equal to nProfiles N = L | |
|
174 | # So, Buffer dimensions [channels (2), FFTPoints (24), Heights (99)] | |
|
162 | 175 | |
|
163 | if nVoltProfiles == nProfiles: | |
|
176 | ### Sets the .buffer and .profIndex | |
|
177 | if self.dataIn.flagDataAsBlock: # Data was readed as block of [channel, profile, height] | |
|
178 | nVoltProfiles = self.dataIn.data.shape[1] # number of profiles | |
|
179 | ||
|
180 | #Comparison of FFT points (nProfiles) with sample points (vVoltProfiles) | |
|
181 | if nVoltProfiles == nProfiles: #even-DFT case | |
|
164 | 182 |
self.buffer = self.dataIn.data.copy() |
|
165 | 183 |
self.profIndex = nVoltProfiles |
|
166 | 184 | |
|
167 |
elif nVoltProfiles < nProfiles: |
|
|
168 | ||
|
185 | elif nVoltProfiles < nProfiles: # Frequency Interpolation case (most common) | |
|
169 | 186 |
if self.profIndex == 0: |
|
170 | 187 |
self.id_min = 0 |
|
171 | 188 |
self.id_max = nVoltProfiles |
|
172 | 189 | |
|
173 | 190 |
self.buffer[:, self.id_min:self.id_max, |
|
174 |
:] = self.dataIn.data |
|
|
175 | ||
|
191 | :] = self.dataIn.data # Coppy only the profiles of voltage, VoltProfiles = FFT Point | |
|
176 | 192 |
self.profIndex += nVoltProfiles |
|
177 | 193 |
self.id_min += nVoltProfiles |
|
178 | 194 |
self.id_max += nVoltProfiles |
|
179 | 195 |
else: |
|
196 | ||
|
180 | 197 |
raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % ( |
|
181 | 198 |
self.dataIn.type, self.dataIn.data.shape[1], nProfiles)) |
|
182 | 199 |
self.dataOut.flagNoData = True |
@@ -187,19 +204,19 class SpectraLagProc(ProcessingUnit): | |||
|
187 | 204 |
if self.firstdatatime == None: |
|
188 | 205 |
self.firstdatatime = self.dataIn.utctime |
|
189 | 206 | |
|
190 |
if self.profIndex == nProfiles: |
|
|
191 | self.__updateSpecFromVoltage() | |
|
207 | if self.profIndex == nProfiles: # Num of profiles considered are correct | |
|
208 | self.__updateSpecFromVoltage() # Assign all the metadata of dataIn (Voltage data) to dataOut (Spectra Data) | |
|
209 | # Create List of pairs between channels: e.g. (0,1) (1,0) | |
|
192 | 210 |
if pairsList == None: |
|
193 | 211 |
self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)] |
|
194 | 212 |
else: |
|
195 | 213 |
self.dataOut.pairsList = pairsList |
|
196 | #print(self.dataOut.pairsList) | |
|
197 |
self.__getFft() |
|
|
214 | ||
|
215 | self.__getFft() # Calculate FFT | |
|
216 | ||
|
198 | 217 |
self.dataOut.flagNoData = False |
|
199 | 218 |
self.firstdatatime = None |
|
200 | #print(self.profIndex) | |
|
201 | 219 |
self.profIndex = 0 |
|
202 | #input() | |
|
203 | 220 | |
|
204 | 221 |
''' |
|
205 | 222 |
if not self.dataOut.ByLags: |
@@ -268,20 +285,19 class SpectraLagProc(ProcessingUnit): | |||
|
268 | 285 | |
|
269 | 286 | |
|
270 | 287 |
if i>0 and self.id_min is not None: |
|
271 | ||
|
288 | # Reboot the Indexs | |
|
272 | 289 |
self.profIndex -= self.dataIn.data.shape[1] |
|
273 | 290 |
self.id_min -= self.dataIn.data.shape[1] |
|
274 | 291 |
self.id_max -= self.dataIn.data.shape[1] |
|
275 | 292 | |
|
276 | 293 |
if self.profIndex>0 and self.id_min is not None: |
|
277 | ||
|
294 | # buffer <- bufferlag with lag i | |
|
278 | 295 |
self.buffer[:,:self.id_max-self.dataIn.data.shape[1],:]=self.buffer_Lag[:,:self.id_max-self.dataIn.data.shape[1],:,i] |
|
279 | 296 | |
|
297 | # Voltage to Spectra | |
|
280 | 298 |
self.VoltageType(nFFTPoints,nProfiles,ippFactor,pairsList) |
|
281 | 299 | |
|
282 | ||
|
283 | if self.id_min is not None: | |
|
284 | ||
|
300 | if self.id_min is not None: # Could be eliminated? | |
|
285 | 301 |
self.buffer_Lag[:,self.id_min-self.dataIn.data.shape[1]:self.id_max-self.dataIn.data.shape[1],:,i]=self.buffer[:,self.id_min-self.dataIn.data.shape[1]:self.id_max-self.dataIn.data.shape[1],:] |
|
286 | 302 | |
|
287 | 303 |
if not self.dataOut.flagNoData: |
@@ -290,23 +306,29 class SpectraLagProc(ProcessingUnit): | |||
|
290 | 306 |
if i==self.dataOut.nLags-1: |
|
291 | 307 |
self.profIndex=0 |
|
292 | 308 |
self.firstdatatime = None |
|
309 | # Add data for each lag to dataLag | |
|
293 | 310 |
self.dataOut.dataLag_spc.append(self.dataOut.data_spc) |
|
294 | 311 |
self.dataOut.dataLag_cspc.append(self.dataOut.data_cspc) |
|
295 | 312 |
self.dataOut.dataLag_dc.append(self.dataOut.data_dc) |
|
296 | 313 | |
|
297 | 314 | |
|
298 | 315 |
if not self.dataOut.flagNoData: |
|
316 | #Convert Data to array | |
|
299 | 317 |
self.dataOut.dataLag_spc=numpy.array(self.dataOut.dataLag_spc) |
|
300 | 318 |
self.dataOut.dataLag_cspc=numpy.array(self.dataOut.dataLag_cspc) |
|
301 |
self.dataOut.dataLag_dc=numpy.array(self.dataOut.dataLag_dc) |
|
|
302 | self.dataOut.dataLag_spc=self.dataOut.dataLag_spc.transpose(1,2,3,0) | |
|
319 | self.dataOut.dataLag_dc = numpy.array(self.dataOut.dataLag_dc) | |
|
320 | ||
|
321 | # Return the shape of the data to[channel, profile, heigh, lag] | |
|
322 | self.dataOut.dataLag_spc = self.dataOut.dataLag_spc.transpose(1, 2, 3, 0) | |
|
303 | 323 |
self.dataOut.dataLag_cspc=self.dataOut.dataLag_cspc.transpose(1,2,3,0) |
|
304 |
self.dataOut.dataLag_dc=self.dataOut.dataLag_dc.transpose(1,2,0) |
|
|
305 | ||
|
324 | self.dataOut.dataLag_dc = self.dataOut.dataLag_dc.transpose(1, 2, 0) | |
|
325 | ||
|
326 | # Save the Lagdata into a copy with the channel select to be plotted | |
|
306 | 327 |
self.dataOut.data_spc=self.dataOut.dataLag_spc[:,:,:,self.dataOut.LagPlot] |
|
307 | 328 |
self.dataOut.data_cspc=self.dataOut.dataLag_cspc[:,:,:,self.dataOut.LagPlot] |
|
308 | 329 |
self.dataOut.data_dc=self.dataOut.dataLag_dc[:,:,self.dataOut.LagPlot] |
|
309 | 330 | |
|
331 | # Copy metadata | |
|
310 | 332 |
self.dataOut.TimeBlockSeconds=self.dataIn.TimeBlockSeconds |
|
311 | 333 |
self.dataOut.flagDataAsBlock=self.dataIn.flagDataAsBlock |
|
312 | 334 |
try: |
@@ -444,7 +466,7 class removeDCLagFlip(Operation): | |||
|
444 | 466 |
num_pairs = jcspectra.shape[0] |
|
445 | 467 |
else: |
|
446 | 468 |
jcspectraExist = False |
|
447 | ||
|
469 | ||
|
448 | 470 |
freq_dc = int(jspectra.shape[1] / 2) |
|
449 | 471 |
ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc |
|
450 | 472 |
ind_vel = ind_vel.astype(int) |
@@ -453,6 +475,7 class removeDCLagFlip(Operation): | |||
|
453 | 475 |
ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof |
|
454 | 476 | |
|
455 | 477 |
if mode == 1: |
|
478 | ''' DC correction is taked as an average of the first neighboords at w=0''' | |
|
456 | 479 |
jspectra[:, freq_dc, :] = ( |
|
457 | 480 |
jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION |
|
458 | 481 | |
@@ -462,6 +485,8 class removeDCLagFlip(Operation): | |||
|
462 | 485 | |
|
463 | 486 |
if mode == 2: |
|
464 | 487 | |
|
488 | ''' ''' | |
|
489 | ||
|
465 | 490 |
vel = numpy.array([-2, -1, 1, 2]) |
|
466 | 491 |
xx = numpy.zeros([4, 4]) |
|
467 | 492 | |
@@ -472,9 +497,10 class removeDCLagFlip(Operation): | |||
|
472 | 497 |
xx_aux = xx_inv[0, :] |
|
473 | 498 | |
|
474 | 499 |
for ich in range(num_chan): |
|
500 | ''' Flipped signal -> DC at most negative value ''' | |
|
475 | 501 |
if ich in self.dataOut.FlipChannels: |
|
476 | ||
|
477 | ||
|
502 | ''' Flipped case.- DC at 0 index ''' | |
|
503 | ||
|
478 | 504 |
ind_freq_flip=[-1, -2, 1, 2] |
|
479 | 505 | |
|
480 | 506 |
yy = jspectra[ich, ind_freq_flip, :] |
@@ -490,6 +516,7 class removeDCLagFlip(Operation): | |||
|
490 | 516 | |
|
491 | 517 | |
|
492 | 518 |
else: |
|
519 | ''' Unflipped case.- DC at freq_dc (center) index ''' | |
|
493 | 520 |
yy = jspectra[ich, ind_vel, :] |
|
494 | 521 |
jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
495 | 522 | |
@@ -1111,6 +1138,10 class removeInterference(Operation): | |||
|
1111 | 1138 |
class IntegrationFaradaySpectra(Operation): |
|
1112 | 1139 |
''' |
|
1113 | 1140 |
Written by R. Flores |
|
1141 | ||
|
1142 | spc: Spectra | |
|
1143 | cspc: Cross Spectra | |
|
1144 | dc: Direct Current | |
|
1114 | 1145 |
''' |
|
1115 | 1146 |
__profIndex = 0 |
|
1116 | 1147 |
__withOverapping = False |
@@ -1136,1440 +1167,113 class IntegrationFaradaySpectra(Operation): | |||
|
1136 | 1167 | |
|
1137 | 1168 |
def setup(self, n=None, timeInterval=None, overlapping=False): |
|
1138 | 1169 |
""" |
|
1139 |
Set the parameters of the integration class. |
|
|
1140 | ||
|
1141 | Inputs: | |
|
1142 | ||
|
1143 | n : Number of coherent integrations | |
|
1144 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
|
1145 | overlapping : | |
|
1146 | ||
|
1147 | """ | |
|
1148 | ||
|
1149 | self.__initime = None | |
|
1150 | self.__lastdatatime = 0 | |
|
1151 | ||
|
1152 | self.__buffer_spc = [] | |
|
1153 | self.__buffer_cspc = [] | |
|
1154 | self.__buffer_dc = 0 | |
|
1155 | ||
|
1156 | self.__profIndex = 0 | |
|
1157 | self.__dataReady = False | |
|
1158 | self.__byTime = False | |
|
1159 | ||
|
1160 | if n is None and timeInterval is None: | |
|
1161 | raise ValueError("n or timeInterval should be specified ...") | |
|
1162 | ||
|
1163 | if n is not None: | |
|
1164 | self.n = int(n) | |
|
1165 | else: | |
|
1166 | ||
|
1167 | self.__integrationtime = int(timeInterval) | |
|
1168 | self.n = None | |
|
1169 | self.__byTime = True | |
|
1170 | ||
|
1171 | def putData(self, data_spc, data_cspc, data_dc): | |
|
1172 | """ | |
|
1173 | Add a profile to the __buffer_spc and increase in one the __profileIndex | |
|
1174 | ||
|
1175 | """ | |
|
1176 | ||
|
1177 | self.__buffer_spc.append(data_spc) | |
|
1178 | ||
|
1179 | if data_cspc is None: | |
|
1180 | self.__buffer_cspc = None | |
|
1181 | else: | |
|
1182 | self.__buffer_cspc.append(data_cspc) | |
|
1183 | ||
|
1184 | if data_dc is None: | |
|
1185 | self.__buffer_dc = None | |
|
1186 | else: | |
|
1187 | self.__buffer_dc += data_dc | |
|
1188 | ||
|
1189 | self.__profIndex += 1 | |
|
1190 | ||
|
1191 | return | |
|
1192 | ||
|
1193 | def hildebrand_sekhon_Integration(self,data,navg): | |
|
1194 | ||
|
1195 | sortdata = numpy.sort(data, axis=None) | |
|
1196 | sortID=data.argsort() | |
|
1197 | lenOfData = len(sortdata) | |
|
1198 | nums_min = lenOfData*0.75 | |
|
1199 | if nums_min <= 5: | |
|
1200 | nums_min = 5 | |
|
1201 | sump = 0. | |
|
1202 | sumq = 0. | |
|
1203 | j = 0 | |
|
1204 | cont = 1 | |
|
1205 | while((cont == 1)and(j < lenOfData)): | |
|
1206 | sump += sortdata[j] | |
|
1207 | sumq += sortdata[j]**2 | |
|
1208 | if j > nums_min: | |
|
1209 | rtest = float(j)/(j-1) + 1.0/navg | |
|
1210 | if ((sumq*j) > (rtest*sump**2)): | |
|
1211 | j = j - 1 | |
|
1212 | sump = sump - sortdata[j] | |
|
1213 | sumq = sumq - sortdata[j]**2 | |
|
1214 | cont = 0 | |
|
1215 | j += 1 | |
|
1216 | #lnoise = sump / j | |
|
1217 | ||
|
1218 | return j,sortID | |
|
1219 | ||
|
1220 | def pushData(self): | |
|
1221 | """ | |
|
1222 | Return the sum of the last profiles and the profiles used in the sum. | |
|
1223 | ||
|
1224 | Affected: | |
|
1225 | ||
|
1226 | self.__profileIndex | |
|
1227 | ||
|
1228 | """ | |
|
1229 | bufferH=None | |
|
1230 | buffer=None | |
|
1231 | buffer1=None | |
|
1232 | buffer_cspc=None | |
|
1233 | self.__buffer_spc=numpy.array(self.__buffer_spc) | |
|
1234 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) | |
|
1235 | freq_dc = int(self.__buffer_spc.shape[2] / 2) | |
|
1236 | #print("FREQ_DC",freq_dc) | |
|
1237 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
1238 | #lag_array=[0,2,4,6,8,10,12,14,16,18,20] | |
|
1239 | for l in range(self.DPL):#dataOut.DPL): | |
|
1240 | #breakFlag=False | |
|
1241 | for k in range(7,self.nHeights): | |
|
1242 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,0,:,k,l]) | |
|
1243 | outliers_IDs_cspc=[] | |
|
1244 | cspc_outliers_exist=False | |
|
1245 | #indexmin_cspc=0 | |
|
1246 | for i in range(self.nChannels):#dataOut.nChannels): | |
|
1247 | if i==1 and k >= self.nHeights-2*l: | |
|
1248 | #breakFlag=True | |
|
1249 | continue | |
|
1250 | #pass | |
|
1251 | else: | |
|
1252 | buffer1=numpy.copy(self.__buffer_spc[:,i,:,k,l]) | |
|
1253 | indexes=[] | |
|
1254 | #sortIDs=[] | |
|
1255 | outliers_IDs=[] | |
|
1256 | for j in range(self.nProfiles): | |
|
1257 | if i==0 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 0 | |
|
1258 | continue | |
|
1259 | if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
1260 | continue | |
|
1261 | buffer=buffer1[:,j] | |
|
1262 | #index,sortID=self.hildebrand_sekhon_Integration(buffer,1) | |
|
1263 | index=int(_HS_algorithm.HS_algorithm(numpy.sort(buffer, axis=None),1)) | |
|
1264 | sortID = buffer.argsort() | |
|
1265 | ''' | |
|
1266 | if i==1 and l==0 and k==37: | |
|
1267 | print("j",j) | |
|
1268 | print("INDEX",index) | |
|
1269 | print(sortID[index:]) | |
|
1270 | if j==5: | |
|
1271 | aa=numpy.mean(buffer,axis=0) | |
|
1272 | bb=numpy.sort(buffer) | |
|
1273 | print(buffer) | |
|
1274 | print(aa) | |
|
1275 | print(bb[-1]) | |
|
1276 | ''' | |
|
1277 | indexes.append(index) | |
|
1278 | #sortIDs.append(sortID) | |
|
1279 | outliers_IDs=numpy.append(outliers_IDs,sortID[index:]) | |
|
1280 | ||
|
1281 | outliers_IDs=numpy.array(outliers_IDs) | |
|
1282 | outliers_IDs=outliers_IDs.ravel() | |
|
1283 | outliers_IDs=numpy.unique(outliers_IDs) | |
|
1284 | outliers_IDs=outliers_IDs.astype(numpy.dtype('int64')) | |
|
1285 | indexes=numpy.array(indexes) | |
|
1286 | indexmin=numpy.min(indexes) | |
|
1287 | ||
|
1288 | if indexmin != buffer1.shape[0]: | |
|
1289 | cspc_outliers_exist=True | |
|
1290 | ###sortdata=numpy.sort(buffer1,axis=0) | |
|
1291 | ###avg2=numpy.mean(sortdata[:indexmin,:],axis=0) | |
|
1292 | lt=outliers_IDs | |
|
1293 | avg=numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
1294 | ''' | |
|
1295 | if k==37 and i==1 and l==0: | |
|
1296 | #cc= | |
|
1297 | print("index_min",indexmin) | |
|
1298 | print("outliers_ID",lt) | |
|
1299 | print("AVG",avg[5]) | |
|
1300 | print("AVG_2",avg2[5]) | |
|
1301 | ''' | |
|
1302 | ||
|
1303 | for p in list(outliers_IDs): | |
|
1304 | buffer1[p,:]=avg | |
|
1305 | ||
|
1306 | self.__buffer_spc[:,i,:,k,l]=numpy.copy(buffer1) | |
|
1307 | ###cspc IDs | |
|
1308 | #indexmin_cspc+=indexmin_cspc | |
|
1309 | outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) | |
|
1310 | ||
|
1311 | #if not breakFlag: | |
|
1312 | outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) | |
|
1313 | if cspc_outliers_exist: | |
|
1314 | #sortdata=numpy.sort(buffer_cspc,axis=0) | |
|
1315 | #avg=numpy.mean(sortdata[:indexmin_cpsc,:],axis=0) | |
|
1316 | lt=outliers_IDs_cspc | |
|
1317 | ||
|
1318 | avg=numpy.mean(buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:],axis=0) | |
|
1319 | for p in list(outliers_IDs_cspc): | |
|
1320 | buffer_cspc[p,:]=avg | |
|
1321 | ||
|
1322 | self.__buffer_cspc[:,0,:,k,l]=numpy.copy(buffer_cspc) | |
|
1323 | #else: | |
|
1324 | #break | |
|
1325 | ||
|
1326 | ||
|
1327 | ||
|
1328 | ||
|
1329 | buffer=None | |
|
1330 | bufferH=None | |
|
1331 | buffer1=None | |
|
1332 | buffer_cspc=None | |
|
1333 | ||
|
1334 | #print("cpsc",self.__buffer_cspc[:,0,0,0,0]) | |
|
1335 | #print(self.__profIndex) | |
|
1336 | #exit() | |
|
1337 | ||
|
1338 | buffer=None | |
|
1339 | #print(self.__buffer_spc[:,1,3,20,0]) | |
|
1340 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
1341 | data_spc = numpy.sum(self.__buffer_spc,axis=0) | |
|
1342 | data_cspc = numpy.sum(self.__buffer_cspc,axis=0) | |
|
1343 | ||
|
1344 | #print(numpy.shape(data_spc)) | |
|
1345 | #data_spc[1,4,20,0]=numpy.nan | |
|
1346 | ||
|
1347 | #data_cspc = self.__buffer_cspc | |
|
1348 | data_dc = self.__buffer_dc | |
|
1349 | n = self.__profIndex | |
|
1350 | ||
|
1351 | self.__buffer_spc = [] | |
|
1352 | self.__buffer_cspc = [] | |
|
1353 | self.__buffer_dc = 0 | |
|
1354 | self.__profIndex = 0 | |
|
1355 | ||
|
1356 | return data_spc, data_cspc, data_dc, n | |
|
1357 | ||
|
1358 | def byProfiles(self, *args): | |
|
1359 | ||
|
1360 | self.__dataReady = False | |
|
1361 | avgdata_spc = None | |
|
1362 | avgdata_cspc = None | |
|
1363 | avgdata_dc = None | |
|
1364 | ||
|
1365 | self.putData(*args) | |
|
1366 | ||
|
1367 | if self.__profIndex == self.n: | |
|
1368 | ||
|
1369 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
|
1370 | self.n = n | |
|
1371 | self.__dataReady = True | |
|
1372 | ||
|
1373 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
|
1374 | ||
|
1375 | def byTime(self, datatime, *args): | |
|
1376 | ||
|
1377 | self.__dataReady = False | |
|
1378 | avgdata_spc = None | |
|
1379 | avgdata_cspc = None | |
|
1380 | avgdata_dc = None | |
|
1381 | ||
|
1382 | self.putData(*args) | |
|
1383 | ||
|
1384 | if (datatime - self.__initime) >= self.__integrationtime: | |
|
1385 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
|
1386 | self.n = n | |
|
1387 | self.__dataReady = True | |
|
1388 | ||
|
1389 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
|
1390 | ||
|
1391 | def integrate(self, datatime, *args): | |
|
1392 | ||
|
1393 | if self.__profIndex == 0: | |
|
1394 | self.__initime = datatime | |
|
1395 | ||
|
1396 | if self.__byTime: | |
|
1397 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime( | |
|
1398 | datatime, *args) | |
|
1399 | else: | |
|
1400 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args) | |
|
1401 | ||
|
1402 | if not self.__dataReady: | |
|
1403 | return None, None, None, None | |
|
1404 | ||
|
1405 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc | |
|
1406 | ||
|
1407 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False): | |
|
1408 | if n == 1: | |
|
1409 | dataOut.VelRange = dataOut.getVelRange(0) | |
|
1410 | return dataOut | |
|
1411 | #print("holo") | |
|
1412 | dataOut.flagNoData = True | |
|
1413 | ||
|
1414 | if not self.isConfig: | |
|
1415 | self.setup(n, timeInterval, overlapping) | |
|
1416 | self.isConfig = True | |
|
1417 | ||
|
1418 | if not dataOut.ByLags: | |
|
1419 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, | |
|
1420 | dataOut.data_spc, | |
|
1421 | dataOut.data_cspc, | |
|
1422 | dataOut.data_dc) | |
|
1423 | else: | |
|
1424 | self.nProfiles=dataOut.nProfiles | |
|
1425 | self.nChannels=dataOut.nChannels | |
|
1426 | self.nHeights=dataOut.nHeights | |
|
1427 | self.DPL=dataOut.DPL | |
|
1428 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, | |
|
1429 | dataOut.dataLag_spc, | |
|
1430 | dataOut.dataLag_cspc, | |
|
1431 | dataOut.dataLag_dc) | |
|
1432 | ||
|
1433 | if self.__dataReady: | |
|
1434 | ||
|
1435 | if not dataOut.ByLags: | |
|
1436 | dataOut.data_spc = avgdata_spc | |
|
1437 | dataOut.data_cspc = avgdata_cspc | |
|
1438 | dataOut.data_dc = avgdata_dc | |
|
1439 | else: | |
|
1440 | dataOut.dataLag_spc = avgdata_spc | |
|
1441 | dataOut.dataLag_cspc = avgdata_cspc | |
|
1442 | dataOut.dataLag_dc = avgdata_dc | |
|
1443 | ||
|
1444 | dataOut.data_spc=dataOut.dataLag_spc[:,:,:,dataOut.LagPlot] | |
|
1445 | dataOut.data_cspc=dataOut.dataLag_cspc[:,:,:,dataOut.LagPlot] | |
|
1446 | dataOut.data_dc=dataOut.dataLag_dc[:,:,dataOut.LagPlot] | |
|
1447 | ||
|
1448 | dataOut.VelRange = dataOut.getVelRange(0) | |
|
1449 | dataOut.nIncohInt *= self.n | |
|
1450 | dataOut.utctime = avgdatatime | |
|
1451 | dataOut.flagNoData = False | |
|
1452 | ||
|
1453 | return dataOut | |
|
1454 | ||
|
1455 | ||
|
1456 | ||
|
1457 | class IntegrationFaradaySpectra2(Operation): | |
|
1458 | ''' | |
|
1459 | Written by R. Flores | |
|
1460 | ''' | |
|
1461 | __profIndex = 0 | |
|
1462 | __withOverapping = False | |
|
1463 | ||
|
1464 | __byTime = False | |
|
1465 | __initime = None | |
|
1466 | __lastdatatime = None | |
|
1467 | __integrationtime = None | |
|
1468 | ||
|
1469 | __buffer_spc = None | |
|
1470 | __buffer_cspc = None | |
|
1471 | __buffer_dc = None | |
|
1472 | ||
|
1473 | __dataReady = False | |
|
1474 | ||
|
1475 | __timeInterval = None | |
|
1476 | ||
|
1477 | n = None | |
|
1478 | ||
|
1479 | def __init__(self): | |
|
1480 | ||
|
1481 | Operation.__init__(self) | |
|
1482 | ||
|
1483 | def setup(self, n=None, timeInterval=None, overlapping=False): | |
|
1484 | """ | |
|
1485 | Set the parameters of the integration class. | |
|
1486 | ||
|
1487 | Inputs: | |
|
1488 | ||
|
1489 | n : Number of coherent integrations | |
|
1490 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
|
1491 | overlapping : | |
|
1492 | ||
|
1493 | """ | |
|
1494 | ||
|
1495 | self.__initime = None | |
|
1496 | self.__lastdatatime = 0 | |
|
1497 | ||
|
1498 | self.__buffer_spc = None | |
|
1499 | self.__buffer_cspc = None | |
|
1500 | self.__buffer_dc = 0 | |
|
1501 | ||
|
1502 | self.__profIndex = 0 | |
|
1503 | self.__dataReady = False | |
|
1504 | self.__byTime = False | |
|
1505 | ||
|
1506 | if n is None and timeInterval is None: | |
|
1507 | raise ValueError("n or timeInterval should be specified ...") | |
|
1508 | ||
|
1509 | if n is not None: | |
|
1510 | self.n = int(n) | |
|
1511 | else: | |
|
1512 | ||
|
1513 | self.__integrationtime = int(timeInterval) | |
|
1514 | self.n = None | |
|
1515 | self.__byTime = True | |
|
1516 | ||
|
1517 | def putData(self, data_spc, data_cspc, data_dc): | |
|
1518 | """ | |
|
1519 | Add a profile to the __buffer_spc and increase in one the __profileIndex | |
|
1520 | ||
|
1521 | """ | |
|
1522 | ||
|
1523 | #print(numpy.shape(self.__buffer_spc)) | |
|
1524 | ##print(numpy.shape(data_spc)) | |
|
1525 | ||
|
1526 | #self.__buffer_spc = numpy.insert(self.__buffer_spc,[],data_spc,axis=0) | |
|
1527 | self.__buffer_spc[self.__profIndex,:]=data_spc[:] | |
|
1528 | ##self.__buffer_spc.append(data_spc) | |
|
1529 | #self.__buffer_spc = numpy.array(self.__buffer_spc) | |
|
1530 | #print(numpy.shape(self.__buffer_spc)) | |
|
1531 | #print("bytes",sys.getsizeof(self.__buffer_spc)) | |
|
1532 | #print("bytes",asizeof(self.__buffer_spc)) | |
|
1533 | if data_cspc is None: | |
|
1534 | self.__buffer_cspc = None | |
|
1535 | ||
|
1536 | else: | |
|
1537 | self.__buffer_cspc[self.__profIndex,:]=data_cspc[:] | |
|
1538 | ||
|
1539 | if data_dc is None: | |
|
1540 | self.__buffer_dc = None | |
|
1541 | else: | |
|
1542 | self.__buffer_dc += data_dc | |
|
1543 | ||
|
1544 | self.__profIndex += 1 | |
|
1545 | ||
|
1546 | return | |
|
1547 | ||
|
1548 | def hildebrand_sekhon_Integration(self,data,navg): | |
|
1549 | ||
|
1550 | sortdata = numpy.sort(data, axis=None) | |
|
1551 | sortID=data.argsort() | |
|
1552 | lenOfData = len(sortdata) | |
|
1553 | nums_min = lenOfData*0.75 | |
|
1554 | if nums_min <= 5: | |
|
1555 | nums_min = 5 | |
|
1556 | sump = 0. | |
|
1557 | sumq = 0. | |
|
1558 | j = 0 | |
|
1559 | cont = 1 | |
|
1560 | while((cont == 1)and(j < lenOfData)): | |
|
1561 | sump += sortdata[j] | |
|
1562 | sumq += sortdata[j]**2 | |
|
1563 | if j > nums_min: | |
|
1564 | rtest = float(j)/(j-1) + 1.0/navg | |
|
1565 | if ((sumq*j) > (rtest*sump**2)): | |
|
1566 | j = j - 1 | |
|
1567 | sump = sump - sortdata[j] | |
|
1568 | sumq = sumq - sortdata[j]**2 | |
|
1569 | cont = 0 | |
|
1570 | j += 1 | |
|
1571 | #lnoise = sump / j | |
|
1572 | ||
|
1573 | return j,sortID | |
|
1574 | ||
|
1575 | def pushData_V0(self): | |
|
1576 | """ | |
|
1577 | Return the sum of the last profiles and the profiles used in the sum. | |
|
1578 | ||
|
1579 | Affected: | |
|
1580 | ||
|
1581 | self.__profileIndex | |
|
1582 | ||
|
1583 | """ | |
|
1584 | bufferH=None | |
|
1585 | buffer=None | |
|
1586 | buffer1=None | |
|
1587 | buffer_cspc=None | |
|
1588 | self.__buffer_spc=numpy.array(self.__buffer_spc) | |
|
1589 | if self.__buffer_cspc is not None: | |
|
1590 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) | |
|
1591 | freq_dc = int(self.__buffer_spc.shape[2] / 2) | |
|
1592 | #print("FREQ_DC",freq_dc) | |
|
1593 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
1594 | #lag_array=[0,2,4,6,8,10,12,14,16,18,20] | |
|
1595 | ||
|
1596 | if self.nLags == 11: | |
|
1597 | h0 = 7 | |
|
1598 | elif self.nLags == 16: | |
|
1599 | h0 = 180 | |
|
1600 | ||
|
1601 | ||
|
1602 | ''' | |
|
1603 | import matplotlib.pyplot as plt | |
|
1604 | plt.plot(self.__buffer_spc[:,0,freq_dc,33,0],marker='*') | |
|
1605 | plt.ylim((0,700000)) | |
|
1606 | plt.show() | |
|
1607 | import time | |
|
1608 | time.sleep(60) | |
|
1609 | exit(1) | |
|
1610 | ''' | |
|
1611 | #''' | |
|
1612 | import matplotlib.pyplot as plt | |
|
1613 | #plt.plot(self.__buffer_spc[:,0,freq_dc-2,33,1],marker='*') | |
|
1614 | plt.plot(sorted(self.__buffer_spc[:,0,freq_dc-2,33,1]),marker='*') | |
|
1615 | plt.ylim((0,1.1*1.e6)) | |
|
1616 | plt.show() | |
|
1617 | import time | |
|
1618 | time.sleep(60) | |
|
1619 | exit(1) | |
|
1620 | #''' | |
|
1621 | ||
|
1622 | print(self.nLags) | |
|
1623 | ''' | |
|
1624 | if self.nLags == 16: | |
|
1625 | self.nLags = 0 | |
|
1626 | #exit(1) | |
|
1627 | ''' | |
|
1628 | ||
|
1629 | for l in range(self.nLags):#dataOut.DPL): | |
|
1630 | #breakFlag=False | |
|
1631 | for k in range(7,self.nHeights): | |
|
1632 | if self.__buffer_cspc is not None: | |
|
1633 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,0,:,k,l]) | |
|
1634 | outliers_IDs_cspc=[] | |
|
1635 | cspc_outliers_exist=False | |
|
1636 | #indexmin_cspc=0 | |
|
1637 | for i in range(2): | |
|
1638 | #for i in range(self.nChannels):#dataOut.nChannels): | |
|
1639 | #if self.TrueLags: | |
|
1640 | #print("HERE") | |
|
1641 | if i==1 and k >= self.nHeights-2*l and self.TrueLags: | |
|
1642 | #breakFlag=True | |
|
1643 | continue | |
|
1644 | ||
|
1645 | #pass | |
|
1646 | else: | |
|
1647 | buffer1=numpy.copy(self.__buffer_spc[:,i,:,k,l]) | |
|
1648 | indexes=[] | |
|
1649 | #sortIDs=[] | |
|
1650 | outliers_IDs=[] | |
|
1651 | for j in range(self.nProfiles): | |
|
1652 | if i==0 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 0 | |
|
1653 | continue | |
|
1654 | if self.FlipChannelsExist: | |
|
1655 | if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
1656 | continue | |
|
1657 | else: | |
|
1658 | if i==1 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
1659 | continue | |
|
1660 | #buffer=buffer1[:,j] | |
|
1661 | buffer=(buffer1[:,j]).real | |
|
1662 | ''' | |
|
1663 | if self.nLags ==16 and l!=0: | |
|
1664 | print(buffer) | |
|
1665 | exit(1) | |
|
1666 | ''' | |
|
1667 | #index,sortID=self.hildebrand_sekhon_Integration(buffer,1) | |
|
1668 | index=int(_HS_algorithm.HS_algorithm(numpy.sort(buffer, axis=None),1)) | |
|
1669 | sortID = buffer.argsort() | |
|
1670 | ||
|
1671 | indexes.append(index) | |
|
1672 | #sortIDs.append(sortID) | |
|
1673 | outliers_IDs=numpy.append(outliers_IDs,sortID[index:]) | |
|
1674 | ||
|
1675 | outliers_IDs=numpy.array(outliers_IDs) | |
|
1676 | outliers_IDs=outliers_IDs.ravel() | |
|
1677 | outliers_IDs=numpy.unique(outliers_IDs) | |
|
1678 | outliers_IDs=outliers_IDs.astype(numpy.dtype('int64')) | |
|
1679 | indexes=numpy.array(indexes) | |
|
1680 | indexmin=numpy.min(indexes) | |
|
1681 | ||
|
1682 | if indexmin != buffer1.shape[0]: | |
|
1683 | cspc_outliers_exist=True | |
|
1684 | ###sortdata=numpy.sort(buffer1,axis=0) | |
|
1685 | ###avg2=numpy.mean(sortdata[:indexmin,:],axis=0) | |
|
1686 | lt=outliers_IDs | |
|
1687 | avg=numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
1688 | ||
|
1689 | ||
|
1690 | for p in list(outliers_IDs): | |
|
1691 | buffer1[p,:]=avg | |
|
1692 | ||
|
1693 | self.__buffer_spc[:,i,:,k,l]=numpy.copy(buffer1) | |
|
1694 | ###cspc IDs | |
|
1695 | #indexmin_cspc+=indexmin_cspc | |
|
1696 | if self.__buffer_cspc is not None: | |
|
1697 | outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) | |
|
1698 | ||
|
1699 | #if not breakFlag: | |
|
1700 | #print(outliers_IDs_cspc) | |
|
1701 | if self.__buffer_cspc is not None: | |
|
1702 | outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) | |
|
1703 | if cspc_outliers_exist: | |
|
1704 | #sortdata=numpy.sort(buffer_cspc,axis=0) | |
|
1705 | #avg=numpy.mean(sortdata[:indexmin_cpsc,:],axis=0) | |
|
1706 | lt=outliers_IDs_cspc | |
|
1707 | ||
|
1708 | avg=numpy.mean(buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:],axis=0) | |
|
1709 | for p in list(outliers_IDs_cspc): | |
|
1710 | buffer_cspc[p,:]=avg | |
|
1711 | ||
|
1712 | self.__buffer_cspc[:,0,:,k,l]=numpy.copy(buffer_cspc) | |
|
1713 | ||
|
1714 | #else: | |
|
1715 | #break | |
|
1716 | #''' | |
|
1717 | import matplotlib.pyplot as plt | |
|
1718 | plt.plot(self.__buffer_spc[:,0,freq_dc-2,33,1],marker='*') | |
|
1719 | plt.ylim((0,1.1*1.e6)) | |
|
1720 | plt.show() | |
|
1721 | import time | |
|
1722 | time.sleep(60) | |
|
1723 | exit(1) | |
|
1724 | #''' | |
|
1725 | ||
|
1726 | buffer=None | |
|
1727 | bufferH=None | |
|
1728 | buffer1=None | |
|
1729 | buffer_cspc=None | |
|
1730 | ||
|
1731 | #print("cpsc",self.__buffer_cspc[:,0,0,0,0]) | |
|
1732 | #print(self.__profIndex) | |
|
1733 | #exit() | |
|
1734 | ''' | |
|
1735 | if self.nLags == 16: | |
|
1736 | print(self.__buffer_spc[:,0,0,0,2]) | |
|
1737 | exit(1) | |
|
1738 | ''' | |
|
1739 | ||
|
1740 | buffer=None | |
|
1741 | #print(self.__buffer_spc[:,1,3,20,0]) | |
|
1742 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
1743 | data_spc = numpy.sum(self.__buffer_spc,axis=0) | |
|
1744 | ||
|
1745 | if self.__buffer_cspc is not None: | |
|
1746 | data_cspc = numpy.sum(self.__buffer_cspc,axis=0) | |
|
1747 | else: | |
|
1748 | data_cspc = None | |
|
1749 | ||
|
1750 | #print(numpy.shape(data_spc)) | |
|
1751 | #data_spc[1,4,20,0]=numpy.nan | |
|
1752 | ||
|
1753 | ||
|
1754 | data_dc = self.__buffer_dc | |
|
1755 | ||
|
1756 | n = self.__profIndex | |
|
1757 | ||
|
1758 | self.__buffer_spc = None | |
|
1759 | self.__buffer_cspc = None | |
|
1760 | self.__buffer_dc = 0 | |
|
1761 | self.__profIndex = 0 | |
|
1762 | ||
|
1763 | return data_spc, data_cspc, data_dc, n | |
|
1764 | ||
|
1765 | def pushData(self): | |
|
1766 | """ | |
|
1767 | Return the sum of the last profiles and the profiles used in the sum. | |
|
1768 | ||
|
1769 | Affected: | |
|
1770 | ||
|
1771 | self.__profileIndex | |
|
1772 | ||
|
1773 | """ | |
|
1774 | bufferH=None | |
|
1775 | buffer=None | |
|
1776 | buffer1=None | |
|
1777 | buffer_cspc=None | |
|
1778 | self.__buffer_spc=numpy.array(self.__buffer_spc) | |
|
1779 | if self.__buffer_cspc is not None: | |
|
1780 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) | |
|
1781 | freq_dc = int(self.__buffer_spc.shape[2] / 2) | |
|
1782 | #print("FREQ_DC",freq_dc) | |
|
1783 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
1784 | #lag_array=[0,2,4,6,8,10,12,14,16,18,20] | |
|
1785 | ||
|
1786 | if self.nLags == 11: | |
|
1787 | h0 = 7 | |
|
1788 | elif self.nLags == 16: | |
|
1789 | h0 = 180 | |
|
1790 | ||
|
1791 | ||
|
1792 | ||
|
1793 | ''' | |
|
1794 | import matplotlib.pyplot as plt | |
|
1795 | #plt.plot(self.__buffer_spc[:,0,freq_dc-2,33,1],marker='*') | |
|
1796 | aux = self.__buffer_spc[:,0,freq_dc-2,66,1] | |
|
1797 | a,b=self.hildebrand_sekhon_Integration(numpy.abs(aux),1) | |
|
1798 | print(a) | |
|
1799 | plt.plot(sorted(aux),marker='*') | |
|
1800 | plt.vlines(x=a,ymin=min(aux),ymax=max(aux)) | |
|
1801 | #plt.ylim((-35000,65000)) | |
|
1802 | plt.show() | |
|
1803 | import time | |
|
1804 | time.sleep(60) | |
|
1805 | exit(1) | |
|
1806 | ''' | |
|
1807 | ||
|
1808 | #print(self.nLags) | |
|
1809 | ''' | |
|
1810 | if self.nLags == 16: | |
|
1811 | self.nLags = 3 | |
|
1812 | #exit(1) | |
|
1813 | ''' | |
|
1814 | #print(self.nHeights) | |
|
1815 | #exit(1) | |
|
1816 | for l in range(self.nLags):#dataOut.DPL): #if DP --> nLags=11, elif HP --> nLags=16 | |
|
1817 | #breakFlag=False | |
|
1818 | for k in range(7,self.nHeights): | |
|
1819 | if self.__buffer_cspc is not None: | |
|
1820 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,0,:,k,l]) | |
|
1821 | outliers_IDs_cspc=[] | |
|
1822 | cspc_outliers_exist=False | |
|
1823 | #indexmin_cspc=0 | |
|
1824 | for i in range(2): #Solo nos interesa los 2 primeros canales que son los canales con señal | |
|
1825 | #for i in range(self.nChannels):#dataOut.nChannels): | |
|
1826 | #if self.TrueLags: | |
|
1827 | #print("HERE") | |
|
1828 | ''' | |
|
1829 | if i==1 and k >= self.nHeights-2*l and self.TrueLags: | |
|
1830 | #breakFlag=True | |
|
1831 | print("here") | |
|
1832 | exit(1) | |
|
1833 | continue | |
|
1834 | ''' | |
|
1835 | ||
|
1836 | #pass | |
|
1837 | #else: | |
|
1838 | buffer1=numpy.copy(self.__buffer_spc[:,i,:,k,l]) | |
|
1839 | indexes=[] | |
|
1840 | #sortIDs=[] | |
|
1841 | outliers_IDs=[] | |
|
1842 | for j in range(self.nProfiles): | |
|
1843 | if i==0 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 0 | |
|
1844 | continue | |
|
1845 | if self.FlipChannelsExist: | |
|
1846 | if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
1847 | continue | |
|
1848 | else: | |
|
1849 | if i==1 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
1850 | continue | |
|
1851 | #buffer=buffer1[:,j] | |
|
1852 | buffer=(buffer1[:,j]) | |
|
1853 | ''' | |
|
1854 | if self.nLags ==16 and l!=0: | |
|
1855 | print(buffer) | |
|
1856 | exit(1) | |
|
1857 | ''' | |
|
1858 | #index,sortID=self.hildebrand_sekhon_Integration(numpy.abs(buffer),1) | |
|
1859 | index=int(_HS_algorithm.HS_algorithm(numpy.sort(buffer, axis=None),1)) | |
|
1860 | sortID = buffer.argsort() | |
|
1861 | ||
|
1862 | indexes.append(index) | |
|
1863 | #sortIDs.append(sortID) | |
|
1864 | outliers_IDs=numpy.append(outliers_IDs,sortID[index:]) | |
|
1865 | ||
|
1866 | sortdata=numpy.sort(buffer,axis=0) | |
|
1867 | avg=numpy.mean(sortdata[:index],axis=0) | |
|
1868 | #lt=outliers_IDs | |
|
1869 | #avg=numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
1870 | ||
|
1871 | if index != buffer.shape[0]: | |
|
1872 | for p in list(sortID[index:]): | |
|
1873 | buffer1[p,j]=avg | |
|
1874 | ||
|
1875 | ||
|
1876 | self.__buffer_spc[:,i,j,k,l]=numpy.copy(buffer1[:,j]) | |
|
1877 | ###cspc IDs | |
|
1878 | #indexmin_cspc+=indexmin_cspc | |
|
1879 | if self.__buffer_cspc is not None: | |
|
1880 | outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) | |
|
1881 | ||
|
1882 | #if not breakFlag: | |
|
1883 | #print(outliers_IDs_cspc) | |
|
1884 | if self.__buffer_cspc is not None: | |
|
1885 | outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) | |
|
1886 | if cspc_outliers_exist: | |
|
1887 | #sortdata=numpy.sort(buffer_cspc,axis=0) | |
|
1888 | #avg=numpy.mean(sortdata[:indexmin_cpsc,:],axis=0) | |
|
1889 | lt=outliers_IDs_cspc | |
|
1890 | ||
|
1891 | avg=numpy.mean(buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:],axis=0) | |
|
1892 | for p in list(outliers_IDs_cspc): | |
|
1893 | buffer_cspc[p,:]=avg | |
|
1894 | ||
|
1895 | self.__buffer_cspc[:,0,:,k,l]=numpy.copy(buffer_cspc) | |
|
1896 | ||
|
1897 | #else: | |
|
1898 | #break | |
|
1899 | ''' | |
|
1900 | import matplotlib.pyplot as plt | |
|
1901 | plt.plot(sorted(self.__buffer_spc[:,0,freq_dc-2,66,1]),marker='*') | |
|
1902 | #plt.ylim((0,1.1*1.e6)) | |
|
1903 | plt.ylim((-30000,65000)) | |
|
1904 | plt.show() | |
|
1905 | import time | |
|
1906 | time.sleep(60) | |
|
1907 | exit(1) | |
|
1908 | ''' | |
|
1909 | ||
|
1910 | buffer=None | |
|
1911 | bufferH=None | |
|
1912 | buffer1=None | |
|
1913 | buffer_cspc=None | |
|
1914 | ||
|
1915 | #print("cpsc",self.__buffer_cspc[:,0,0,0,0]) | |
|
1916 | #print(self.__profIndex) | |
|
1917 | #exit() | |
|
1918 | ''' | |
|
1919 | if self.nLags == 16: | |
|
1920 | print(self.__buffer_spc[:,0,0,0,2]) | |
|
1921 | exit(1) | |
|
1922 | ''' | |
|
1923 | ||
|
1924 | buffer=None | |
|
1925 | #print(self.__buffer_spc[:,1,3,20,0]) | |
|
1926 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
1927 | data_spc = numpy.sum(self.__buffer_spc,axis=0) | |
|
1928 | ||
|
1929 | if self.__buffer_cspc is not None: | |
|
1930 | data_cspc = numpy.sum(self.__buffer_cspc,axis=0) | |
|
1931 | else: | |
|
1932 | data_cspc = None | |
|
1933 | ||
|
1934 | #print(numpy.shape(data_spc)) | |
|
1935 | #data_spc[1,4,20,0]=numpy.nan | |
|
1936 | ||
|
1937 | ||
|
1938 | data_dc = self.__buffer_dc | |
|
1939 | ||
|
1940 | n = self.__profIndex | |
|
1941 | ||
|
1942 | self.__buffer_spc = None | |
|
1943 | self.__buffer_cspc = None | |
|
1944 | self.__buffer_dc = 0 | |
|
1945 | self.__profIndex = 0 | |
|
1946 | ||
|
1947 | return data_spc, data_cspc, data_dc, n | |
|
1948 | ||
|
1949 | def byProfiles(self, data_spc, data_cspc, *args): | |
|
1950 | ||
|
1951 | self.__dataReady = False | |
|
1952 | avgdata_spc = None | |
|
1953 | avgdata_cspc = None | |
|
1954 | avgdata_dc = None | |
|
1955 | ||
|
1956 | self.putData(data_spc, data_cspc, *args) | |
|
1957 | ||
|
1958 | if self.__profIndex == self.n: | |
|
1959 | ||
|
1960 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
|
1961 | self.n = n | |
|
1962 | self.__dataReady = True | |
|
1963 | ||
|
1964 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
|
1965 | ||
|
1966 | def byTime(self, datatime, *args): | |
|
1967 | ||
|
1968 | self.__dataReady = False | |
|
1969 | avgdata_spc = None | |
|
1970 | avgdata_cspc = None | |
|
1971 | avgdata_dc = None | |
|
1972 | ||
|
1973 | self.putData(*args) | |
|
1974 | ||
|
1975 | if (datatime - self.__initime) >= self.__integrationtime: | |
|
1976 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
|
1977 | self.n = n | |
|
1978 | self.__dataReady = True | |
|
1979 | ||
|
1980 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
|
1981 | ||
|
1982 | def integrate(self, datatime, data_spc, data_cspc, *args): | |
|
1983 | ||
|
1984 | if self.__profIndex == 0: | |
|
1985 | self.__initime = datatime | |
|
1986 | #print(data_cspc.shape) | |
|
1987 | ||
|
1988 | #self.__buffer_spc = numpy.empty_like(data_spc,shape=(self.n,self.nChannels,self.nProfiles,self.nHeights,self.nLags)) | |
|
1989 | self.__buffer_spc = numpy.ones_like(data_spc,shape=(self.n,self.nChannels,self.nProfiles,self.nHeights,self.nLags))*numpy.NAN | |
|
1990 | ||
|
1991 | #print(self.__buffer_spc[0]) | |
|
1992 | #print(self.__buffer_spc.dtype) | |
|
1993 | #print(data_spc.dtype) | |
|
1994 | ||
|
1995 | if data_cspc is not None: | |
|
1996 | nLags = numpy.shape(data_cspc)[-1] | |
|
1997 | nCrossChannels = numpy.shape(data_cspc)[0] | |
|
1998 | ||
|
1999 | #self.__buffer_cspc = numpy.empty_like(data_cspc,shape=(self.n,crossChannels,self.nProfiles,self.nHeights,self.nLags)) | |
|
2000 | self.__buffer_cspc = numpy.ones_like(data_cspc,shape=(self.n,nCrossChannels,self.nProfiles,self.nHeights,nLags))*numpy.NAN | |
|
2001 | else: | |
|
2002 | self.__buffer_cspc = None | |
|
2003 | #print("HEREEEE") | |
|
2004 | #print(self.__buffer_cspc.dtype) | |
|
2005 | #print(data_cspc.dtype) | |
|
2006 | #exit(1) | |
|
2007 | if self.__byTime: | |
|
2008 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime( | |
|
2009 | datatime, *args) | |
|
2010 | else: | |
|
2011 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(data_spc, data_cspc, *args) | |
|
2012 | ||
|
2013 | if not self.__dataReady: | |
|
2014 | return None, None, None, None | |
|
2015 | ||
|
2016 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc | |
|
2017 | ||
|
2018 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False,TrueLags=True): | |
|
2019 | if n == 1: | |
|
2020 | return dataOut | |
|
2021 | ||
|
2022 | dataOut.flagNoData = True | |
|
2023 | ||
|
2024 | if not self.isConfig: | |
|
2025 | self.setup(n, timeInterval, overlapping) | |
|
2026 | try: | |
|
2027 | dataOut.FlipChannels | |
|
2028 | self.FlipChannelsExist=1 | |
|
2029 | except: | |
|
2030 | self.FlipChannelsExist=0 | |
|
2031 | self.isConfig = True | |
|
2032 | ||
|
2033 | self.nProfiles=dataOut.nProfiles | |
|
2034 | self.nChannels=dataOut.nChannels | |
|
2035 | self.nHeights=dataOut.nHeights | |
|
2036 | if not dataOut.ByLags: | |
|
2037 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, | |
|
2038 | dataOut.data_spc, | |
|
2039 | dataOut.data_cspc, | |
|
2040 | dataOut.data_dc) | |
|
2041 | else: | |
|
2042 | #self.nProfiles=dataOut.nProfiles | |
|
2043 | #self.nChannels=dataOut.nChannels | |
|
2044 | #self.nHeights=dataOut.nHeights | |
|
2045 | self.nLags=dataOut.nLags | |
|
2046 | self.TrueLags=TrueLags | |
|
2047 | ||
|
2048 | ||
|
2049 | ||
|
2050 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, | |
|
2051 | dataOut.dataLag_spc, | |
|
2052 | dataOut.dataLag_cspc, | |
|
2053 | dataOut.dataLag_dc) | |
|
2054 | ||
|
2055 | if self.__dataReady: | |
|
2056 | ||
|
2057 | if not dataOut.ByLags: | |
|
2058 | dataOut.data_spc = avgdata_spc | |
|
2059 | dataOut.data_cspc = avgdata_cspc | |
|
2060 | dataOut.data_dc = avgdata_dc | |
|
2061 | else: | |
|
2062 | dataOut.dataLag_spc = avgdata_spc | |
|
2063 | dataOut.dataLag_cspc = avgdata_cspc | |
|
2064 | dataOut.dataLag_dc = avgdata_dc | |
|
2065 | ||
|
2066 | dataOut.data_spc=dataOut.dataLag_spc[:,:,:,dataOut.LagPlot].real | |
|
2067 | ||
|
2068 | if self.__buffer_cspc is not None: | |
|
2069 | dataOut.data_cspc=dataOut.dataLag_cspc[:,:,:,dataOut.LagPlot] | |
|
2070 | dataOut.data_dc=dataOut.dataLag_dc[:,:,dataOut.LagPlot] | |
|
2071 | ||
|
2072 | ||
|
2073 | dataOut.nIncohInt *= self.n | |
|
2074 | dataOut.utctime = avgdatatime | |
|
2075 | dataOut.flagNoData = False | |
|
2076 | ||
|
2077 | return dataOut | |
|
2078 | ||
|
2079 | class IntegrationFaradaySpectra3(Operation): #This class should manage data with no lags as well | |
|
2080 | ''' | |
|
2081 | Written by R. Flores | |
|
2082 | ''' | |
|
2083 | __profIndex = 0 | |
|
2084 | __withOverapping = False | |
|
2085 | ||
|
2086 | __byTime = False | |
|
2087 | __initime = None | |
|
2088 | __lastdatatime = None | |
|
2089 | __integrationtime = None | |
|
2090 | ||
|
2091 | __buffer_spc = None | |
|
2092 | __buffer_cspc = None | |
|
2093 | __buffer_dc = None | |
|
2094 | ||
|
2095 | __dataReady = False | |
|
2096 | ||
|
2097 | __timeInterval = None | |
|
2098 | ||
|
2099 | n = None | |
|
2100 | ||
|
2101 | def __init__(self): | |
|
2102 | ||
|
2103 | Operation.__init__(self) | |
|
2104 | ||
|
2105 | def setup(self, n=None, timeInterval=None, overlapping=False): | |
|
2106 | """ | |
|
2107 | Set the parameters of the integration class. | |
|
2108 | ||
|
2109 | Inputs: | |
|
2110 | ||
|
2111 | n : Number of coherent integrations | |
|
2112 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
|
2113 | overlapping : | |
|
2114 | ||
|
2115 | """ | |
|
2116 | ||
|
2117 | self.__initime = None | |
|
2118 | self.__lastdatatime = 0 | |
|
2119 | ||
|
2120 | self.__buffer_spc = None | |
|
2121 | self.__buffer_cspc = None | |
|
2122 | self.__buffer_dc = 0 | |
|
2123 | ||
|
2124 | self.__profIndex = 0 | |
|
2125 | self.__dataReady = False | |
|
2126 | self.__byTime = False | |
|
2127 | ||
|
2128 | if n is None and timeInterval is None: | |
|
2129 | raise ValueError("n or timeInterval should be specified ...") | |
|
2130 | ||
|
2131 | if n is not None: | |
|
2132 | self.n = int(n) | |
|
2133 | else: | |
|
2134 | ||
|
2135 | self.__integrationtime = int(timeInterval) | |
|
2136 | self.n = None | |
|
2137 | self.__byTime = True | |
|
2138 | ||
|
2139 | def putData(self, data_spc, data_cspc, data_dc): | |
|
2140 | """ | |
|
2141 | Add a profile to the __buffer_spc and increase in one the __profileIndex | |
|
2142 | ||
|
2143 | """ | |
|
2144 | ||
|
2145 | #print(numpy.shape(self.__buffer_spc)) | |
|
2146 | ##print(numpy.shape(data_spc)) | |
|
2147 | ||
|
2148 | #self.__buffer_spc = numpy.insert(self.__buffer_spc,[],data_spc,axis=0) | |
|
2149 | self.__buffer_spc[self.__profIndex,:]=data_spc[:] | |
|
2150 | ##self.__buffer_spc.append(data_spc) | |
|
2151 | #self.__buffer_spc = numpy.array(self.__buffer_spc) | |
|
2152 | #print(numpy.shape(self.__buffer_spc)) | |
|
2153 | #print("bytes",sys.getsizeof(self.__buffer_spc)) | |
|
2154 | #print("bytes",asizeof(self.__buffer_spc)) | |
|
2155 | if self.clean_cspc: | |
|
2156 | if data_cspc is None: | |
|
2157 | self.__buffer_cspc = None | |
|
2158 | ||
|
2159 | else: | |
|
2160 | self.__buffer_cspc[self.__profIndex,:]=data_cspc[:] | |
|
2161 | else: | |
|
2162 | self.__buffer_cspc += data_cspc | |
|
2163 | ||
|
2164 | if data_dc is None: | |
|
2165 | self.__buffer_dc = None | |
|
2166 | else: | |
|
2167 | self.__buffer_dc += data_dc | |
|
2168 | ||
|
2169 | self.__profIndex += 1 | |
|
2170 | ||
|
2171 | return | |
|
2172 | ||
|
2173 | def hildebrand_sekhon_Integration(self,data,navg): | |
|
2174 | ||
|
2175 | sortdata = numpy.sort(data, axis=None) | |
|
2176 | sortID=data.argsort() | |
|
2177 | lenOfData = len(sortdata) | |
|
2178 | nums_min = lenOfData*0.75 | |
|
2179 | if nums_min <= 5: | |
|
2180 | nums_min = 5 | |
|
2181 | sump = 0. | |
|
2182 | sumq = 0. | |
|
2183 | j = 0 | |
|
2184 | cont = 1 | |
|
2185 | while((cont == 1)and(j < lenOfData)): | |
|
2186 | sump += sortdata[j] | |
|
2187 | sumq += sortdata[j]**2 | |
|
2188 | if j > nums_min: | |
|
2189 | rtest = float(j)/(j-1) + 1.0/navg | |
|
2190 | if ((sumq*j) > (rtest*sump**2)): | |
|
2191 | j = j - 1 | |
|
2192 | sump = sump - sortdata[j] | |
|
2193 | sumq = sumq - sortdata[j]**2 | |
|
2194 | cont = 0 | |
|
2195 | j += 1 | |
|
2196 | #lnoise = sump / j | |
|
2197 | ||
|
2198 | return j,sortID | |
|
2199 | ||
|
2200 | def pushData_V0(self): | |
|
2201 | """ | |
|
2202 | Return the sum of the last profiles and the profiles used in the sum. | |
|
2203 | ||
|
2204 | Affected: | |
|
2205 | ||
|
2206 | self.__profileIndex | |
|
2207 | ||
|
2208 | """ | |
|
2209 | bufferH=None | |
|
2210 | buffer=None | |
|
2211 | buffer1=None | |
|
2212 | buffer_cspc=None | |
|
2213 | self.__buffer_spc=numpy.array(self.__buffer_spc) | |
|
2214 | if self.__buffer_cspc is not None: | |
|
2215 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) | |
|
2216 | freq_dc = int(self.__buffer_spc.shape[2] / 2) | |
|
2217 | #print("FREQ_DC",freq_dc) | |
|
2218 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
2219 | #lag_array=[0,2,4,6,8,10,12,14,16,18,20] | |
|
2220 | ||
|
2221 | if self.nLags == 11: | |
|
2222 | h0 = 7 | |
|
2223 | elif self.nLags == 16: | |
|
2224 | h0 = 180 | |
|
2225 | ||
|
2226 | ||
|
2227 | ''' | |
|
2228 | import matplotlib.pyplot as plt | |
|
2229 | plt.plot(self.__buffer_spc[:,0,freq_dc,33,0],marker='*') | |
|
2230 | plt.ylim((0,700000)) | |
|
2231 | plt.show() | |
|
2232 | import time | |
|
2233 | time.sleep(60) | |
|
2234 | exit(1) | |
|
2235 | ''' | |
|
2236 | #''' | |
|
2237 | import matplotlib.pyplot as plt | |
|
2238 | #plt.plot(self.__buffer_spc[:,0,freq_dc-2,33,1],marker='*') | |
|
2239 | plt.plot(sorted(self.__buffer_spc[:,0,freq_dc-2,33,1]),marker='*') | |
|
2240 | plt.ylim((0,1.1*1.e6)) | |
|
2241 | plt.show() | |
|
2242 | import time | |
|
2243 | time.sleep(60) | |
|
2244 | exit(1) | |
|
2245 | #''' | |
|
2246 | ||
|
2247 | print(self.nLags) | |
|
2248 | ''' | |
|
2249 | if self.nLags == 16: | |
|
2250 | self.nLags = 0 | |
|
2251 | #exit(1) | |
|
2252 | ''' | |
|
2253 | ||
|
2254 | for l in range(self.nLags):#dataOut.DPL): | |
|
2255 | #breakFlag=False | |
|
2256 | for k in range(7,self.nHeights): | |
|
2257 | if self.__buffer_cspc is not None: | |
|
2258 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,0,:,k,l]) | |
|
2259 | outliers_IDs_cspc=[] | |
|
2260 | cspc_outliers_exist=False | |
|
2261 | #indexmin_cspc=0 | |
|
2262 | for i in range(2): | |
|
2263 | #for i in range(self.nChannels):#dataOut.nChannels): | |
|
2264 | #if self.TrueLags: | |
|
2265 | #print("HERE") | |
|
2266 | if i==1 and k >= self.nHeights-2*l and self.TrueLags: | |
|
2267 | #breakFlag=True | |
|
2268 | continue | |
|
2269 | ||
|
2270 | #pass | |
|
2271 | else: | |
|
2272 | buffer1=numpy.copy(self.__buffer_spc[:,i,:,k,l]) | |
|
2273 | indexes=[] | |
|
2274 | #sortIDs=[] | |
|
2275 | outliers_IDs=[] | |
|
2276 | for j in range(self.nProfiles): | |
|
2277 | if i==0 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 0 | |
|
2278 | continue | |
|
2279 | if self.FlipChannelsExist: | |
|
2280 | if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
2281 | continue | |
|
2282 | else: | |
|
2283 | if i==1 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
2284 | continue | |
|
2285 | #buffer=buffer1[:,j] | |
|
2286 | buffer=(buffer1[:,j]).real | |
|
2287 | ''' | |
|
2288 | if self.nLags ==16 and l!=0: | |
|
2289 | print(buffer) | |
|
2290 | exit(1) | |
|
2291 | ''' | |
|
2292 | #index,sortID=self.hildebrand_sekhon_Integration(buffer,1) | |
|
2293 | index=int(_HS_algorithm.HS_algorithm(numpy.sort(buffer, axis=None),1)) | |
|
2294 | sortID = buffer.argsort() | |
|
2295 | ||
|
2296 | indexes.append(index) | |
|
2297 | #sortIDs.append(sortID) | |
|
2298 | outliers_IDs=numpy.append(outliers_IDs,sortID[index:]) | |
|
2299 | ||
|
2300 | outliers_IDs=numpy.array(outliers_IDs) | |
|
2301 | outliers_IDs=outliers_IDs.ravel() | |
|
2302 | outliers_IDs=numpy.unique(outliers_IDs) | |
|
2303 | outliers_IDs=outliers_IDs.astype(numpy.dtype('int64')) | |
|
2304 | indexes=numpy.array(indexes) | |
|
2305 | indexmin=numpy.min(indexes) | |
|
2306 | ||
|
2307 | if indexmin != buffer1.shape[0]: | |
|
2308 | cspc_outliers_exist=True | |
|
2309 | ###sortdata=numpy.sort(buffer1,axis=0) | |
|
2310 | ###avg2=numpy.mean(sortdata[:indexmin,:],axis=0) | |
|
2311 | lt=outliers_IDs | |
|
2312 | avg=numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
2313 | ||
|
2314 | ||
|
2315 | for p in list(outliers_IDs): | |
|
2316 | buffer1[p,:]=avg | |
|
2317 | ||
|
2318 | self.__buffer_spc[:,i,:,k,l]=numpy.copy(buffer1) | |
|
2319 | ###cspc IDs | |
|
2320 | #indexmin_cspc+=indexmin_cspc | |
|
2321 | if self.__buffer_cspc is not None: | |
|
2322 | outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) | |
|
2323 | ||
|
2324 | #if not breakFlag: | |
|
2325 | #print(outliers_IDs_cspc) | |
|
2326 | if self.__buffer_cspc is not None: | |
|
2327 | outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) | |
|
2328 | if cspc_outliers_exist: | |
|
2329 | #sortdata=numpy.sort(buffer_cspc,axis=0) | |
|
2330 | #avg=numpy.mean(sortdata[:indexmin_cpsc,:],axis=0) | |
|
2331 | lt=outliers_IDs_cspc | |
|
2332 | ||
|
2333 | avg=numpy.mean(buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:],axis=0) | |
|
2334 | for p in list(outliers_IDs_cspc): | |
|
2335 | buffer_cspc[p,:]=avg | |
|
2336 | ||
|
2337 | self.__buffer_cspc[:,0,:,k,l]=numpy.copy(buffer_cspc) | |
|
2338 | ||
|
2339 | #else: | |
|
2340 | #break | |
|
2341 | #''' | |
|
2342 | import matplotlib.pyplot as plt | |
|
2343 | plt.plot(self.__buffer_spc[:,0,freq_dc-2,33,1],marker='*') | |
|
2344 | plt.ylim((0,1.1*1.e6)) | |
|
2345 | plt.show() | |
|
2346 | import time | |
|
2347 | time.sleep(60) | |
|
2348 | exit(1) | |
|
2349 | #''' | |
|
2350 | ||
|
2351 | buffer=None | |
|
2352 | bufferH=None | |
|
2353 | buffer1=None | |
|
2354 | buffer_cspc=None | |
|
2355 | ||
|
2356 | #print("cpsc",self.__buffer_cspc[:,0,0,0,0]) | |
|
2357 | #print(self.__profIndex) | |
|
2358 | #exit() | |
|
2359 | ''' | |
|
2360 | if self.nLags == 16: | |
|
2361 | print(self.__buffer_spc[:,0,0,0,2]) | |
|
2362 | exit(1) | |
|
2363 | ''' | |
|
2364 | ||
|
2365 | buffer=None | |
|
2366 | #print(self.__buffer_spc[:,1,3,20,0]) | |
|
2367 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
2368 | data_spc = numpy.sum(self.__buffer_spc,axis=0) | |
|
2369 | ||
|
2370 | if self.__buffer_cspc is not None: | |
|
2371 | data_cspc = numpy.sum(self.__buffer_cspc,axis=0) | |
|
2372 | else: | |
|
2373 | data_cspc = None | |
|
2374 | ||
|
2375 | #print(numpy.shape(data_spc)) | |
|
2376 | #data_spc[1,4,20,0]=numpy.nan | |
|
2377 | ||
|
2378 | ||
|
2379 | data_dc = self.__buffer_dc | |
|
2380 | ||
|
2381 | n = self.__profIndex | |
|
2382 | ||
|
2383 | self.__buffer_spc = None | |
|
2384 | self.__buffer_cspc = None | |
|
2385 | self.__buffer_dc = 0 | |
|
2386 | self.__profIndex = 0 | |
|
2387 | ||
|
2388 | return data_spc, data_cspc, data_dc, n | |
|
2389 | ||
|
2390 | def pushData_ByLags(self): | |
|
2391 | """ | |
|
2392 | Return the sum of the last profiles and the profiles used in the sum. | |
|
2393 | ||
|
2394 | Affected: | |
|
2395 | ||
|
2396 | self.__profileIndex | |
|
2397 | ||
|
2398 | """ | |
|
2399 | bufferH=None | |
|
2400 | buffer=None | |
|
2401 | buffer1=None | |
|
2402 | buffer_cspc=None | |
|
2403 | self.__buffer_spc=numpy.array(self.__buffer_spc) | |
|
2404 | if self.__buffer_cspc is not None: | |
|
2405 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) | |
|
2406 | freq_dc = int(self.__buffer_spc.shape[2] / 2) | |
|
2407 | #print("FREQ_DC",freq_dc) | |
|
2408 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
2409 | #lag_array=[0,2,4,6,8,10,12,14,16,18,20] | |
|
2410 | ||
|
2411 | if self.nLags == 11: | |
|
2412 | h0 = 7 | |
|
2413 | elif self.nLags == 16: | |
|
2414 | h0 = 180 | |
|
2415 | ||
|
2416 | ||
|
2417 | ||
|
2418 | ''' | |
|
2419 | import matplotlib.pyplot as plt | |
|
2420 | #plt.plot(self.__buffer_spc[:,0,freq_dc-2,33,1],marker='*') | |
|
2421 | aux = self.__buffer_spc[:,0,freq_dc-2,66,1] | |
|
2422 | a,b=self.hildebrand_sekhon_Integration(numpy.abs(aux),1) | |
|
2423 | print(a) | |
|
2424 | plt.plot(sorted(aux),marker='*') | |
|
2425 | plt.vlines(x=a,ymin=min(aux),ymax=max(aux)) | |
|
2426 | #plt.ylim((-35000,65000)) | |
|
2427 | plt.show() | |
|
2428 | import time | |
|
2429 | time.sleep(60) | |
|
2430 | exit(1) | |
|
2431 | ''' | |
|
2432 | ||
|
2433 | print(self.nLags) | |
|
2434 | ''' | |
|
2435 | if self.nLags == 16: | |
|
2436 | self.nLags = 3 | |
|
2437 | #exit(1) | |
|
2438 | ''' | |
|
2439 | #print(self.nHeights) | |
|
2440 | #exit(1) | |
|
2441 | for l in range(self.nLags):#dataOut.DPL): | |
|
2442 | #breakFlag=False | |
|
2443 | for k in range(7,self.nHeights): | |
|
2444 | if self.__buffer_cspc is not None: | |
|
2445 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,0,:,k,l]) | |
|
2446 | outliers_IDs_cspc=[] | |
|
2447 | cspc_outliers_exist=False | |
|
2448 | #indexmin_cspc=0 | |
|
2449 | for i in range(2): | |
|
2450 | #for i in range(self.nChannels):#dataOut.nChannels): | |
|
2451 | #if self.TrueLags: | |
|
2452 | #print("HERE") | |
|
2453 | ''' | |
|
2454 | if i==1 and k >= self.nHeights-2*l and self.TrueLags: | |
|
2455 | #breakFlag=True | |
|
2456 | print("here") | |
|
2457 | exit(1) | |
|
2458 | continue | |
|
2459 | ''' | |
|
2460 | ||
|
2461 | #pass | |
|
2462 | #else: | |
|
2463 | buffer1=numpy.copy(self.__buffer_spc[:,i,:,k,l]) | |
|
2464 | indexes=[] | |
|
2465 | #sortIDs=[] | |
|
2466 | outliers_IDs=[] | |
|
2467 | for j in range(self.nProfiles): | |
|
2468 | if i==0 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 0 | |
|
2469 | continue | |
|
2470 | if self.FlipChannelsExist: | |
|
2471 | if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
2472 | continue | |
|
2473 | else: | |
|
2474 | if i==1 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
2475 | continue | |
|
2476 | #buffer=buffer1[:,j] | |
|
2477 | buffer=(buffer1[:,j]) | |
|
2478 | ''' | |
|
2479 | if self.nLags ==16 and l!=0: | |
|
2480 | print(buffer) | |
|
2481 | exit(1) | |
|
2482 | ''' | |
|
2483 | #index,sortID=self.hildebrand_sekhon_Integration(numpy.abs(buffer),1) | |
|
2484 | index=int(_HS_algorithm.HS_algorithm(numpy.sort(buffer, axis=None),1)) | |
|
2485 | sortID = buffer.argsort() | |
|
1170 | Set the parameters of the integration class. | |
|
2486 | 1171 | |
|
2487 | indexes.append(index) | |
|
2488 | #sortIDs.append(sortID) | |
|
2489 | outliers_IDs=numpy.append(outliers_IDs,sortID[index:]) | |
|
1172 | Inputs: | |
|
2490 | 1173 | |
|
2491 | sortdata=numpy.sort(buffer,axis=0) | |
|
2492 | avg=numpy.mean(sortdata[:index],axis=0) | |
|
2493 | #lt=outliers_IDs | |
|
2494 | #avg=numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
1174 | n : Number of coherent integrations | |
|
1175 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
|
1176 | overlapping : | |
|
2495 | 1177 | |
|
2496 | if index != buffer.shape[0]: | |
|
2497 | for p in list(sortID[index:]): | |
|
2498 | buffer1[p,j]=avg | |
|
1178 | """ | |
|
2499 | 1179 | |
|
1180 | self.__initime = None | |
|
1181 | self.__lastdatatime = 0 | |
|
2500 | 1182 | |
|
2501 | self.__buffer_spc[:,i,j,k,l]=numpy.copy(buffer1[:,j]) | |
|
2502 | ###cspc IDs | |
|
2503 | #indexmin_cspc+=indexmin_cspc | |
|
2504 | if self.__buffer_cspc is not None: | |
|
2505 | outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) | |
|
1183 | self.__buffer_spc = [] | |
|
1184 | self.__buffer_cspc = [] | |
|
1185 | self.__buffer_dc = 0 | |
|
2506 | 1186 | |
|
2507 | #if not breakFlag: | |
|
2508 | #print(outliers_IDs_cspc) | |
|
2509 | if self.__buffer_cspc is not None: | |
|
2510 | outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) | |
|
2511 | if cspc_outliers_exist: | |
|
2512 | #sortdata=numpy.sort(buffer_cspc,axis=0) | |
|
2513 | #avg=numpy.mean(sortdata[:indexmin_cpsc,:],axis=0) | |
|
2514 | lt=outliers_IDs_cspc | |
|
1187 | self.__profIndex = 0 | |
|
1188 | self.__dataReady = False | |
|
1189 | self.__byTime = False | |
|
2515 | 1190 | |
|
2516 | avg=numpy.mean(buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:],axis=0) | |
|
2517 | for p in list(outliers_IDs_cspc): | |
|
2518 | buffer_cspc[p,:]=avg | |
|
1191 | if n is None and timeInterval is None: | |
|
1192 | raise ValueError("n or timeInterval should be specified ...") | |
|
2519 | 1193 | |
|
2520 | self.__buffer_cspc[:,0,:,k,l]=numpy.copy(buffer_cspc) | |
|
1194 | if n is not None: | |
|
1195 | self.n = int(n) | |
|
1196 | else: | |
|
2521 | 1197 | |
|
2522 | #else: | |
|
2523 | #break | |
|
2524 | ''' | |
|
2525 | import matplotlib.pyplot as plt | |
|
2526 | plt.plot(sorted(self.__buffer_spc[:,0,freq_dc-2,66,1]),marker='*') | |
|
2527 | #plt.ylim((0,1.1*1.e6)) | |
|
2528 | plt.ylim((-30000,65000)) | |
|
2529 | plt.show() | |
|
2530 | import time | |
|
2531 | time.sleep(60) | |
|
2532 | exit(1) | |
|
2533 | ''' | |
|
1198 | self.__integrationtime = int(timeInterval) | |
|
1199 | self.n = None | |
|
1200 | self.__byTime = True | |
|
2534 | 1201 | |
|
2535 | buffer=None | |
|
2536 | bufferH=None | |
|
2537 | buffer1=None | |
|
2538 | buffer_cspc=None | |
|
1202 | def putData(self, data_spc, data_cspc, data_dc): | |
|
1203 | """ | |
|
1204 | Add a profile to the __buffer_spc and increase in one the __profileIndex | |
|
1205 | """ | |
|
2539 | 1206 | |
|
2540 | #print("cpsc",self.__buffer_cspc[:,0,0,0,0]) | |
|
2541 | #print(self.__profIndex) | |
|
2542 | #exit() | |
|
2543 | ''' | |
|
2544 | if self.nLags == 16: | |
|
2545 | print(self.__buffer_spc[:,0,0,0,2]) | |
|
2546 | exit(1) | |
|
2547 | ''' | |
|
1207 | self.__buffer_spc.append(data_spc) | |
|
2548 | 1208 | |
|
2549 | buffer=None | |
|
2550 | #print(self.__buffer_spc[:,1,3,20,0]) | |
|
2551 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
2552 | data_spc = numpy.sum(self.__buffer_spc,axis=0) | |
|
2553 | 1209 | |
|
2554 |
if |
|
|
2555 |
|
|
|
1210 | if data_cspc is None: | |
|
1211 | self.__buffer_cspc = None | |
|
2556 | 1212 |
else: |
|
2557 | data_cspc = None | |
|
1213 | self.__buffer_cspc.append(data_cspc) | |
|
2558 | 1214 | |
|
2559 | #print(numpy.shape(data_spc)) | |
|
2560 | #data_spc[1,4,20,0]=numpy.nan | |
|
1215 | if data_dc is None: | |
|
1216 | self.__buffer_dc = None | |
|
1217 | else: | |
|
1218 | self.__buffer_dc += data_dc | |
|
2561 | 1219 | |
|
1220 | self.__profIndex += 1 | |
|
2562 | 1221 | |
|
2563 | data_dc = self.__buffer_dc | |
|
1222 | return | |
|
2564 | 1223 | |
|
2565 | n = self.__profIndex | |
|
1224 | def hildebrand_sekhon_Integration_V2(self,data,navg): | |
|
1225 | sortdata = numpy.sort(data, axis=None) | |
|
1226 | sortID=data.argsort() | |
|
1227 | lenOfData = len(sortdata) | |
|
1228 | nums_min = lenOfData*0.75 | |
|
1229 | if nums_min <= 5: | |
|
1230 | nums_min = 5 | |
|
1231 | sump = 0. | |
|
1232 | sumq = 0. | |
|
1233 | j = 0 | |
|
1234 | cont = 1 | |
|
1235 | while((cont == 1)and(j < lenOfData)): | |
|
1236 | sump += sortdata[j] | |
|
1237 | sumq += sortdata[j]**2 | |
|
1238 | if j > nums_min: | |
|
1239 | P = sump / j | |
|
1240 | Q = sumq/j - P **2 | |
|
1241 | R2 = P**2/(Q*navg) | |
|
1242 | if R2 < 1: | |
|
1243 | j = j - 1 | |
|
1244 | sump = sump - sortdata[j] | |
|
1245 | sumq = sumq - sortdata[j]**2 | |
|
1246 | cont = 0 | |
|
1247 | j += 1 | |
|
1248 | #lnoise = sump / j | |
|
2566 | 1249 | |
|
2567 | self.__buffer_spc = None | |
|
2568 | self.__buffer_cspc = None | |
|
2569 | self.__buffer_dc = 0 | |
|
2570 | self.__profIndex = 0 | |
|
1250 | return j,sortID | |
|
2571 | 1251 | |
|
2572 | return data_spc, data_cspc, data_dc, n | |
|
1252 | def hildebrand_sekhon_Integration(self,data,navg): | |
|
1253 | sortdata = numpy.sort(data, axis=None) | |
|
1254 | sortID=data.argsort() | |
|
1255 | lenOfData = len(sortdata) | |
|
1256 | nums_min = lenOfData*0.75 #*0.87 | |
|
1257 | if nums_min <= 5: | |
|
1258 | nums_min = 5 | |
|
1259 | sump = 0. | |
|
1260 | sumq = 0. | |
|
1261 | j = 0 | |
|
1262 | cont = 1 | |
|
1263 | while((cont == 1)and(j < lenOfData)): | |
|
1264 | sump += sortdata[j] | |
|
1265 | sumq += sortdata[j]**2 | |
|
1266 | if j > nums_min: | |
|
1267 | rtest = float(j)/(j-1) + 1.0/navg | |
|
1268 | if ((sumq*j) > (rtest*sump**2)): | |
|
1269 | j = j - 1 | |
|
1270 | sump = sump - sortdata[j] | |
|
1271 | sumq = sumq - sortdata[j]**2 | |
|
1272 | cont = 0 | |
|
1273 | j += 1 | |
|
1274 | #lnoise = sump / j | |
|
1275 | ||
|
1276 | return j,sortID | |
|
2573 | 1277 | |
|
2574 | 1278 |
def pushData(self): |
|
2575 | 1279 |
""" |
@@ -2584,126 +1288,200 class IntegrationFaradaySpectra3(Operation): #This class should manage data with | |||
|
2584 | 1288 |
buffer=None |
|
2585 | 1289 |
buffer1=None |
|
2586 | 1290 |
buffer_cspc=None |
|
1291 | ||
|
2587 | 1292 |
self.__buffer_spc=numpy.array(self.__buffer_spc) |
|
2588 |
|
|
|
2589 | self.__buffer_cspc=numpy.array(self.__buffer_cspc) | |
|
1293 | self.__buffer_cspc = numpy.array(self.__buffer_cspc) | |
|
1294 | ||
|
2590 | 1295 |
freq_dc = int(self.__buffer_spc.shape[2] / 2) |
|
1296 | #print("FREQ_DC",freq_dc) | |
|
1297 | #print(self.__buffer_spc[:,1,5,37,0]) | |
|
1298 | #lag_array=[0,2,4,6,8,10,12,14,16,18,20] | |
|
2591 | 1299 | |
|
2592 | for k in range(7,self.nHeights): | |
|
2593 | if self.__buffer_cspc is not None and self.clean_cspc: | |
|
2594 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,0,:,k]) | |
|
2595 | outliers_IDs_cspc=[] | |
|
2596 | cspc_outliers_exist=False | |
|
1300 | ''' | |
|
1301 | l lags | |
|
1302 | k heights | |
|
1303 | i channel | |
|
1304 | j profiles | |
|
2597 | 1305 | |
|
2598 | for i in range(2): | |
|
1306 | Buffer_cspc and spc with dimensions | |
|
1307 | [integration number(n), channel, profile, height, lag] | |
|
1308 | ''' | |
|
2599 | 1309 | |
|
2600 | #else: | |
|
2601 | buffer1=numpy.copy(self.__buffer_spc[:,i,:,k]) | |
|
2602 | indexes=[] | |
|
2603 | #sortIDs=[] | |
|
2604 |
outliers_IDs=[] |
|
|
2605 | for j in range(self.nProfiles): | |
|
2606 | if i==0 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 0 | |
|
1310 | for l in range(self.DPL):#dataOut.DPL): | |
|
1311 | #breakFlag=False | |
|
1312 | for k in range(7,self.nHeights): | |
|
1313 | buffer_cspc=numpy.copy(self.__buffer_cspc[:,0,:,k,l]) | |
|
1314 | outliers_IDs_cspc=[] | |
|
1315 | cspc_outliers_exist=False | |
|
1316 | #indexmin_cspc=0 | |
|
1317 | for i in range(self.nChannels): #dataOut.nChannels): | |
|
1318 | ''' Recognition of index with outliers''' | |
|
1319 | if i==1 and k >= self.nHeights-2*l: | |
|
1320 | #breakFlag=True | |
|
2607 | 1321 |
continue |
|
2608 |
|
|
|
2609 | if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
2610 | continue | |
|
1322 | #pass | |
|
2611 | 1323 |
else: |
|
2612 | if i==1 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
2613 |
|
|
|
2614 |
|
|
|
2615 |
|
|
|
2616 | ||
|
2617 | #index,sortID=self.hildebrand_sekhon_Integration(numpy.abs(buffer),1) | |
|
2618 | index=int(_HS_algorithm.HS_algorithm(numpy.sort(buffer, axis=None),1)) | |
|
2619 | sortID = buffer.argsort() | |
|
2620 | ||
|
2621 | indexes.append(index) | |
|
2622 | #sortIDs.append(sortID) | |
|
2623 | outliers_IDs=numpy.append(outliers_IDs,sortID[index:]) | |
|
2624 | ||
|
2625 |
|
|
|
2626 | avg=numpy.mean(sortdata[:index],axis=0) | |
|
2627 | #lt=outliers_IDs | |
|
2628 | #avg=numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
2629 | ||
|
2630 | if index != buffer.shape[0]: | |
|
2631 |
|
|
|
2632 |
|
|
|
1324 | buffer1=numpy.copy(self.__buffer_spc[:,i,:,k,l]) # [int, profile] | |
|
1325 | indexes=[] | |
|
1326 | #sortIDs=[] | |
|
1327 | outliers_IDs=[] | |
|
1328 | for j in range(self.nProfiles): | |
|
1329 | if i==0 and j==freq_dc: #NOT CONSIDERING DC PROFILE AT CHANNEL 0 | |
|
1330 | continue | |
|
1331 | if i==1 and j==0: #NOT CONSIDERING DC PROFILE AT CHANNEL 1 | |
|
1332 | continue | |
|
1333 | buffer=buffer1[:,j] # [int] | |
|
1334 | ||
|
1335 | '''Finding the outlier index with Hildebrand Sekhon algorithm''' | |
|
1336 | index=int(_HS_algorithm.HS_algorithm(numpy.sort(buffer, axis=None),1)) | |
|
1337 | sortID = buffer.argsort() | |
|
1338 | #index,sortID=self.hildebrand_sekhon_Integration(buffer,1) | |
|
1339 | indexes.append(index) | |
|
1340 | ||
|
1341 | #sortIDs.append(sortID) | |
|
1342 | outliers_IDs = numpy.append(outliers_IDs, sortID[index:]) | |
|
1343 | ||
|
1344 | ''' | |
|
1345 | #if k == 39 or k == 38: | |
|
1346 | m = 2. | |
|
1347 | d = numpy.abs(buffer - numpy.median(buffer)) | |
|
1348 | mdev = numpy.median(d) | |
|
1349 | s=d / mdev if mdev else numpy.zeros(len(d)) | |
|
1350 | outliers_IDs2 = numpy.where(s >= m)[0] | |
|
1351 | outliers_IDs2 = numpy.sort(numpy.concatenate((sortID[index:], outliers_IDs2))) | |
|
1352 | #print(sortID[index:], outliers_IDs2) | |
|
1353 | outliers_IDs = numpy.append(outliers_IDs, outliers_IDs2) | |
|
1354 | ''' | |
|
1355 | ||
|
1356 | ''' | |
|
1357 | # | |
|
1358 | if k == 39: | |
|
1359 | print("channel", i, " Profile", j, " Buffer:", buffer) | |
|
1360 | ||
|
1361 | print("outliers_IDs ", sortID[index:]) | |
|
1362 | outliers_IDs_buffer = numpy.array(sortID[index:],dtype = int) | |
|
1363 | NUM=numpy.size(buffer) | |
|
1364 | plt.plot(range(NUM), buffer, 'b') | |
|
1365 | plt.plot(outliers_IDs_buffer, buffer[numpy.array(outliers_IDs_buffer,dtype = int)], 'r.', label='Outliers') | |
|
1366 | text_time = datetime.datetime.utcfromtimestamp(self.__initime) | |
|
1367 | title = '{}Height{}km_Ch{}_Lag{}_Profile{}.png'.format(text_time,k*15,i,l,j) | |
|
1368 | plt.title(title) | |
|
1369 | plt.savefig('{}.png'.format(title),dpi = 50) | |
|
1370 | plt.clf() | |
|
1371 | ''' | |
|
1372 | ||
|
1373 | ||
|
1374 | ||
|
1375 | ||
|
2633 | 1376 | |
|
1377 | outliers_IDs=numpy.array(outliers_IDs) | |
|
1378 | outliers_IDs=outliers_IDs.ravel() | |
|
1379 | outliers_IDs=numpy.unique(outliers_IDs) | |
|
1380 | outliers_IDs=outliers_IDs.astype(numpy.dtype('int64')) | |
|
1381 | indexes=numpy.array(indexes) | |
|
1382 | indexmin=numpy.min(indexes) | |
|
2634 | 1383 | |
|
2635 | self.__buffer_spc[:,i,j,k]=numpy.copy(buffer1[:,j]) | |
|
2636 | ###cspc IDs | |
|
2637 | #indexmin_cspc+=indexmin_cspc | |
|
2638 | if self.__buffer_cspc is not None and self.clean_cspc: | |
|
1384 | #if indexmin != buffer1.shape[0]: | |
|
1385 | if (indexmin != buffer1.shape[0]): | |
|
1386 | cspc_outliers_exist=True | |
|
1387 | ###sortdata=numpy.sort(buffer1,axis=0) | |
|
1388 | ###avg2=numpy.mean(sortdata[:indexmin,:],axis=0) | |
|
1389 | lt = outliers_IDs | |
|
1390 | time_text = datetime.datetime.utcfromtimestamp(self.__initime) | |
|
1391 | '''Average profile signal value without taking account outleirs ''' | |
|
1392 | #if time_text.hour >= 11 or time_text.hour <= 19: | |
|
1393 | if True: | |
|
1394 | data_buffer1 = buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:] | |
|
1395 | (mu, sigma) = numpy.apply_along_axis(lambda x: norm.fit(x), 0, data_buffer1) | |
|
1396 | filtered_data = data_buffer1[(data_buffer1 >= 0) & (data_buffer1 <= 2 * mu[numpy.newaxis, :])] | |
|
1397 | avg = numpy.median(filtered_data, axis=0) | |
|
1398 | #avg=numpy.median(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
1399 | else: | |
|
1400 | avg=numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:],axis=0) | |
|
1401 | ||
|
1402 | ''' New outlier value take the average''' | |
|
1403 | for p in list(outliers_IDs): | |
|
1404 | buffer1[p,:] = avg | |
|
1405 | ||
|
1406 | else: | |
|
1407 | print("No average!!") | |
|
1408 | '''Reasignate the buffer 1 edition to the original buffer''' | |
|
1409 | self.__buffer_spc[:,i,:,k,l]=numpy.copy(buffer1) | |
|
1410 | ###cspc IDs | |
|
1411 | #indexmin_cspc+=indexmin_cspc | |
|
2639 | 1412 |
outliers_IDs_cspc=numpy.append(outliers_IDs_cspc,outliers_IDs) |
|
2640 | 1413 | |
|
2641 | #if not breakFlag: | |
|
2642 | #print(outliers_IDs_cspc) | |
|
2643 | if self.__buffer_cspc is not None and self.clean_cspc: | |
|
1414 | ''' Same process for cross-spectra''' | |
|
1415 | #if not breakFlag: | |
|
2644 | 1416 |
outliers_IDs_cspc=outliers_IDs_cspc.astype(numpy.dtype('int64')) |
|
2645 | 1417 |
if cspc_outliers_exist: |
|
2646 | 1418 |
#sortdata=numpy.sort(buffer_cspc,axis=0) |
|
2647 | 1419 |
#avg=numpy.mean(sortdata[:indexmin_cpsc,:],axis=0) |
|
2648 |
lt=outliers_IDs_cspc |
|
|
2649 | ||
|
2650 | avg=numpy.mean(buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:],axis=0) | |
|
1420 | lt = outliers_IDs_cspc | |
|
1421 | #if time_text.hour >= 11 or time_text.hour <= 19: | |
|
1422 | if True: | |
|
1423 | data_buffer_cspc = buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:] | |
|
1424 | (mu, sigma) = numpy.apply_along_axis(lambda x: norm.fit(numpy.abs(x)), 0, data_buffer_cspc) | |
|
1425 | mu = mu[numpy.newaxis, :] | |
|
1426 | mask = (numpy.abs(data_buffer_cspc ) >= 0) & (numpy.abs(data_buffer_cspc ) <= 2 * mu) | |
|
1427 | filtered_data = numpy.where(mask, data_buffer_cspc, numpy.nan) | |
|
1428 | avg = numpy.nanmean(filtered_data, axis=0) | |
|
1429 | ||
|
1430 | #avg=numpy.median(buffer_cspc[[t for t in range(buffer_cspc.shape[0]) if t not in lt],:],axis=0) | |
|
1431 | else: | |
|
1432 | avg = numpy.mean(buffer1[[t for t in range(buffer1.shape[0]) if t not in lt],:], axis=0) | |
|
1433 | ||
|
1434 | #print("avg2",avg) | |
|
2651 | 1435 |
for p in list(outliers_IDs_cspc): |
|
2652 |
buffer_cspc[p,:]=avg |
|
|
2653 | ||
|
2654 | self.__buffer_cspc[:,0,:,k]=numpy.copy(buffer_cspc) | |
|
1436 | buffer_cspc[p,:]= avg | |
|
2655 | 1437 | |
|
1438 | self.__buffer_cspc[:,0,:,k,l]=numpy.copy(buffer_cspc) | |
|
1439 | #else: | |
|
1440 | #break | |
|
2656 | 1441 | |
|
2657 | 1442 |
buffer=None |
|
2658 | 1443 |
bufferH=None |
|
2659 | 1444 |
buffer1=None |
|
2660 | 1445 |
buffer_cspc=None |
|
2661 | 1446 | |
|
1447 | #print("cpsc",self.__buffer_cspc[:,0,0,0,0]) | |
|
1448 | #print(self.__profIndex) | |
|
1449 | #exit() | |
|
1450 | ||
|
2662 | 1451 |
buffer=None |
|
2663 | 1452 |
#print(self.__buffer_spc[:,1,3,20,0]) |
|
2664 | 1453 |
#print(self.__buffer_spc[:,1,5,37,0]) |
|
1454 | '''Integration of the improved spectra and cross-spectra''' | |
|
2665 | 1455 |
data_spc = numpy.sum(self.__buffer_spc,axis=0) |
|
2666 | ||
|
2667 | if self.clean_cspc: | |
|
2668 | if self.__buffer_cspc is not None: | |
|
2669 | data_cspc = numpy.sum(self.__buffer_cspc,axis=0) | |
|
2670 | else: | |
|
2671 | data_cspc = None | |
|
2672 | else: | |
|
2673 | data_cspc = self.__buffer_cspc | |
|
1456 | data_cspc = numpy.sum(self.__buffer_cspc,axis=0) | |
|
2674 | 1457 | |
|
2675 | 1458 |
#print(numpy.shape(data_spc)) |
|
2676 | 1459 |
#data_spc[1,4,20,0]=numpy.nan |
|
2677 | 1460 | |
|
2678 | ||
|
1461 | #data_cspc = self.__buffer_cspc | |
|
2679 | 1462 |
data_dc = self.__buffer_dc |
|
2680 | ||
|
2681 | 1463 |
n = self.__profIndex |
|
2682 | 1464 | |
|
2683 |
self.__buffer_spc = |
|
|
2684 |
|
|
|
2685 | self.__buffer_cspc = None | |
|
2686 | else: | |
|
2687 | self.__buffer_cspc = 0 | |
|
1465 | self.__buffer_spc = [] | |
|
1466 | self.__buffer_cspc = [] | |
|
2688 | 1467 |
self.__buffer_dc = 0 |
|
2689 | 1468 |
self.__profIndex = 0 |
|
2690 | 1469 | |
|
2691 | 1470 |
return data_spc, data_cspc, data_dc, n |
|
2692 | 1471 | |
|
2693 |
def byProfiles(self, |
|
|
1472 | def byProfiles(self, *args): | |
|
2694 | 1473 | |
|
1474 | """Call variables and push data""" | |
|
2695 | 1475 |
self.__dataReady = False |
|
2696 | 1476 |
avgdata_spc = None |
|
2697 | 1477 |
avgdata_cspc = None |
|
2698 | 1478 |
avgdata_dc = None |
|
2699 | 1479 | |
|
2700 |
self.putData( |
|
|
1480 | self.putData(*args) | |
|
2701 | 1481 | |
|
2702 | 1482 |
if self.__profIndex == self.n: |
|
2703 | if self.ByLags: | |
|
2704 |
|
|
|
2705 | else: | |
|
2706 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
|
1483 | ||
|
1484 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
|
2707 | 1485 |
self.n = n |
|
2708 | 1486 |
self.__dataReady = True |
|
2709 | 1487 | |
@@ -2725,89 +1503,53 class IntegrationFaradaySpectra3(Operation): #This class should manage data with | |||
|
2725 | 1503 | |
|
2726 | 1504 |
return avgdata_spc, avgdata_cspc, avgdata_dc |
|
2727 | 1505 | |
|
2728 |
def integrate(self, datatime, |
|
|
1506 | def integrate(self, datatime, *args): | |
|
1507 | ||
|
1508 | """Integration if the signal by n datablocks""" | |
|
2729 | 1509 | |
|
2730 | 1510 |
if self.__profIndex == 0: |
|
2731 | 1511 |
self.__initime = datatime |
|
2732 | #print(data_cspc.shape) | |
|
2733 | ||
|
2734 | #self.__buffer_spc = numpy.empty_like(data_spc,shape=(self.n,self.nChannels,self.nProfiles,self.nHeights,self.nLags)) | |
|
2735 | if self.ByLags: | |
|
2736 | self.__buffer_spc = numpy.ones_like(data_spc,shape=(self.n,self.nChannels,self.nProfiles,self.nHeights,self.nLags))*numpy.NAN | |
|
2737 | else: | |
|
2738 | self.__buffer_spc = numpy.ones_like(data_spc,shape=(self.n,self.nChannels,self.nProfiles,self.nHeights))*numpy.NAN | |
|
2739 | 1512 | |
|
2740 | #print(self.__buffer_spc[0]) | |
|
2741 | #print(self.__buffer_spc.dtype) | |
|
2742 | #print(data_spc.dtype) | |
|
2743 | ||
|
2744 | if data_cspc is not None: | |
|
2745 | nCrossChannels = numpy.shape(data_cspc)[0] | |
|
2746 | if self.ByLags: | |
|
2747 | nLags = numpy.shape(data_cspc)[-1] | |
|
2748 | ||
|
2749 | self.__buffer_cspc = numpy.ones_like(data_cspc,shape=(self.n,nCrossChannels,self.nProfiles,self.nHeights,nLags))*numpy.NAN | |
|
2750 | else: | |
|
2751 | if self.clean_cspc: | |
|
2752 | self.__buffer_cspc = numpy.ones_like(data_cspc,shape=(self.n,nCrossChannels,self.nProfiles,self.nHeights))*numpy.NAN | |
|
2753 | else: | |
|
2754 | self.__buffer_cspc = 0 | |
|
2755 | else: | |
|
2756 | self.__buffer_cspc = None | |
|
2757 | #print("HEREEEE") | |
|
2758 | #print(self.__buffer_cspc.dtype) | |
|
2759 | #print(data_cspc.dtype) | |
|
2760 | #exit(1) | |
|
2761 | 1513 |
if self.__byTime: |
|
2762 | 1514 |
avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime( |
|
2763 | 1515 |
datatime, *args) |
|
2764 | 1516 |
else: |
|
2765 |
avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles( |
|
|
1517 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args) | |
|
2766 | 1518 | |
|
2767 | 1519 |
if not self.__dataReady: |
|
2768 | 1520 |
return None, None, None, None |
|
2769 | 1521 | |
|
2770 | 1522 |
return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc |
|
2771 | 1523 | |
|
2772 |
def run(self, dataOut, n=None, timeInterval=None, overlapping=False |
|
|
1524 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False): | |
|
1525 | '''If no integration then exit''' | |
|
2773 | 1526 |
if n == 1: |
|
1527 | dataOut.VelRange = dataOut.getVelRange(0) | |
|
2774 | 1528 |
return dataOut |
|
2775 | 1529 | |
|
2776 | 1530 |
dataOut.flagNoData = True |
|
2777 | self.clean_cspc = clean_cspc | |
|
2778 | ||
|
2779 | if not self.isConfig: | |
|
1531 | ''' Assignation setup of integration time or number of integrations ''' | |
|
1532 | if not self.isConfig: #assignation setup of integration time or number of integrations | |
|
2780 | 1533 |
self.setup(n, timeInterval, overlapping) |
|
2781 | try: | |
|
2782 | dataOut.FlipChannels | |
|
2783 | self.FlipChannelsExist=1 | |
|
2784 | except: | |
|
2785 | self.FlipChannelsExist=0 | |
|
2786 | 1534 |
self.isConfig = True |
|
2787 | ||
|
2788 | self.nProfiles=dataOut.nProfiles | |
|
2789 | self.nChannels=dataOut.nChannels | |
|
2790 | self.nHeights=dataOut.nHeights | |
|
2791 | self.ByLags = dataOut.ByLags | |
|
1535 | ||
|
1536 | '''Integration call''' | |
|
2792 | 1537 |
if not dataOut.ByLags: |
|
2793 | 1538 |
avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, |
|
2794 | 1539 |
dataOut.data_spc, |
|
2795 | 1540 |
dataOut.data_cspc, |
|
2796 | 1541 |
dataOut.data_dc) |
|
2797 | 1542 |
else: |
|
2798 |
|
|
|
2799 |
|
|
|
2800 |
|
|
|
2801 |
self. |
|
|
2802 | self.TrueLags=TrueLags | |
|
2803 | ||
|
2804 | ||
|
2805 | ||
|
1543 | self.nProfiles=dataOut.nProfiles | |
|
1544 | self.nChannels=dataOut.nChannels | |
|
1545 | self.nHeights=dataOut.nHeights | |
|
1546 | self.DPL=dataOut.DPL | |
|
2806 | 1547 |
avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, |
|
2807 | 1548 |
dataOut.dataLag_spc, |
|
2808 | 1549 |
dataOut.dataLag_cspc, |
|
2809 | 1550 |
dataOut.dataLag_dc) |
|
2810 | 1551 | |
|
1552 | '''Asignate integrated data to output''' | |
|
2811 | 1553 |
if self.__dataReady: |
|
2812 | 1554 | |
|
2813 | 1555 |
if not dataOut.ByLags: |
@@ -2819,19 +1561,19 class IntegrationFaradaySpectra3(Operation): #This class should manage data with | |||
|
2819 | 1561 |
dataOut.dataLag_cspc = avgdata_cspc |
|
2820 | 1562 |
dataOut.dataLag_dc = avgdata_dc |
|
2821 | 1563 | |
|
2822 |
dataOut.data_spc=dataOut.dataLag_spc[:,:,:,dataOut.LagPlot] |
|
|
2823 | ||
|
2824 | if self.__buffer_cspc is not None: | |
|
2825 | dataOut.data_cspc=dataOut.dataLag_cspc[:,:,:,dataOut.LagPlot] | |
|
1564 | dataOut.data_spc=dataOut.dataLag_spc[:,:,:,dataOut.LagPlot] | |
|
1565 | dataOut.data_cspc=dataOut.dataLag_cspc[:,:,:,dataOut.LagPlot] | |
|
2826 | 1566 |
dataOut.data_dc=dataOut.dataLag_dc[:,:,dataOut.LagPlot] |
|
2827 | 1567 | |
|
2828 | ||
|
1568 | dataOut.VelRange = dataOut.getVelRange(0) | |
|
2829 | 1569 |
dataOut.nIncohInt *= self.n |
|
2830 | 1570 |
dataOut.utctime = avgdatatime |
|
2831 | 1571 |
dataOut.flagNoData = False |
|
2832 | 1572 | |
|
2833 | 1573 |
return dataOut |
|
2834 | 1574 | |
|
1575 | ||
|
1576 | ||
|
2835 | 1577 |
class IntegrationFaradaySpectraNoLags(Operation): |
|
2836 | 1578 |
''' |
|
2837 | 1579 |
Written by R. Flores |
@@ -4021,6 +2763,7 class SpectraDataToFaraday(Operation): #ISR MODE | |||
|
4021 | 2763 |
input() |
|
4022 | 2764 |
''' |
|
4023 | 2765 | |
|
2766 | # Normalization Factor that take account the Number of integrations and profiles | |
|
4024 | 2767 |
def normFactor(self,dataOut): |
|
4025 | 2768 |
dataOut.rnint2=numpy.zeros(dataOut.DPL,'float32') |
|
4026 | 2769 |
for l in range(dataOut.DPL): |
@@ -4036,7 +2779,7 class SpectraDataToFaraday(Operation): #ISR MODE | |||
|
4036 | 2779 |
dataOut.data_spc = dataOut.dataLag_spc[:,:,:,lag] |
|
4037 | 2780 |
dataOut.noise_lag[:,lag] = dataOut.getNoise(ymin_index=46) |
|
4038 | 2781 |
#dataOut.noise_lag[:,lag] = dataOut.getNoise(ymin_index=33,ymax_index=46) |
|
4039 |
|
|
|
2782 | ''' | |
|
4040 | 2783 |
#print(dataOut.NDP) |
|
4041 | 2784 |
#exit(1) |
|
4042 | 2785 |
#Channel B |
@@ -4176,16 +2919,16 class SpectraDataToFaraday(Operation): #ISR MODE | |||
|
4176 | 2919 | |
|
4177 | 2920 |
self.normFactor(dataOut) |
|
4178 | 2921 |
#print(dataOut.NDP) |
|
4179 |
dataOut.NDP=dataOut.nHeights |
|
|
4180 |
dataOut.NR=len(dataOut.channelList) |
|
|
4181 |
dataOut.DH=dataOut.heightList[1]-dataOut.heightList[0] |
|
|
4182 |
dataOut.H0=int(dataOut.heightList[0]) |
|
|
2922 | dataOut.NDP=dataOut.nHeights # Number of heights for Double Pulse.* | |
|
2923 | dataOut.NR=len(dataOut.channelList) # num receptores (channels) | |
|
2924 | dataOut.DH=dataOut.heightList[1]-dataOut.heightList[0] # delta H | |
|
2925 | dataOut.H0=int(dataOut.heightList[0]) # H(0) | |
|
4183 | 2926 | |
|
4184 | 2927 |
self.ConvertData(dataOut) |
|
4185 | 2928 |
#print(dataOut.NDP) |
|
4186 | 2929 |
#exit(1) |
|
4187 | 2930 |
dataOut.NAVG=16#dataOut.rnint2[0] #CHECK THIS! |
|
4188 |
if hasattr(dataOut, 'NRANGE'): |
|
|
2931 | if hasattr(dataOut, 'NRANGE'): # NRANGE.- Number of samples for Long Pulse. | |
|
4189 | 2932 |
dataOut.MAXNRANGENDT = max(dataOut.NRANGE,dataOut.NDT) |
|
4190 | 2933 |
else: |
|
4191 | 2934 |
dataOut.MAXNRANGENDT = dataOut.NDP |
@@ -4381,7 +3124,8 class SpectraDataToFaraday_MST(Operation): #MST MODE | |||
|
4381 | 3124 |
#dataOut.kabxys_integrated[5][:,:,0]+=self.dataLag_spc[0,:,:].imag |
|
4382 | 3125 |
dataOut.kabxys_integrated[6][:,:,0]=self.dataLag_spc[1,:,:].real |
|
4383 | 3126 |
#dataOut.kabxys_integrated[7][:,:,0]+=self.dataLag_spc[1,:,:].imag |
|
4384 | ||
|
3127 | print("self.dataLag_cspc shape:", self.dataLag_cspc.shape) | |
|
3128 | print("dataOut.kabxys_integrated[8][:,:,0]", dataOut.kabxys_integrated[8][:,:,0]) | |
|
4385 | 3129 |
dataOut.kabxys_integrated[8][:,:,0]=self.dataLag_cspc[0,:,:].real |
|
4386 | 3130 |
dataOut.kabxys_integrated[10][:,:,0]=self.dataLag_cspc[0,:,:].imag |
|
4387 | 3131 |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now