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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.