Changeset 1168


Ignore:
Timestamp:
Dec 6, 2021 4:47:20 PM (10 months ago)
Author:
ilavsky
Message:

Fixed Guinier-Porod model where fitting small Q range was failing. This model needs to be calculated over whole available Q range or it fails to give proper intensities.

Location:
trunk/User Procedures/Irena
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/User Procedures/Irena/IR3_GuinierPorodModel.ipf

    r1167 r1168  
    11#pragma TextEncoding = "UTF-8"
    22#pragma rtGlobals=3             // Use modern global access method.
    3 #pragma version=1.11            //this is Irena package Guinier-Porod model based on Hammouda's paper
     3#pragma version=1.12            //this is Irena package Guinier-Porod model based on Hammouda's paper
    44Constant IR3GPversionNumber=1.08
    55
     
    1919
    2020//version history
     21//1.12 Fixed fitting issue where fittung data in small Q range (at low-Q) failed. It was working for large Q range. FIxed by always calculating full data Q range and using subset for fitting.
    2122//1.11 Added ability to export Level fits (Int-Q) which was missing before.  Adds Level0 which is simply flat background wave.
    2223//1.10 2019-05 Testing, fixes for Correlation fitting parameters (were not fitted at all) and some fixes to Uncertainty evaluation, was misbehaving.
     
    11471148        NVAR SlitLengthUnif=root:Packages:Irena:GuinierPorod:SlitLengthUnif
    11481149        NVAR ActiveLevel=root:Packages:Irena:GuinierPorod:ActiveLevel
    1149         //clean old individual levels, so they arfe not in our way...
     1150        //clean old individual levels, so they are not in our way...
    11501151        KillWaves/Z ModelIntGPLevel_1, ModelIntGPLevel_2, ModelIntGPLevel_3, ModelIntGPLevel_4, ModelIntGPLevel_5
    11511152        Duplicate/O OriginalIntensity, ModelIntensity, ModelCurrentLevel
     
    11651166                ModelIntensity+=TempIntensity
    11661167        endfor         
    1167         //calculate currnetly diplasyed tab level.
     1168        //calculate currently displayed tab level.
    11681169        if(ActiveLevel<=NumberOfLevels)
    11691170                IR3GP_CalculateOneLevelModelInt(OriginalQvector,ModelCurrentLevel, ActiveLevel)
     
    12061207        setDataFolder root:Packages:Irena:GuinierPorod
    12071208        Wave OriginalIntensity=root:Packages:Irena:GuinierPorod:OriginalIntensity
     1209        Wave OriginalQvector=root:Packages:Irena:GuinierPorod:OriginalQvector   
    12081210        NVAR NumberOfLevels=root:Packages:Irena:GuinierPorod:NumberOfLevels
    12091211        NVAR UseSMRData=root:Packages:Irena:GuinierPorod:UseSMRData
     
    12111213        NVAR ActiveLevel=root:Packages:Irena:GuinierPorod:ActiveLevel
    12121214        FitIntensity=0
    1213         Duplicate/Free FitIntensity, tempIntensity
     1215        //NOTE: These fits fail if we do not use full Q range, missing high-Q breaks everything.
     1216        //So we need to calculate full Q range and then pick the right subset...
     1217        Duplicate/Free OriginalIntensity, tempIntensity, FitIntLocal            //Full Q range
     1218        FitIntLocal = 0
    12141219        variable i
    1215        
    1216         for(i=1;i<=NumberOfLevels;i+=1) // initialize variables;continue test
    1217                 IR3GP_CalculateOneLevelModelInt(Qvector,TempIntensity, i)
    1218                 FitIntensity+=TempIntensity
     1220        for(i=1;i<=NumberOfLevels;i+=1)
     1221                IR3GP_CalculateOneLevelModelInt(OriginalQvector,TempIntensity, i)
     1222                FitIntLocal+=TempIntensity
    12191223        endfor                   
    12201224        NVAR SASBackground=root:Packages:Irena:GuinierPorod:SASBackground
    1221         FitIntensity+=SASBackground             
     1225        FitIntLocal+=SASBackground             
    12221226        if(UseSMRData)
    1223                 duplicate/free FitIntensity, ModelIntensitySM
    1224                 IR1B_SmearData(FitIntensity, Qvector, SlitLengthUnif, ModelIntensitySM)
    1225                 FitIntensity=ModelIntensitySM
    1226         endif
     1227                duplicate/free FitIntLocal, ModelIntensitySM
     1228                IR1B_SmearData(FitIntLocal, OriginalQvector, SlitLengthUnif, ModelIntensitySM)
     1229                FitIntLocal=ModelIntensitySM
     1230        endif
     1231        //OK, now we have model over the whole data Q range
     1232        //pick subset over fitted Q range
     1233        variable startP
     1234        startP = BinarySearch(OriginalQvector, Qvector[0])
     1235        FitIntensity = FitIntLocal[p+startP]
     1236       
    12271237end
    12281238
     
    16441654        Variable V_chisq, level
    16451655        Duplicate/O W_Coef, E_wave, CoefficientInput
    1646         E_wave=W_coef/100
     1656        E_wave=W_coef/1000
    16471657
    16481658        Variable V_FitError=0                   //This should prevent errors from being generated
  • trunk/User Procedures/Irena/Modification history.txt

    r1148 r1168  
    1010Modification history:
    1111********************************************
     122.72 ???
     13Fixed Anomalous Contrast calculator which failed to run in old experiments due to lookup tables incompatibility. Needed proper reinitialization.
     14Fixed Guinier-Porod fitting where fitting small Q range was failing.
     15
     16
    12172.71 10/10/2021
    1318Igor 9 compatible.
Note: See TracChangeset for help on using the changeset viewer.