Changeset 41e8114 in sasview


Ignore:
Timestamp:
Nov 2, 2007 11:04:05 AM (17 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
5a2070e
Parents:
7e845ea
Message:

Added error estimation for 2D simulation

Location:
realSpaceModeling/pointsmodelpy
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • realSpaceModeling/pointsmodelpy/libpointsmodelpy/points_model.cc

    r2bb0b26 r41e8114  
    412412} 
    413413 
     414double PointsModel::CalculateIQ_2D_Error(const vector<Point3D>&points, double qx, double qy){ 
     415         
     416        int size = points.size(); 
     417 
     418        double delta_x, delta_y; 
     419        double q_t2 = qx*qx + qy*qy; 
     420        double cos_term = 0; 
     421        double sin_term = 0; 
     422        double cos_err = 0; 
     423        double sin_err = 0; 
     424         
     425        // Estimate the error on the position of each point 
     426        // in x or y as V^(1/3)/N 
     427         
     428        for (int i = 0; i < size; i++) { 
     429                 
     430                 
     431                //the sld for the pair of points 
     432         
     433                double phase = qx*points[i].getX() + qy*points[i].getY(); 
     434                double sld_fac = points[i].getSLD() * points[i].getSLD(); 
     435                 
     436                cos_term += cos(phase) * points[i].getSLD(); 
     437                sin_term += sin(phase) * points[i].getSLD(); 
     438 
     439                sin_err += cos(phase) * cos(phase) * sld_fac; 
     440                cos_err += sin(phase) * sin(phase) * sld_fac; 
     441         
     442        }                        
     443 
     444        // P(q) = 1/V I(q) = (V/N)^2 (1/V) (cos_term^2 + sin_term^2)  
     445        // We divide by N here and we will multiply by the density later. 
     446 
     447        // We will need to multiply this error by V^(1/3)/N. 
     448        // We don't have access to V from within this class. 
     449        return 2*sqrt(cos_term*cos_term*cos_err*cos_err + sin_term*sin_term*sin_err*sin_err)/size;       
     450} 
     451 
  • realSpaceModeling/pointsmodelpy/libpointsmodelpy/points_model.h

    r2bb0b26 r41e8114  
    2828  // Fast 2D simulation 
    2929  double CalculateIQ_2D(const vector<Point3D>&, double qx, double qy); 
     30  double CalculateIQ_2D_Error(const vector<Point3D>&, double qx, double qy); 
    3031   
    3132  //given a set of points, calculate distance correlation 
  • realSpaceModeling/pointsmodelpy/pointsmodelpymodule/bindings.cc

    r2bb0b26 r41e8114  
    121121        METH_VARARGS, pypointsmodelpy_get_complex_Iqxy__doc__}, 
    122122 
     123        //ComplexModel calculateIQ_2D_Error(pts,Qx,Qy) 
     124        {pypointsmodelpy_get_complex_Iqxy_err__name__, pypointsmodelpy_get_complex_Iqxy_err, 
     125         METH_VARARGS, pypointsmodelpy_get_complex_Iqxy_err__doc__}, 
     126 
    123127    //ComplexModel calculateIQ 
    124128    {pypointsmodelpy_get_complex_iq__name__, pypointsmodelpy_get_complex_iq, 
  • realSpaceModeling/pointsmodelpy/pointsmodelpymodule/misc.cc

    r2bb0b26 r41e8114  
    554554} 
    555555 
     556//LORESModel method CalculateIQ_2D_Error(points,qx,qy)  
     557char pypointsmodelpy_get_complex_Iqxy_err__name__[] = "get_complex_iq_2D_err"; 
     558char pypointsmodelpy_get_complex_Iqxy_err__doc__[] = "calculate averaged scattering intensity from a single q"; 
     559 
     560PyObject * pypointsmodelpy_get_complex_Iqxy_err(PyObject *, PyObject *args) 
     561{ 
     562  PyObject *pylores = 0, *pypoint3dvec = 0; 
     563  double qx = 0, qy = 0; 
     564  int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx, &qy); 
     565  if(!ok) return NULL; 
     566 
     567  void *temp = PyCObject_AsVoidPtr(pylores); 
     568  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp); 
     569  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec); 
     570  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2); 
     571 
     572  double I = thiscomplex->CalculateIQ_2D_Error(*thisvec,qx,qy); 
     573 
     574  return Py_BuildValue("d",I); 
     575} 
     576 
    556577//LORESModel method CalculateIQ(q)  
    557578char pypointsmodelpy_get_complex_i__name__[] = "get_complex_i"; 
  • realSpaceModeling/pointsmodelpy/pointsmodelpymodule/misc.h

    r2bb0b26 r41e8114  
    182182PyObject * pypointsmodelpy_get_complex_Iqxy(PyObject *, PyObject *); 
    183183 
     184// ComplexModel method calculateIQ_2D_Error(pts,qx,qy) 
     185extern char pypointsmodelpy_get_complex_Iqxy_err__name__[]; 
     186extern char pypointsmodelpy_get_complex_Iqxy_err__doc__[]; 
     187extern "C" 
     188PyObject * pypointsmodelpy_get_complex_Iqxy_err(PyObject *, PyObject *); 
     189 
    184190// ComplexModel method calculateIQ(iq) 
    185191extern char pypointsmodelpy_get_complex_iq__name__[]; 
Note: See TracChangeset for help on using the changeset viewer.