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

    r127 r128  
    3838        make/o/t parameters_Parallelepiped = {"Scale Factor","Shortest Edge A ()","B ()","Longest Edge C ()","Contrast (^-2)","Incoherent Bgd (cm-1)"}      //CH#3 
    3939        Edit parameters_Parallelepiped, coef_Parallelepiped 
    40         ywave_Parallelepiped  := Parallelepiped(coef_Parallelepiped, xwave_Parallelepiped) 
     40         
     41        Variable/G root:g_Parallelepiped 
     42        g_Parallelepiped := Parallelepiped(coef_Parallelepiped,ywave_Parallelepiped, xwave_Parallelepiped) 
    4143        Display ywave_Parallelepiped vs xwave_Parallelepiped 
    4244        ModifyGraph marker=29, msize=2, mode=4 
     
    4850End 
    4951 
    50 // 
    51 //this macro sets up all the necessary parameters and waves that are 
    52 //needed to calculate the  smeared model function. 
    53 // 
    54 //no input parameters are necessary, it MUST use the experimental q-values 
    55 // from the experimental data read in from an AVE/QSIG data file 
    56 //////////////////////////////////////////////////// 
    57 Proc PlotSmeared_Parallelepiped()                                                               //Parallelepiped 
    58         // if no gQvals wave, data must not have been loaded => abort 
    59         if(ResolutionWavesMissing()) 
     52// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     53Proc PlotSmeared_Parallelepiped(str)                                                             
     54        String str 
     55        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     56         
     57        // if any of the resolution waves are missing => abort 
     58        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    6059                Abort 
    6160        endif 
    6261         
     62        SetDataFolder $("root:"+str) 
    6363         
    6464        // Setup parameter table for model function 
     
    6969        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    7070        // make extra copy of experimental q-values for easy plotting 
    71         Duplicate/O $gQvals smeared_Parallelepiped,smeared_qvals                                // 
     71        Duplicate/O $(str+"_q") smeared_Parallelepiped,smeared_qvals                            // 
    7272        SetScale d,0,0,"1/cm",smeared_Parallelepiped                                                    // 
    73  
    74         smeared_Parallelepiped := Parallelepiped_Smeared(smear_coef_Parallelepiped,$gQvals)             // SMEARED function name 
     73                                         
     74        Variable/G gs_Parallelepiped=0 
     75        gs_Parallelepiped := fParallelepiped_Smeared(smear_coef_Parallelepiped,smeared_Parallelepiped,smeared_qvals)    //this wrapper fills the STRUCT 
     76         
    7577        Display smeared_Parallelepiped vs smeared_qvals                                                                 // 
    7678        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    7880        Label left "I(q) (cm\\S-1\\M)" 
    7981        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    80 End     // end macro  
     82         
     83        SetDataFolder root: 
     84End 
     85 
     86 
     87 
     88//AAO version, uses XOP if available 
     89// simply calls the original single point calculation with 
     90// a wave assignment (this will behave nicely if given point ranges) 
     91Function Parallelepiped(cw,yw,xw) : FitFunc 
     92        Wave cw,yw,xw 
     93         
     94#if exists("ParallelepipedX") 
     95        yw = ParallelepipedX(cw,xw) 
     96#else 
     97        yw = fParallelepiped(cw,xw) 
     98#endif 
     99        return(0) 
     100End 
    81101 
    82102// calculates the form factor of a rectangular solid 
    83103// - a double integral - choose points wisely 
    84104// 
    85 Function Parallelepiped(w,x) : FitFunc 
     105Function fParallelepiped(w,x) : FitFunc 
    86106        Wave w 
    87107        Variable x 
     
    178198End 
    179199 
     200//wrapper to calculate the smeared model as an AAO-Struct 
     201// fills the struct and calls the ususal function with the STRUCT parameter 
     202// 
     203// used only for the dependency, not for fitting 
     204// 
     205Function fParallelepiped_Smeared(coefW,yW,xW) 
     206        Wave coefW,yW,xW 
     207         
     208        String str = getWavesDataFolder(yW,0) 
     209        String DF="root:"+str+":" 
     210         
     211        WAVE resW = $(DF+str+"_res") 
     212         
     213        STRUCT ResSmearAAOStruct fs 
     214        WAVE fs.coefW = coefW    
     215        WAVE fs.yW = yW 
     216        WAVE fs.xW = xW 
     217        WAVE fs.resW = resW 
     218         
     219        Variable err 
     220        err = Parallelepiped_Smeared(fs) 
     221         
     222        return (0) 
     223End 
    180224 
    181225// this is all there is to the smeared calculation! 
    182 Function Parallelepiped_Smeared(w,x) :FitFunc 
    183         Wave w 
    184         Variable x 
    185          
    186         Variable ans 
    187         SVAR sq = gSig_Q 
    188         SVAR qb = gQ_bar 
    189         SVAR sh = gShadow 
    190         SVAR gQ = gQVals 
    191          
    192         //the name of your unsmeared model is the first argument 
    193         ans = Smear_Model_20(Parallelepiped,$sq,$qb,$sh,$gQ,w,x) 
    194  
    195         return(ans) 
    196 End 
     226Function Parallelepiped_Smeared(s) :FitFunc 
     227        Struct ResSmearAAOStruct &s 
     228 
     229//      the name of your unsmeared model (AAO) is the first argument 
     230        s.yW = Smear_Model_20(Parallelepiped,s.coefW,s.xW,s.resW) 
     231 
     232        return(0) 
     233End 
Note: See TracChangeset for help on using the changeset viewer.