Changeset 198


Ignore:
Timestamp:
Nov 8, 2007 5:05:14 PM (15 years ago)
Author:
srkline
Message:

Adding three new 2D functions, the easy ones that use a Gaussian distribution of parameters.

Changed the parsing of constraints to only build a constraint wave for those parameters that are not being held. failing to do so results in an "unknown error" from curve fitting. This fix was done in both the 1D and 2D wrappers.

Changed the default mask that was two pixels all around to now mask out the beamstop for 2D data sets. 8 pixel radius is currently hard-wired in PlotUtils2D - and is generated as the fit is dispatched, automatically determining the beam center from the data set.

Location:
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Models_2D/Cylinder_2D.ipf

    r197 r198  
    1313// 
    1414 
    15  
    1615///  REQUIRES DANSE XOP for 2D FUNCTIONS 
    1716 
     
    2322        String str 
    2423        Prompt str,"Pick the data folder containing the 2D data",popup,getAList(4) 
    25          
    26         // if any of the resolution waves are missing => abort 
    27 //      if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    28 //              Abort 
    29 //      endif 
    3024         
    3125        SetDataFolder $("root:"+str) 
     
    7771        ModifyGraph width={Aspect,1} 
    7872        ModifyGraph lowTrip=0.001 
    79         Label bottom "q (\\S-1\\M)" 
    80         Label left "q (\\S-1\\M)" 
     73        Label bottom "qx (A\\S-1\\M)" 
     74        Label left "qy (A\\S-1\\M)" 
    8175        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    8276         
     
    8680        // _mat is for display, _lin is the real calculation 
    8781 
     82        // not a function evaluation - this simply keeps the matrix for display in sync with the triplet calculation 
    8883        Variable/G gs_Cyl2Dmat=0 
    8984        gs_Cyl2Dmat := UpdateQxQy2Mat(xwave_Cyl2D,ywave_Cyl2D,zwave_Cyl2D,Cyl2D_lin,Cyl2D_mat) 
     
    121116#endif 
    122117 
    123 //      return stopMSTimer(-2)          // time when we finished 
    124118        return 0 
    125119End 
    126120 
    127 //function that is actually a wrapper to dispatch the calculation to N threads 
     121// 
     122//  Fit function that is actually a wrapper to dispatch the calculation to N threads 
     123// 
     124// nthreads is 1 or an even number, typically 2 
     125// it doesn't matter if npt is odd. In this case, fractional point numbers are passed 
     126// and the wave indexing works just fine - I tested this with test waves of 7 and 8 points 
     127// and the points "2.5" and "3.5" evaluate correctly as 2 and 3 
    128128// 
    129129Function Cylinder2D(cw,zw,xw,yw) : FitFunc 
     
    135135 
    136136        for(i=0;i<nthreads;i+=1) 
    137 //              Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 
     137        //      Print (i*npt/nthreads),((i+1)*npt/nthreads-1) 
    138138                ThreadStart mt,i,Cylinder2D_T(cw,zw,xw,yw,(i*npt/nthreads),((i+1)*npt/nthreads-1)) 
    139139        endfor 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Packages/PlotUtils2D.ipf

    r197 r198  
    524524        // generate my own mask wave - as a matrix first, then redimension to N*N vector 
    525525        // default mask is two pixels all the way around, (0 is excluded, 1 is included) 
    526         WAVE DataMat=$(DF+folderStr+"_lin")  
    527         Duplicate/O dataMat mask 
    528         Variable xDim, yDim 
    529         xDim = DimSize(dataMat,0) 
    530         yDim = DimSize(dataMat,1) 
    531         mask = 1 
    532         mask[][0] = 0 
    533         mask[][1] = 0 
    534         mask[][yDim-2] = 0 
    535         mask[][yDim-1] = 0 
    536         mask[0][] = 0 
    537         mask[1][] = 0 
    538         mask[xDim-2][] = 0 
    539         mask[xDim-1][] = 0 
    540         Redimension/N=(xDim*yDim) mask          //now 1D 
    541          
     526        WAVE DataMat=$(DF+folderStr+"_lin") 
     527        if(exists(DF+"mask") == 0) 
     528                Duplicate/O dataMat mask 
     529                Variable bsRadius=8             //pixels? 
     530                MakeBSMask(mask,bsRadius) 
     531        Endif 
     532         
     533 
    542534         
    543535//      Duplicate/O yw $(DF+"FitYw") 
     
    551543        endif 
    552544         
     545        // do not construct constraints for any of the coefficients that are being held 
     546        // -- this will generate an "unknown error" from the curve fitting 
    553547        Make/O/T/N=0 constr 
    554548        if(useConstr) 
     
    556550                Variable i, nPnts=DimSize(lolim, 0),nextRow=0 
    557551                for (i=0; i < nPnts; i += 1) 
    558                         if (strlen(lolim[i]) > 0) 
     552                        if (strlen(lolim[i]) > 0 && hold[i] == 0) 
    559553                                InsertPoints nextRow, 1, constr 
    560554                                sprintf constraintExpression, "K%d > %s", i, lolim[i] 
     
    562556                                nextRow += 1 
    563557                        endif 
    564                         if (strlen(hilim[i]) > 0) 
     558                        if (strlen(hilim[i]) > 0 && hold[i] == 0) 
    565559                                InsertPoints nextRow, 1, constr 
    566560                                sprintf constraintExpression, "K%d < %s", i, hilim[i] 
     
    839833//      SetDataFolder fldrSav0 
    840834//EndMacro 
     835 
     836 
     837Function MakeBSMask(mask,rad) 
     838        Wave mask 
     839        Variable rad 
     840 
     841 
     842// find the center based on the wave scaling 
     843        Variable xCtr,yCtr,Qzero=0 
     844        xCtr = (Qzero - DimOffset(Mask, 0))/DimDelta(Mask,0) 
     845        yCtr = (Qzero - DimOffset(Mask, 1))/DimDelta(Mask,1) 
     846 
     847        Print xctr,yctr 
     848 
     849//      Variable center = sqrt(numpnts(mask))/2 -0.5 
     850 
     851        mask = (sqrt((p-xCtr)^2+(q-yCtr)^2) < rad) ? 0 : 1 
     852 
     853        Variable xDim, yDim 
     854        xDim = DimSize(mask,0) 
     855        yDim = DimSize(mask,1) 
     856        mask[][0] = 0 
     857        mask[][1] = 0 
     858        mask[][yDim-2] = 0 
     859        mask[][yDim-1] = 0 
     860        mask[0][] = 0 
     861        mask[1][] = 0 
     862        mask[xDim-2][] = 0 
     863        mask[xDim-1][] = 0 
     864         
     865        Redimension/N=(xDim*yDim) mask          //now 1D 
     866         
     867         
     868End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Packages/Wrapper.ipf

    r185 r198  
    599599        endif 
    600600         
     601        // do not construct constraints for any of the coefficients that are being held 
     602        // -- this will generate an "unknown error" from the curve fitting 
    601603        Make/O/T/N=0 constr 
    602604        if(useConstr) 
     
    604606                Variable i, nPnts=DimSize(lolim, 0),nextRow=0 
    605607                for (i=0; i < nPnts; i += 1) 
    606                         if (strlen(lolim[i]) > 0) 
     608                        if (strlen(lolim[i]) > 0 && hold[i] == 0) 
    607609                                InsertPoints nextRow, 1, constr 
    608610                                sprintf constraintExpression, "K%d > %s", i, lolim[i] 
     
    610612                                nextRow += 1 
    611613                        endif 
    612                         if (strlen(hilim[i]) > 0) 
     614                        if (strlen(hilim[i]) > 0 && hold[i] == 0) 
    613615                                InsertPoints nextRow, 1, constr 
    614616                                sprintf constraintExpression, "K%d < %s", i, hilim[i] 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/SA_includes_v301.ipf

    r196 r198  
    1818#include "Wrapper" 
    1919#include "PlotUtils2D" 
     20#include "GizmoCylinder" 
    2021 
    2122Menu "SANS Models" 
Note: See TracChangeset for help on using the changeset viewer.