Ignore:
Timestamp:
Aug 3, 2009 6:22:39 PM (13 years ago)
Author:
srkline
Message:

Lots of changes to add the first version of a USANS simulator, like SASCALC

(!) first issue is with the entanglement of dependencies - need to load SANS macros first!

otherwise, worth a first test for interface and accuracy. behavior is similar to the 1D SASCALC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf

    r542 r544  
    473473                                        // this would not be true if simulating anisotropic scattering. 
    474474                                        //testPhi = abs(enoise(1))*2*Pi 
    475                                         testPhi = FindPhi(Vx,Vy)                //use the exiting phi value as defined by Vx and Vy 
     475                                        testPhi = MC_FindPhi(Vx,Vy)             //use the exiting phi value as defined by Vx and Vy 
    476476                                         
    477477                                        // is it on the detector?        
     
    731731Function/S MC_FunctionPopupList() 
    732732        String list,tmp 
    733         list = FunctionList("*",";","KIND:10")          //get every user defined curve fit function 
    734  
    735         //now start to remove everything the user doesn't need to see... 
    736                  
    737         tmp = FunctionList("*_proto",";","KIND:10")             //prototypes 
    738         list = RemoveFromList(tmp, list  ,";") 
    739         //prototypes that show up if GF is loaded 
    740         list = RemoveFromList("GFFitFuncTemplate", list) 
    741         list = RemoveFromList("GFFitAllAtOnceTemplate", list) 
    742         list = RemoveFromList("NewGlblFitFunc", list) 
    743         list = RemoveFromList("NewGlblFitFuncAllAtOnce", list) 
    744         list = RemoveFromList("GlobalFitFunc", list) 
    745         list = RemoveFromList("GlobalFitAllAtOnce", list) 
    746         list = RemoveFromList("GFFitAAOStructTemplate", list) 
    747         list = RemoveFromList("NewGF_SetXWaveInList", list) 
    748         list = RemoveFromList("NewGlblFitFuncAAOStruct", list) 
    749          
    750         // more to remove as a result of 2D/Gizmo 
    751         list = RemoveFromList("A_WMRunLessThanDelta", list) 
    752         list = RemoveFromList("WMFindNaNValue", list) 
    753         list = RemoveFromList("WM_Make3DBarChartParametricWave", list) 
    754         list = RemoveFromList("UpdateQxQy2Mat", list) 
    755         list = RemoveFromList("MakeBSMask", list) 
    756          
    757         // MOTOFIT/GenFit bits 
    758         tmp = "GEN_allatoncefitfunc;GEN_fitfunc;GetCheckBoxesState;MOTO_GFFitAllAtOnceTemplate;MOTO_GFFitFuncTemplate;MOTO_NewGF_SetXWaveInList;MOTO_NewGlblFitFunc;MOTO_NewGlblFitFuncAllAtOnce;GeneticFit_UnSmearedModel;GeneticFit_SmearedModel;" 
    759         list = RemoveFromList(tmp, list  ,";") 
    760  
    761         // SANS Reduction bits 
    762         tmp = "ASStandardFunction;Ann_1D_Graph;Avg_1D_Graph;BStandardFunction;CStandardFunction;Draw_Plot1D;MyMat2XYZ;NewDirection;SANSModelAAO_MCproto;Monte_SANS_Threaded;Monte_SANS_NotThreaded;Monte_SANS_W1;Monte_SANS_W2;FractionReachingDetector;" 
    763         list = RemoveFromList(tmp, list  ,";") 
    764         list = RemoveFromList("Monte_SANS", list) 
    765  
    766         tmp = FunctionList("f*",";","NPARAMS:2")                //point calculations 
    767         list = RemoveFromList(tmp, list  ,";") 
    768          
    769         tmp = FunctionList("fSmear*",";","NPARAMS:3")           //smeared dependency calculations 
    770         list = RemoveFromList(tmp, list  ,";") 
    771          
    772         //non-fit functions that I can't seem to filter out 
    773         list = RemoveFromList("BinaryHS_PSF11;BinaryHS_PSF12;BinaryHS_PSF22;EllipCyl_Integrand;PP_Inner;PP_Outer;Phi_EC;TaE_Inner;TaE_Outer;",list,";") 
    774 //////////////// 
    775  
    776         //more functions from analysis models (2008) 
    777         tmp = "Barbell_Inner;Barbell_Outer;Barbell_integrand;BCC_Integrand;Integrand_BCC_Inner;Integrand_BCC_Outer;" 
    778         list = RemoveFromList(tmp, list  ,";") 
    779         tmp = "CapCyl;CapCyl_Inner;CapCyl_Outer;ConvLens;ConvLens_Inner;ConvLens_Outer;" 
    780         list = RemoveFromList(tmp, list  ,";") 
    781         tmp = "Dumb;Dumb_Inner;Dumb_Outer;FCC_Integrand;Integrand_FCC_Inner;Integrand_FCC_Outer;" 
    782         list = RemoveFromList(tmp, list  ,";") 
    783         tmp = "Integrand_SC_Inner;Integrand_SC_Outer;SC_Integrand;SphCyl;SphCyl_Inner;SphCyl_Outer;" 
    784         list = RemoveFromList(tmp, list  ,";") 
    785  
     733        list = User_FunctionPopupList() 
     734         
    786735        //simplify the display, forcing smeared calculations behind the scenes 
    787736        tmp = FunctionList("Smear*",";","NPARAMS:1")            //smeared dependency calculations 
    788         list = RemoveFromList(tmp, list  ,";") 
     737        list = RemoveFromList(tmp, list,";") 
     738 
    789739 
    790740        if(strlen(list)==0) 
     
    794744        list = SortList(list) 
    795745         
    796 //      list = "default;"+list 
    797746        return(list) 
    798747End               
     
    1005954// 
    1006955// currently only works with SANS data, but can later be expanded to generate fake USANS data sets 
     956// ---- use FakeUSANSDataFolder() instead---- 
    1007957// 
    1008958Function        Fake1DDataFolder(qval,aveint,sigave,sigmaQ,qbar,fSubs,dataFolder) 
     
    12531203end 
    12541204 
     1205//phi is defined from +x axis, proceeding CCW around [0,2Pi] 
     1206ThreadSafe Function MC_FindPhi(vx,vy) 
     1207        variable vx,vy 
     1208         
     1209        variable phi 
     1210         
     1211        phi = atan(vy/vx)               //returns a value from -pi/2 to pi/2 
     1212         
     1213        // special cases 
     1214        if(vx==0 && vy > 0) 
     1215                return(pi/2) 
     1216        endif 
     1217        if(vx==0 && vy < 0) 
     1218                return(3*pi/2) 
     1219        endif 
     1220        if(vx >= 0 && vy == 0) 
     1221                return(0) 
     1222        endif 
     1223        if(vx < 0 && vy == 0) 
     1224                return(pi) 
     1225        endif 
     1226         
     1227         
     1228        if(vx > 0 && vy > 0) 
     1229                return(phi) 
     1230        endif 
     1231        if(vx < 0 && vy > 0) 
     1232                return(phi + pi) 
     1233        endif 
     1234        if(vx < 0 && vy < 0) 
     1235                return(phi + pi) 
     1236        endif 
     1237        if( vx > 0 && vy < 0) 
     1238                return(phi + 2*pi) 
     1239        endif 
     1240         
     1241        return(phi) 
     1242end 
     1243 
     1244 
     1245 
    12551246 
    12561247 
Note: See TracChangeset for help on using the changeset viewer.