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/MultiShell.ipf

    r127 r128  
    2222        make/O/T parameters_mss = {"scale","core radius (A)","shell thickness (A)","water thickness","core & solvent SLD (A-2)","Shell SLD (A-2)","number of water/shell pairs","bkg (cm-1)"} 
    2323        Edit/K=1 parameters_mss,coef_mss 
    24         ywave_mss := MultiShellForm(coef_mss,xwave_mss) 
     24         
     25        Variable/G root:g_mss 
     26        g_mss := MultiShellForm(coef_mss,ywave_mss,xwave_mss) 
    2527        Display/K=1 ywave_mss vs xwave_mss 
    2628        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3032End 
    3133 
    32 Proc PlotSmearedMultiShell()                                                             
    33         //no input parameters necessary, it MUST use the experimental q-values 
    34         // from the experimental data read in from an AVE/QSIG data file 
     34// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     35Proc PlotSmearedMultiShell(str)                                                          
     36        String str 
     37        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    3538         
    36         // if no gQvals wave, data must not have been loaded => abort 
    37         if(Exists("gQvals") != 2)               // 2 = string or numeric variable exists 
    38                 Abort "6-column QSIG data not loaded. Use LoadQSIGData macro" 
    39         else 
    40                 if(WaveExists($gQvals) ==0)     //wave ref does not exist 
    41                         Abort "6-column QSIG waves are missing. Re-load with LoadQSIGData macro" 
    42                 endif 
     39        // if any of the resolution waves are missing => abort 
     40        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
     41                Abort 
    4342        endif 
     43         
     44        SetDataFolder $("root:"+str) 
    4445         
    4546        // Setup parameter table for model function 
     
    5051        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5152        // make extra copy of experimental q-values for easy plotting 
    52         Duplicate/O $gQvals smeared_mss,smeared_qvals                            
     53        Duplicate/O $(str+"_q") smeared_mss,smeared_qvals                                
    5354        SetScale d,0,0,"1/cm",smeared_mss                                                        
    54  
    55         smeared_mss := SmearedMultiShell(smear_coef_mss,$gQvals)                 
     55                                         
     56        Variable/G gs_mss=0 
     57        gs_mss := fSmearedMultiShell(smear_coef_mss,smeared_mss,smeared_qvals)  //this wrapper fills the STRUCT 
     58         
    5659        Display/K=1 smeared_mss vs smeared_qvals                                                                         
    5760        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5962        Label left "Intensity (cm\\S-1\\M)" 
    6063        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     64         
     65        SetDataFolder root: 
    6166End 
    6267 
    63 Function MultiShellForm(w,x) :FitFunc 
     68 
     69 
     70 
     71//AAO version, uses XOP if available 
     72// simply calls the original single point calculation with 
     73// a wave assignment (this will behave nicely if given point ranges) 
     74Function MultiShellForm(cw,yw,xw) : FitFunc 
     75        Wave cw,yw,xw 
     76         
     77#if exists("MultiShellFormX") 
     78        yw = MultiShellFormX(cw,xw) 
     79#else 
     80        yw = fMultiShellForm(cw,xw) 
     81#endif 
     82        return(0) 
     83End 
     84 
     85Function fMultiShellForm(w,x) :FitFunc 
    6486        Wave w 
    6587        Variable x 
     
    136158//End 
    137159 
     160//wrapper to calculate the smeared model as an AAO-Struct 
     161// fills the struct and calls the ususal function with the STRUCT parameter 
     162// 
     163// used only for the dependency, not for fitting 
     164// 
     165Function fSmearedMultiShell(coefW,yW,xW) 
     166        Wave coefW,yW,xW 
     167         
     168        String str = getWavesDataFolder(yW,0) 
     169        String DF="root:"+str+":" 
     170         
     171        WAVE resW = $(DF+str+"_res") 
     172         
     173        STRUCT ResSmearAAOStruct fs 
     174        WAVE fs.coefW = coefW    
     175        WAVE fs.yW = yW 
     176        WAVE fs.xW = xW 
     177        WAVE fs.resW = resW 
     178         
     179        Variable err 
     180        err = SmearedMultiShell(fs) 
     181         
     182        return (0) 
     183End 
     184 
    138185// this is all there is to the smeared calculation! 
    139 Function SmearedMultiShell(w,x) :FitFunc 
    140         Wave w 
    141         Variable x 
     186Function SmearedMultiShell(s) :FitFunc 
     187        Struct ResSmearAAOStruct &s 
     188 
     189//      the name of your unsmeared model (AAO) is the first argument 
     190        s.yW = Smear_Model_20(MultiShellForm,s.coefW,s.xW,s.resW) 
     191 
     192        return(0) 
     193End 
    142194         
    143         Variable ans 
    144         SVAR sq = gSig_Q 
    145         SVAR qb = gQ_bar 
    146         SVAR sh = gShadow 
    147         SVAR gQ = gQVals 
    148          
    149         //the name of your unsmeared model is the first argument 
    150         ans = Smear_Model_76(MultiShellForm,$sq,$qb,$sh,$gQ,w,x) 
    151  
    152         return(ans) 
    153 End 
Note: See TracChangeset for help on using the changeset viewer.