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