Ignore:
Timestamp:
Jul 25, 2007 3:07:20 PM (16 years ago)
Author:
srkline
Message:

Second round of changes to ipf files to (hopefully) complete the changes to bring all of the model functions to be:

  • this set of changes is for the "2006" set of models
  • AAO
  • new dependencies
  • smearing using structures
  • #if conditional compile for XOPS

-this needs to be FULLY tested for correctness and bugs
-packages are certainly still broken (data folders)

SRK 25 JUL 07

File:
1 edited

Legend:

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

    r127 r128  
    2828        make/o/t parameters_cypl = {"scale","radius (A)","length (A)","polydispersity of Length","SLD diff (A^-2)","incoh. bkg (cm^-1)"} 
    2929        Edit parameters_cypl,coef_cypl 
    30         ywave_cypl := Cyl_PolyLength(coef_cypl,xwave_cypl) 
     30         
     31        Variable/G root:g_cypl 
     32        g_cypl := Cyl_PolyLength(coef_cypl,ywave_cypl,xwave_cypl) 
    3133        Display ywave_cypl vs xwave_cypl 
    3234        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3638End 
    3739 
    38 // plot the smeared version - quite slow - use only for final fit 
    39 Proc PlotSmearedCyl_PolyLength()         
    40         //no input parameters necessary, it MUST use the experimental q-values 
    41         // from the experimental data read in from an AVE/QSIG data file 
    42          
    43         // if no gQvals wave, data must not have been loaded => abort 
    44         if(ResolutionWavesMissing()) 
     40// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     41Proc PlotSmearedCyl_PolyLength(str)                                                              
     42        String str 
     43        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     44         
     45        // if any of the resolution waves are missing => abort 
     46        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4547                Abort 
    4648        endif 
     49         
     50        SetDataFolder $("root:"+str) 
    4751         
    4852        // Setup parameter table for model function 
     
    5357        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5458        // make extra copy of experimental q-values for easy plotting 
    55         Duplicate/O $gQvals smeared_cypl,smeared_qvals 
     59        Duplicate/O $(str+"_q") smeared_cypl,smeared_qvals 
    5660        SetScale d,0,0,"1/cm",smeared_cypl       
    57  
    58         smeared_cypl := SmearedCyl_PolyLength(smear_coef_cypl,$gQvals) 
     61                                         
     62        Variable/G gs_cypl=0 
     63        gs_cypl := fSmearedCyl_PolyLength(smear_coef_cypl,smeared_cypl,smeared_qvals)   //this wrapper fills the STRUCT 
     64         
    5965        Display smeared_cypl vs smeared_qvals 
    6066        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    6268        Label left "Intensity (cm\\S-1\\M)" 
    6369        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     70         
     71        SetDataFolder root: 
     72End 
     73         
     74 
     75 
     76//AAO version, uses XOP if available 
     77// simply calls the original single point calculation with 
     78// a wave assignment (this will behave nicely if given point ranges) 
     79Function Cyl_PolyLength(cw,yw,xw) : FitFunc 
     80        Wave cw,yw,xw 
     81         
     82#if exists("Cyl_PolyLengthX") 
     83        yw = Cyl_PolyLengthX(cw,xw) 
     84#else 
     85        yw = fCyl_PolyLength(cw,xw) 
     86#endif 
     87        return(0) 
    6488End 
    6589 
     
    6791// both integrals are done using quadrature, although both may benefit from an 
    6892// adaptive integration 
    69 Function Cyl_PolyLength(w,x)  : FitFunc 
     93Function fCyl_PolyLength(w,x)  : FitFunc 
    7094        Wave w 
    7195        Variable x 
     
    182206        kp[4] = 0               //bkg fixed at 0 
    183207         
    184         Pq = CylinderForm(kp,qw) 
    185         //Pq = CylinderFit(kp,qw)       //from the XOP 
     208#if exists("CylinderFormX") 
     209        Pq = CylinderFormX(kp,qw) 
     210#else 
     211        Pq = fCylinderForm(kp,qw) 
     212#endif 
    186213         
    187214        // undo the normalization that CylinderForm does 
     
    208235End 
    209236 
     237//wrapper to calculate the smeared model as an AAO-Struct 
     238// fills the struct and calls the ususal function with the STRUCT parameter 
     239// 
     240// used only for the dependency, not for fitting 
     241// 
     242Function fSmearedCyl_PolyLength(coefW,yW,xW) 
     243        Wave coefW,yW,xW 
     244         
     245        String str = getWavesDataFolder(yW,0) 
     246        String DF="root:"+str+":" 
     247         
     248        WAVE resW = $(DF+str+"_res") 
     249         
     250        STRUCT ResSmearAAOStruct fs 
     251        WAVE fs.coefW = coefW    
     252        WAVE fs.yW = yW 
     253        WAVE fs.xW = xW 
     254        WAVE fs.resW = resW 
     255         
     256        Variable err 
     257        err = SmearedCyl_PolyLength(fs) 
     258         
     259        return (0) 
     260End 
     261 
    210262// this is all there is to the smeared calculation! 
    211 Function SmearedCyl_PolyLength(w,x) :FitFunc 
    212         Wave w 
    213         Variable x 
    214          
    215         Variable ans 
    216         SVAR sq = gSig_Q 
    217         SVAR qb = gQ_bar 
    218         SVAR sh = gShadow 
    219         SVAR gQ = gQVals 
    220          
    221         //the name of your unsmeared model is the first argument 
    222         ans = Smear_Model_20(Cyl_PolyLength,$sq,$qb,$sh,$gQ,w,x) 
    223  
    224         return(ans) 
    225 End 
     263Function SmearedCyl_PolyLength(s) :FitFunc 
     264        Struct ResSmearAAOStruct &s 
     265 
     266//      the name of your unsmeared model (AAO) is the first argument 
     267        s.yW = Smear_Model_20(Cyl_PolyLength,s.coefW,s.xW,s.resW) 
     268 
     269        return(0) 
     270End 
     271         
Note: See TracChangeset for help on using the changeset viewer.