Ignore:
Timestamp:
Jul 24, 2007 3:23:44 PM (16 years ago)
Author:
srkline
Message:

LOTS of changes to the analysis ipf files:

-- see sphere.ipf for the simplest example of the changes --

  • #pragma Igor 6
  • #if directive to look for XOP
  • AAO unsmeared functions
  • STRUCT functions for smearing (also AAO)
  • new wrappers for dependencies to struct functions

(2006 models have NOT been completed yet, only the old models)

  • loading data files into data folders (PlotUtils?) + some streamlining of the loaders
  • Smear_Model_N is now AAO + some streamlining of the quadrature code

-- SHS and SW structure factor XOPs are crashing (need DP wave, I may have old XOP)
-- this breaks fitting of the smeared models until wrappers can be devised
-- all packages will be broken due to the new data folder structure
-- multiple instances of functions will now cause problems (MSA)
-- RPA model is a problem with its odd functional form (extra wave)

-- lots of other carnage to follow as the bugs and typos are shaken out

24 JUL 2007 SRK

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

Legend:

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

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
     
    2324        make/o/t parameters_BE = {"K (barns)","Lb ()","h (-3)","b ()","Cs (mol/L)","alpha","C (mol/L)","Background"}  
    2425        Edit parameters_BE,coef_BE 
    25         ywave_BE := BEPolyelectrolyte(coef_BE,xwave_BE) 
     26        Variable/G root:g_BE 
     27        g_BE := BEPolyelectrolyte(coef_BE,ywave_BE,xwave_BE) 
     28//      ywave_BE := BEPolyelectrolyte(coef_BE,xwave_BE) 
    2629        Display ywave_BE vs xwave_BE 
    2730        ModifyGraph log=0,marker=29,msize=2,mode=4                      //**** log=0 if linear scale desired 
     
    3235 
    3336/////////////////////////////////////////////////////////// 
    34  
    35 Proc PlotSmearedBE_Polyelectrolyte()                                                            //**** name of your function 
    36         //no input parameters necessary, it MUST use the experimental q-values 
    37         // from the experimental data read in from an AVE/QSIG data file 
    38         // if no gQvals wave, data must not have been loaded => abort 
    39         if(ResolutionWavesMissing()) 
     37// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     38Proc PlotSmearedBE_Polyelectrolyte(str)                                                          
     39        String str 
     40        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     41         
     42        // if any of the resolution waves are missing => abort 
     43        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4044                Abort 
    4145        endif 
     46         
     47        SetDataFolder $("root:"+str) 
    4248         
    4349        // Setup parameter table for model function 
     
    4854        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4955        // make extra copy of experimental q-values for easy plotting 
    50         Duplicate/O $gQvals smeared_BE,smeared_qvals                            //**** mod 
     56        Duplicate/O $(str+"_q") smeared_BE,smeared_qvals                                //**** mod 
    5157        SetScale d,0,0,"1/cm",smeared_BE                                                //**** mod 
    52  
    53         smeared_BE := SmearedBEPolyelec(smear_coef_BE,$gQvals)          //**** mod, your SMEARED function name 
     58                                         
     59        Variable/G gs_BE=0 
     60        gs_BE := fSmearedBEPolyelec(smear_coef_BE,smeared_BE,smeared_qvals)     //this wrapper fills the STRUCT 
     61         
    5462        Display smeared_BE vs smeared_qvals                                                                     //**** mod 
    5563        ModifyGraph log=0,marker=29,msize=2,mode=4 
     
    5765        Label left "I  sBE (cm\\S-1\\M)" 
    5866        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     67         
     68        SetDataFolder root: 
     69End 
     70         
     71 
     72//AAO version 
     73Function BEPolyelectrolyte(cw,yw,xw) : FitFunc 
     74        Wave cw,yw,xw 
     75 
     76#if exists("BEPolyelectrolyteX") 
     77        yw = BEPolyelectrolyteX(cw,xw) 
     78#else 
     79        yw = fBEPolyelectrolyte(cw,xw) 
     80#endif 
     81        return(0) 
    5982End 
    6083 
     
    6487// Borue-Erukhimovich RPA model for linear polyelectrolytes 
    6588/////////////////////////// 
    66  
    67  
    68 Function BEPolyelectrolyte(w,q) : FitFunc 
     89Function fBEPolyelectrolyte(w,q) : FitFunc 
    6990        Wave w 
    7091        Variable q 
     
    116137 
    117138 
     139// this is all there is to the smeared calculation! 
     140Function SmearedBEPolyelec(s) :FitFunc 
     141        Struct ResSmearAAOStruct &s 
    118142 
    119 /////////////////////////////////////////////////////////////// 
    120 // smeared model calculation 
    121 /////////////////////////// 
     143////the name of your unsmeared model is the first argument 
     144        s.yW = Smear_Model_20(BEPolyelectrolyte,s.coefW,s.xW,s.resW) 
    122145 
    123         // this is all there is to the smeared calculation! 
    124 Function SmearedBEPolyelec(w,x) :FitFunc 
    125         Wave w 
    126         Variable x 
     146        return(0) 
     147End 
     148 
     149//wrapper to calculate the smeared model as an AAO-Struct 
     150// fills the struct and calls the ususal function with the STRUCT parameter 
     151// 
     152// used only for the dependency, not for fitting 
     153// 
     154Function fSmearedBEPolyelec(coefW,yW,xW) 
     155        Wave coefW,yW,xW 
    127156         
    128         Variable ans 
    129         SVAR sq = gSig_Q 
    130         SVAR qb = gQ_bar 
    131         SVAR sh = gShadow 
    132         SVAR gQ = gQVals 
     157        String str = getWavesDataFolder(yW,0) 
     158        String DF="root:"+str+":" 
    133159         
    134         //the name of your unsmeared model is the first argument 
    135         ans = Smear_Model_20(BEPolyelectrolyte,$sq,$qb,$sh,$gQ,w,x) 
    136  
    137         return(ans) 
     160        WAVE resW = $(DF+str+"_res") 
     161         
     162        STRUCT ResSmearAAOStruct fs 
     163        WAVE fs.coefW = coefW    
     164        WAVE fs.yW = yW 
     165        WAVE fs.xW = xW 
     166        WAVE fs.resW = resW 
     167         
     168        Variable err 
     169        err = SmearedBEPolyelec(fs) 
     170         
     171        return (0) 
    138172End 
    139173 
    140174 
    141  
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CoreShell.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
     
    2223        make/o/t parameters_css = {"scale","core radius (A)","shell thickness (A)","Core SLD (A-2)","Shell SLD (A-2)","Solvent SLD (A-2)","bkg (cm-1)"} 
    2324        Edit parameters_css,coef_css 
    24         ywave_css := CoreShellForm(coef_css,xwave_css) 
     25        Variable/G root:g_css 
     26        g_css := CoreShellForm(coef_css,ywave_css,xwave_css) 
     27//      ywave_css := CoreShellForm(coef_css,xwave_css) 
    2528        Display ywave_css vs xwave_css 
    2629        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3134 
    3235/////////////////////////////////////////////////////////// 
    33  
    34 Proc PlotSmearedCoreShellSphere()                                                               //**** name of your function 
    35         //no input parameters necessary, it MUST use the experimental q-values 
    36         // from the experimental data read in from an AVE/QSIG data file 
     36// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     37Proc PlotSmearedCoreShellSphere(str)                                                             
     38        String str 
     39        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    3740         
    38         // if no gQvals wave, data must not have been loaded => abort 
    39         if(ResolutionWavesMissing()) 
     41        // if any of the resolution waves are missing => abort 
     42        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4043                Abort 
    4144        endif 
     45         
     46        SetDataFolder $("root:"+str) 
    4247         
    4348        // Setup parameter table for model function 
     
    4954        // make extra copy of experimental q-values for easy plotting 
    5055         
    51         Duplicate/O $gQvals smeared_css,smeared_qvals                            
     56        Duplicate/O $(str+"_q") smeared_css,smeared_qvals                                
    5257        SetScale d,0,0,"1/cm",smeared_css                                                        
    53  
    54         smeared_css := SmearedCoreShellForm(smear_coef_css,$gQvals)                                                                      
     58                                         
     59        Variable/G gs_css=0 
     60        gs_css := fSmearedCoreShellForm(smear_coef_css,smeared_css,smeared_qvals)       //this wrapper fills the STRUCT 
     61         
    5562        Display smeared_css vs smeared_qvals                                                                     
    5663        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5865        Label left "Intensity (cm\\S-1\\M)" 
    5966        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     67         
     68        SetDataFolder root: 
     69End 
     70 
     71 
     72//AAO version 
     73Function CoreShellForm(cw,yw,xw) : FitFunc 
     74        Wave cw,yw,xw 
     75 
     76#if exists("CoreShellFormX") 
     77        yw = CoreShellFormX(cw,xw) 
     78#else 
     79        yw = fCoreShellForm(cw,xw) 
     80#endif 
     81        return(0) 
    6082End 
    6183 
     
    6385// unsmeared model calculation 
    6486/////////////////////////// 
    65 Function CoreShellForm(w,x) : FitFunc 
     87Function fCoreShellForm(w,x) : FitFunc 
    6688        Wave w 
    6789        Variable x 
     
    117139 
    118140// this is all there is to the smeared calculation! 
    119 Function SmearedCoreShellForm(w,x) :FitFunc 
    120         Wave w 
    121         Variable x 
     141Function SmearedCoreShellForm(s) :FitFunc 
     142        Struct ResSmearAAOStruct &s 
     143 
     144////the name of your unsmeared model is the first argument 
     145        s.yW = Smear_Model_20(CoreShellForm,s.coefW,s.xW,s.resW) 
     146 
     147        return(0) 
     148End 
     149 
     150//wrapper to calculate the smeared model as an AAO-Struct 
     151// fills the struct and calls the ususal function with the STRUCT parameter 
     152// 
     153// used only for the dependency, not for fitting 
     154// 
     155Function fSmearedCoreShellForm(coefW,yW,xW) 
     156        Wave coefW,yW,xW 
    122157         
    123         Variable ans 
    124         SVAR sq = gSig_Q 
    125         SVAR qb = gQ_bar 
    126         SVAR sh = gShadow 
    127         SVAR gQ = gQVals 
     158        String str = getWavesDataFolder(yW,0) 
     159        String DF="root:"+str+":" 
    128160         
    129         //the name of your unsmeared model is the first argument 
    130         ans = Smear_Model_20(CoreShellForm,$sq,$qb,$sh,$gQ,w,x) 
    131  
    132         return(ans) 
     161        WAVE resW = $(DF+str+"_res") 
     162         
     163        STRUCT ResSmearAAOStruct fs 
     164        WAVE fs.coefW = coefW    
     165        WAVE fs.yW = yW 
     166        WAVE fs.xW = xW 
     167        WAVE fs.resW = resW 
     168         
     169        Variable err 
     170        err = SmearedCoreShellForm(fs) 
     171         
     172        return (0) 
    133173End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CoreShellCylinder.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
     
    2425        make/o/t parameters_cscyl = {"scale","core radius (A)","shell THICKNESS (A)","CORE length (A)","SLD core (A^-2)","SLD shell (A^-2)","SLD solvent (A^-2)","incoh. bkg (cm^-1)"} 
    2526        Edit parameters_cscyl,coef_cscyl 
    26         ywave_cscyl := CoreShellCylinderForm(coef_cscyl,xwave_cscyl) 
     27        Variable/G root:g_cscyl 
     28        g_cscyl := CoreShellCylinder(coef_cscyl,ywave_cscyl,xwave_cscyl) 
     29//      ywave_cscyl := CoreShellCylinder(coef_cscyl,xwave_cscyl) 
    2730        Display ywave_cscyl vs xwave_cscyl 
    2831        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3134        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    3235End 
     36 
    3337/////////////////////////////////////////////////////////// 
    34  
    35 Proc PlotSmearedCSCylinderForm()         
    36         //no input parameters necessary, it MUST use the experimental q-values 
    37         // from the experimental data read in from an AVE/QSIG data file 
    38          
    39         // if no gQvals wave, data must not have been loaded => abort 
    40         if(ResolutionWavesMissing()) 
     38// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     39Proc PlotSmearedCSCylinderForm(str)                                                              
     40        String str 
     41        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     42         
     43        // if any of the resolution waves are missing => abort 
     44        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    4145                Abort 
    4246        endif 
     47         
     48        SetDataFolder $("root:"+str) 
    4349         
    4450        // Setup parameter table for model function 
     
    4955        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    5056        // make extra copy of experimental q-values for easy plotting 
    51         Duplicate/O $gQvals smeared_cscyl,smeared_qvals 
     57        Duplicate/O $(str+"_q") smeared_cscyl,smeared_qvals 
    5258        SetScale d,0,0,"1/cm",smeared_cscyl      
    53  
    54         smeared_cscyl := SmearedCoreShellCylinderForm(smear_coef_cscyl,$gQvals) 
     59                                         
     60        Variable/G gs_cscyl=0 
     61        gs_cscyl := fSmearedCoreShellCylinderForm(smear_coef_cscyl,smeared_cscyl,smeared_qvals) //this wrapper fills the STRUCT 
     62         
    5563        Display smeared_cscyl vs smeared_qvals 
    5664        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5866        Label left "Intensity (cm\\S-1\\M)" 
    5967        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     68         
     69        SetDataFolder root: 
     70End 
     71         
     72 
     73//AAO version 
     74Function CoreShellCylinder(cw,yw,xw) : FitFunc 
     75        Wave cw,yw,xw 
     76 
     77#if exists("CoreShellCylinderX") 
     78        yw = CoreShellCylinderX(cw,xw) 
     79#else 
     80        yw = fCoreShellCylinder(cw,xw) 
     81#endif 
     82        return(0) 
    6083End 
    6184 
     
    6386// unsmeared model calculation 
    6487/////////////////////////// 
    65 Function CoreShellCylinderForm(w,x) : FitFunc 
     88Function fCoreShellCylinder(w,x) : FitFunc 
    6689        Wave w 
    6790        Variable x 
     
    200223 
    201224// this is all there is to the smeared calculation! 
    202 Function SmearedCoreShellCylinderForm(w,x) :FitFunc 
    203         Wave w 
    204         Variable x 
    205          
    206         Variable ans 
    207         SVAR sq = gSig_Q 
    208         SVAR qb = gQ_bar 
    209         SVAR sh = gShadow 
    210         SVAR gQ = gQVals 
    211          
    212         //the name of your unsmeared model is the first argument 
    213         ans = Smear_Model_20(CoreShellCylinderForm,$sq,$qb,$sh,$gQ,w,x) 
    214  
    215         return(ans) 
    216 End 
    217  
     225Function SmearedCoreShellCylinderForm(s) :FitFunc 
     226        Struct ResSmearAAOStruct &s 
     227 
     228////the name of your unsmeared model is the first argument 
     229        s.yW = Smear_Model_20(CoreShellCylinder,s.coefW,s.xW,s.resW) 
     230 
     231        return(0) 
     232End 
     233 
     234 
     235//wrapper to calculate the smeared model as an AAO-Struct 
     236// fills the struct and calls the ususal function with the STRUCT parameter 
     237// 
     238// used only for the dependency, not for fitting 
     239// 
     240Function fSmearedCoreShellCylinderForm(coefW,yW,xW) 
     241        Wave coefW,yW,xW 
     242         
     243        String str = getWavesDataFolder(yW,0) 
     244        String DF="root:"+str+":" 
     245         
     246        WAVE resW = $(DF+str+"_res") 
     247         
     248        STRUCT ResSmearAAOStruct fs 
     249        WAVE fs.coefW = coefW    
     250        WAVE fs.yW = yW 
     251        WAVE fs.xW = xW 
     252        WAVE fs.resW = resW 
     253         
     254        Variable err 
     255        err = SmearedCoreShellCylinderForm(fs) 
     256         
     257        return (0) 
     258End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CoreShell_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24//// include everything that is necessary 
    35// 
     
    2022        make/o/t parameters_CSS_HS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"} 
    2123        Edit/K=1 parameters_CSS_HS,coef_CSS_HS 
    22         ywave_CSS_HS := CoreShell_HS(coef_CSS_HS,xwave_CSS_HS) 
     24         
     25        Variable/G root:g_CSS_HS 
     26        g_CSS_HS := CoreShell_HS(coef_CSS_HS,ywave_CSS_HS,xwave_CSS_HS) 
    2327        Display/K=1 ywave_CSS_HS vs xwave_CSS_HS 
    2428        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2933End 
    3034 
    31 Proc PlotSmearedCoreShell_HS()                                                           
    32         //no input parameters necessary, it MUST use the experimental q-values 
    33         // from the experimental data read in from an AVE/QSIG data file 
    34          
    35         // if no gQvals wave, data must not have been loaded => abort 
    36         if(ResolutionWavesMissing()) 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedCoreShell_HS(str)                                                                
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     39         
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3742                Abort 
    3843        endif 
     44         
     45        SetDataFolder $("root:"+str) 
    3946         
    4047        // Setup parameter table for model function 
     
    4552        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4653        // make extra copy of experimental q-values for easy plotting 
    47         Duplicate/O $gQvals smeared_CSS_HS,smeared_qvals                                 
     54        Duplicate/O $(str+"_q") smeared_CSS_HS,smeared_qvals                             
    4855        SetScale d,0,0,"1/cm",smeared_CSS_HS                                                     
    49  
    50         smeared_CSS_HS := SmearedCoreShell_HS(smear_coef_CSS_HS,$gQvals)                 
     56                                         
     57        Variable/G gs_CSS_HS=0 
     58        gs_CSS_HS := fSmearedCoreShell_HS(smear_coef_CSS_HS,smeared_CSS_HS,smeared_qvals)       //this wrapper fills the STRUCT 
     59         
    5160        Display smeared_CSS_HS vs smeared_qvals                                                                  
    5261        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5564 
    5665        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    57 End 
    58  
    59 Function CoreShell_HS(w,x) : FitFunc 
    60         Wave w 
    61         Variable x 
     66         
     67        SetDataFolder root: 
     68End 
     69         
     70 
     71Function CoreShell_HS(w,yw,xw) : FitFunc 
     72        Wave w,yw,xw 
    6273         
    6374        Variable inten 
     
    7990         
    8091        //calculate each and combine 
    81         inten = CoreShellForm(form_CSS_HS,x) 
    82         inten *= HardSphereStruct(struct_CSS_HS,x) 
    83         inten *= w[0] 
    84         inten += w[6] 
     92        Duplicate/O xw temp_CSS_HS_PQ,temp_CSS_HS_SQ            //make waves for the AAO 
     93        CoreShellForm(form_CSS_HS,temp_CSS_HS_PQ,xw) 
     94        HardSphereStruct(struct_CSS_HS,temp_CSS_HS_SQ,xw) 
     95        yw = temp_CSS_HS_PQ * temp_CSS_HS_SQ 
     96        yw *= w[0] 
     97        yw += w[6] 
    8598         
    8699        //cleanup waves 
    87100//      Killwaves/Z form_CSS_HS,struct_CSS_HS 
    88101         
    89         return (inten) 
     102        return (0) 
    90103End 
    91104 
     
    102115        make/o/t parameters_CSS_SW = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"} 
    103116        Edit/K=1 parameters_CSS_SW,coef_CSS_SW 
    104         ywave_CSS_SW := CoreShell_SW(coef_CSS_SW,xwave_CSS_SW) 
     117         
     118        Variable/G root:g_CSS_SW 
     119        g_CSS_SW := CoreShell_SW(coef_CSS_SW,ywave_CSS_SW,xwave_CSS_SW) 
    105120        Display/K=1 ywave_CSS_SW vs xwave_CSS_SW 
    106121        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    111126End 
    112127 
    113 Proc PlotSmearedCoreShell_SW()                                                           
    114         //no input parameters necessary, it MUST use the experimental q-values 
    115         // from the experimental data read in from an AVE/QSIG data file 
    116          
    117         // if no gQvals wave, data must not have been loaded => abort 
    118         if(ResolutionWavesMissing()) 
     128// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     129Proc PlotSmearedCoreShell_SW(str)                                                                
     130        String str 
     131        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     132         
     133        // if any of the resolution waves are missing => abort 
     134        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    119135                Abort 
    120136        endif 
     137         
     138        SetDataFolder $("root:"+str) 
    121139         
    122140        // Setup parameter table for model function 
     
    127145        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    128146        // make extra copy of experimental q-values for easy plotting 
    129         Duplicate/O $gQvals smeared_CSS_SW,smeared_qvals                                 
     147        Duplicate/O $(str+"_q") smeared_CSS_SW,smeared_qvals                             
    130148        SetScale d,0,0,"1/cm",smeared_CSS_SW                                                     
    131  
    132         smeared_CSS_SW := SmearedCoreShell_SW(smear_coef_CSS_SW,$gQvals)                 
     149                                         
     150        Variable/G gs_CSS_SW=0 
     151        gs_CSS_SW := fSmearedCoreShell_SW(smear_coef_CSS_SW,smeared_CSS_SW,smeared_qvals)       //this wrapper fills the STRUCT 
     152         
    133153        Display smeared_CSS_SW vs smeared_qvals                                                                  
    134154        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    137157 
    138158        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    139 End 
    140  
    141 Function CoreShell_SW(w,x) : FitFunc 
    142         Wave w 
    143         Variable x 
     159         
     160        SetDataFolder root: 
     161End 
     162         
     163 
     164Function CoreShell_SW(w,yw,xw) : FitFunc 
     165        Wave w,yw,xw 
    144166         
    145167        Variable inten 
     
    163185         
    164186        //calculate each and combine 
    165         inten = CoreShellForm(form_CSS_SW,x) 
    166         inten *= SquareWellStruct(struct_CSS_SW,x) 
    167         inten *= w[0] 
    168         inten += w[8] 
     187        Duplicate/O xw temp_CSS_SW_PQ,temp_CSS_SW_SQ            //make waves for the AAO 
     188        CoreShellForm(form_CSS_SW,temp_CSS_SW_PQ,xw) 
     189        SquareWellStruct(struct_CSS_SW,temp_CSS_SW_SQ,xw) 
     190        yw = temp_CSS_SW_PQ * temp_CSS_SW_SQ 
     191        yw *= w[0] 
     192        yw += w[8] 
    169193         
    170194        //cleanup waves 
    171195//      Killwaves/Z form_CSS_SW,struct_CSS_SW 
    172196         
    173         return (inten) 
     197        return (0) 
    174198End 
    175199 
     
    194218        make/o/t parameters_CSS_SC = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","charge","Monovalent salt (M)","Temperature (K)","dielectric const.","bkg (cm-1)"} 
    195219        Edit/K=1 parameters_CSS_SC,coef_CSS_SC 
    196         ywave_CSS_SC := CoreShell_SC(coef_CSS_SC,xwave_CSS_SC) 
     220         
     221        Variable/G root:g_CSS_SC 
     222        g_CSS_SC := CoreShell_SC(coef_CSS_SC,ywave_CSS_SC,xwave_CSS_SC) 
    197223        Display/K=1 ywave_CSS_SC vs xwave_CSS_SC 
    198224        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    203229End 
    204230 
    205 Proc PlotSmearedCoreShell_SC()                                                           
    206         //no input parameters necessary, it MUST use the experimental q-values 
    207         // from the experimental data read in from an AVE/QSIG data file 
    208          
    209         // if no gQvals wave, data must not have been loaded => abort 
    210         if(ResolutionWavesMissing()) 
     231// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     232Proc PlotSmearedCoreShell_SC(str)                                                                
     233        String str 
     234        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     235         
     236        // if any of the resolution waves are missing => abort 
     237        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    211238                Abort 
    212239        endif 
     240         
     241        SetDataFolder $("root:"+str) 
    213242         
    214243        if (DataFolderExists("root:HayPenMSA")) 
     
    226255        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    227256        // make extra copy of experimental q-values for easy plotting 
    228         Duplicate/O $gQvals smeared_CSS_SC,smeared_qvals                                 
     257        Duplicate/O $(str+"_q") smeared_CSS_SC,smeared_qvals                             
    229258        SetScale d,0,0,"1/cm",smeared_CSS_SC                                                     
    230  
    231         smeared_CSS_SC := SmearedCoreShell_SC(smear_coef_CSS_SC,$gQvals)                 
     259                                         
     260        Variable/G gs_CSS_SC=0 
     261        gs_CSS_SC := fSmearedCoreShell_SC(smear_coef_CSS_SC,smeared_CSS_SC,smeared_qvals)       //this wrapper fills the STRUCT 
     262         
    232263        Display smeared_CSS_SC vs smeared_qvals                                                                  
    233264        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    236267 
    237268        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    238 End 
    239  
    240 Function CoreShell_SC(w,x) : FitFunc 
    241         Wave w 
    242         Variable x 
     269         
     270        SetDataFolder root: 
     271End 
     272         
     273 
     274Function CoreShell_SC(w,yw,xw) : FitFunc 
     275        Wave w,yw,xw 
    243276         
    244277        Variable inten 
     
    264297         
    265298        //calculate each and combine 
    266         inten = CoreShellForm(form_CSS_SC,x) 
    267         inten *= HayterPenfoldMSA(struct_CSS_SC,x) 
    268         inten *= w[0] 
    269         inten += w[10] 
     299        Duplicate/O xw temp_CSS_SC_PQ,temp_CSS_SC_SQ            //make waves for the AAO 
     300        CoreShellForm(form_CSS_SC,temp_CSS_SC_PQ,xw) 
     301        HayterPenfoldMSA(struct_CSS_SC,temp_CSS_SC_SQ,xw) 
     302        yw = temp_CSS_SC_PQ * temp_CSS_SC_SQ 
     303        yw *= w[0] 
     304        yw += w[10] 
    270305         
    271306        //cleanup waves 
    272307//      Killwaves/Z form_CSS_SC,struct_CSS_SC 
    273308         
    274         return (inten) 
     309        return (0) 
    275310End 
    276311 
     
    287322        make/o/t parameters_CSS_SHS = {"volume fraction","core rad (A)","shell thickness (A)","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"} 
    288323        Edit/K=1 parameters_CSS_SHS,coef_CSS_SHS 
    289         ywave_CSS_SHS := CoreShell_SHS(coef_CSS_SHS,xwave_CSS_SHS) 
     324         
     325        Variable/G root:g_CSS_SHS 
     326        g_CSS_SHS := CoreShell_SHS(coef_CSS_SHS,ywave_CSS_SHS,xwave_CSS_SHS) 
    290327        Display/K=1 ywave_CSS_SHS vs xwave_CSS_SHS 
    291328        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    296333End 
    297334 
    298 Proc PlotSmearedCoreShell_SHS()                                                          
    299         //no input parameters necessary, it MUST use the experimental q-values 
    300         // from the experimental data read in from an AVE/QSIG data file 
    301          
    302         // if no gQvals wave, data must not have been loaded => abort 
    303         if(ResolutionWavesMissing()) 
     335// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     336Proc PlotSmearedCoreShell_SHS(str)                                                               
     337        String str 
     338        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     339         
     340        // if any of the resolution waves are missing => abort 
     341        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    304342                Abort 
    305343        endif 
     344         
     345        SetDataFolder $("root:"+str) 
    306346         
    307347        // Setup parameter table for model function 
     
    312352        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    313353        // make extra copy of experimental q-values for easy plotting 
    314         Duplicate/O $gQvals smeared_CSS_SHS,smeared_qvals                                
     354        Duplicate/O $(str+"_q") smeared_CSS_SHS,smeared_qvals                            
    315355        SetScale d,0,0,"1/cm",smeared_CSS_SHS                                                    
    316  
    317         smeared_CSS_SHS := SmearedCoreShell_SHS(smear_coef_CSS_SHS,$gQvals)              
     356                                         
     357        Variable/G gs_CSS_SHS=0 
     358        gs_CSS_SHS := fSmearedCoreShell_SHS(smear_coef_CSS_SHS,smeared_CSS_SHS,smeared_qvals)   //this wrapper fills the STRUCT 
     359         
    318360        Display smeared_CSS_SHS vs smeared_qvals                                                                         
    319361        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    322364 
    323365        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    324 End 
    325  
    326 Function CoreShell_SHS(w,x) : FitFunc 
    327         Wave w 
    328         Variable x 
     366         
     367        SetDataFolder root: 
     368End 
     369         
     370 
     371Function CoreShell_SHS(w,yw,xw) : FitFunc 
     372        Wave w,yw,xw 
    329373         
    330374        Variable inten 
     
    348392         
    349393        //calculate each and combine 
    350         inten = CoreShellForm(form_CSS_SHS,x) 
    351         inten *= StickyHS_Struct(struct_CSS_SHS,x) 
    352         inten *= w[0] 
    353         inten += w[8] 
     394        Duplicate/O xw temp_CSS_SHS_PQ,temp_CSS_SHS_SQ          //make waves for the AAO 
     395        CoreShellForm(form_CSS_SHS,temp_CSS_SHS_PQ,xw) 
     396        StickyHS_Struct(struct_CSS_SHS,temp_CSS_SHS_SQ,xw) 
     397        yw = temp_CSS_SHS_PQ * temp_CSS_SHS_SQ 
     398        yw *= w[0] 
     399        yw += w[8] 
    354400         
    355401        //cleanup waves 
    356402//      Killwaves/Z form_CSS_SHS,struct_CSS_SHS 
    357403         
    358         return (inten) 
     404        return (0) 
    359405End 
    360406 
     
    362408 
    363409// this is all there is to the smeared calculation! 
    364 Function SmearedCoreShell_HS(w,x) :FitFunc 
    365         Wave w 
    366         Variable x 
    367          
    368         Variable ans 
    369         SVAR sq = gSig_Q 
    370         SVAR qb = gQ_bar 
    371         SVAR sh = gShadow 
    372         SVAR gQ = gQVals 
    373          
    374         //the name of your unsmeared model is the first argument 
    375         ans = Smear_Model_20(CoreShell_HS,$sq,$qb,$sh,$gQ,w,x) 
    376  
    377         return(ans) 
     410Function SmearedCoreShell_HS(s) :FitFunc 
     411        Struct ResSmearAAOStruct &s 
     412 
     413//      the name of your unsmeared model is the first argument 
     414        s.yW = Smear_Model_20(CoreShell_HS,s.coefW,s.xW,s.resW) 
     415 
     416        return(0) 
    378417End 
    379418 
    380419// this is all there is to the smeared calculation! 
    381 Function SmearedCoreShell_SW(w,x) :FitFunc 
    382         Wave w 
    383         Variable x 
    384          
    385         Variable ans 
    386         SVAR sq = gSig_Q 
    387         SVAR qb = gQ_bar 
    388         SVAR sh = gShadow 
    389         SVAR gQ = gQVals 
    390          
    391         //the name of your unsmeared model is the first argument 
    392         ans = Smear_Model_20(CoreShell_SW,$sq,$qb,$sh,$gQ,w,x) 
    393  
    394         return(ans) 
     420Function SmearedCoreShell_SW(s) :FitFunc 
     421        Struct ResSmearAAOStruct &s 
     422 
     423//      the name of your unsmeared model is the first argument 
     424        s.yW = Smear_Model_20(CoreShell_SW,s.coefW,s.xW,s.resW) 
     425 
     426        return(0) 
    395427End 
    396428 
    397429// this is all there is to the smeared calculation! 
    398 Function SmearedCoreShell_SC(w,x) :FitFunc 
    399         Wave w 
    400         Variable x 
    401          
    402         Variable ans 
    403         SVAR sq = gSig_Q 
    404         SVAR qb = gQ_bar 
    405         SVAR sh = gShadow 
    406         SVAR gQ = gQVals 
    407          
    408         //the name of your unsmeared model is the first argument 
    409         ans = Smear_Model_20(CoreShell_SC,$sq,$qb,$sh,$gQ,w,x) 
    410  
    411         return(ans) 
     430Function SmearedCoreShell_SC(s) :FitFunc 
     431        Struct ResSmearAAOStruct &s 
     432 
     433//      the name of your unsmeared model is the first argument 
     434        s.yW = Smear_Model_20(CoreShell_SC,s.coefW,s.xW,s.resW) 
     435 
     436        return(0) 
    412437End 
    413438 
    414439// this is all there is to the smeared calculation! 
    415 Function SmearedCoreShell_SHS(w,x) :FitFunc 
    416         Wave w 
    417         Variable x 
    418          
    419         Variable ans 
    420         SVAR sq = gSig_Q 
    421         SVAR qb = gQ_bar 
    422         SVAR sh = gShadow 
    423         SVAR gQ = gQVals 
    424          
    425         //the name of your unsmeared model is the first argument 
    426         ans = Smear_Model_20(CoreShell_SHS,$sq,$qb,$sh,$gQ,w,x) 
    427  
    428         return(ans) 
    429 End 
     440Function SmearedCoreShell_SHS(s) :FitFunc 
     441        Struct ResSmearAAOStruct &s 
     442 
     443//      the name of your unsmeared model is the first argument 
     444        s.yW = Smear_Model_20(CoreShell_SHS,s.coefW,s.xW,s.resW) 
     445 
     446        return(0) 
     447End 
     448 
     449//wrapper to calculate the smeared model as an AAO-Struct 
     450// fills the struct and calls the ususal function with the STRUCT parameter 
     451// 
     452// used only for the dependency, not for fitting 
     453// 
     454Function fSmearedCoreShell_HS(coefW,yW,xW) 
     455        Wave coefW,yW,xW 
     456         
     457        String str = getWavesDataFolder(yW,0) 
     458        String DF="root:"+str+":" 
     459         
     460        WAVE resW = $(DF+str+"_res") 
     461         
     462        STRUCT ResSmearAAOStruct fs 
     463        WAVE fs.coefW = coefW    
     464        WAVE fs.yW = yW 
     465        WAVE fs.xW = xW 
     466        WAVE fs.resW = resW 
     467         
     468        Variable err 
     469        err = SmearedCoreShell_HS(fs) 
     470         
     471        return (0) 
     472End 
     473 
     474//wrapper to calculate the smeared model as an AAO-Struct 
     475// fills the struct and calls the ususal function with the STRUCT parameter 
     476// 
     477// used only for the dependency, not for fitting 
     478// 
     479Function fSmearedCoreShell_SW(coefW,yW,xW) 
     480        Wave coefW,yW,xW 
     481         
     482        String str = getWavesDataFolder(yW,0) 
     483        String DF="root:"+str+":" 
     484         
     485        WAVE resW = $(DF+str+"_res") 
     486         
     487        STRUCT ResSmearAAOStruct fs 
     488        WAVE fs.coefW = coefW    
     489        WAVE fs.yW = yW 
     490        WAVE fs.xW = xW 
     491        WAVE fs.resW = resW 
     492         
     493        Variable err 
     494        err = SmearedCoreShell_SW(fs) 
     495         
     496        return (0) 
     497End 
     498 
     499//wrapper to calculate the smeared model as an AAO-Struct 
     500// fills the struct and calls the ususal function with the STRUCT parameter 
     501// 
     502// used only for the dependency, not for fitting 
     503// 
     504Function fSmearedCoreShell_SC(coefW,yW,xW) 
     505        Wave coefW,yW,xW 
     506         
     507        String str = getWavesDataFolder(yW,0) 
     508        String DF="root:"+str+":" 
     509         
     510        WAVE resW = $(DF+str+"_res") 
     511         
     512        STRUCT ResSmearAAOStruct fs 
     513        WAVE fs.coefW = coefW    
     514        WAVE fs.yW = yW 
     515        WAVE fs.xW = xW 
     516        WAVE fs.resW = resW 
     517         
     518        Variable err 
     519        err = SmearedCoreShell_SC(fs) 
     520         
     521        return (0) 
     522End 
     523 
     524//wrapper to calculate the smeared model as an AAO-Struct 
     525// fills the struct and calls the ususal function with the STRUCT parameter 
     526// 
     527// used only for the dependency, not for fitting 
     528// 
     529Function fSmearedCoreShell_SHS(coefW,yW,xW) 
     530        Wave coefW,yW,xW 
     531         
     532        String str = getWavesDataFolder(yW,0) 
     533        String DF="root:"+str+":" 
     534         
     535        WAVE resW = $(DF+str+"_res") 
     536         
     537        STRUCT ResSmearAAOStruct fs 
     538        WAVE fs.coefW = coefW    
     539        WAVE fs.yW = yW 
     540        WAVE fs.xW = xW 
     541        WAVE fs.resW = resW 
     542         
     543        Variable err 
     544        err = SmearedCoreShell_SHS(fs) 
     545         
     546        return (0) 
     547End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CylinderForm.ipf

    r49 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
     
    2122        make/o/t parameters_cyl = {"scale","radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"} 
    2223        Edit parameters_cyl,coef_cyl 
    23         ywave_cyl := CylinderForm(coef_cyl,xwave_cyl) 
     24        Variable/G root:g_cyl 
     25        g_cyl := CylinderForm(coef_cyl,ywave_cyl,xwave_cyl) 
     26//      ywave_cyl := CylinderForm(coef_cyl,xwave_cyl) 
    2427        Display ywave_cyl vs xwave_cyl 
    2528        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2831        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    2932End 
     33 
    3034/////////////////////////////////////////////////////////// 
    31  
    32 Proc PlotSmearedCylinderForm()   
    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 
    35          
    36         // if no gQvals wave, data must not have been loaded => abort 
    37         if(ResolutionWavesMissing()) 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedCylinderForm(str)                                                                
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     39         
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3842                Abort 
    3943        endif 
     44         
     45        SetDataFolder $("root:"+str) 
    4046         
    4147        // Setup parameter table for model function 
     
    4652        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4753        // make extra copy of experimental q-values for easy plotting 
    48         Duplicate/O $gQvals smeared_cyl,smeared_qvals 
     54        Duplicate/O $(str+"_q") smeared_cyl,smeared_qvals 
    4955        SetScale d,0,0,"1/cm",smeared_cyl        
    50  
    51         smeared_cyl := SmearedCylinderForm(smear_coef_cyl,$gQvals) 
     56                                         
     57        Variable/G gs_cyl=0 
     58        gs_cyl := fSmearedCylinderForm(smear_coef_cyl,smeared_cyl,smeared_qvals)        //this wrapper fills the STRUCT 
     59         
    5260        Display smeared_cyl vs smeared_qvals 
    5361        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5563        Label left "Intensity (cm\\S-1\\M)" 
    5664        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     65         
     66        SetDataFolder root: 
     67End 
     68 
     69// AAO verison 
     70Function CylinderForm(cw,yw,xw) : FitFunc 
     71        Wave cw,yw,xw 
     72 
     73#if exists("CylinderFormX") 
     74        yw = CylinderFormX(cw,xw) 
     75#else 
     76        yw = fCylinderForm(cw,xw) 
     77#endif 
     78        return(0) 
    5779End 
    5880 
     
    6082// unsmeared model calculation 
    6183/////////////////////////// 
    62 Function CylinderForm(w,x) : FitFunc 
     84Function fCylinderForm(w,x) : FitFunc 
    6385        Wave w 
    6486        Variable x 
    65  
    66         String funcStr = SelectString(exists("CylinderFormX")==3,"", "CylinderFormX") 
    67         if(strlen(funcStr) > 0) 
    68                 FUNCREF SANSModel_proto func=$funcStr 
    69                 return func(w,x) 
    70         endif 
    7187         
    7288//The input variables are (and output) 
     
    190206 
    191207// this is all there is to the smeared calculation! 
    192 Function SmearedCylinderForm(w,x) :FitFunc 
    193         Wave w 
    194         Variable x 
    195          
    196         Variable ans 
    197         SVAR sq = gSig_Q 
    198         SVAR qb = gQ_bar 
    199         SVAR sh = gShadow 
    200         SVAR gQ = gQVals 
    201          
    202         //the name of your unsmeared model is the first argument 
    203         if(exists("CylinderFormX") == 3) 
    204                 ans = Smear_Model_20($"CylinderFormX",$sq,$qb,$sh,$gQ,w,x) 
    205         else 
    206         ans = Smear_Model_20(CylinderForm,$sq,$qb,$sh,$gQ,w,x) 
    207         endif 
    208  
    209         return(ans) 
    210 End 
    211  
     208Function SmearedCylinderForm(s) :FitFunc 
     209        Struct ResSmearAAOStruct &s 
     210 
     211////the name of your unsmeared model is the first argument 
     212        s.yW = Smear_Model_20(CylinderForm,s.coefW,s.xW,s.resW) 
     213 
     214        return(0) 
     215End 
     216 
     217 
     218//wrapper to calculate the smeared model as an AAO-Struct 
     219// fills the struct and calls the ususal function with the STRUCT parameter 
     220// 
     221// used only for the dependency, not for fitting 
     222// 
     223Function fSmearedCylinderForm(coefW,yW,xW) 
     224        Wave coefW,yW,xW 
     225         
     226        String str = getWavesDataFolder(yW,0) 
     227        String DF="root:"+str+":" 
     228         
     229        WAVE resW = $(DF+str+"_res") 
     230         
     231        STRUCT ResSmearAAOStruct fs 
     232        WAVE fs.coefW = coefW    
     233        WAVE fs.yW = yW 
     234        WAVE fs.xW = xW 
     235        WAVE fs.resW = resW 
     236         
     237        Variable err 
     238        err = SmearedCylinderForm(fs) 
     239         
     240        return (0) 
     241End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Cylinder_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34// be sure to include all the necessary files... 
     
    2122        make/o/t parameters_CYL_HS = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"} 
    2223        Edit parameters_CYL_HS,coef_CYL_HS 
    23         ywave_CYL_HS := Cylinder_HS(coef_CYL_HS,xwave_CYL_HS) 
     24         
     25        Variable/G root:g_CYL_HS 
     26        g_CYL_HS := Cylinder_HS(coef_CYL_HS,ywave_CYL_HS,xwave_CYL_HS) 
    2427        Display ywave_CYL_HS vs xwave_CYL_HS 
    2528        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3033End 
    3134 
    32 Proc PlotSmearedCylinder_HS()                                                            
    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 
    35          
    36         // if no gQvals wave, data must not have been loaded => abort 
    37         if(ResolutionWavesMissing()) 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedCylinder_HS(str)                                                                 
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     39         
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3842                Abort 
    3943        endif 
    40                  
     44         
     45        SetDataFolder $("root:"+str) 
     46         
    4147        // Setup parameter table for model function 
    4248        Make/O/D smear_coef_CYL_HS = {0.01,20.,400,3.0e-6,0.01} 
     
    4652        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4753        // make extra copy of experimental q-values for easy plotting 
    48         Duplicate/O $gQvals smeared_CYL_HS,smeared_qvals                                 
     54        Duplicate/O $(str+"_q") smeared_CYL_HS,smeared_qvals                             
    4955        SetScale d,0,0,"1/cm",smeared_CYL_HS                                                     
    50  
    51         smeared_CYL_HS := SmearedCylinder_HS(smear_coef_CYL_HS,$gQvals)          
     56                                         
     57        Variable/G gs_CYL_HS=0 
     58        gs_CYL_HS := fSmearedCylinder_HS(smear_coef_CYL_HS,smeared_CYL_HS,smeared_qvals)        //this wrapper fills the STRUCT 
     59         
    5260        Display smeared_CYL_HS vs smeared_qvals                                                                  
    5361        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5664 
    5765        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    58 End 
    59  
    60 Function Cylinder_HS(w,x) : FitFunc 
    61         Wave w 
    62         Variable x 
     66         
     67        SetDataFolder root: 
     68End 
     69                 
     70 
     71Function Cylinder_HS(w,yw,xw) : FitFunc 
     72        Wave w,yw,xw 
    6373         
    6474        Variable inten,rad,len 
     
    8090         
    8191        //calculate each and combine 
    82         inten = CylinderForm(form_CYL_HS,x) 
    83         inten *= HardSphereStruct(struct_CYL_HS,x) 
    84         inten *= w[0] 
    85         inten += w[4] 
     92        Duplicate/O xw temp_CYL_HS_PQ,temp_CYL_HS_SQ            //make waves for the AAO 
     93        CylinderForm(form_CYL_HS,temp_CYL_HS_PQ,xw) 
     94        HardSphereStruct(struct_CYL_HS,temp_CYL_HS_SQ,xw) 
     95        yw = temp_CYL_HS_PQ * temp_CYL_HS_SQ 
     96        yw *= w[0] 
     97        yw += w[4] 
    8698         
    8799        //cleanup waves (don't do this - it takes a lot of time...) 
    88100//      Killwaves/Z form_CYL_HS,struct_CYL_HS 
    89101         
    90         return (inten) 
     102        return (0) 
    91103End 
    92104 
     
    102114        make/o/t parameters_CYL_SW = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","well depth (kT)","well width (diam.)","incoh. bkg (cm^-1)"} 
    103115        Edit parameters_CYL_SW,coef_CYL_SW 
    104         ywave_CYL_SW := Cylinder_SW(coef_CYL_SW,xwave_CYL_SW) 
     116         
     117        Variable/G root:g_CYL_SW 
     118        g_CYL_SW := Cylinder_SW(coef_CYL_SW,ywave_CYL_SW,xwave_CYL_SW) 
    105119        Display ywave_CYL_SW vs xwave_CYL_SW 
    106120        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    111125End 
    112126 
    113 Proc PlotSmearedCylinder_SW()                                                            
    114         //no input parameters necessary, it MUST use the experimental q-values 
    115         // from the experimental data read in from an AVE/QSIG data file 
    116          
    117         // if no gQvals wave, data must not have been loaded => abort 
    118         if(ResolutionWavesMissing()) 
     127// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     128Proc PlotSmearedCylinder_SW(str)                                                                 
     129        String str 
     130        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     131         
     132        // if any of the resolution waves are missing => abort 
     133        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    119134                Abort 
    120135        endif 
     136         
     137        SetDataFolder $("root:"+str) 
    121138         
    122139        // Setup parameter table for model function 
     
    127144        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    128145        // make extra copy of experimental q-values for easy plotting 
    129         Duplicate/O $gQvals smeared_CYL_SW,smeared_qvals                                 
     146        Duplicate/O $(str+"_q") smeared_CYL_SW,smeared_qvals                             
    130147        SetScale d,0,0,"1/cm",smeared_CYL_SW                                                     
    131  
    132         smeared_CYL_SW := SmearedCylinder_SW(smear_coef_CYL_SW,$gQvals)          
     148                                         
     149        Variable/G gs_CYL_SW=0 
     150        gs_CYL_SW := fSmearedCylinder_SW(smear_coef_CYL_SW,smeared_CYL_SW,smeared_qvals)        //this wrapper fills the STRUCT 
     151         
    133152        Display smeared_CYL_SW vs smeared_qvals                                                                  
    134153        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    137156 
    138157        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    139 End 
    140  
    141 Function Cylinder_SW(w,x) : FitFunc 
    142         Wave w 
    143         Variable x 
     158         
     159        SetDataFolder root: 
     160End 
     161         
     162 
     163Function Cylinder_SW(w,yw,xw) : FitFunc 
     164        Wave w,yw,xw 
    144165         
    145166        Variable inten,rad,len 
     
    163184         
    164185        //calculate each and combine 
    165         inten = CylinderForm(form_CYL_SW,x) 
    166         inten *= SquareWellStruct(struct_CYL_SW,x) 
    167         inten *= w[0] 
    168         inten += w[6] 
     186        Duplicate/O xw temp_CYL_SW_PQ,temp_CYL_SW_SQ            //make waves for the AAO 
     187        CylinderForm(form_CYL_SW,temp_CYL_SW_PQ,xw) 
     188        SquareWellStruct(struct_CYL_SW,temp_CYL_SW_SQ,xw) 
     189        yw = temp_CYL_SW_PQ * temp_CYL_SW_SQ 
     190        yw *= w[0] 
     191        yw += w[6] 
    169192         
    170193        //cleanup waves 
    171194//      Killwaves/Z form_CYL_SW,struct_CYL_SW 
    172195         
    173         return (inten) 
     196        return (0) 
    174197End 
    175198 
     
    192215        make/o/t parameters_CYL_SC = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","incoh. bkg (cm^-1)"} 
    193216        Edit parameters_CYL_SC,coef_CYL_SC 
    194         ywave_CYL_SC := Cylinder_SC(coef_CYL_SC,xwave_CYL_SC) 
     217         
     218        Variable/G root:g_CYL_SC 
     219        g_CYL_SC := Cylinder_SC(coef_CYL_SC,ywave_CYL_SC,xwave_CYL_SC) 
    195220        Display ywave_CYL_SC vs xwave_CYL_SC 
    196221        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    201226End 
    202227 
    203 Proc PlotSmearedCylinder_SC()                                                            
    204         //no input parameters necessary, it MUST use the experimental q-values 
    205         // from the experimental data read in from an AVE/QSIG data file 
    206          
    207         // if no gQvals wave, data must not have been loaded => abort 
    208         if(ResolutionWavesMissing()) 
     228// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     229Proc PlotSmearedCylinder_SC(str)                                                                 
     230        String str 
     231        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     232         
     233        // if any of the resolution waves are missing => abort 
     234        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    209235                Abort 
    210236        endif 
    211  
     237         
     238        SetDataFolder $("root:"+str) 
     239         
    212240        if (DataFolderExists("root:HayPenMSA")) 
    213241                Make/O/D/N=17 root:HayPenMSA:gMSAWave 
     
    224252        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    225253        // make extra copy of experimental q-values for easy plotting 
    226         Duplicate/O $gQvals smeared_CYL_SC,smeared_qvals                                 
     254        Duplicate/O $(str+"_q") smeared_CYL_SC,smeared_qvals                             
    227255        SetScale d,0,0,"1/cm",smeared_CYL_SC                                                     
    228  
    229         smeared_CYL_SC := SmearedCylinder_SC(smear_coef_CYL_SC,$gQvals)          
     256                                         
     257        Variable/G gs_CYL_SC=0 
     258        gs_CYL_SC := fSmearedCylinder_SC(smear_coef_CYL_SC,smeared_CYL_SC,smeared_qvals)        //this wrapper fills the STRUCT 
     259         
    230260        Display smeared_CYL_SC vs smeared_qvals                                                                  
    231261        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    234264 
    235265        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    236 End 
    237  
    238 Function Cylinder_SC(w,x) : FitFunc 
    239         Wave w 
    240         Variable x 
     266         
     267        SetDataFolder root: 
     268End 
     269 
     270 
     271Function Cylinder_SC(w,yw,xw) : FitFunc 
     272        Wave w,yw,xw 
    241273         
    242274        Variable inten,rad,len 
     
    262294         
    263295        //calculate each and combine 
    264         inten = CylinderForm(form_CYL_SC,x) 
    265         inten *= HayterPenfoldMSA(struct_CYL_SC,x) 
    266         inten *= w[0] 
    267         inten += w[8] 
     296        Duplicate/O xw temp_CYL_SC_PQ,temp_CYL_SC_SQ            //make waves for the AAO 
     297        CylinderForm(form_CYL_SC,temp_CYL_SC_PQ,xw) 
     298        HayterPenfoldMSA(struct_CYL_SC,temp_CYL_SC_SQ,xw) 
     299        yw = temp_CYL_SC_PQ * temp_CYL_SC_SQ 
     300        yw *= w[0] 
     301        yw += w[8] 
    268302         
    269303        //cleanup waves 
    270304//      Killwaves/Z form_CYL_SC,struct_CYL_SC 
    271305         
    272         return (inten) 
     306        return (0) 
    273307End 
    274308 
     
    285319        make/o/t parameters_CYL_SHS = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","perturbation parameter (0.1)","stickiness, tau","incoh. bkg (cm^-1)"} 
    286320        Edit parameters_CYL_SHS,coef_CYL_SHS 
    287         ywave_CYL_SHS := Cylinder_SHS(coef_CYL_SHS,xwave_CYL_SHS) 
     321         
     322        Variable/G root:g_CYL_SHS 
     323        g_CYL_SHS := Cylinder_SHS(coef_CYL_SHS,ywave_CYL_SHS,xwave_CYL_SHS) 
    288324        Display ywave_CYL_SHS vs xwave_CYL_SHS 
    289325        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    294330End 
    295331 
    296 Proc PlotSmearedCylinder_SHS()                                                           
    297         //no input parameters necessary, it MUST use the experimental q-values 
    298         // from the experimental data read in from an AVE/QSIG data file 
    299          
    300         // if no gQvals wave, data must not have been loaded => abort 
    301         if(ResolutionWavesMissing()) 
     332// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     333Proc PlotSmearedCylinder_SHS(str)                                                                
     334        String str 
     335        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     336         
     337        // if any of the resolution waves are missing => abort 
     338        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    302339                Abort 
    303340        endif 
     341         
     342        SetDataFolder $("root:"+str) 
    304343         
    305344        // Setup parameter table for model function 
     
    310349        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    311350        // make extra copy of experimental q-values for easy plotting 
    312         Duplicate/O $gQvals smeared_CYL_SHS,smeared_qvals                                
     351        Duplicate/O $(str+"_q") smeared_CYL_SHS,smeared_qvals                            
    313352        SetScale d,0,0,"1/cm",smeared_CYL_SHS                                                    
    314  
    315         smeared_CYL_SHS := SmearedCylinder_SHS(smear_coef_CYL_SHS,$gQvals)               
     353                                         
     354        Variable/G gs_CYL_SHS=0 
     355        gs_CYL_SHS := fSmearedCylinder_SHS(smear_coef_CYL_SHS,smeared_CYL_SHS,smeared_qvals)    //this wrapper fills the STRUCT 
     356         
    316357        Display smeared_CYL_SHS vs smeared_qvals                                                                         
    317358        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    320361 
    321362        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    322 End 
    323  
    324 Function Cylinder_SHS(w,x) : FitFunc 
    325         Wave w 
    326         Variable x 
     363         
     364        SetDataFolder root: 
     365End 
     366         
     367 
     368Function Cylinder_SHS(w,yw,xw) : FitFunc 
     369        Wave w,yw,xw 
    327370         
    328371        Variable inten,rad,len 
     
    346389         
    347390        //calculate each and combine 
    348         inten = CylinderForm(form_CYL_SHS,x) 
    349         inten *= StickyHS_Struct(struct_CYL_SHS,x) 
    350         inten *= w[0] 
    351         inten += w[6] 
     391        Duplicate/O xw temp_CYL_SHS_PQ,temp_CYL_SHS_SQ          //make waves for the AAO 
     392        CylinderForm(form_CYL_SHS,temp_CYL_SHS_PQ,xw) 
     393        StickyHS_Struct(struct_CYL_SHS,temp_CYL_SHS_SQ,xw) 
     394        yw = temp_CYL_SHS_PQ * temp_CYL_SHS_SQ 
     395        yw *= w[0] 
     396        yw += w[6] 
    352397         
    353398        //cleanup waves 
    354399//      Killwaves/Z form_CYL_SHS,struct_CYL_SHS 
    355400         
    356         return (inten) 
     401        return (0) 
    357402End 
    358403 
     
    360405 
    361406// this is all there is to the smeared calculation! 
    362 Function SmearedCylinder_HS(w,x) :FitFunc 
    363         Wave w 
    364         Variable x 
    365          
    366         Variable ans 
    367         SVAR sq = gSig_Q 
    368         SVAR qb = gQ_bar 
    369         SVAR sh = gShadow 
    370         SVAR gQ = gQVals 
    371          
    372         //the name of your unsmeared model is the first argument 
    373         ans = Smear_Model_20(Cylinder_HS,$sq,$qb,$sh,$gQ,w,x) 
    374  
    375         return(ans) 
     407Function SmearedCylinder_HS(s) :FitFunc 
     408        Struct ResSmearAAOStruct &s 
     409 
     410//      the name of your unsmeared model is the first argument 
     411        s.yW = Smear_Model_20(Cylinder_HS,s.coefW,s.xW,s.resW) 
     412 
     413        return(0) 
    376414End 
    377415 
    378416// this is all there is to the smeared calculation! 
    379 Function SmearedCylinder_SW(w,x) :FitFunc 
    380         Wave w 
    381         Variable x 
    382          
    383         Variable ans 
    384         SVAR sq = gSig_Q 
    385         SVAR qb = gQ_bar 
    386         SVAR sh = gShadow 
    387         SVAR gQ = gQVals 
    388          
    389         //the name of your unsmeared model is the first argument 
    390         ans = Smear_Model_20(Cylinder_SW,$sq,$qb,$sh,$gQ,w,x) 
    391  
    392         return(ans) 
     417Function SmearedCylinder_SW(s) :FitFunc 
     418        Struct ResSmearAAOStruct &s 
     419 
     420//      the name of your unsmeared model is the first argument 
     421        s.yW = Smear_Model_20(Cylinder_SW,s.coefW,s.xW,s.resW) 
     422 
     423        return(0) 
    393424End 
    394425 
    395426// this is all there is to the smeared calculation! 
    396 Function SmearedCylinder_SC(w,x) :FitFunc 
    397         Wave w 
    398         Variable x 
    399          
    400         Variable ans 
    401         SVAR sq = gSig_Q 
    402         SVAR qb = gQ_bar 
    403         SVAR sh = gShadow 
    404         SVAR gQ = gQVals 
    405          
    406         //the name of your unsmeared model is the first argument 
    407         ans = Smear_Model_20(Cylinder_SC,$sq,$qb,$sh,$gQ,w,x) 
    408  
    409         return(ans) 
     427Function SmearedCylinder_SC(s) :FitFunc 
     428        Struct ResSmearAAOStruct &s 
     429 
     430//      the name of your unsmeared model is the first argument 
     431        s.yW = Smear_Model_20(Cylinder_SC,s.coefW,s.xW,s.resW) 
     432 
     433        return(0) 
    410434End 
    411435 
    412436// this is all there is to the smeared calculation! 
    413 Function SmearedCylinder_SHS(w,x) :FitFunc 
    414         Wave w 
    415         Variable x 
    416          
    417         Variable ans 
    418         SVAR sq = gSig_Q 
    419         SVAR qb = gQ_bar 
    420         SVAR sh = gShadow 
    421         SVAR gQ = gQVals 
    422          
    423         //the name of your unsmeared model is the first argument 
    424         ans = Smear_Model_20(Cylinder_SHS,$sq,$qb,$sh,$gQ,w,x) 
    425  
    426         return(ans) 
    427 End 
     437Function SmearedCylinder_SHS(s) :FitFunc 
     438        Struct ResSmearAAOStruct &s 
     439 
     440//      the name of your unsmeared model is the first argument 
     441        s.yW = Smear_Model_20(Cylinder_SHS,s.coefW,s.xW,s.resW) 
     442 
     443        return(0) 
     444End 
     445 
     446//wrapper to calculate the smeared model as an AAO-Struct 
     447// fills the struct and calls the ususal function with the STRUCT parameter 
     448// 
     449// used only for the dependency, not for fitting 
     450// 
     451Function fSmearedCylinder_HS(coefW,yW,xW) 
     452        Wave coefW,yW,xW 
     453         
     454        String str = getWavesDataFolder(yW,0) 
     455        String DF="root:"+str+":" 
     456         
     457        WAVE resW = $(DF+str+"_res") 
     458         
     459        STRUCT ResSmearAAOStruct fs 
     460        WAVE fs.coefW = coefW    
     461        WAVE fs.yW = yW 
     462        WAVE fs.xW = xW 
     463        WAVE fs.resW = resW 
     464         
     465        Variable err 
     466        err = SmearedCylinder_HS(fs) 
     467         
     468        return (0) 
     469End 
     470 
     471//wrapper to calculate the smeared model as an AAO-Struct 
     472// fills the struct and calls the ususal function with the STRUCT parameter 
     473// 
     474// used only for the dependency, not for fitting 
     475// 
     476Function fSmearedCylinder_SW(coefW,yW,xW) 
     477        Wave coefW,yW,xW 
     478         
     479        String str = getWavesDataFolder(yW,0) 
     480        String DF="root:"+str+":" 
     481         
     482        WAVE resW = $(DF+str+"_res") 
     483         
     484        STRUCT ResSmearAAOStruct fs 
     485        WAVE fs.coefW = coefW    
     486        WAVE fs.yW = yW 
     487        WAVE fs.xW = xW 
     488        WAVE fs.resW = resW 
     489         
     490        Variable err 
     491        err = SmearedCylinder_SW(fs) 
     492         
     493        return (0) 
     494End 
     495 
     496//wrapper to calculate the smeared model as an AAO-Struct 
     497// fills the struct and calls the ususal function with the STRUCT parameter 
     498// 
     499// used only for the dependency, not for fitting 
     500// 
     501Function fSmearedCylinder_SC(coefW,yW,xW) 
     502        Wave coefW,yW,xW 
     503         
     504        String str = getWavesDataFolder(yW,0) 
     505        String DF="root:"+str+":" 
     506         
     507        WAVE resW = $(DF+str+"_res") 
     508         
     509        STRUCT ResSmearAAOStruct fs 
     510        WAVE fs.coefW = coefW    
     511        WAVE fs.yW = yW 
     512        WAVE fs.xW = xW 
     513        WAVE fs.resW = resW 
     514         
     515        Variable err 
     516        err = SmearedCylinder_SC(fs) 
     517         
     518        return (0) 
     519End 
     520 
     521//wrapper to calculate the smeared model as an AAO-Struct 
     522// fills the struct and calls the ususal function with the STRUCT parameter 
     523// 
     524// used only for the dependency, not for fitting 
     525// 
     526Function fSmearedCylinder_SHS(coefW,yW,xW) 
     527        Wave coefW,yW,xW 
     528         
     529        String str = getWavesDataFolder(yW,0) 
     530        String DF="root:"+str+":" 
     531         
     532        WAVE resW = $(DF+str+"_res") 
     533         
     534        STRUCT ResSmearAAOStruct fs 
     535        WAVE fs.coefW = coefW    
     536        WAVE fs.yW = yW 
     537        WAVE fs.xW = xW 
     538        WAVE fs.resW = resW 
     539         
     540        Variable err 
     541        err = SmearedCylinder_SHS(fs) 
     542         
     543        return (0) 
     544End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/DAB_model.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24//////////////////////////////////////////////////// 
    35//      C. Glinka, 11-22-98 
    46//////////////// 
     7 
     8 
     9                                                                //Debye-Anderson-Brumberger 
     10 
    511 
    612Proc PlotDAB(num,qmin,qmax) 
     
    1521        make/o/t parameters_DAB = {"Scale Factor, A ", "Correlation Length ()", "Incoherent Bgd (cm-1)"} 
    1622        Edit parameters_DAB, coef_DAB 
    17         ywave_DAB  := DAB_Model(coef_DAB, xwave_DAB) 
     23        Variable/G root:g_DAB 
     24        g_DAB  := DAB_Model(coef_DAB, ywave_DAB, xwave_DAB) 
     25//      ywave_DAB  := DAB_Model(coef_DAB, xwave_DAB) 
    1826        Display ywave_DAB vs xwave_DAB 
    1927        ModifyGraph marker=29, msize=2, mode=4 
     
    2331        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    2432End 
     33 
    2534//////////////////////////////////////////////////// 
    26 Proc PlotSmearedDAB()                                                           //Debye-Anderson-Brumberger 
    27         //no input parameters necessary, it MUST use the experimental q-values 
    28         // from the experimental data read in from an AVE/QSIG data file 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedDAB(str)                                                                 
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    2939         
    30         // if no gQvals wave, data must not have been loaded => abort 
    31         if(ResolutionWavesMissing()) 
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3242                Abort 
    3343        endif 
     44         
     45        SetDataFolder $("root:"+str) 
    3446         
    3547        // Setup parameter table for model function 
     
    4052        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4153        // make extra copy of experimental q-values for easy plotting 
    42         Duplicate/O $gQvals smeared_DAB,smeared_qvals                           // 
     54        Duplicate/O $(str+"_q") smeared_DAB,smeared_qvals                               // 
    4355        SetScale d,0,0,"1/cm",smeared_DAB                                                       // 
    44  
    45         smeared_DAB := SmearedDAB_Model(smear_coef_DAB,$gQvals)         // SMEARED function name 
     56                                         
     57        Variable/G gs_DAB=0 
     58        gs_DAB := fSmearedDAB_Model(smear_coef_DAB,smeared_DAB,smeared_qvals)   //this wrapper fills the STRUCT 
     59         
    4660        Display smeared_DAB vs smeared_qvals                                                                    // 
    4761        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    4963        Label left "Debye-Anderson-Brumberger Model (cm\\S-1\\M)" 
    5064        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    51 End     // end macro PlotSmearedDAB 
     65         
     66        SetDataFolder root: 
     67End 
    5268 
    53 Function DAB_model(w,x) : FitFunc 
     69//AAO version 
     70Function DAB_model(cw,yw,xw) : FitFunc 
     71        Wave cw,yw,xw 
     72 
     73#if exists("DAB_modelX") 
     74        yw = DAB_modelX(cw,xw) 
     75#else 
     76        yw = fDAB_model(cw,xw) 
     77#endif 
     78        return(0) 
     79End 
     80 
     81Function fDAB_model(w,x) : FitFunc 
    5482        Wave w 
    5583        Variable x 
     
    75103 
    76104// this is all there is to the smeared calculation! 
    77 Function SmearedDAB_Model(w,x) :FitFunc 
    78         Wave w 
    79         Variable x 
     105Function SmearedDAB_Model(s) :FitFunc 
     106        Struct ResSmearAAOStruct &s 
     107 
     108////the name of your unsmeared model is the first argument 
     109        s.yW = Smear_Model_20(DAB_Model,s.coefW,s.xW,s.resW) 
     110 
     111        return(0) 
     112End 
     113 
     114//wrapper to calculate the smeared model as an AAO-Struct 
     115// fills the struct and calls the ususal function with the STRUCT parameter 
     116// 
     117// used only for the dependency, not for fitting 
     118// 
     119Function fSmearedDAB_Model(coefW,yW,xW) 
     120        Wave coefW,yW,xW 
    80121         
    81         Variable ans 
    82         SVAR sq = gSig_Q 
    83         SVAR qb = gQ_bar 
    84         SVAR sh = gShadow 
    85         SVAR gQ = gQVals 
     122        String str = getWavesDataFolder(yW,0) 
     123        String DF="root:"+str+":" 
    86124         
    87         //the name of your unsmeared model is the first argument 
    88         ans = Smear_Model_20(DAB_Model,$sq,$qb,$sh,$gQ,w,x) 
    89  
    90         return(ans) 
     125        WAVE resW = $(DF+str+"_res") 
     126         
     127        STRUCT ResSmearAAOStruct fs 
     128        WAVE fs.coefW = coefW    
     129        WAVE fs.yW = yW 
     130        WAVE fs.xW = xW 
     131        WAVE fs.resW = resW 
     132         
     133        Variable err 
     134        err = SmearedDAB_Model(fs) 
     135         
     136        return (0) 
    91137End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/EffectiveDiameter.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34// these routines are used to calculate an effective spherical diameter for 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/GaussUtils.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
    22#pragma version=3.00 
    3 #pragma IgorVersion=4.0 
     3#pragma IgorVersion=6.0 
    44 
    55// GaussUtils.ipf 
     
    2828// did not give sufficient accuracy. 
    2929// 
     30//////////////////////////////////////////////// 
     31// 23 JUL 2007 SRK 
     32// major overhaul to use AAO functions in the smearing calculations 
     33// 
     34// - re-definition of function prototype in Smear_Model_N 
     35// - re-definition in trapezoidal routines too 
     36// - calls from model functions are somewhat different, so this will generate a lot of errors 
     37//   until all can be changed 
     38// - now is looking for a resolution matrix that contains the 3 resolution waves plus Q 
     39// = mat[num_Qvals][0] = sigQ 
     40// = mat[num_Qvals][1] = Qbar 
     41// = mat[num_Qvals][2] = fShad 
     42// = mat[num_Qvals][3] = qvals 
     43// 
     44// -- does not yet use the matrix calculation for USANS 
     45// -- SO THERE IS NO SWITCH YET IN Smear_Model_N() 
     46// 
     47// 
     48 
     49//maybe not the optimal set of parameters for the STRUCT 
     50// 
     51// resW is /N=(np,4) if SANS data 
     52// resW is /N=(np,np) if USANS data 
     53// 
     54// info may be useful later as a "KEY=value;" string to carry additional information 
     55Structure ResSmearAAOStruct 
     56        Wave coefW 
     57        Wave yW 
     58        Wave xW 
     59        Wave resW 
     60        String info 
     61EndStructure 
     62 
     63Function/S getHoldStr() 
     64 
     65        String str="0010" 
     66        return str 
     67End 
     68 
     69// utility used in the "PlotSmeared...() macros to get a list of data folders 
     70// 
     71//1:    Waves. 
     72//2:    Numeric variables. 
     73//3:    String variables. 
     74//4:    Data folders. 
     75Function/S GetAList(type) 
     76        Variable type 
     77         
     78        SetDataFolder root: 
     79         
     80        String objName,str="" 
     81        Variable index = 0 
     82        do 
     83                objName = GetIndexedObjName(":", type, index) 
     84                if (strlen(objName) == 0) 
     85                        break 
     86                endif 
     87                //Print objName 
     88                str += objName + ";" 
     89                index += 1 
     90        while(1) 
     91         
     92        return(str) 
     93End 
     94 
    3095 
    3196Function Make5GaussPoints(w5,z5) 
     
    126191//          printf "w[0],z[0] = %g %g\r", w20[0],z20[0] 
    127192End 
    128  
    129  
    130  
    131193 
    132194Function Make76GaussPoints(w76,z76) 
     
    535597         
    536598        if(err) 
    537                 DoAlert 0,"Some 6-column QSIG waves are missing. Re-load experimental data with LoadOneDData macro" 
     599                DoAlert 0,"Some 6-column QSIG waves are missing. Re-load experimental data with 'Load SANS or USANS Data' macro" 
    538600        endif 
    539601         
     
    541603end 
    542604 
    543  
    544 //Utility function to smear model function with resolution 
    545 // 
    546 // call as in this example... 
    547 // 
    548 ////Function SmearedSphere_HS(w,x) :FitFunc 
    549 ////    Wave w 
    550 ////    Variable x 
    551 ////     
    552 //////  Variable timer=StartMSTimer 
    553 ////    Variable ans 
    554 ////    SVAR sq = gSig_Q 
    555 ////    SVAR qb = gQ_bar 
    556 ////    SVAR sh = gShadow 
    557 ////    SVAR gQ = gQVals 
    558 ////     
    559 ////    ans = Smear_Model_20(Sphere_HS,$sq,$qb,$sh,$gQ,w,x)      
    560 //// 
    561 //////  Print "HS elapsed time(s) = ",StopMSTimer(timer)*1e-6 
    562 ////    return(ans) 
    563 ////End 
    564 // 
    565 // 
    566  
    567 Function Smear_Model_76(fcn,sigq,qbar,shad,qvals,w,x)                            
    568         FUNCREF SANSModel_proto fcn 
    569         Wave sigq               //std dev of resolution fn 
    570         Wave qbar               //mean q-value 
    571         Wave shad               //beamstop shadow factor 
    572         Wave qvals      //q-values where R(q) is known 
     605//////Resolution Smearing Utilities 
     606 
     607// To check for the existence of all waves needed for smearing 
     608// returns 1 if any waves are missing, 0 if all is OK 
     609// str passed in is the data folder containing the data 
     610// 
     611// 19 JUN07 using new data folder structure for loading 
     612// and resolution matrix 
     613Function ResolutionWavesMissingDF(str) 
     614        String str 
     615         
     616        String DF="root:"+str+":" 
     617 
     618        WAVE/Z res = $(DF+str+"_res") 
     619         
     620        if(!WaveExists(res)) 
     621                DoAlert 0,"The resolution matrix is missing. Re-load experimental data with the 'Load SANS or USANS Data' macro" 
     622                return(1) 
     623        endif 
     624         
     625        return(0) 
     626end 
     627 
     628/////////////////////////////////////////////////////////////// 
     629 
     630// "backwards" wrapped to reduce redundant code 
     631// there are only 4 choices of N (5,10,20,76) for smearing 
     632Function Smear_Model_N(fcn,w,x,resW,wi,zi,nord) 
     633        FUNCREF SANSModelAAO_proto fcn 
    573634        Wave w                  //coefficients of function fcn(w,x) 
    574         Variable x      //x-value (q) for the calculation 
    575  
    576 //**** The coefficient wave is passed into this function and straight through to the unsmeared model function 
     635        Variable x      //x-value (q) for the calculation THIS IS PASSED IN AS A WAVE 
     636        Wave resW               // Nx4 or NxN matrix of resolution 
     637        Wave wi         //weight wave 
     638        Wave zi         //abscissa wave 
     639        Variable nord           //order of integration 
    577640 
    578641// local variables 
    579         Variable nord,ii,va,vb,contr,nden,summ,yyy,zi,q 
    580         Variable answer,Resoln,i_shad,i_qbar,i_sigq 
    581         String weightStr,zStr,weightStr1,zStr1 
    582          
    583 //      weightStr = "gauss20wt" 
    584 //      zStr = "gauss20z" 
    585         weightStr = "gauss76wt" 
    586         zStr = "gauss76z" 
    587          
    588 //      if wt,z waves don't exist, create them (only check for weight, should really check for both) 
    589 // 20 Gauss points (enough for smearing with Gaussian resolution function) 
    590         if (WaveExists($weightStr) == 0) // wave reference is not valid,  
    591                 Make/D/N=76 $weightStr,$zStr 
    592                 Wave w76 = $weightStr 
    593                 Wave z76 = $zStr                // wave references to pass 
    594                 Make76GaussPoints(w76,z76)       
    595         else 
    596                 if(exists(weightStr) > 1)  
    597                          Abort "wave name is already in use"            //executed only if name is in use elsewhere 
    598                 endif 
    599                 Wave w76 = $weightStr 
    600                 Wave z76 = $zStr                // create the wave references 
    601         endif 
    602          
    603                 // current x point is the q-value for evaluation 
    604                 // 
    605                 // * for the input x, the resolution function waves are interpolated to get the correct values for 
    606                 //  sigq, qbar and shad - since the model x-spacing may not be the same as 
    607                 // the experimental QSIG data. This is always the case when curve fitting, since fit_wave is  
    608                 // Igor-defined as 200 points and has its own (linear) q-(x)-scaling which will be quite different 
    609                 // from experimental data. 
    610                 // **note** if the (x) passed in is the experimental q-values, these values are 
    611                 // returned from the interpolation (as expected) 
     642        Variable ii,va,vb 
     643        Variable answer,i_shad,i_qbar,i_sigq 
     644 
     645        // current x point is the q-value for evaluation 
     646        // 
     647        // * for the input x, the resolution function waves are interpolated to get the correct values for 
     648        //  sigq, qbar and shad - since the model x-spacing may not be the same as 
     649        // the experimental QSIG data. This is always the case when curve fitting, since fit_wave is  
     650        // Igor-defined as 200 points and has its own (linear) q-(x)-scaling which will be quite different 
     651        // from experimental data. 
     652        // **note** if the (x) passed in is the experimental q-values, these values are 
     653        // returned from the interpolation (as expected) 
     654 
     655        Make/O/N=(DimSize(resW, 0)) sigQ,qbar,shad,qvals 
     656        sigq = resW[p][0]               //std dev of resolution fn 
     657        qbar = resW[p][1]               //mean q-value 
     658        shad = resW[p][2]               //beamstop shadow factor 
     659        qvals = resW[p][3]      //q-values where R(q) is known 
    612660 
    613661        i_shad = interp(x,qvals,shad) 
     
    615663        i_sigq = interp(x,qvals,sigq) 
    616664                         
    617                 // set up the integration 
    618                 // number of Gauss Quadrature points 
    619                  
    620         if (i_sigq >= 0) 
     665// set up the integration 
     666// number of Gauss Quadrature points 
     667                 
     668        if (isSANSResolution(i_sigq)) 
    621669                 
    622670                // end points of integration 
     
    626674                //integration from va to vb 
    627675         
    628                 nord = 76 
    629676                va = -3*i_sigq + i_qbar 
    630677                if (va<0) 
     
    635682                 
    636683                // Using 20 Gauss points                     
    637                 // remember to index from 0,size-1 
    638  
    639                 summ = 0.0              // initialize integral 
    640684                ii=0                    // loop counter 
     685                // do the calculation as a single pass w/AAO function 
     686                Make/O/N=(nord) Resoln,yyy,xGauss 
    641687                do 
    642688                        // calculate Gauss points on integration interval (q-value for evaluation) 
    643                         zi = ( z76[ii]*(vb-va) + vb + va )/2.0 
     689                        xGauss[ii] = ( zi[ii]*(vb-va) + vb + va )/2.0 
    644690                        // calculate resolution function at input q-value (use the interpolated values and zi) 
    645                         Resoln = i_shad/sqrt(2*pi*i_sigq*i_sigq) 
    646                         Resoln *= exp((-1*(zi - i_qbar)^2)/(2*i_sigq*i_sigq)) 
    647                         //calculate partial sum for the passed-in model function         
    648                         yyy = w76[ii] * Resoln * fcn(w,zi)                                               
    649                         summ += yyy             //add to the running total of the quadrature 
    650                          ii+=1           
     691                        Resoln[ii] = i_shad/sqrt(2*pi*i_sigq*i_sigq) 
     692                        Resoln[ii] *= exp((-1*(xGauss[ii] - i_qbar)^2)/(2*i_sigq*i_sigq)) 
     693                        ii+=1            
    651694                while (ii<nord)                         // end of loop over quadrature points 
    652     
     695                 
     696                fcn(w,yyy,xGauss)               //yyy is the return value as a wave 
     697                 
     698                yyy *= wi *Resoln               //multiply function by resolution and weights 
    653699                // calculate value of integral to return 
    654                 answer = (vb-va)/2.0*summ 
     700                answer = (vb-va)/2.0*sum(yyy) 
    655701                // all scaling, background addition... etc. is done in the model calculation 
    656702         
     
    674720        endif 
    675721         
     722        //killing these waves is cleaner, but MUCH SLOWER 
     723//      Killwaves/Z Resoln,yyy,xGauss 
     724//      Killwaves/Z sigQ,qbar,shad,qvals 
    676725        Return (answer) 
    677726         
    678727End 
    679 /////////////////////////////////////////////////////////////// 
    680  
    681 Function Smear_Model_20(fcn,sigq,qbar,shad,qvals,w,x)                            
    682         FUNCREF SANSModel_proto fcn 
    683         Wave sigq               //std dev of resolution fn 
    684         Wave qbar               //mean q-value 
    685         Wave shad               //beamstop shadow factor 
    686         Wave qvals      //q-values where R(q) is known 
     728 
     729//resolution smearing, using only 5 Gauss points 
     730// 
     731// 
     732Function Smear_Model_5(fcn,w,x,resW)                             
     733        FUNCREF SANSModelAAO_proto fcn 
    687734        Wave w                  //coefficients of function fcn(w,x) 
    688735        Variable x      //x-value (q) for the calculation 
    689  
    690 //**** The coefficient wave is passed into this function and straight through to the unsmeared model function 
    691  
    692 // local variables 
    693         Variable nord,ii,va,vb,contr,nden,summ,yyy,zi,q 
    694         Variable answer,Resoln,i_shad,i_qbar,i_sigq 
    695         String weightStr,zStr,weightStr1,zStr1 
    696          
    697         weightStr = "gauss20wt" 
    698         zStr = "gauss20z" 
    699         weightStr1 = "gauss76wt" 
    700         zStr1 = "gauss76z" 
     736        Wave resW               // Nx4 or NxN matrix of resolution 
     737 
     738        String weightStr,zStr 
     739        Variable answer,nord=5 
     740         
     741        weightStr = "gauss5wt" 
     742        zStr = "gauss5z" 
    701743         
    702744//      if wt,z waves don't exist, create them (only check for weight, should really check for both) 
    703 // 20 Gauss points (enough for smearing with Gaussian resolution function) 
    704745        if (WaveExists($weightStr) == 0) // wave reference is not valid,  
    705                 Make/D/N=20 $weightStr,$zStr 
    706                 Wave w20 = $weightStr 
    707                 Wave z20 = $zStr                // wave references to pass 
    708                 Make20GaussPoints(w20,z20)       
     746                Make/D/N=(nord) $weightStr,$zStr 
     747                Wave weightW = $weightStr 
     748                Wave abscissW = $zStr           // wave references to pass 
     749                Make5GaussPoints(weightW,abscissW)       
    709750        else 
    710751                if(exists(weightStr) > 1)  
    711752                         Abort "wave name is already in use"            //executed only if name is in use elsewhere 
    712753                endif 
    713                 Wave w20 = $weightStr 
    714                 Wave z20 = $zStr                // create the wave references 
    715         endif 
    716          
    717                 // current x point is the q-value for evaluation 
    718                 // 
    719                 // * for the input x, the resolution function waves are interpolated to get the correct values for 
    720                 //  sigq, qbar and shad - since the model x-spacing may not be the same as 
    721                 // the experimental QSIG data. This is always the case when curve fitting, since fit_wave is  
    722                 // Igor-defined as 200 points and has its own (linear) q-(x)-scaling which will be quite different 
    723                 // from experimental data. 
    724                 // **note** if the (x) passed in is the experimental q-values, these values are 
    725                 // returned from the interpolation (as expected) 
    726  
    727         i_shad = interp(x,qvals,shad) 
    728         i_qbar = interp(x,qvals,qbar) 
    729         i_sigq = interp(x,qvals,sigq) 
    730                          
    731                 // set up the integration 
    732                 // number of Gauss Quadrature points 
    733                  
    734         if (i_sigq >= 0) 
    735                  
    736                 // end points of integration 
    737                 // limits are technically 0-inf, but wisely choose interesting region of q where R() is nonzero 
    738                 // +/- 3 sigq catches 99.73% of distrubution 
    739                 // change limits (and spacing of zi) at each evaluation based on R() 
    740                 //integration from va to vb 
    741          
    742                 nord = 20 
    743                 va = -3*i_sigq + i_qbar 
    744                 if (va<0) 
    745                         va=0            //to avoid numerical error when  va<0 (-ve q-value) 
    746 //                      Print "truncated Gaussian at nominal q = ",x 
    747                 endif 
    748                 vb = 3*i_sigq + i_qbar 
    749                  
    750                 // Using 20 Gauss points                     
    751                 // remember to index from 0,size-1 
    752  
    753                 summ = 0.0              // initialize integral 
    754                 ii=0                    // loop counter 
    755                 do 
    756                         // calculate Gauss points on integration interval (q-value for evaluation) 
    757                         zi = ( z20[ii]*(vb-va) + vb + va )/2.0 
    758                         // calculate resolution function at input q-value (use the interpolated values and zi) 
    759                         Resoln = i_shad/sqrt(2*pi*i_sigq*i_sigq) 
    760                         Resoln *= exp((-1*(zi - i_qbar)^2)/(2*i_sigq*i_sigq)) 
    761                         //calculate partial sum for the passed-in model function         
    762                         yyy = w20[ii] * Resoln * fcn(w,zi)                                               
    763                         summ += yyy             //add to the running total of the quadrature 
    764                          ii+=1           
    765                 while (ii<nord)                         // end of loop over quadrature points 
    766     
    767                 // calculate value of integral to return 
    768                 answer = (vb-va)/2.0*summ 
    769                 // all scaling, background addition... etc. is done in the model calculation 
    770          
    771         else 
    772                 //smear with the USANS routine 
    773                 // Make global string and local variables 
    774                 // now data folder aware, necessary for GlobalFit = FULL path to wave    
    775                 String/G gTrap_coefStr = GetWavesDataFolder(w, 2 )       
    776                 Variable maxiter=20, tol=1e-4 
    777                  
    778                 // set up limits for the integration 
    779                 va=0 
    780                 vb=abs(i_sigq) 
    781                  
    782                 Variable/G gEvalQval = x 
    783                  
    784                 // call qtrap to do actual work 
    785                 answer = qtrap_USANS(fcn,va,vb,tol,maxiter) 
    786                 answer /= vb 
    787                  
    788         endif 
    789          
     754                Wave weightW = $weightStr 
     755                Wave abscissW = $zStr           // create the wave references 
     756        endif 
     757         
     758        answer = Smear_Model_N(fcn,w,x,resW,weightW,abscissW,nord) 
    790759        Return (answer) 
    791760         
    792761End 
    793 /////////////////////////////////////////////////////////////// 
    794  
    795  
    796 //resolution smearing, using only 5 Gauss points 
    797 // 
    798 Function Smear_Model_5(fcn,sigq,qbar,shad,qvals,w,x)                             
    799         FUNCREF SANSModel_proto fcn 
    800         Wave sigq               //std dev of resolution fn 
    801         Wave qbar               //mean q-value 
    802         Wave shad               //beamstop shadow factor 
    803         Wave qvals      //q-values where R(q) is known 
     762 
     763//resolution smearing, using only 10 Gauss points 
     764// 
     765// 
     766Function Smear_Model_10(fcn,w,x,resW)                            
     767        FUNCREF SANSModelAAO_proto fcn 
    804768        Wave w                  //coefficients of function fcn(w,x) 
    805769        Variable x      //x-value (q) for the calculation 
    806  
    807 //**** The coefficient wave is passed into this function and straight through to the unsmeared model function 
    808  
    809 // local variables 
    810         Variable nord,ii,va,vb,contr,nden,summ,yyy,zi,q 
    811         Variable answer,Resoln,i_shad,i_qbar,i_sigq 
     770        Wave resW               // Nx4 or NxN matrix of resolution 
     771 
    812772        String weightStr,zStr 
    813          
    814         weightStr = "gauss5wt" 
    815         zStr = "gauss5z" 
     773        Variable answer,nord=10 
     774         
     775        weightStr = "gauss10wt" 
     776        zStr = "gauss10z" 
    816777         
    817778//      if wt,z waves don't exist, create them (only check for weight, should really check for both) 
    818 // 5 Gauss points  
    819779        if (WaveExists($weightStr) == 0) // wave reference is not valid,  
    820                 Make/D/N=5 $weightStr,$zStr 
    821                 Wave w5 = $weightStr 
    822                 Wave z5 = $zStr         // wave references to pass 
    823                 Make5GaussPoints(w5,z5)  
     780                Make/D/N=(nord) $weightStr,$zStr 
     781                Wave weightW = $weightStr 
     782                Wave abscissW = $zStr           // wave references to pass 
     783                Make10GaussPoints(weightW,abscissW)      
    824784        else 
    825785                if(exists(weightStr) > 1)  
    826786                         Abort "wave name is already in use"            //executed only if name is in use elsewhere 
    827787                endif 
    828                 Wave w5 = $weightStr 
    829                 Wave z5 = $zStr         // create the wave references 
    830         endif 
    831          
    832 // current x point is the q-value for evaluation 
    833 // 
    834 // * for the input x, the resolution function waves are interpolated to get the correct values for 
    835 //  sigq, qbar and shad - since the model x-spacing may not be the same as 
    836 // the experimental QSIG data. This is always the case when curve fitting, since fit_wave is  
    837 // Igor-defined as 200 points and has its own (linear) q-(x)-scaling which will be quite different 
    838 // from experimental data. 
    839 // **note** if the (x) passed in is the experimental q-values, these values are 
    840 // returned from the interpolation (as expected) 
    841  
    842         i_shad = interp(x,qvals,shad) 
    843         i_qbar = interp(x,qvals,qbar) 
    844         i_sigq = interp(x,qvals,sigq) 
    845          
    846         if (i_sigq>=0) 
    847                 // set up the integration 
    848                 // number of Gauss Quadrature points 
    849                 nord = 5 
    850                  
    851                 // end points of integration 
    852                 // limits are technically 0-inf, but wisely choose interesting region of q where R() is nonzero 
    853                 // +/- 3 sigq catches 99.73% of distrubution 
    854                 // change limits (and spacing of zi) at each evaluation based on R() 
    855                 //integration from va to vb 
    856                 va = -3*i_sigq + i_qbar 
    857                 if (va<0) 
    858                         va=0            //to avoid numerical error when  va<0 (-ve q-value) 
    859                 endif 
    860                 vb = 3*i_sigq + i_qbar 
    861                 // Using 5 Gauss points              
    862                 // remember to index from 0,size-1 
    863          
    864            summ = 0.0           // initialize integral 
    865            ii=0                 // loop counter 
    866            do 
    867                         // calculate Gauss points on integration interval (q-value for evaluation) 
    868                         zi = ( z5[ii]*(vb-va) + vb + va )/2.0 
    869                         // calculate resolution function at input q-value (use the interpolated values and zi) 
    870                         Resoln = i_shad/sqrt(2*pi*i_sigq*i_sigq) 
    871                         Resoln *= exp((-1*(zi - i_qbar)^2)/(2*i_sigq*i_sigq)) 
    872                         //calculate partial sum for the passed-in model function         
    873                         yyy = w5[ii] * Resoln * fcn(w,zi)                                                
    874                         summ += yyy             //add to the running total of the quadrature 
    875                ii+=1             
    876                 while (ii<nord)                         // end of loop over quadrature points 
    877             
    878                 // calculate value of integral to return 
    879            answer = (vb-va)/2.0*summ 
    880            // all scaling, background addition... etc. is done in the model calculation 
    881          
     788                Wave weightW = $weightStr 
     789                Wave abscissW = $zStr           // create the wave references 
     790        endif 
     791         
     792        answer = Smear_Model_N(fcn,w,x,resW,weightW,abscissW,nord) 
     793        Return (answer) 
     794         
     795End 
     796 
     797// 
     798//Smear_Model_20(SphereForm,s.coefW,s.yW,s.xW,s.resW) 
     799// 
     800//      Wave sigq               //std dev of resolution fn 
     801//      Wave qbar               //mean q-value 
     802//      Wave shad               //beamstop shadow factor 
     803//      Wave qvals      //q-values where R(q) is known 
     804// 
     805Function Smear_Model_20(fcn,w,x,resW)                            
     806        FUNCREF SANSModelAAO_proto fcn 
     807        Wave w                  //coefficients of function fcn(w,x) 
     808        Variable x      //x-value (q) for the calculation 
     809        Wave resW               // Nx4 or NxN matrix of resolution 
     810 
     811        String weightStr,zStr 
     812        Variable answer,nord=20 
     813         
     814        weightStr = "gauss20wt" 
     815        zStr = "gauss20z" 
     816         
     817//      if wt,z waves don't exist, create them (only check for weight, should really check for both) 
     818        if (WaveExists($weightStr) == 0) // wave reference is not valid,  
     819                Make/D/N=(nord) $weightStr,$zStr 
     820                Wave weightW = $weightStr 
     821                Wave abscissW = $zStr           // wave references to pass 
     822                Make20GaussPoints(weightW,abscissW)      
    882823        else 
    883                 // smear with the USANS routine 
    884                 // Make global string and local variables 
    885                 // now data folder aware, necessary for GlobalFit = FULL path to wave    
    886                 String/G gTrap_coefStr = GetWavesDataFolder(w, 2 ) 
    887                 Variable maxiter=10, tol=1e-2 
    888                  
    889                 // set up limits for the integration 
    890                 va=0 
    891                 vb=abs(i_sigq) 
    892                  
    893                 Variable/G gEvalQval = x 
    894                  
    895                 // call qtrap to do actual work 
    896                 answer = qtrap_USANS(fcn,va,vb,tol,maxiter) 
    897                 answer /= vb 
    898          
    899         endif 
    900  
     824                if(exists(weightStr) > 1)  
     825                         Abort "wave name is already in use"            //executed only if name is in use elsewhere 
     826                endif 
     827                Wave weightW = $weightStr 
     828                Wave abscissW = $zStr           // create the wave references 
     829        endif 
     830         
     831        answer = Smear_Model_N(fcn,w,x,resW,weightW,abscissW,nord) 
    901832        Return (answer) 
    902833         
    903834End 
    904835/////////////////////////////////////////////////////////////// 
     836Function Smear_Model_76(fcn,w,x,resW)                            
     837        FUNCREF SANSModelAAO_proto fcn 
     838        Wave w                  //coefficients of function fcn(w,x) 
     839        Variable x      //x-value (q) for the calculation 
     840        Wave resW               // Nx4 or NxN matrix of resolution 
     841 
     842 
     843// local variables 
     844        Variable answer,nord=76 
     845        String weightStr,zStr 
     846         
     847        weightStr = "gauss76wt" 
     848        zStr = "gauss76z" 
     849         
     850        if (WaveExists($weightStr) == 0) // wave reference is not valid,  
     851                Make/D/N=(nord) $weightStr,$zStr 
     852                Wave weightW = $weightStr 
     853                Wave abscissW = $zStr           // wave references to pass 
     854                Make76GaussPoints(weightW,abscissW)      
     855        else 
     856                if(exists(weightStr) > 1)  
     857                         Abort "wave name is already in use"            //executed only if name is in use elsewhere 
     858                endif 
     859                Wave weightW = $weightStr 
     860                Wave abscissW = $zStr           // create the wave references 
     861        endif 
     862        answer = Smear_Model_N(fcn,w,x,resW,weightW,abscissW,nord) 
     863        Return (answer) 
     864End 
     865 
     866 
     867/////////////////////////////////////////////////////////////// 
     868 
     869//typically, the first point (or any point) of sigQ is passed 
     870// if negative, it's USANS data... 
     871Function isSANSResolution(val) 
     872        Variable val 
     873        if(val>=0) 
     874                return(1)               //true, SANS data 
     875        else 
     876                return(0)               //false, USANS 
     877        endif 
     878End 
    905879 
    906880Function GenericQuadrature_proto(w,x,dum) 
     
    911885        return(1) 
    912886end 
    913  
     887  
    914888// prototype function for smearing routines, Smear_Model_N 
    915889// and trapzd_USANS() and qtrap_USANS() 
     
    923897end 
    924898 
     899// prototype function for smearing routines, Smear_Model_N 
     900// and trapzd_USANS() and qtrap_USANS() 
     901// it intentionally does nothing 
     902Function SANSModelAAO_proto(w,yw,xw) 
     903        Wave w,yw,xw 
     904         
     905        Print "in SANSModel_proto function" 
     906        return(1) 
     907end 
     908 
    925909//Numerical Recipes routine to calculate the nn(th) stage 
    926910//refinement of a trapezoid integration 
     
    938922// 
    939923Function trapzd_USANS(fcn,aa,bb,nn) 
    940         FUNCREF SANSModel_proto fcn 
     924        FUNCREF SANSModelAAO_proto fcn 
    941925        Variable aa,bb,nn 
    942926         
     
    948932        Wave cw=$cwStr                   
    949933        Variable temp=0 
     934        Make/O/N=2 tmp_xw,tmp_yw 
    950935        if(nn==1) 
    951                 arg1 = qval^2 + aa^2 
    952                 arg2 = qval^2 + bb^2 
    953                 temp = 0.5*(bb-aa)*(fcn(cw,sqrt(arg1)) + fcn(cw,sqrt(arg2))) 
     936                tmp_xw[0] = sqrt(qval^2 + aa^2) 
     937                tmp_xw[1] = sqrt(qval^2 + bb^2) 
     938                fcn(cw,tmp_yw,tmp_xw) 
     939                temp = 0.5*(bb-aa)*(tmp_yw[0] + tmp_yw[1]) 
    954940                sval = temp 
    955941                return(sVal) 
     
    962948                summ=0 
    963949                for(jj=1;jj<=it;jj+=1) 
    964                         arg1 = qval^2 + xx^2 
    965                         summ += fcn(cw,sqrt(arg1)) 
     950                        tmp_xw = sqrt(qval^2 + xx^2) 
     951                        fcn(cw,tmp_yw,tmp_xw)           //not the most efficient... but replaced by the matrix method 
     952                        summ += tmp_yw[0] 
    966953                        xx += del 
    967954                endfor 
     
    969956                return (sval) 
    970957        endif 
    971          
    972 End 
    973  
     958        //KillWaves/Z tmp_xw,tmp_yw 
     959End 
     960 
     961////Numerical Recipes routine to calculate the nn(th) stage 
     962////refinement of a trapezoid integration 
     963//// 
     964////must be called sequentially from nn=1...n from qtrap() 
     965//// to cumulatively refine the integration value 
     966//// 
     967//// in the conversion: 
     968//// -- s was replaced with sVal and declared global (rather than static) 
     969////  so that the nn-1 value would be available during the nn(th) call 
     970//// 
     971//// -- the specific coefficient wave for func() is passed in as a 
     972////  global string (then converted to a wave reference), since 
     973////  func() will eventually call sphereForm() 
     974//// 
     975//Function trapzd_USANS_point(fcn,aa,bb,nn) 
     976//      FUNCREF SANSModel_proto fcn 
     977//      Variable aa,bb,nn 
     978//       
     979//      Variable xx,tnm,summ,del 
     980//      Variable it,jj,arg1,arg2 
     981//      NVAR sVal=sVal          //calling function must initialize this global 
     982//      NVAR qval = gEvalQval 
     983//      SVAR cwStr = gTrap_CoefStr              //pass in the coefficient wave (string) 
     984//      Wave cw=$cwStr                   
     985//      Variable temp=0 
     986//      if(nn==1) 
     987//              arg1 = qval^2 + aa^2 
     988//              arg2 = qval^2 + bb^2 
     989//              temp = 0.5*(bb-aa)*(fcn(cw,sqrt(arg1)) + fcn(cw,sqrt(arg2))) 
     990//              sval = temp 
     991//              return(sVal) 
     992//      else 
     993//              it=1 
     994//              it= 2^(nn-2)  //done in NR with a bit shift <<= 
     995//              tnm = it 
     996//              del = (bb - aa)/tnm             //this is the spacing of points to add 
     997//              xx = aa+0.5*del 
     998//              summ=0 
     999//              for(jj=1;jj<=it;jj+=1) 
     1000//                      arg1 = qval^2 + xx^2 
     1001//                      summ += fcn(cw,sqrt(arg1)) 
     1002//                      xx += del 
     1003//              endfor 
     1004//              sval = 0.5*(sval+(bb-aa)*summ/tnm)      //replaces sval with its refined value 
     1005//              return (sval) 
     1006//      endif 
     1007//       
     1008//End 
    9741009 
    9751010// Numerical Recipes routine to calculate the integral of a 
     
    9811016// maxit typically 20 
    9821017Function qtrap_USANS(fcn,aa,bb,eps,maxIt) 
    983         FUNCREF SANSModel_proto fcn 
     1018        FUNCREF SANSModelAAO_proto fcn 
    9841019        Variable aa,bb,eps,maxit 
    9851020         
     
    10041039End      
    10051040 
     1041//// Numerical Recipes routine to calculate the integral of a 
     1042//// specified function, trapezoid rule is used to a user-specified 
     1043//// level of refinement using sequential calls to trapzd() 
     1044//// 
     1045//// in NR, eps and maxIt were global, pass them in here... 
     1046//// eps typically 1e-5 
     1047//// maxit typically 20 
     1048//Function qtrap_USANS_point(fcn,aa,bb,eps,maxIt) 
     1049//      FUNCREF SANSModel_proto fcn 
     1050//      Variable aa,bb,eps,maxit 
     1051//       
     1052//      Variable/G sVal=0               //create and initialize what trapzd will return 
     1053//      Variable jj,ss,olds 
     1054//       
     1055//      olds = -1e30            //any number that is not the avg. of endpoints of the funciton 
     1056//      for(jj=1;jj<=maxit;jj+=1)       //call trapzd() repeatedly until convergence 
     1057//              ss = trapzd_USANS_point(fcn,aa,bb,jj) 
     1058//              if( abs(ss-olds) < eps*abs(olds) )              // good enough, stop now 
     1059//                      return ss 
     1060//              endif 
     1061//              if( (ss == 0.0) && (olds == 0.0) && (jj>6) )            //no progress? 
     1062//                      return ss 
     1063//              endif 
     1064//              olds = ss 
     1065//      endfor 
     1066// 
     1067//      Print "Maxit exceeded in qtrap. If you're here, there was an error in qtrap" 
     1068//      return(ss)              //should never get here if function is well-behaved 
     1069//       
     1070//End    
     1071 
    10061072Proc RRW() 
    10071073        ResetResolutionWaves() 
     
    10121078        String Str 
    10131079        Prompt str,"Pick the intensity wave with the resolution you want",popup,WaveList("*_i",";","") 
    1014          
     1080 
     1081 
     1082        Abort "This function is not data floder aware and does nothing..." 
     1083                 
    10151084        String/G root:gQvals = str[0,strlen(str)-3]+"_q" 
    10161085        String/G root:gSig_Q = str[0,strlen(str)-3]+"sq" 
    10171086        String/G root:gQ_bar = str[0,strlen(str)-3]+"qb" 
    10181087        String/G root:gShadow = str[0,strlen(str)-3]+"fs" 
    1019          
    1020  
    10211088         
    10221089        //touch everything to make sure that the dependencies are 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/HPMSA.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
    2  
     2#pragma IgorVersion = 6.0 
     3 
     4// converted to Igor code by Paul Butler 
     5// 
    36Proc PlotHayterPenfoldMSA(num,qmin,qmax) 
    47        Variable num=128, qmin=.001, qmax=.3 
     
    2326        make/o/t parameters_hpmsa = {"Diameter (A)","Charge","Volume Fraction","Temperature(K)","monovalent salt conc. (M)","dielectric constant of solvent"} 
    2427        Edit parameters_hpmsa,coef_hpmsa 
    25         ywave_hpmsa := HayterPenfoldMSA(coef_hpmsa,xwave_hpmsa) 
     28        Variable/G root:g_HPMSA 
     29        g_hpmsa := HayterPenfoldMSA(coef_hpmsa,ywave_hpmsa,xwave_hpmsa) 
     30//      ywave_hpmsa := HayterPenfoldMSA(coef_hpmsa,xwave_hpmsa) 
    2631        xdiamwave_hpmsa:=xwave_hpmsa*coef_hpmsa[0] 
    2732        //Display ywave_hpmsa vs xdiamwave_hpmsa         
     
    3338End 
    3439 
     40//AAO version 
     41Function HayterPenfoldMSA(cw,yw,xw) : FitFunc 
     42        Wave cw,yw,xw 
     43 
     44#if exists("HayterPenfoldMSAX") 
     45        yw = HayterPenfoldMSAX(cw,xw) 
     46#else 
     47        yw = fHayterPenfoldMSA(cw,xw) 
     48#endif 
     49        return(0) 
     50End 
     51 
    3552////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    3653// 
     
    4461//                     A POWER OF 2 
    4562// 
    46  
    47 Function HayterPenfoldMSA(w,x) : FitFunc 
     63Function fHayterPenfoldMSA(w,x) : FitFunc 
    4864        wave w 
    4965        variable x 
     
    769785                qcosk = qk*cosk 
    770786                aqk = gMSAWave[0]*(sink-qcosk) 
    771                 aqk=aqk+gMSAWave[1]*((2.0*qk2-1.0)*qcosk+2.0*sink-2.0/qk) 
    772                 inter=24.0*qk3+4.0*(1.0-6.0*qk2)*sink 
    773                 aqk=(aqk+0.5*etaz*gMSAWave[0]*(inter-(1.0-12.0*qk2+24.0*qk2*qk2)*qcosk))*qk3 
    774                 aqk=aqk +gMSAWave[2]*(ck*asink-sk*qcosk)*qqk 
    775                 aqk=aqk +gMSAWave[3]*(sk*asink-qk*(ck*cosk-1.0))*qqk 
    776                 aqk=aqk +gMSAWave[3]*(cosk-1.0)*qk2 
    777                 aqk=aqk -gekz*(asink+qcosk)*qqk 
     787        aqk=aqk+gMSAWave[1]*((2.0*qk2-1.0)*qcosk+2.0*sink-2.0/qk) 
     788                inter=24.0*qk3+4.0*(1.0-6.0*qk2)*sink 
     789                aqk=(aqk+0.5*etaz*gMSAWave[0]*(inter-(1.0-12.0*qk2+24.0*qk2*qk2)*qcosk))*qk3 
     790                aqk=aqk +gMSAWave[2]*(ck*asink-sk*qcosk)*qqk 
     791                aqk=aqk +gMSAWave[3]*(sk*asink-qk*(ck*cosk-1.0))*qqk 
     792                aqk=aqk +gMSAWave[3]*(cosk-1.0)*qk2 
     793                aqk=aqk -gekz*(asink+qcosk)*qqk 
    778794                SofQ = 1.0/(1.0-e24*aqk) 
    779795      endif 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/HardSphereStruct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
     
    2223        make/o/t parameters_hss = {"Radius (A)","vol fraction"} 
    2324        Edit parameters_hss,coef_hss 
    24         ywave_hss := HardSphereStruct(coef_hss,xwave_hss) 
     25        Variable/G root:g_hss 
     26        g_hss := HardSphereStruct(coef_hss,ywave_hss,xwave_hss) 
     27//      ywave_hss := HardSphereStruct(coef_hss,xwave_hss) 
    2528        Display ywave_hss vs xwave_hss 
    2629        ModifyGraph marker=29,msize=2,mode=4 
     
    2831        Label left "Structure Factor" 
    2932        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     33End 
     34 
     35//AAO version 
     36Function HardSphereStruct(cw,yw,xw) : FitFunc 
     37        Wave cw,yw,xw 
     38 
     39#if exists("HardSphereStructX") 
     40        yw = HardSphereStructX(cw,xw) 
     41#else 
     42        yw = fHardSphereStruct(cw,xw) 
     43#endif 
     44        return(0) 
    3045End 
    3146 
     
    3651// unsmeared model calculation 
    3752/////////////////////////// 
    38 Function HardSphereStruct(w,x) : FitFunc 
     53Function fHardSphereStruct(w,x) : FitFunc 
    3954        Wave w 
    4055        Variable x 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/HollowCylinders.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
     
    2122        make/o/t parameters_Hcyl = {"scale","core radius (A)","shell radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"} 
    2223        Edit parameters_Hcyl,coef_Hcyl 
    23         ywave_Hcyl := HollowCylinderForm(coef_Hcyl,xwave_Hcyl) 
     24        Variable/G root:g_hcyl 
     25        g_Hcyl := HollowCylinder(coef_Hcyl,ywave_Hcyl,xwave_Hcyl) 
     26//      ywave_Hcyl := HollowCylinder(coef_Hcyl,xwave_Hcyl) 
    2427        Display ywave_Hcyl vs xwave_Hcyl 
    2528        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2831        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    2932End 
     33 
    3034/////////////////////////////////////////////////////////// 
    31  
    32 Proc PlotSmearedHollowCylinderForm()     
    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 
    35          
    36         // if no gQvals wave, data must not have been loaded => abort 
    37         if(ResolutionWavesMissing()) 
     35// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     36Proc PlotSmearedHollowCylinderForm(str)                                                          
     37        String str 
     38        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     39         
     40        // if any of the resolution waves are missing => abort 
     41        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3842                Abort 
    3943        endif 
     44         
     45        SetDataFolder $("root:"+str) 
    4046         
    4147        // Setup parameter table for model function 
     
    4652        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4753        // make extra copy of experimental q-values for easy plotting 
    48         Duplicate/O $gQvals smeared_Hcyl,smeared_qvals 
     54        Duplicate/O $(str+"_q") smeared_Hcyl,smeared_qvals 
    4955        SetScale d,0,0,"1/cm",smeared_Hcyl       
    50  
    51         smeared_Hcyl := SmearedHollowCylinderForm(smear_coef_Hcyl,$gQvals) 
     56                                         
     57        Variable/G gs_Hcyl=0 
     58        gs_Hcyl := fSmearedHollowCylinder(smear_coef_Hcyl,smeared_Hcyl,smeared_qvals)   //this wrapper fills the STRUCT 
     59         
    5260        Display smeared_Hcyl vs smeared_qvals 
    5361        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5563        Label left "Intensity (cm\\S-1\\M)" 
    5664        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    57 End 
    58  
     65         
     66        SetDataFolder root: 
     67End 
     68 
     69 
     70//AAO version 
     71Function HollowCylinder(cw,yw,xw) : FitFunc 
     72        Wave cw,yw,xw 
     73 
     74#if exists("HollowCylinderX") 
     75        yw = HollowCylinderX(cw,xw) 
     76#else 
     77        yw = fHollowCylinder(cw,xw) 
     78#endif 
     79        return(0) 
     80End 
    5981/////////////////////////////////////////////////////////////// 
    6082// unsmeared model calculation 
    6183/////////////////////////// 
    62 Function HollowCylinderForm(w,x) : FitFunc 
     84Function fHollowCylinder(w,x) : FitFunc 
    6385        Wave w 
    6486        Variable x 
     
    186208 
    187209// this is all there is to the smeared calculation! 
    188 Function SmearedHollowCylinderForm(w,x) :FitFunc 
    189         Wave w 
    190         Variable x 
    191          
    192         Variable ans 
    193         SVAR sq = gSig_Q 
    194         SVAR qb = gQ_bar 
    195         SVAR sh = gShadow 
    196         SVAR gQ = gQVals 
    197          
    198         //the name of your unsmeared model is the first argument 
    199         ans = Smear_Model_20(HollowCylinderForm,$sq,$qb,$sh,$gQ,w,x) 
    200  
    201         return(ans) 
    202 End 
     210Function SmearedHollowCylinder(s) :FitFunc 
     211        Struct ResSmearAAOStruct &s 
     212 
     213////the name of your unsmeared model is the first argument 
     214        s.yW = Smear_Model_20(HollowCylinder,s.coefW,s.xW,s.resW) 
     215 
     216        return(0) 
     217End 
     218 
     219//wrapper to calculate the smeared model as an AAO-Struct 
     220// fills the struct and calls the ususal function with the STRUCT parameter 
     221// 
     222// used only for the dependency, not for fitting 
     223// 
     224Function fSmearedHollowCylinder(coefW,yW,xW) 
     225        Wave coefW,yW,xW 
     226         
     227        String str = getWavesDataFolder(yW,0) 
     228        String DF="root:"+str+":" 
     229         
     230        WAVE resW = $(DF+str+"_res") 
     231         
     232        STRUCT ResSmearAAOStruct fs 
     233        WAVE fs.coefW = coefW    
     234        WAVE fs.yW = yW 
     235        WAVE fs.xW = xW 
     236        WAVE fs.resW = resW 
     237         
     238        Variable err 
     239        err = SmearedHollowCylinder(fs) 
     240         
     241        return (0) 
     242End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Lorentz_model.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24//////////////////////////////////////////////////// 
    35//      J. Barker, 2-10-99 
     
    1416        make/o/t parameters_Lorentz = {"Scale Factor, I0 ", "Screening Length ()","Incoherent Bgd (cm-1)"} 
    1517        Edit parameters_Lorentz, coef_Lorentz 
    16         ywave_Lorentz  := Lorentz_Model(coef_Lorentz, xwave_Lorentz) 
     18        Variable/G root:g_Lorentz 
     19        g_Lorentz  := Lorentz_Model(coef_Lorentz,ywave_Lorentz, xwave_Lorentz) 
     20//      ywave_Lorentz  := Lorentz_Model(coef_Lorentz, xwave_Lorentz) 
    1721        Display ywave_Lorentz vs xwave_Lorentz 
    1822        ModifyGraph marker=29, msize=2, mode=4 
     
    2428 
    2529//////////////////////////////////////////////////// 
    26 Proc PlotSmeared_Lorentz()                                                              //Lorentz 
    27         //no input parameters necessary, it MUST use the experimental q-values 
    28         // from the experimental data read in from an AVE/QSIG data file 
     30// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     31Proc PlotSmeared_Lorentz(str)                                                            
     32        String str 
     33        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    2934         
    30         // if no gQvals wave, data must not have been loaded => abort 
    31         if(ResolutionWavesMissing()) 
     35        // if any of the resolution waves are missing => abort 
     36        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3237                Abort 
    3338        endif 
     39         
     40        SetDataFolder $("root:"+str) 
    3441         
    3542        // Setup parameter table for model function 
     
    4047        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4148        // make extra copy of experimental q-values for easy plotting 
    42         Duplicate/O $gQvals smeared_Lorentz,smeared_qvals                               // 
    43         SetScale d,0,0,"1/cm",smeared_Lorentz                                                   // 
    44  
    45         smeared_Lorentz := Smeared_Lorentz_Model(smear_coef_Lorentz,$gQvals)            // SMEARED function name 
     49        Duplicate/O $(str+"_q") smeared_Lorentz,smeared_qvals                           // 
     50        SetScale d,0,0,"1/cm",smeared_Lorentz                                                   //                                       
     51                 
     52        Variable/G gs_Lorentz=0 
     53        gs_Lorentz := fSmeared_Lorentz_Model(smear_coef_Lorentz,smeared_Lorentz,smeared_qvals)  //this wrapper fills the STRUCT 
     54         
    4655        Display smeared_Lorentz vs smeared_qvals                                                                        // 
    4756        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    4958        Label left "Lorentz Model (cm\\S-1\\M)" 
    5059        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    51 End     // end macro PlotSmearedPeak_Lorentz 
     60                 
     61        SetDataFolder root: 
     62End 
    5263 
    53 Function Lorentz_model(w,x) : FitFunc 
     64 
     65//AAO version 
     66Function Lorentz_model(cw,yw,xw) : FitFunc 
     67        Wave cw,yw,xw 
     68 
     69#if exists("Lorentz_modelX") 
     70        yw = Lorentz_modelX(cw,xw) 
     71#else 
     72        yw = fLorentz_model(cw,xw) 
     73#endif 
     74        return(0) 
     75End 
     76 
     77Function fLorentz_model(w,x) : FitFunc 
    5478        Wave w 
    5579        Variable x 
     
    77101 
    78102// this is all there is to the smeared calculation! 
    79 Function Smeared_Lorentz_Model(w,x) :FitFunc 
    80         Wave w 
    81         Variable x 
    82          
    83         Variable ans 
    84         SVAR sq = gSig_Q 
    85         SVAR qb = gQ_bar 
    86         SVAR sh = gShadow 
    87         SVAR gQ = gQVals 
    88          
    89         //the name of your unsmeared model is the first argument 
    90         ans = Smear_Model_20(Lorentz_model,$sq,$qb,$sh,$gQ,w,x) 
     103Function Smeared_Lorentz_Model(s) :FitFunc 
     104        Struct ResSmearAAOStruct &s 
    91105 
    92         return(ans) 
     106////the name of your unsmeared model is the first argument 
     107        s.yW = Smear_Model_20(Lorentz_model,s.coefW,s.xW,s.resW) 
     108 
     109        return(0) 
    93110End 
    94111         
     112 
     113//wrapper to calculate the smeared model as an AAO-Struct 
     114// fills the struct and calls the ususal function with the STRUCT parameter 
     115// 
     116// used only for the dependency, not for fitting 
     117// 
     118Function fSmeared_Lorentz_Model(coefW,yW,xW) 
     119        Wave coefW,yW,xW 
     120         
     121        String str = getWavesDataFolder(yW,0) 
     122        String DF="root:"+str+":" 
     123         
     124        WAVE resW = $(DF+str+"_res") 
     125         
     126        STRUCT ResSmearAAOStruct fs 
     127        WAVE fs.coefW = coefW    
     128        WAVE fs.yW = yW 
     129        WAVE fs.xW = xW 
     130        WAVE fs.resW = resW 
     131         
     132        Variable err 
     133        err = Smeared_Lorentz_Model(fs) 
     134         
     135        return (0) 
     136End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Beaucage.ipf

    r62 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34///////////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/BimodalSchulzSpheres.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/BinaryHardSpheres.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Cylinder_PolyLength.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34#include "CylinderForm" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Cylinder_PolyRadius.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34#include "CylinderForm" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Debye.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34// plots the Debye function for polymer scattering 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/EllipticalCylinder.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34/////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_EllipCross.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34#include "FlexibleCylinder" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_PolyLen.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34#include "FlexibleCylinder" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_PolyRadius.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34#include "FlexibleCylinder" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexibleCylinder.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Fractal.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34// plots scattering from a mass fractal object 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/GaussSpheres.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34#include "sphere" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/GaussSpheres_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24// 
    35// be sure to include all of the necessary files 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarFF.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarFF_HG.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarPS.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarPS_HG.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LogNormSpheres_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24// 
    35// be sure to include all of the necessary files 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LogNormalSphere.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34#include "sphere" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/MultiShell.ipf

    r56 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34// calculates the scattering from a spherical particle made up of a core (aqueous) surrounded 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Parallelepiped.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/PolyCoreShellCylinder.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/SchulzSpheres.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//#include "Sphere" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/SchulzSpheres_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24// 
    35// be sure to include all of the necessary files 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/StickyHardSphereStruct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24//////////////////////////////////////////////////// 
    35// 
     
    3133        make/o/t parameters_shsSQ = {"Radius","volume fraction","perturbation parameter (0.1)","stickiness, tau"}       //CH#3 
    3234        Edit parameters_shsSQ, coef_shsSQ 
    33         ywave_shsSQ  := StickyHS_Struct(coef_shsSQ, xwave_shsSQ) 
     35        Variable/G root:g_shsSQ 
     36        g_shsSQ  := StickyHS_Struct(coef_shsSQ, ywave_shsSQ, xwave_shsSQ) 
     37//      ywave_shsSQ  := StickyHS_Struct(coef_shsSQ, xwave_shsSQ) 
    3438        Display ywave_shsSQ vs xwave_shsSQ 
    3539        ModifyGraph marker=29, msize=2, mode=4 
     
    4145End 
    4246 
    43 Function StickyHS_Struct(w,x) : FitFunc 
     47//AAO function 
     48Function StickyHS_Struct(cw,yw,xw) : FitFunc 
     49        Wave cw,yw,xw 
     50 
     51#if exists("StickyHS_StructX") 
     52        yw = StickyHS_StructX(cw,xw) 
     53#else 
     54        yw = fStickyHS_Struct(cw,xw) 
     55#endif 
     56        return(0) 
     57End 
     58 
     59Function fStickyHS_Struct(w,x) : FitFunc 
    4460        Wave w 
    4561        Variable x 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/TriaxialEllipsoid.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//#include "GaussUtils" 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Vesicle_UL.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Vesicle_UL_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/OblateCS_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34// be sure to include all of the necessary files 
     
    2223        make/o/t parameters_OEF_HS = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","bkg (cm-1)"} 
    2324        Edit parameters_OEF_HS,coef_OEF_HS 
    24         ywave_OEF_HS := Oblate_HS(coef_OEF_HS,xwave_OEF_HS) 
     25         
     26        Variable/G root:g_OEF_HS 
     27        g_OEF_HS := Oblate_HS(coef_OEF_HS,ywave_OEF_HS,xwave_OEF_HS) 
    2528        Display ywave_OEF_HS vs xwave_OEF_HS 
    2629        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    3134End 
    3235 
    33 Proc PlotSmearedOblate_HS()                                                              
    34         //no input parameters necessary, it MUST use the experimental q-values 
    35         // from the experimental data read in from an AVE/QSIG data file 
    36          
    37         // if no gQvals wave, data must not have been loaded => abort 
    38         if(ResolutionWavesMissing()) 
     36// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     37Proc PlotSmearedOblate_HS(str)                                                           
     38        String str 
     39        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     40         
     41        // if any of the resolution waves are missing => abort 
     42        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3943                Abort 
    4044        endif 
     45         
     46        SetDataFolder $("root:"+str) 
    4147         
    4248        // Setup parameter table for model function 
     
    4753        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4854        // make extra copy of experimental q-values for easy plotting 
    49         Duplicate/O $gQvals smeared_OEF_HS,smeared_qvals                                 
     55        Duplicate/O $(str+"_q") smeared_OEF_HS,smeared_qvals                             
    5056        SetScale d,0,0,"1/cm",smeared_OEF_HS                                                     
    51  
    52         smeared_OEF_HS := SmearedOblate_HS(smear_coef_OEF_HS,$gQvals)            
     57                                         
     58        Variable/G gs_OEF_HS=0 
     59        gs_OEF_HS := fSmearedOblate_HS(smear_coef_OEF_HS,smeared_OEF_HS,smeared_qvals)  //this wrapper fills the STRUCT 
     60         
    5361        Display smeared_OEF_HS vs smeared_qvals                                                                  
    5462        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5765 
    5866        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    59 End 
    60  
    61 Function Oblate_HS(w,x) : FitFunc 
    62         Wave w 
    63         Variable x 
     67         
     68        SetDataFolder root: 
     69End 
     70         
     71 
     72Function Oblate_HS(w,yw,xw) : FitFunc 
     73        Wave w,yw,xw 
    6474         
    6575        Variable inten,Ras,Rbs 
     
    8494         
    8595        //calculate each and combine 
    86         inten = OblateForm(form_OEF_HS,x) 
    87         inten *= HardSphereStruct(struct_OEF_HS,x) 
    88         inten *= w[0] 
    89         inten += w[7] 
     96        Duplicate/O xw temp_OEF_HS_PQ,temp_OEF_HS_SQ            //make waves for the AAO 
     97        OblateForm(form_OEF_HS,temp_OEF_HS_PQ,xw) 
     98        HardSphereStruct(struct_OEF_HS,temp_OEF_HS_SQ,xw) 
     99        yw = temp_OEF_HS_PQ * temp_OEF_HS_SQ 
     100        yw *= w[0] 
     101        yw += w[7] 
    90102         
    91103        //cleanup waves 
    92104//      Killwaves/Z form_OEF_HS,struct_OEF_HS 
    93105         
    94         return (inten) 
     106        return (0) 
    95107End 
    96108 
     
    106118        make/o/t parameters_OEF_SW = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","well depth (kT)","well width (diam.)","bkg (cm-1)"} 
    107119        Edit parameters_OEF_SW,coef_OEF_SW 
    108         ywave_OEF_SW := Oblate_SW(coef_OEF_SW,xwave_OEF_SW) 
     120         
     121        Variable/G root:g_OEF_SW 
     122        g_OEF_SW := Oblate_SW(coef_OEF_SW,ywave_OEF_SW,xwave_OEF_SW) 
    109123        Display ywave_OEF_SW vs xwave_OEF_SW 
    110124        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    115129End 
    116130 
    117 Proc PlotSmearedOblate_SW()                                                              
    118         //no input parameters necessary, it MUST use the experimental q-values 
    119         // from the experimental data read in from an AVE/QSIG data file 
    120          
    121         // if no gQvals wave, data must not have been loaded => abort 
    122         if(ResolutionWavesMissing()) 
     131// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     132Proc PlotSmearedOblate_SW(str)                                                           
     133        String str 
     134        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     135         
     136        // if any of the resolution waves are missing => abort 
     137        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    123138                Abort 
    124139        endif 
     140         
     141        SetDataFolder $("root:"+str) 
    125142         
    126143        // Setup parameter table for model function 
     
    131148        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    132149        // make extra copy of experimental q-values for easy plotting 
    133         Duplicate/O $gQvals smeared_OEF_SW,smeared_qvals                                 
     150        Duplicate/O $(str+"_q") smeared_OEF_SW,smeared_qvals                             
    134151        SetScale d,0,0,"1/cm",smeared_OEF_SW                                                     
    135  
    136         smeared_OEF_SW := SmearedOblate_SW(smear_coef_OEF_SW,$gQvals)            
     152                                         
     153        Variable/G gs_OEF_SW=0 
     154        gs_OEF_SW := fSmearedOblate_SW(smear_coef_OEF_SW,smeared_OEF_SW,smeared_qvals)  //this wrapper fills the STRUCT 
     155         
    137156        Display smeared_OEF_SW vs smeared_qvals                                                                  
    138157        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    141160 
    142161        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    143 End 
    144  
    145 Function Oblate_SW(w,x) : FitFunc 
    146         Wave w 
    147         Variable x 
     162         
     163        SetDataFolder root: 
     164End 
     165 
     166 
     167Function Oblate_SW(w,yw,xw) : FitFunc 
     168        Wave w,yw,xw 
    148169         
    149170        Variable inten,Ras,Rbs 
     
    170191         
    171192        //calculate each and combine 
    172         inten = OblateForm(form_OEF_SW,x) 
    173         inten *= SquareWellStruct(struct_OEF_SW,x) 
    174         inten *= w[0] 
    175         inten += w[9] 
     193        Duplicate/O xw temp_OEF_SW_PQ,temp_OEF_SW_SQ            //make waves for the AAO 
     194        OblateForm(form_OEF_SW,temp_OEF_SW_PQ,xw) 
     195        SquareWellStruct(struct_OEF_SW,temp_OEF_SW_SQ,xw) 
     196        yw = temp_OEF_SW_PQ * temp_OEF_SW_SQ 
     197        yw *= w[0] 
     198        yw += w[9] 
    176199         
    177200        //cleanup waves 
    178201//      Killwaves/Z form_OEF_SW,struct_OEF_SW 
    179202         
    180         return (inten) 
     203        return (0) 
    181204End 
    182205 
     
    199222        make/o/t parameters_OEF_SC = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","charge","movalent salt(M)","Temperature (K)","dielectric const","bkg (cm-1)"} 
    200223        Edit parameters_OEF_SC,coef_OEF_SC 
    201         ywave_OEF_SC := Oblate_SC(coef_OEF_SC,xwave_OEF_SC) 
     224         
     225        Variable/G root:g_OEF_SC 
     226        g_OEF_SC := Oblate_SC(coef_OEF_SC,ywave_OEF_SC,xwave_OEF_SC) 
    202227        Display ywave_OEF_SC vs xwave_OEF_SC 
    203228        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    208233End 
    209234 
    210 Proc PlotSmearedOblate_SC()                                                              
    211         //no input parameters necessary, it MUST use the experimental q-values 
    212         // from the experimental data read in from an AVE/QSIG data file 
    213          
    214         // if no gQvals wave, data must not have been loaded => abort 
    215         if(ResolutionWavesMissing()) 
     235// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     236Proc PlotSmearedOblate_SC(str)                                                           
     237        String str 
     238        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     239         
     240        // if any of the resolution waves are missing => abort 
     241        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    216242                Abort 
    217243        endif 
    218  
     244         
     245        SetDataFolder $("root:"+str) 
     246         
    219247        if (DataFolderExists("root:HayPenMSA")) 
    220248                Make/O/D/N=17 root:HayPenMSA:gMSAWave 
     
    231259        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    232260        // make extra copy of experimental q-values for easy plotting 
    233         Duplicate/O $gQvals smeared_OEF_SC,smeared_qvals                                 
     261        Duplicate/O $(str+"_q") smeared_OEF_SC,smeared_qvals                             
    234262        SetScale d,0,0,"1/cm",smeared_OEF_SC                                                     
    235  
    236         smeared_OEF_SC := SmearedOblate_SC(smear_coef_OEF_SC,$gQvals)            
     263                                         
     264        Variable/G gs_OEF_SC=0 
     265        gs_OEF_SC := fSmearedOblate_SC(smear_coef_OEF_SC,smeared_OEF_SC,smeared_qvals)  //this wrapper fills the STRUCT 
     266         
    237267        Display smeared_OEF_SC vs smeared_qvals                                                                  
    238268        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    241271 
    242272        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    243 End 
    244  
    245 Function Oblate_SC(w,x) : FitFunc 
    246         Wave w 
    247         Variable x 
     273         
     274        SetDataFolder root: 
     275End 
     276 
     277 
     278Function Oblate_SC(w,yw,xw) : FitFunc 
     279        Wave w,yw,xw 
    248280         
    249281        Variable inten,Ras,Rbs 
     
    272304         
    273305        //calculate each and combine 
    274         inten = OblateForm(form_OEF_SC,x) 
    275         inten *= HayterPenfoldMSA(struct_OEF_SC,x) 
    276         inten *= w[0] 
    277         inten += w[11] 
     306        Duplicate/O xw temp_OEF_SC_PQ,temp_OEF_SC_SQ            //make waves for the AAO 
     307        OblateForm(form_OEF_SC,temp_OEF_SC_PQ,xw) 
     308        HayterPenfoldMSA(struct_OEF_SC,temp_OEF_SC_SQ,xw) 
     309        yw = temp_OEF_SC_PQ * temp_OEF_SC_SQ 
     310        yw *= w[0] 
     311        yw += w[11] 
    278312         
    279313        //cleanup waves 
    280314//      Killwaves/Z form_OEF_SC,struct_OEF_SC 
    281315         
    282         return (inten) 
     316        return (0) 
    283317End 
    284318 
     
    295329        make/o/t parameters_OEF_SHS = {"volume fraction","major core radius (A)","minor core radius (A)","major shell radius (A)","minor shell radius (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","perturbation parameter (0.1)","stickiness, tau","bkg (cm-1)"} 
    296330        Edit parameters_OEF_SHS,coef_OEF_SHS 
    297         ywave_OEF_SHS := Oblate_SHS(coef_OEF_SHS,xwave_OEF_SHS) 
     331         
     332        Variable/G root:g_OEF_SHS 
     333        g_OEF_SHS := Oblate_SHS(coef_OEF_SHS,ywave_OEF_SHS,xwave_OEF_SHS) 
    298334        Display ywave_OEF_SHS vs xwave_OEF_SHS 
    299335        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    304340End 
    305341 
    306 Proc PlotSmearedOblate_SHS()                                                             
    307         //no input parameters necessary, it MUST use the experimental q-values 
    308         // from the experimental data read in from an AVE/QSIG data file 
    309          
    310         // if no gQvals wave, data must not have been loaded => abort 
    311         if(ResolutionWavesMissing()) 
     342// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     343Proc PlotSmearedOblate_SHS(str)                                                          
     344        String str 
     345        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     346         
     347        // if any of the resolution waves are missing => abort 
     348        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    312349                Abort 
    313350        endif 
     351         
     352        SetDataFolder $("root:"+str) 
    314353         
    315354        // Setup parameter table for model function 
     
    320359        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    321360        // make extra copy of experimental q-values for easy plotting 
    322         Duplicate/O $gQvals smeared_OEF_SHS,smeared_qvals                                
     361        Duplicate/O $(str+"_q") smeared_OEF_SHS,smeared_qvals                            
    323362        SetScale d,0,0,"1/cm",smeared_OEF_SHS                                                    
    324  
    325         smeared_OEF_SHS := SmearedOblate_SHS(smear_coef_OEF_SHS,$gQvals)                 
     363                                         
     364        Variable/G gs_OEF_SHS=0 
     365        gs_OEF_SHS := fSmearedOblate_SHS(smear_coef_OEF_SHS,smeared_OEF_SHS,smeared_qvals)      //this wrapper fills the STRUCT 
     366         
    326367        Display smeared_OEF_SHS vs smeared_qvals                                                                         
    327368        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    330371 
    331372        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    332 End 
    333  
    334 Function Oblate_SHS(w,x) : FitFunc 
    335         Wave w 
    336         Variable x 
     373         
     374        SetDataFolder root: 
     375End 
     376         
     377 
     378Function Oblate_SHS(w,yw,xw) : FitFunc 
     379        Wave w,yw,xw 
    337380         
    338381        Variable inten,Ras,Rbs 
     
    359402         
    360403        //calculate each and combine 
    361         inten = OblateForm(form_OEF_SHS,x) 
    362         inten *= StickyHS_Struct(struct_OEF_SHS,x) 
    363         inten *= w[0] 
    364         inten += w[9] 
     404        Duplicate/O xw temp_OEF_SHS_PQ,temp_OEF_SHS_SQ          //make waves for the AAO 
     405        OblateForm(form_OEF_SHS,temp_OEF_SHS_PQ,xw) 
     406        StickyHS_Struct(struct_OEF_SHS,temp_OEF_SHS_SQ,xw) 
     407        yw = temp_OEF_SHS_PQ * temp_OEF_SHS_SQ 
     408        yw *= w[0] 
     409        yw += w[9] 
    365410         
    366411        //cleanup waves 
    367412//      Killwaves/Z form_OEF_SHS,struct_OEF_SHS 
    368413         
    369         return (inten) 
     414        return (0) 
    370415End 
    371416 
    372417 
    373418// this is all there is to the smeared calculation! 
    374 Function SmearedOblate_HS(w,x) :FitFunc 
    375         Wave w 
    376         Variable x 
    377          
    378         Variable ans 
    379         SVAR sq = gSig_Q 
    380         SVAR qb = gQ_bar 
    381         SVAR sh = gShadow 
    382         SVAR gQ = gQVals 
    383          
    384         //the name of your unsmeared model is the first argument 
    385         ans = Smear_Model_20(Oblate_HS,$sq,$qb,$sh,$gQ,w,x) 
    386  
    387         return(ans) 
     419Function SmearedOblate_HS(s) :FitFunc 
     420        Struct ResSmearAAOStruct &s 
     421 
     422//      the name of your unsmeared model is the first argument 
     423        s.yW = Smear_Model_20(Oblate_HS,s.coefW,s.xW,s.resW) 
     424 
     425        return(0) 
    388426End 
    389427 
    390428// this is all there is to the smeared calculation! 
    391 Function SmearedOblate_SW(w,x) :FitFunc 
    392         Wave w 
    393         Variable x 
    394          
    395         Variable ans 
    396         SVAR sq = gSig_Q 
    397         SVAR qb = gQ_bar 
    398         SVAR sh = gShadow 
    399         SVAR gQ = gQVals 
    400          
    401         //the name of your unsmeared model is the first argument 
    402         ans = Smear_Model_20(Oblate_SW,$sq,$qb,$sh,$gQ,w,x) 
    403  
    404         return(ans) 
     429Function SmearedOblate_SW(s) :FitFunc 
     430        Struct ResSmearAAOStruct &s 
     431 
     432//      the name of your unsmeared model is the first argument 
     433        s.yW = Smear_Model_20(Oblate_SW,s.coefW,s.xW,s.resW) 
     434 
     435        return(0) 
    405436End 
    406437 
    407438// this is all there is to the smeared calculation! 
    408 Function SmearedOblate_SC(w,x) :FitFunc 
    409         Wave w 
    410         Variable x 
    411          
    412         Variable ans 
    413         SVAR sq = gSig_Q 
    414         SVAR qb = gQ_bar 
    415         SVAR sh = gShadow 
    416         SVAR gQ = gQVals 
    417          
    418         //the name of your unsmeared model is the first argument 
    419         ans = Smear_Model_20(Oblate_SC,$sq,$qb,$sh,$gQ,w,x) 
    420  
    421         return(ans) 
     439Function SmearedOblate_SC(s) :FitFunc 
     440        Struct ResSmearAAOStruct &s 
     441 
     442//      the name of your unsmeared model is the first argument 
     443        s.yW = Smear_Model_20(Oblate_SC,s.coefW,s.xW,s.resW) 
     444 
     445        return(0) 
    422446End 
    423447 
    424448// this is all there is to the smeared calculation! 
    425 Function SmearedOblate_SHS(w,x) :FitFunc 
    426         Wave w 
    427         Variable x 
    428          
    429         Variable ans 
    430         SVAR sq = gSig_Q 
    431         SVAR qb = gQ_bar 
    432         SVAR sh = gShadow 
    433         SVAR gQ = gQVals 
    434          
    435         //the name of your unsmeared model is the first argument 
    436         ans = Smear_Model_20(Oblate_SHS,$sq,$qb,$sh,$gQ,w,x) 
    437  
    438         return(ans) 
    439 End 
     449Function SmearedOblate_SHS(s) :FitFunc 
     450        Struct ResSmearAAOStruct &s 
     451 
     452//      the name of your unsmeared model is the first argument 
     453        s.yW = Smear_Model_20(Oblate_SHS,s.coefW,s.xW,s.resW) 
     454 
     455        return(0) 
     456End 
     457 
     458//wrapper to calculate the smeared model as an AAO-Struct 
     459// fills the struct and calls the ususal function with the STRUCT parameter 
     460// 
     461// used only for the dependency, not for fitting 
     462// 
     463Function fSmearedOblate_HS(coefW,yW,xW) 
     464        Wave coefW,yW,xW 
     465         
     466        String str = getWavesDataFolder(yW,0) 
     467        String DF="root:"+str+":" 
     468         
     469        WAVE resW = $(DF+str+"_res") 
     470         
     471        STRUCT ResSmearAAOStruct fs 
     472        WAVE fs.coefW = coefW    
     473        WAVE fs.yW = yW 
     474        WAVE fs.xW = xW 
     475        WAVE fs.resW = resW 
     476         
     477        Variable err 
     478        err = SmearedOblate_HS(fs) 
     479         
     480        return (0) 
     481End 
     482 
     483//wrapper to calculate the smeared model as an AAO-Struct 
     484// fills the struct and calls the ususal function with the STRUCT parameter 
     485// 
     486// used only for the dependency, not for fitting 
     487// 
     488Function fSmearedOblate_SW(coefW,yW,xW) 
     489        Wave coefW,yW,xW 
     490         
     491        String str = getWavesDataFolder(yW,0) 
     492        String DF="root:"+str+":" 
     493         
     494        WAVE resW = $(DF+str+"_res") 
     495         
     496        STRUCT ResSmearAAOStruct fs 
     497        WAVE fs.coefW = coefW    
     498        WAVE fs.yW = yW 
     499        WAVE fs.xW = xW 
     500        WAVE fs.resW = resW 
     501         
     502        Variable err 
     503        err = SmearedOblate_SW(fs) 
     504         
     505        return (0) 
     506End 
     507 
     508//wrapper to calculate the smeared model as an AAO-Struct 
     509// fills the struct and calls the ususal function with the STRUCT parameter 
     510// 
     511// used only for the dependency, not for fitting 
     512// 
     513Function fSmearedOblate_SC(coefW,yW,xW) 
     514        Wave coefW,yW,xW 
     515         
     516        String str = getWavesDataFolder(yW,0) 
     517        String DF="root:"+str+":" 
     518         
     519        WAVE resW = $(DF+str+"_res") 
     520         
     521        STRUCT ResSmearAAOStruct fs 
     522        WAVE fs.coefW = coefW    
     523        WAVE fs.yW = yW 
     524        WAVE fs.xW = xW 
     525        WAVE fs.resW = resW 
     526         
     527        Variable err 
     528        err = SmearedOblate_SC(fs) 
     529         
     530        return (0) 
     531End 
     532 
     533//wrapper to calculate the smeared model as an AAO-Struct 
     534// fills the struct and calls the ususal function with the STRUCT parameter 
     535// 
     536// used only for the dependency, not for fitting 
     537// 
     538Function fSmearedOblate_SHS(coefW,yW,xW) 
     539        Wave coefW,yW,xW 
     540         
     541        String str = getWavesDataFolder(yW,0) 
     542        String DF="root:"+str+":" 
     543         
     544        WAVE resW = $(DF+str+"_res") 
     545         
     546        STRUCT ResSmearAAOStruct fs 
     547        WAVE fs.coefW = coefW    
     548        WAVE fs.yW = yW 
     549        WAVE fs.xW = xW 
     550        WAVE fs.resW = resW 
     551         
     552        Variable err 
     553        err = SmearedOblate_SHS(fs) 
     554         
     555        return (0) 
     556End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/OblateForm.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34//////////////////////////////////////////////// 
     
    2223        make/o/t parameters_oef = {"scale","major core (A)","minor core (A)","major shell (A)","minor shell (A)","Contrast (core-shell) (A-2)","Constrast (shell-solvent) (A-2)","bkg (cm-1)"} 
    2324        Edit parameters_oef,coef_oef 
    24         ywave_oef := OblateForm(coef_oef,xwave_oef) 
     25        Variable/G root:g_oef 
     26        g_oef := OblateForm(coef_oef,ywave_oef,xwave_oef) 
     27//      ywave_oef := OblateForm(coef_oef,xwave_oef) 
    2528        Display ywave_oef vs xwave_oef 
    2629        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    2932        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    3033End 
     34 
    3135/////////////////////////////////////////////////////////// 
    32  
    33 Proc PlotSmearedOblateForm()                                                            //**** name of your function 
    34         //no input parameters necessary, it MUST use the experimental q-values 
    35         // from the experimental data read in from an AVE/QSIG data file 
    36          
    37         // if no gQvals wave, data must not have been loaded => abort 
    38         if(ResolutionWavesMissing()) 
     36// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     37Proc PlotSmearedOblateForm(str)                                                          
     38        String str 
     39        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
     40         
     41        // if any of the resolution waves are missing => abort 
     42        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3943                Abort 
    4044        endif 
     45         
     46        SetDataFolder $("root:"+str) 
    4147         
    4248        // Setup parameter table for model function 
     
    4753        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4854        // make extra copy of experimental q-values for easy plotting 
    49         Duplicate/O $gQvals smeared_oef,smeared_qvals                            
    50         SetScale d,0,0,"1/cm",smeared_oef                                        
    51  
    52         smeared_oef := SmearedOblateForm(smear_coef_oef,$gQvals) 
     55        Duplicate/O $(str+"_q") smeared_oef,smeared_qvals                                
     56        SetScale d,0,0,"1/cm",smeared_oef                                                                                
     57                 
     58        Variable/G gs_oef=0 
     59        gs_oef := fSmearedOblateForm(smear_coef_oef,smeared_oef,smeared_qvals)  //this wrapper fills the STRUCT 
     60         
    5361        Display smeared_oef vs smeared_qvals 
    5462        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    5664        Label left "Intensity (cm\\S-1\\M)" 
    5765        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     66         
     67        SetDataFolder root: 
     68End 
     69 
     70 
     71//AAO version 
     72Function OblateForm(cw,yw,xw) : FitFunc 
     73        Wave cw,yw,xw 
     74 
     75#if exists("OblateFormX") 
     76        yw = OblateFormX(cw,xw) 
     77#else 
     78        yw = fOblateForm(cw,xw) 
     79#endif 
     80        return(0) 
    5881End 
    5982 
     
    6184// unsmeared model calculation 
    6285/////////////////////////// 
    63 Function OblateForm(w,x) : FitFunc 
     86Function fOblateForm(w,x) : FitFunc 
    6487        Wave w 
    6588        Variable x 
     
    199222 
    200223// this is all there is to the smeared calculation! 
    201 Function SmearedOblateForm(w,x) :FitFunc 
    202         Wave w 
    203         Variable x 
    204          
    205         Variable ans 
    206         SVAR sq = gSig_Q 
    207         SVAR qb = gQ_bar 
    208         SVAR sh = gShadow 
    209         SVAR gQ = gQVals 
    210          
    211         //the name of your unsmeared model is the first argument 
    212         ans = Smear_Model_20(OblateForm,$sq,$qb,$sh,$gQ,w,x) 
    213  
    214         return(ans) 
    215 End 
     224Function SmearedOblateForm(s) :FitFunc 
     225        Struct ResSmearAAOStruct &s 
     226 
     227////the name of your unsmeared model is the first argument 
     228        s.yW = Smear_Model_20(OblateForm,s.coefW,s.xW,s.resW) 
     229 
     230        return(0) 
     231End 
     232 
     233//wrapper to calculate the smeared model as an AAO-Struct 
     234// fills the struct and calls the ususal function with the STRUCT parameter 
     235// 
     236// used only for the dependency, not for fitting 
     237// 
     238Function fSmearedOblateForm(coefW,yW,xW) 
     239        Wave coefW,yW,xW 
     240         
     241        String str = getWavesDataFolder(yW,0) 
     242        String DF="root:"+str+":" 
     243         
     244        WAVE resW = $(DF+str+"_res") 
     245         
     246        STRUCT ResSmearAAOStruct fs 
     247        WAVE fs.coefW = coefW    
     248        WAVE fs.yW = yW 
     249        WAVE fs.xW = xW 
     250        WAVE fs.resW = resW 
     251         
     252        Variable err 
     253        err = SmearedOblateForm(fs) 
     254         
     255        return (0) 
     256End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Peak_Gauss_model.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24//////////////////////////////////////////////////// 
    35//      J. Barker, 2-10-99 
     
    1416        make/o/t parameters_Peak_Gauss = {"Scale Factor, I0 ", "Peak position (^-1)", "Std Dev (^-1)","Incoherent Bgd (cm-1)"} 
    1517        Edit parameters_Peak_Gauss, coef_Peak_Gauss 
    16         ywave_Peak_Gauss  := Peak_Gauss_Model(coef_Peak_Gauss, xwave_Peak_Gauss) 
     18        Variable/G root:g_Peak_Gauss 
     19        g_Peak_Gauss  := Peak_Gauss_Model(coef_Peak_Gauss, ywave_Peak_Gauss, xwave_Peak_Gauss) 
     20//      ywave_Peak_Gauss  := Peak_Gauss_Model(coef_Peak_Gauss, xwave_Peak_Gauss) 
    1721        Display ywave_Peak_Gauss vs xwave_Peak_Gauss 
    1822        ModifyGraph marker=29, msize=2, mode=4 
     
    2327// 
    2428End 
     29 
    2530//////////////////////////////////////////////////// 
    26 Proc PlotSmearedPeak_Gauss()                                                            //Peak_Gauss 
    27         //no input parameters necessary, it MUST use the experimental q-values 
    28         // from the experimental data read in from an AVE/QSIG data file 
     31// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     32Proc PlotSmearedPeak_Gauss(str)                                                          
     33        String str 
     34        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    2935         
    30         // if no gQvals wave, data must not have been loaded => abort 
    31         if(ResolutionWavesMissing()) 
     36        // if any of the resolution waves are missing => abort 
     37        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3238                Abort 
    3339        endif 
     40         
     41        SetDataFolder $("root:"+str) 
    3442         
    3543        // Setup parameter table for model function 
     
    4048        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4149        // make extra copy of experimental q-values for easy plotting 
    42         Duplicate/O $gQvals smeared_Peak_Gauss,smeared_qvals                            // 
    43         SetScale d,0,0,"1/cm",smeared_Peak_Gauss                                                        // 
    44  
    45         smeared_Peak_Gauss := SmearedPeak_Gauss_Model(smear_coef_Peak_Gauss,$gQvals)            // SMEARED function name 
     50        Duplicate/O $(str+"_q") smeared_Peak_Gauss,smeared_qvals                                // 
     51        SetScale d,0,0,"1/cm",smeared_Peak_Gauss                                                        //                                       
     52                 
     53        Variable/G gs_Peak_Gauss=0 
     54        gs_Peak_Gauss := fSmearedPeak_Gauss_Model(smear_coef_Peak_Gauss,smeared_Peak_Gauss,smeared_qvals)       //this wrapper fills the STRUCT 
     55         
    4656        Display smeared_Peak_Gauss vs smeared_qvals                                                                     // 
    4757        ModifyGraph log=1,marker=29,msize=2,mode=4 
     
    4959        Label left "Peak_Gauss Model (cm\\S-1\\M)" 
    5060        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
    51 End     // end macro PlotSmearedPeak_Gauss 
     61         
     62        SetDataFolder root: 
     63End 
    5264 
    53 Function Peak_Gauss_model(w,x) : FitFunc 
     65 
     66 
     67//AAO version 
     68Function Peak_Gauss_model(cw,yw,xw) : FitFunc 
     69        Wave cw,yw,xw 
     70 
     71#if exists("Peak_Gauss_modelX") 
     72        yw = Peak_Gauss_modelX(cw,xw) 
     73#else 
     74        yw = fPeak_Gauss_model(cw,xw) 
     75#endif 
     76        return(0) 
     77End 
     78 
     79Function fPeak_Gauss_model(w,x) : FitFunc 
    5480        Wave w 
    5581        Variable x 
     
    78104 
    79105// this is all there is to the smeared calculation! 
    80 Function SmearedPeak_Gauss_Model(w,x) :FitFunc 
    81         Wave w 
    82         Variable x 
     106Function SmearedPeak_Gauss_Model(s) :FitFunc 
     107        Struct ResSmearAAOStruct &s 
     108 
     109////the name of your unsmeared model is the first argument 
     110        s.yW = Smear_Model_20(Peak_Gauss_model,s.coefW,s.xW,s.resW) 
     111 
     112        return(0) 
     113End 
     114 
     115//wrapper to calculate the smeared model as an AAO-Struct 
     116// fills the struct and calls the ususal function with the STRUCT parameter 
     117// 
     118// used only for the dependency, not for fitting 
     119// 
     120Function fSmearedPeak_Gauss_Model(coefW,yW,xW) 
     121        Wave coefW,yW,xW 
    83122         
    84         Variable ans 
    85         SVAR sq = gSig_Q 
    86         SVAR qb = gQ_bar 
    87         SVAR sh = gShadow 
    88         SVAR gQ = gQVals 
     123        String str = getWavesDataFolder(yW,0) 
     124        String DF="root:"+str+":" 
    89125         
    90         //the name of your unsmeared model is the first argument 
    91         ans = Smear_Model_20(Peak_Gauss_model,$sq,$qb,$sh,$gQ,w,x) 
    92  
    93         return(ans) 
     126        WAVE resW = $(DF+str+"_res") 
     127         
     128        STRUCT ResSmearAAOStruct fs 
     129        WAVE fs.coefW = coefW    
     130        WAVE fs.yW = yW 
     131        WAVE fs.xW = xW 
     132        WAVE fs.resW = resW 
     133         
     134        Variable err 
     135        err = SmearedPeak_Gauss_Model(fs) 
     136         
     137        return (0) 
    94138End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Peak_Lorentz_model.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
     3 
    24//////////////////////////////////////////////////// 
    35//      J. Barker, 2-10-99 
     
    1416        make/o/t parameters_Peak_Lorentz = {"Scale Factor, I0 ", "Peak position (^-1)", "Peak hwhm (^-1)","Incoherent Bgd (cm-1)"} 
    1517        Edit parameters_Peak_Lorentz, coef_Peak_Lorentz 
    16         ywave_Peak_Lorentz  := Peak_Lorentz_Model(coef_Peak_Lorentz, xwave_Peak_Lorentz) 
     18        Variable/G root:g_Peak_Lorentz 
     19        g_Peak_Lorentz  := Peak_Lorentz_Model(coef_Peak_Lorentz, ywave_Peak_Lorentz,xwave_Peak_Lorentz) 
     20//      ywave_Peak_Lorentz  := Peak_Lorentz_Model(coef_Peak_Lorentz, xwave_Peak_Lorentz) 
    1721        Display ywave_Peak_Lorentz vs xwave_Peak_Lorentz 
    1822        ModifyGraph marker=29, msize=2, mode=4 
     
    2327// 
    2428End 
     29 
    2530//////////////////////////////////////////////////// 
    26 Proc PlotSmearedPeak_Lorentz()                                                          //Peak_Lorentz 
    27         //no input parameters necessary, it MUST use the experimental q-values 
    28         // from the experimental data read in from an AVE/QSIG data file 
     31// - sets up a dependency to a wrapper, not the actual SmearedModelFunction 
     32Proc PlotSmearedPeak_Lorentz(str)                                                                
     33        String str 
     34        Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 
    2935         
    30         // if no gQvals wave, data must not have been loaded => abort 
    31         if(ResolutionWavesMissing()) 
     36        // if any of the resolution waves are missing => abort 
     37        if(ResolutionWavesMissingDF(str))               //updated to NOT use global strings (in GaussUtils) 
    3238                Abort 
    3339        endif 
     40         
     41        SetDataFolder $("root:"+str) 
    3442         
    3543        // Setup parameter table for model function 
     
    4048        // output smeared intensity wave, dimensions are identical to experimental QSIG values 
    4149        // make extra copy of experimental q-values for easy plotting 
    42         Duplicate/O $gQvals smeared_Peak_Lorentz,smeared_qvals                          // 
    43         SetScale d,0,0,"1/cm",smeared_Peak_Lorentz                                                      // 
     50        Duplicate/O $(str+"_q") smeared_Peak_Lorentz,smeared_qvals                              // 
     51        SetScale d,0,0,"1/cm",smeared_Peak_Lorentz                                                      //                                       
     52                 
     53        Variable/G gs_Peak_Lorentz=0 
     54        gs_Peak_Lorentz := fSmearedPeak_Lorentz_Model(smear_coef_Peak_Lorentz,smeared_Peak_Lorentz,smeared_qvals)       //this wrapper fills the STRUCT 
    4455 
    45         smeared_Peak_Lorentz := SmearedPeak_Lorentz_Model(smear_coef_Peak_Lorentz,$gQvals)              // SMEARED function name 
    4656        Display smeared_Peak_Lorentz vs smeared_qvals                                                                   // 
    4757        ModifyGraph log=1,marker=29,msize=2,mode=4 
    4858        Label bottom "q (\\S-1\\M)" 
    4959        Label left "Peak_Lorentz Model (cm\\S-1\\M)" 
    50         AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     60        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2)   
     61         
     62        SetDataFolder root: 
     63End 
    5164 
    52 End     // end macro PlotSmearedPeak_Lorentz 
    5365 
    54 Function Peak_Lorentz_model(w,x) : FitFunc 
     66//AAO version 
     67Function Peak_Lorentz_model(cw,yw,xw) : FitFunc 
     68        Wave cw,yw,xw 
     69 
     70#if exists("Peak_Lorentz_modelX") 
     71        yw = Peak_Lorentz_modelX(cw,xw) 
     72#else 
     73        yw = fPeak_Lorentz_model(cw,xw) 
     74#endif 
     75        return(0) 
     76End 
     77 
     78Function fPeak_Lorentz_model(w,x) : FitFunc 
    5579        Wave w 
    5680        Variable x 
     
    79103 
    80104// this is all there is to the smeared calculation! 
    81 Function SmearedPeak_Lorentz_Model(w,x) :FitFunc 
    82         Wave w 
    83         Variable x 
     105Function SmearedPeak_Lorentz_Model(s) :FitFunc 
     106        Struct ResSmearAAOStruct &s 
     107 
     108////the name of your unsmeared model is the first argument 
     109        s.yW = Smear_Model_20(Peak_Lorentz_model,s.coefW,s.xW,s.resW) 
     110 
     111        return(0) 
     112End 
     113 
     114//wrapper to calculate the smeared model as an AAO-Struct 
     115// fills the struct and calls the ususal function with the STRUCT parameter 
     116// 
     117// used only for the dependency, not for fitting 
     118// 
     119Function fSmearedPeak_Lorentz_Model(coefW,yW,xW) 
     120        Wave coefW,yW,xW 
    84121         
    85         Variable ans 
    86         SVAR sq = gSig_Q 
    87         SVAR qb = gQ_bar 
    88         SVAR sh = gShadow 
    89         SVAR gQ = gQVals 
     122        String str = getWavesDataFolder(yW,0) 
     123        String DF="root:"+str+":" 
    90124         
    91         //the name of your unsmeared model is the first argument 
    92         ans = Smear_Model_20(Peak_Lorentz_model,$sq,$qb,$sh,$gQ,w,x) 
    93  
    94         return(ans) 
     125        WAVE resW = $(DF+str+"_res") 
     126         
     127        STRUCT ResSmearAAOStruct fs 
     128        WAVE fs.coefW = coefW    
     129        WAVE fs.yW = yW 
     130        WAVE fs.xW = xW 
     131        WAVE fs.resW = resW 
     132         
     133        Variable err 
     134        err = SmearedPeak_Lorentz_Model(fs) 
     135         
     136        return (0) 
    95137End 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/PlotUtilsMacro.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
    22#pragma version=3.00 
    3 #pragma IgorVersion=4.0 
     3#pragma IgorVersion=6.0 
    44 
    55// This is to be used with the Analysis packages ONLY 
     
    2222 
    2323// loads a 1-d (ascii) datafile and plots the data 
    24 // will not overwrite existing data (old data must be deleted first) 
     24// will overwrite existing data if user is OK with this 
    2525// - multiple datasets can be automatically plotted on the same graph 
    2626// 
    2727//substantially easier to write this as a Proc rather than a function... 
     28 
    2829// 
    2930Proc A_LoadOneDData() 
    30  
     31        A_LoadOneDDataWithName("",1)            //will prompt for file and plot data 
     32End 
     33 
     34// load the data specified by fileStr (a full path:name) 
     35// and plots if doPlot==1 
     36// if fileStr is null, a dialog is presented to select the file 
     37// 
     38// 3 cases (if) 
     39// - 3 columns = QIS, no resolution 
     40// - 6 columns = QSIG, SANS w/resolution 
     41// - 5 columns = old-style desmeared USANS data (from VAX) 
     42// 
     43// This loader replaces the A_LoadOneDData() which was almost completely duplicated code 
     44// 
     45//new version, 19JUN07 that loads each data set into a separate data folder 
     46// the data folder is given the "base name" of the data file as it's loaded 
     47// 
     48Proc A_LoadOneDDataWithName(fileStr,doPlot) 
     49        String fileStr 
     50        Variable doPlot 
     51         
     52        Variable rr,gg,bb 
     53        SetDataFolder root:             //build sub-folders for each data set under root 
     54         
    3155        //Load the waves, using default waveX names 
    3256        //if no path or file is specified for LoadWave, the default Mac open dialog will appear 
    33         LoadWave/G/D/A 
    34         String filename = S_fileName 
    35          
    36         if(V_flag==3) 
    37                 String w0,w1,w2,n0,n1,n2,wt 
    38                 Variable rr,gg,bb 
     57        LoadWave/G/D/A/Q fileStr 
     58        String fileName = S_fileName 
     59        Variable numCols = V_flag 
     60         
     61        if(numCols==3)          //simple 3-column data with no resolution information 
     62                String w0,w1,w2,n0,n1,n2 
    3963                 
    4064                // put the names of the three loaded waves into local names 
     
    4771                w1 = CleanupName((S_fileName + "_i"),0) 
    4872                w2 = CleanupName((S_fileName + "_s"),0) 
    49                 wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave 
    50                  
    51                 if(exists(w0) !=0) 
    52                         DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
    53                         if(V_flag==2)   //user selected No 
    54                                 KillWaves/Z $n0,$n1,$n2         // kill the default waveX that were loaded 
    55                                 if(DataFolderExists("root:myGlobals")) 
    56                                         String/G root:myGlobals:gLastFileName = filename 
    57                                 endif           //set the last file loaded to the one NOT loaded 
    58                                 return          //quits the macro 
    59                         endif 
     73                 
     74                String baseStr=w1[0,strlen(w1)-3] 
     75                if(DataFolderExists("root:"+baseStr)) 
     76                                DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
     77                                if(V_flag==2)   //user selected No, don't load the data 
     78                                        SetDataFolder root: 
     79                                        KillWaves $n0,$n1,$n2           // kill the default waveX that were loaded 
     80                                        //if(DataFolderExists("root:myGlobals")) 
     81                                        //      String/G root:myGlobals:gLastFileName = filename 
     82                                        //endif 
     83                                        return          //quits the macro 
     84                                endif 
     85                                SetDataFolder $("root:"+baseStr) 
     86                else 
     87                        NewDataFolder/S $("root:"+baseStr) 
    6088                endif 
    6189                 
    6290                ////overwrite the existing data, if it exists 
    63                 Duplicate/O $n0, $w0 
    64                 Duplicate/O $n1, $w1 
    65                 Duplicate/O $n2, $w2 
    66                 KillWaves $n0,$n1,$n2 
    67                  
    68                 if(DataFolderExists("root:myGlobals")) 
    69                         String/G root:myGlobals:gLastFileName = filename 
    70                 endif 
    71                  
    72                 Duplicate/o $w2 $wt 
    73                 $wt = 1/$w2             //assign the weighting wave 
    74                  
    75                 // set data units for the waves 
    76 //                      if(DataFolderExists("root:myGlobals")) 
    77 //                              String angst = root:myGlobals:gAngstStr 
    78 //                      else 
    79                         String angst = "A" 
    80 //                      endif 
    81                 SetScale d,0,0,"1/"+angst,$w0 
     91                Duplicate/O $("root:"+n0), $w0 
     92                Duplicate/O $("root:"+n1), $w1 
     93                Duplicate/O $("root:"+n2), $w2 
     94 
     95                // no resolution matrix to make 
     96 
     97                SetScale d,0,0,"1/A",$w0 
    8298                SetScale d,0,0,"1/cm",$w1 
    8399                 
    84                 // assign colors randomly 
    85                 rr = abs(trunc(enoise(65535))) 
    86                 gg = abs(trunc(enoise(65535))) 
    87                 bb = abs(trunc(enoise(65535))) 
    88                  
    89                 // if target window is a graph, and user wants to append, do so 
    90            DoWindow/B Plot_Manager 
    91                 if(WinType("") == 1) 
    92                         DoAlert 1,"Do you want to append this data to the current graph?" 
    93                         if(V_Flag == 1) 
    94                                 AppendToGraph $w1 vs $w0 
    95                                 ModifyGraph mode=3,marker=19,msize=2,rgb ($w1) =(rr,gg,bb) 
    96                                 ErrorBars $w1 Y,wave=($w2,$w2) 
    97                         else 
    98                         //new graph 
    99                                 Display $w1 vs $w0 
    100                                 ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) 
    101                                 ModifyGraph grid=1,mirror=2,standoff=0 
    102                                 ErrorBars $w1 Y,wave=($w2,$w2) 
    103                                 Legend 
    104                         endif 
    105                 else 
    106                 // graph window was not target, make new one 
    107                         Display $w1 vs $w0 
    108                         ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) 
    109                         ModifyGraph grid=1,mirror=2,standoff=0 
    110                         ErrorBars $w1 Y,wave=($w2,$w2) 
    111                         Legend 
    112                 endif 
    113                          
    114                 // Annotate graph 
    115                 //Textbox/A=LT "XY data loaded from " + S_fileName 
    116             DoWindow/F Plot_Manager 
    117         endif 
    118          
    119         if(V_flag == 6) 
    120                 String w0,w1,w2,n0,n1,n2,wt 
     100        endif           //3-col data 
     101         
     102        if(numCols == 6)                //6-column SANS or USANS data that has resolution information 
     103                String w0,w1,w2,n0,n1,n2 
    121104                String w3,w4,w5,n3,n4,n5                        //3 extra waves to load 
    122                 Variable rr,gg,bb 
    123                  
    124                  
    125                 // put the names of the three loaded waves into local names 
     105                 
     106                // put the names of the (default named) loaded waves into local names 
    126107                n0 = StringFromList(0, S_waveNames ,";" ) 
    127108                n1 = StringFromList(1, S_waveNames ,";" ) 
     
    138119                w4 = CleanupName((S_fileName + "qb"),0) 
    139120                w5 = CleanupName((S_fileName + "fs"),0) 
    140                 wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave 
    141                  
    142                 if(exists(w0) !=0)              //the wave already exists 
    143                         DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
    144                         if(V_flag==2)   //user selected No 
    145                                 KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded 
    146                                 if(DataFolderExists("root:myGlobals")) 
    147                                         String/G root:myGlobals:gLastFileName = filename 
    148                                 endif           //set the last file loaded to the one NOT loaded 
    149                                 return          //quits the macro 
    150                         endif 
     121                 
     122                String baseStr=w1[0,strlen(w1)-3] 
     123                if(DataFolderExists("root:"+baseStr)) 
     124                                DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
     125                                if(V_flag==2)   //user selected No, don't load the data 
     126                                        SetDataFolder root: 
     127                                        KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded 
     128                                        //if(DataFolderExists("root:myGlobals")) 
     129                                        //      String/G root:myGlobals:gLastFileName = filename 
     130                                        //endif         //set the last file loaded to the one NOT loaded 
     131                                        return          //quits the macro 
     132                                endif 
     133                                SetDataFolder $("root:"+baseStr) 
     134                else 
     135                        NewDataFolder/S $("root:"+baseStr) 
    151136                endif 
    152137 
    153138////overwrite the existing data, if it exists 
    154                 Duplicate/O $n0, $w0 
    155                 Duplicate/O $n1, $w1 
    156                 Duplicate/O $n2, $w2 
    157                 Duplicate/O $n3, $w3 
    158                 Duplicate/O $n4, $w4 
    159                 Duplicate/O $n5, $w5 
    160                 KillWaves $n0,$n1,$n2,$n3,$n4,$n5 
    161                  
    162                 Duplicate/o $w2 $wt 
    163                 $wt = 1/$w2             //assign the weighting wave 
    164                  
    165                 // copy waves to global strings for use in the smearing calculation 
    166                 if(DataFolderExists("root:myGlobals")) 
    167                         String/G root:myGlobals:gLastFileName = filename 
    168                 endif 
    169                 String/G gQVals = w0 
    170                 String/G gSig_Q = w3 
    171                 String/G gQ_bar = w4 
    172                 String/G gShadow = w5 
    173                  
    174                 // set data units for the waves 
    175 //                      if(DataFolderExists("root:myGlobals")) 
    176 //                              String angst = root:myGlobals:gAngstStr 
    177 //                      else 
    178                         String angst = "A" 
    179 //                      endif 
    180                 SetScale d,0,0,"1/"+angst,$w0 
     139                Duplicate/O $("root:"+n0), $w0 
     140                Duplicate/O $("root:"+n1), $w1 
     141                Duplicate/O $("root:"+n2), $w2 
     142                Duplicate/O $("root:"+n3), $w3 
     143                Duplicate/O $("root:"+n4), $w4 
     144                Duplicate/O $("root:"+n5), $w5 
     145 
     146                // make a resolution matrix 
     147                Variable np=numpnts($w0) 
     148                Make/O/N=(np,4) $(baseStr+"_res") 
     149                // need to switch based on SANS/USANS 
     150                if (isSANSResolution($w3[0]))           //checks to see if the first point of the wave is <0 
     151                        $(baseStr+"_res")[][0] = $w3[p]         //sigQ 
     152                        $(baseStr+"_res")[][1] = $w4[p]         //qBar 
     153                        $(baseStr+"_res")[][2] = $w5[p]         //fShad 
     154                        $(baseStr+"_res")[][3] = $w0[p]         //Qvalues 
     155                else 
     156                        //the data is USANS data 
     157                        // marix calculation here, but for now, just copy the waves 
     158                        $(baseStr+"_res")[][0] = $w3[p]         //sigQ 
     159                        $(baseStr+"_res")[][1] = $w4[p]         //qBar 
     160                        $(baseStr+"_res")[][2] = $w5[p]         //fShad 
     161                        $(baseStr+"_res")[][3] = $w0[p]         //Qvalues 
     162                endif 
     163                Killwaves/Z $w3,$w4,$w5                 //get rid of the resolution waves that are in the matrix 
     164 
     165                SetScale d,0,0,"1/A",$w0 
    181166                SetScale d,0,0,"1/cm",$w1 
    182                  
    183                 // assign colors randomly 
    184                 rr = abs(trunc(enoise(65535))) 
    185                 gg = abs(trunc(enoise(65535))) 
    186                 bb = abs(trunc(enoise(65535))) 
    187          
    188                 // if target window is a graph, and user wants to append, do so 
    189                 DoWindow/B Plot_Manager 
    190                 if(WinType("") == 1) 
    191                         DoAlert 1,"Do you want to append this data to the current graph?" 
    192                         if(V_Flag == 1) 
    193                                 AppendToGraph $w1 vs $w0 
    194                                 ModifyGraph mode=3,marker=19,msize=2,rgb ($w1) =(rr,gg,bb) 
    195                                 ErrorBars $w1 Y,wave=($w2,$w2) 
    196                         else 
    197                         //new graph 
    198                                 Display $w1 vs $w0 
    199                                 ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) 
    200                                 ModifyGraph grid=1,mirror=2,standoff=0 
    201                                 ErrorBars $w1 Y,wave=($w2,$w2) 
    202                                 Legend 
    203                         endif 
    204                 else 
    205                 // graph window was not target, make new one 
    206                         Display $w1 vs $w0 
    207                         ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) 
    208                         ModifyGraph grid=1,mirror=2,standoff=0 
    209                         ErrorBars $w1 Y,wave=($w2,$w2) 
    210                         Legend 
    211                 endif 
    212                          
    213                 // Annotate graph 
    214                 //Textbox/A=LT "XY data loaded from " + S_fileName 
    215             DoWindow/F Plot_Manager 
    216         endif 
    217  
    218         if(V_flag==5) 
     167         
     168        endif   //6-col data 
     169 
     170        if(numCols==5)          //this is the "old-style" VAX desmeared data format 
    219171                String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4 
    220172                Variable rr,gg,bb 
     
    235187                w4 = CleanupName((S_fileName+"_fit_ism"),0) 
    236188                 
    237                 if(exists(w0) !=0)              //the wave already exists 
    238                         DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
    239                         if(V_flag==2)   //user selected No 
    240                                 KillWaves $n0,$n1,$n2,$n3,$n4           // kill the default waveX that were loaded 
    241                                 if(DataFolderExists("root:myGlobals")) 
    242                                         String/G root:myGlobals:gLastFileName = filename 
    243                                 endif           //set the last file loaded to the one NOT loaded 
    244                                 return          //quits the macro 
    245                         endif 
    246                 endif 
    247                  
    248                 ////overwrite the existing data, if it exists 
    249                 Duplicate/O $n0, $w0 
    250                 Duplicate/O $n1, $w1 
    251                 Duplicate/O $n2, $w2 
    252                 Duplicate/O $n3, $w3 
    253                 Duplicate/O $n4, $w4 
    254                 KillWaves $n0,$n1,$n2,$n3,$n4 
    255          
    256                 if(DataFolderExists("root:myGlobals")) 
    257                         String/G root:myGlobals:gLastFileName = filename 
    258                 endif 
     189                String baseStr=w1[0,strlen(w1)-3] 
     190                if(DataFolderExists("root:"+baseStr)) 
     191                                DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
     192                                if(V_flag==2)   //user selected No, don't load the data 
     193                                        KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded 
     194                                        //if(DataFolderExists("root:myGlobals")) 
     195                                        //      String/G root:myGlobals:gLastFileName = filename 
     196                                        //endif         //set the last file loaded to the one NOT loaded 
     197                                        return          //quits the macro 
     198                                endif 
     199                                SetDataFolder $("root:"+baseStr) 
     200                else 
     201                        NewDataFolder/S $("root:"+baseStr) 
     202                endif 
     203                 
     204                ////overwrite the existing data, if it exists    
     205                Duplicate/O $("root:"+n0), $w0 
     206                Duplicate/O $("root:"+n1), $w1 
     207                Duplicate/O $("root:"+n2), $w2 
     208                Duplicate/O $("root:"+n3), $w3 
     209                Duplicate/O $("root:"+n4), $w4 
     210                 
     211                // no resolution matrix 
     212        endif           //5-col data 
     213         
     214        ////// 
     215        if(DataFolderExists("root:myGlobals")) 
     216                String/G root:myGlobals:gLastFileName = filename 
     217        endif 
     218         
     219        //plot if desired 
     220        if(doPlot) 
    259221                // assign colors randomly 
    260222                rr = abs(trunc(enoise(65535))) 
     
    262224                bb = abs(trunc(enoise(65535))) 
    263225                 
    264                         // if target window is a graph, and user wants to append, do so 
     226                // if target window is a graph, and user wants to append, do so 
     227           DoWindow/B Plot_Manager 
    265228                if(WinType("") == 1) 
    266229                        DoAlert 1,"Do you want to append this data to the current graph?" 
    267230                        if(V_Flag == 1) 
    268231                                AppendToGraph $w1 vs $w0 
    269                                 ModifyGraph mode=3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2 
     232                                ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb) 
    270233                                ErrorBars $w1 Y,wave=($w2,$w2) 
    271234                        else 
    272235                        //new graph 
    273236                                Display $w1 vs $w0 
    274                                 ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 
     237                                ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb) 
     238                                ModifyGraph grid=1,mirror=2,standoff=0 
    275239                                ErrorBars $w1 Y,wave=($w2,$w2) 
    276240                                Legend 
     
    279243                // graph window was not target, make new one 
    280244                        Display $w1 vs $w0 
    281                         ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 
     245                        ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb) 
     246                        ModifyGraph grid=1,mirror=2,standoff=0 
    282247                        ErrorBars $w1 Y,wave=($w2,$w2) 
    283248                        Legend 
    284249                endif 
    285          
    286250        endif 
    287 End 
    288  
    289  
    290 //load the data specified by fileStr (a full path:name) 
    291 // Does not graph the data - just loads it 
    292 // 
    293 Proc A_LoadOneDDataWithName(fileStr) 
    294         String fileStr 
     251                 
     252        //go back to the root folder and clean up before leaving 
     253        SetDataFolder root: 
     254        KillWaves/Z $n0,$n1,$n2,$n3,$n4,$n5 
     255End 
     256 
     257 
     258//procedure for loading NSE data in the format (4-columns) 
     259// qvals - time - I(q,t) - dI(q,t) 
     260// 
     261// 
     262// this does NOT load the data into separate folders... 
     263// 
     264Proc A_LoadNSEData() 
     265        A_LoadNSEDataWithName("",1) 
     266End 
     267 
     268Proc A_LoadNSEDataWithName(fileStr,doPlot) 
     269 
    295270        //Load the waves, using default waveX names 
    296271        //if no path or file is specified for LoadWave, the default Mac open dialog will appear 
    297         LoadWave/G/D/A/Q fileStr 
    298         String fileName = S_fileName 
    299          
    300         if(V_flag==3) 
    301                 String w0,w1,w2,n0,n1,n2,wt 
    302                  
    303                 // put the names of the three loaded waves into local names 
    304                 n0 = StringFromList(0, S_waveNames ,";" ) 
    305                 n1 = StringFromList(1, S_waveNames ,";" ) 
    306                 n2 = StringFromList(2, S_waveNames ,";" ) 
    307                  
    308                 //remove the semicolon AND period from files from the VAX 
    309                 w0 = CleanupName((S_fileName + "_q"),0) 
    310                 w1 = CleanupName((S_fileName + "_i"),0) 
    311                 w2 = CleanupName((S_fileName + "_s"),0) 
    312                 wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave 
    313                  
    314                 if(exists(w0) !=0) 
    315                         DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
    316                         if(V_flag==2)   //user selected No 
    317                                 KillWaves/Z $n0,$n1,$n2         // kill the default waveX that were loaded 
    318                                 if(DataFolderExists("root:myGlobals")) 
    319                                         String/G root:myGlobals:gLastFileName = filename 
    320                                 endif           //set the last file loaded to the one NOT loaded 
    321                                 return          //quits the macro 
    322                         endif 
    323                 endif 
    324                  
    325                 ////overwrite the existing data, if it exists 
    326                 Duplicate/O $n0, $w0 
    327                 Duplicate/O $n1, $w1 
    328                 Duplicate/O $n2, $w2 
    329                 KillWaves $n0,$n1,$n2 
    330                  
    331                 Duplicate/o $w2 $wt 
    332                 $wt = 1/$w2             //assign the weighting wave 
    333                  
    334                 if(DataFolderExists("root:myGlobals")) 
    335                         String/G root:myGlobals:gLastFileName = filename 
    336                 endif 
    337                 String/G gQVals = w0 
    338                 String/G gInten = w1 
    339                 String/G gSigma = w2 
    340                  
    341         endif 
    342          
    343         if(V_flag == 6) 
    344                 String w0,w1,w2,n0,n1,n2,wt 
    345                 String w3,w4,w5,n3,n4,n5                        //3 extra waves to load 
    346                  
    347                  
    348                 // put the names of the three loaded waves into local names 
    349                 n0 = StringFromList(0, S_waveNames ,";" ) 
    350                 n1 = StringFromList(1, S_waveNames ,";" ) 
    351                 n2 = StringFromList(2, S_waveNames ,";" ) 
    352                 n3 = StringFromList(3, S_waveNames ,";" ) 
    353                 n4 = StringFromList(4, S_waveNames ,";" ) 
    354                 n5 = StringFromList(5, S_waveNames ,";" ) 
    355                  
    356                 //remove the semicolon AND period from files from the VAX 
    357                 w0 = CleanupName((S_fileName + "_q"),0) 
    358                 w1 = CleanupName((S_fileName + "_i"),0) 
    359                 w2 = CleanupName((S_fileName + "_s"),0) 
    360                 w3 = CleanupName((S_fileName + "sq"),0) 
    361                 w4 = CleanupName((S_fileName + "qb"),0) 
    362                 w5 = CleanupName((S_fileName + "fs"),0) 
    363                 wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave 
    364                  
    365                 if(exists(w0) !=0)              //the wave already exists 
    366                         DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
    367                         if(V_flag==2)   //user selected No 
    368                                 KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded 
    369                                 if(DataFolderExists("root:myGlobals")) 
    370                                         String/G root:myGlobals:gLastFileName = filename 
    371                                 endif           //set the last file loaded to the one NOT loaded 
    372                                 return          //quits the macro 
    373                         endif 
    374                 endif 
    375  
    376 ////overwrite the existing data, if it exists 
    377                 Duplicate/O $n0, $w0 
    378                 Duplicate/O $n1, $w1 
    379                 Duplicate/O $n2, $w2 
    380                 Duplicate/O $n3, $w3 
    381                 Duplicate/O $n4, $w4 
    382                 Duplicate/O $n5, $w5 
    383                 KillWaves $n0,$n1,$n2,$n3,$n4,$n5 
    384                  
    385                 Duplicate/o $w2 $wt 
    386                 $wt = 1/$w2             //assign the weighting wave 
    387                  
    388                 // copy waves to global strings for use in the smearing calculation 
    389                 if(DataFolderExists("root:myGlobals")) 
    390                         String/G root:myGlobals:gLastFileName = filename 
    391                 endif 
    392                 String/G gQVals = w0 
    393                 String/G gInten = w1 
    394                 String/G gSigma = w2 
    395                 String/G gSig_Q = w3 
    396                 String/G gQ_bar = w4 
    397                 String/G gShadow = w5 
    398  
    399         endif 
    400  
    401         if(V_flag==5) 
    402                 String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4 
    403                 Variable rr,gg,bb 
    404                  
    405                 // put the names of the three loaded waves into local names 
    406                 n0 = StringFromList(0, S_waveNames ,";" ) 
    407                 n1 = StringFromList(1, S_waveNames ,";" ) 
    408                 n2 = StringFromList(2, S_waveNames ,";" ) 
    409                 n3 = StringFromList(3, S_waveNames ,";" ) 
    410                 n4 = StringFromList(4, S_waveNames ,";" ) 
    411                  
    412                  
    413                 //remove the semicolon AND period from files from the VAX 
    414                 w0 = CleanupName((S_fileName+"_q"),0) 
    415                 w1 = CleanupName((S_fileName+"_i"),0) 
    416                 w2 = CleanupName((S_fileName+"_s"),0) 
    417                 w3 = CleanupName((S_fileName+"_ism"),0) 
    418                 w4 = CleanupName((S_fileName+"_fit_ism"),0) 
    419                  
    420                 if(exists(w0) !=0)              //the wave already exists 
    421                         DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 
    422                         if(V_flag==2)   //user selected No 
    423                                 KillWaves $n0,$n1,$n2,$n3,$n4           // kill the default waveX that were loaded 
    424                                 if(DataFolderExists("root:myGlobals")) 
    425                                         String/G root:myGlobals:gLastFileName = filename 
    426                                 endif           //set the last file loaded to the one NOT loaded 
    427                                 return          //quits the macro 
    428                         endif 
    429                 endif 
    430                  
    431                 ////overwrite the existing data, if it exists 
    432                 Duplicate/O $n0, $w0 
    433                 Duplicate/O $n1, $w1 
    434                 Duplicate/O $n2, $w2 
    435                 Duplicate/O $n3, $w3 
    436                 Duplicate/O $n4, $w4 
    437                 KillWaves $n0,$n1,$n2,$n3,$n4 
    438          
    439                 if(DataFolderExists("root:myGlobals")) 
    440                         String/G root:myGlobals:gLastFileName = filename 
    441                 endif 
    442  
    443         endif 
    444 End 
    445  
    446  
    447 //procedure for loading NSE data in the format (4-columns) 
    448 // qvals - time - I(q,t) - dI(q,t) 
    449 //creates weighting wave for data fitting 
    450  
    451 Proc A_LoadNSEData() 
    452  
    453         //Load the waves, using default waveX names 
    454         //if no path or file is specified for LoadWave, the default Mac open dialog will appear 
    455         LoadWave/G/D/A 
    456         String filename = S_fileName 
     272        LoadWave/G/D/A  fileStr 
     273        String filename = S_fileName 
    457274         
    458275        String w0,w1,w2,n0,n1,n2,wt,w3,n3 
     
    471288        w2 = CleanupName(("iqt_"+S_fileName),0) 
    472289        w3 = CleanupName(("iqterr_"+S_fileName),0) 
    473         wt = CleanupName(("iqtwt_"+S_fileName),0)               //create a name for the weighting wave 
    474290         
    475291        if(exists(w0) !=0) 
     
    484300        Rename $n2, $w2 
    485301        Rename $n3, $w3 
    486          
    487         Duplicate/o $w3 $wt 
    488         $wt = 1/$w3             //assign the weighting wave 
    489          
    490         // assign colors randomly 
    491         rr = abs(trunc(enoise(65535))) 
    492         gg = abs(trunc(enoise(65535))) 
    493         bb = abs(trunc(enoise(65535))) 
    494          
    495         // if target window is a graph, and user wants to append, do so 
    496         if(WinType("") == 1) 
    497                 DoAlert 1,"Do you want to append this data to the current graph?" 
    498                 if(V_Flag == 1) 
    499                         AppendToGraph $w2 vs $w1 
    500                         ModifyGraph mode=3,marker=29,msize=2,rgb ($w2) =(rr,gg,bb),grid=1,mirror=2,tickUnit=1 
    501                         ErrorBars $w2 Y,wave=($w3,$w3) 
    502                 else 
    503                 //new graph 
     302                 
     303        if(doPlot) 
     304                // assign colors randomly 
     305                rr = abs(trunc(enoise(65535))) 
     306                gg = abs(trunc(enoise(65535))) 
     307                bb = abs(trunc(enoise(65535))) 
     308                 
     309                // if target window is a graph, and user wants to append, do so 
     310                if(WinType("") == 1) 
     311                        DoAlert 1,"Do you want to append this data to the current graph?" 
     312                        if(V_Flag == 1) 
     313                                AppendToGraph $w2 vs $w1 
     314                                ModifyGraph mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2) =(rr,gg,bb),grid=1,mirror=2,tickUnit=1 
     315                                ErrorBars $w2 Y,wave=($w3,$w3) 
     316                        else 
     317                        //new graph 
     318                                Display $w2 vs $w1 
     319                                ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 
     320                                ErrorBars $w2 Y,wave=($w3,$w3) 
     321                                Legend 
     322                        endif 
     323                else 
     324                // graph window was not target, make new one 
    504325                        Display $w2 vs $w1 
    505                         ModifyGraph standoff=0,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 
     326                        ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 
    506327                        ErrorBars $w2 Y,wave=($w3,$w3) 
    507328                        Legend 
    508329                endif 
    509         else 
    510         // graph window was not target, make new one 
    511                 Display $w2 vs $w1 
    512                 ModifyGraph standoff=0,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 
    513                 ErrorBars $w2 Y,wave=($w3,$w3) 
    514                 Legend 
    515         endif 
    516                  
    517  
    518 End 
    519  
    520 //DOES NOT graph the data 
    521 Proc A_LoadNSEDataWithName(fileStr) 
    522         String fileStr 
    523         //Load the waves, using default waveX names 
    524         //if no path or file is specified for LoadWave, the default Mac open dialog will appear 
    525         LoadWave/G/D/A/Q fileStr 
    526         String fileName = S_fileName 
    527          
    528          
    529         String w0,w1,w2,n0,n1,n2,wt,w3,n3 
    530         Variable rr,gg,bb 
    531          
    532         // put the names of the three loaded waves into local names 
    533         n0 = StringFromList(0, S_waveNames ,";" ) 
    534         n1 = StringFromList(1, S_waveNames ,";" ) 
    535         n2 = StringFromList(2, S_waveNames ,";" ) 
    536         n3 = StringFromList(3, S_waveNames ,";" ) 
    537          
    538          
    539         //remove the semicolon AND period from files from the VAX 
    540         w0 = CleanupName(("qvals_"+S_fileName),0) 
    541         w1 = CleanupName(("time_"+S_fileName),0) 
    542         w2 = CleanupName(("iqt_"+S_fileName),0) 
    543         w3 = CleanupName(("iqterr_"+S_fileName),0) 
    544         wt = CleanupName(("iqtwt_"+S_fileName),0)               //create a name for the weighting wave 
    545          
    546         if(exists(w0) !=0) 
    547                 DoAlert 0,"This file has already been loaded. Use Append to Graph..." 
    548                 KillWaves $n0,$n1,$n2           // kill the default waveX that were loaded 
    549                 return 
    550         endif 
    551          
    552         // Rename to give nice names 
    553         Rename $n0, $w0 
    554         Rename $n1, $w1 
    555         Rename $n2, $w2 
    556         Rename $n3, $w3 
    557          
    558         Duplicate/o $w3 $wt 
    559         $wt = 1/$w3             //assign the weighting wave              
    560  
    561 End 
    562  
     330        endif //doPlot           
     331 
     332End 
    563333 
    564334//procedure for loading desmeared USANS data in the format (5-columns) 
    565335// qvals - I(q) - sig I - Ism(q) - fitted Ism(q) 
    566336//no weighting wave is created (not needed in IGOR 4) 
     337// 
     338// not really ever used... 
     339// 
    567340Proc A_LoadUSANSData() 
    568341 
  • sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/PolyCSRatio_and_Struct.ipf

    r42 r127  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2#pragma IgorVersion = 6.0 
    23 
    34// be sure to include all the necessary files... 
     
    2122        make/o/t parameters_PCR_HS = {"volume fraction","avg radius (A)","avg shell thickness (A)","overall polydispersity","SLD core (A-2)","SLD shell (A-2)","SLD solvent (A-2)","bkg (cm-1)"} 
    2223  &