Changeset f168d02 in sasview for pr_inversion/c_extensions
- Timestamp:
- Jul 1, 2008 2:56:32 PM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 2a92852
- Parents:
- a17ffdf
- Location:
- pr_inversion/c_extensions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pr_inversion/c_extensions/Cinvertor.c
rbd30f4a5 rf168d02 624 624 625 625 iq_value = iq(pars, self->params.d_max, npars, q); 626 return Py_BuildValue("f", iq_value); 627 } 628 629 const char get_iq_smeared_doc[] = 630 "Function to call to evaluate the scattering intensity.\n" 631 "The scattering intensity is slit-smeared." 632 " @param args: c-parameters, and q\n" 633 " @return: I(q)"; 634 635 /** 636 * Function to call to evaluate the scattering intensity 637 * The scattering intensity is slit-smeared. 638 * @param args: c-parameters, and q 639 * @return: I(q) 640 */ 641 static PyObject * get_iq_smeared(Cinvertor *self, PyObject *args) { 642 double *pars; 643 double q, iq_value; 644 PyObject *data_obj; 645 Py_ssize_t npars; 646 647 if (!PyArg_ParseTuple(args, "Od", &data_obj, &q)) return NULL; 648 OUTVECTOR(data_obj,pars,npars); 649 650 iq_value = iq_smeared(pars, self->params.d_max, npars, 651 self->params.slit_height, self->params.slit_width, 652 q, 21); 626 653 return Py_BuildValue("f", iq_value); 627 654 } … … 875 902 a[i*nfunc+j] = 1.0/self->params.err[i]; 876 903 } else { 877 a[i*nfunc+j] = ortho_transformed(self->params.d_max, j+offset, self->params.x[i])/self->params.err[i]; 904 if (self->params.slit_width>0 || self->params.slit_height>0) { 905 a[i*nfunc+j] = ortho_transformed_smeared(self->params.d_max, 906 j+offset, self->params.slit_height, self->params.slit_width, 907 self->params.x[i], 21)/self->params.err[i]; 908 } else { 909 a[i*nfunc+j] = ortho_transformed(self->params.d_max, j+offset, self->params.x[i])/self->params.err[i]; 910 } 878 911 } 879 912 } … … 1009 1042 {"get_nerr", (PyCFunction)get_nerr, METH_VARARGS, get_nerr_doc}, 1010 1043 {"iq", (PyCFunction)get_iq, METH_VARARGS, get_iq_doc}, 1044 {"iq_smeared", (PyCFunction)get_iq_smeared, METH_VARARGS, get_iq_smeared_doc}, 1011 1045 {"pr", (PyCFunction)get_pr, METH_VARARGS, get_pr_doc}, 1012 1046 {"get_pr_err", (PyCFunction)get_pr_err, METH_VARARGS, get_pr_err_doc}, -
pr_inversion/c_extensions/invertor.c
r9a23253e rf168d02 63 63 double ortho_transformed_smeared(double d_max, int n, double height, double width, double q, int npts) { 64 64 double sum, value, y, z; 65 int i, j; 65 int i, j, n_height, n_width; 66 double count_w; 66 67 double fnpts; 67 68 sum = 0.0; 68 69 fnpts = (float)npts-1.0; 69 70 70 for(i=0; i<npts; i++) { 71 y = -width/2.0+width/fnpts*(float)i; 72 for(j=0; j<npts; j++) { 71 // Check for zero slit size 72 n_height = (height>0) ? npts : 1; 73 n_width = (width>0) ? npts : 1; 74 75 count_w = 0.0; 76 77 for(j=0; j<n_height; j++) { 78 if(height>0){ 73 79 z = height/fnpts*(float)j; 80 } else { 81 z = 0.0; 82 } 83 84 for(i=0; i<n_width; i++) { 85 if(width>0){ 86 y = -width/2.0+width/fnpts*(float)i; 87 } else { 88 y = 0.0; 89 } 90 if (((q-y)*(q-y)+z*z)<=0.0) continue; 91 count_w += 1.0; 74 92 sum += ortho_transformed(d_max, n, sqrt((q-y)*(q-y)+z*z)); 75 93 } 76 94 } 77 78 return sum/npts/npts/height/width; 95 return sum/count_w; 79 96 } 80 97 … … 95 112 for (i=0; i<n_c; i++) { 96 113 sum += pars[i] * ortho_transformed(d_max, i+1, q); 114 } 115 return sum; 116 } 117 118 /** 119 * Scattering intensity calculated from the expansion, 120 * slit-smeared. 121 */ 122 double iq_smeared(double *pars, double d_max, int n_c, double height, double width, double q, int npts) { 123 double sum = 0.0; 124 int i; 125 for (i=0; i<n_c; i++) { 126 sum += pars[i] * ortho_transformed_smeared(d_max, i+1, height, width, q, npts); 97 127 } 98 128 return sum; -
pr_inversion/c_extensions/invertor.h
r9a23253e rf168d02 55 55 double int_pr(double *pars, double d_max, int n_c, int nslice); 56 56 double ortho_transformed_smeared(double d_max, int n, double heigth, double width, double q, int npts); 57 double iq_smeared(double *pars, double d_max, int n_c, double height, double width, double q, int npts); 57 58 58 59 #endif
Note: See TracChangeset
for help on using the changeset viewer.