Changeset 127 for sans/Analysis/branches/ajj_23APR07
- Timestamp:
- Jul 24, 2007 3:23:44 PM (16 years ago)
- 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// … … 23 24 make/o/t parameters_BE = {"K (barns)","Lb ()","h (-3)","b ()","Cs (mol/L)","alpha","C (mol/L)","Background"} 24 25 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) 26 29 Display ywave_BE vs xwave_BE 27 30 ModifyGraph log=0,marker=29,msize=2,mode=4 //**** log=0 if linear scale desired … … 32 35 33 36 /////////////////////////////////////////////////////////// 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 38 Proc 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) 40 44 Abort 41 45 endif 46 47 SetDataFolder $("root:"+str) 42 48 43 49 // Setup parameter table for model function … … 48 54 // output smeared intensity wave, dimensions are identical to experimental QSIG values 49 55 // make extra copy of experimental q-values for easy plotting 50 Duplicate/O $ gQvalssmeared_BE,smeared_qvals //**** mod56 Duplicate/O $(str+"_q") smeared_BE,smeared_qvals //**** mod 51 57 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 54 62 Display smeared_BE vs smeared_qvals //**** mod 55 63 ModifyGraph log=0,marker=29,msize=2,mode=4 … … 57 65 Label left "I sBE (cm\\S-1\\M)" 58 66 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 67 68 SetDataFolder root: 69 End 70 71 72 //AAO version 73 Function 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) 59 82 End 60 83 … … 64 87 // Borue-Erukhimovich RPA model for linear polyelectrolytes 65 88 /////////////////////////// 66 67 68 Function BEPolyelectrolyte(w,q) : FitFunc 89 Function fBEPolyelectrolyte(w,q) : FitFunc 69 90 Wave w 70 91 Variable q … … 116 137 117 138 139 // this is all there is to the smeared calculation! 140 Function SmearedBEPolyelec(s) :FitFunc 141 Struct ResSmearAAOStruct &s 118 142 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) 122 145 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) 147 End 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 // 154 Function fSmearedBEPolyelec(coefW,yW,xW) 155 Wave coefW,yW,xW 127 156 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+":" 133 159 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) 138 172 End 139 173 140 174 141 -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CoreShell.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// … … 22 23 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)"} 23 24 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) 25 28 Display ywave_css vs xwave_css 26 29 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 31 34 32 35 /////////////////////////////////////////////////////////// 33 34 Proc PlotSmearedCoreShellSphere( ) //**** name of your function35 //no input parameters necessary, it MUST use the experimental q-values36 // from the experimental data read in from an AVE/QSIG data file36 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 37 Proc PlotSmearedCoreShellSphere(str) 38 String str 39 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 37 40 38 // if no gQvals wave, data must not have been loaded=> abort39 if(ResolutionWavesMissing ())41 // if any of the resolution waves are missing => abort 42 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 40 43 Abort 41 44 endif 45 46 SetDataFolder $("root:"+str) 42 47 43 48 // Setup parameter table for model function … … 49 54 // make extra copy of experimental q-values for easy plotting 50 55 51 Duplicate/O $ gQvalssmeared_css,smeared_qvals56 Duplicate/O $(str+"_q") smeared_css,smeared_qvals 52 57 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 55 62 Display smeared_css vs smeared_qvals 56 63 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 58 65 Label left "Intensity (cm\\S-1\\M)" 59 66 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 67 68 SetDataFolder root: 69 End 70 71 72 //AAO version 73 Function 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) 60 82 End 61 83 … … 63 85 // unsmeared model calculation 64 86 /////////////////////////// 65 Function CoreShellForm(w,x) : FitFunc87 Function fCoreShellForm(w,x) : FitFunc 66 88 Wave w 67 89 Variable x … … 117 139 118 140 // this is all there is to the smeared calculation! 119 Function SmearedCoreShellForm(w,x) :FitFunc 120 Wave w 121 Variable x 141 Function 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) 148 End 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 // 155 Function fSmearedCoreShellForm(coefW,yW,xW) 156 Wave coefW,yW,xW 122 157 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+":" 128 160 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) 133 173 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CoreShellCylinder.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// … … 24 25 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)"} 25 26 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) 27 30 Display ywave_cscyl vs xwave_cscyl 28 31 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 31 34 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 32 35 End 36 33 37 /////////////////////////////////////////////////////////// 34 35 Proc PlotSmearedCSCylinderForm( )36 //no input parameters necessary, it MUST use the experimental q-values37 // from the experimental data read in from an AVE/QSIG data file38 39 // if no gQvals wave, data must not have been loaded=> abort40 if(ResolutionWavesMissing ())38 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 39 Proc 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) 41 45 Abort 42 46 endif 47 48 SetDataFolder $("root:"+str) 43 49 44 50 // Setup parameter table for model function … … 49 55 // output smeared intensity wave, dimensions are identical to experimental QSIG values 50 56 // make extra copy of experimental q-values for easy plotting 51 Duplicate/O $ gQvalssmeared_cscyl,smeared_qvals57 Duplicate/O $(str+"_q") smeared_cscyl,smeared_qvals 52 58 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 55 63 Display smeared_cscyl vs smeared_qvals 56 64 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 58 66 Label left "Intensity (cm\\S-1\\M)" 59 67 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 68 69 SetDataFolder root: 70 End 71 72 73 //AAO version 74 Function 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) 60 83 End 61 84 … … 63 86 // unsmeared model calculation 64 87 /////////////////////////// 65 Function CoreShellCylinderForm(w,x) : FitFunc88 Function fCoreShellCylinder(w,x) : FitFunc 66 89 Wave w 67 90 Variable x … … 200 223 201 224 // 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 225 Function 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) 232 End 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 // 240 Function 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) 258 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CoreShell_and_Struct.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 //// include everything that is necessary 3 5 // … … 20 22 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)"} 21 23 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) 23 27 Display/K=1 ywave_CSS_HS vs xwave_CSS_HS 24 28 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 29 33 End 30 34 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 36 Proc 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) 37 42 Abort 38 43 endif 44 45 SetDataFolder $("root:"+str) 39 46 40 47 // Setup parameter table for model function … … 45 52 // output smeared intensity wave, dimensions are identical to experimental QSIG values 46 53 // make extra copy of experimental q-values for easy plotting 47 Duplicate/O $ gQvalssmeared_CSS_HS,smeared_qvals54 Duplicate/O $(str+"_q") smeared_CSS_HS,smeared_qvals 48 55 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 51 60 Display smeared_CSS_HS vs smeared_qvals 52 61 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 55 64 56 65 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: 68 End 69 70 71 Function CoreShell_HS(w,yw,xw) : FitFunc 72 Wave w,yw,xw 62 73 63 74 Variable inten … … 79 90 80 91 //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] 85 98 86 99 //cleanup waves 87 100 // Killwaves/Z form_CSS_HS,struct_CSS_HS 88 101 89 return ( inten)102 return (0) 90 103 End 91 104 … … 102 115 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)"} 103 116 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) 105 120 Display/K=1 ywave_CSS_SW vs xwave_CSS_SW 106 121 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 111 126 End 112 127 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 129 Proc 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) 119 135 Abort 120 136 endif 137 138 SetDataFolder $("root:"+str) 121 139 122 140 // Setup parameter table for model function … … 127 145 // output smeared intensity wave, dimensions are identical to experimental QSIG values 128 146 // make extra copy of experimental q-values for easy plotting 129 Duplicate/O $ gQvalssmeared_CSS_SW,smeared_qvals147 Duplicate/O $(str+"_q") smeared_CSS_SW,smeared_qvals 130 148 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 133 153 Display smeared_CSS_SW vs smeared_qvals 134 154 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 137 157 138 158 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: 161 End 162 163 164 Function CoreShell_SW(w,yw,xw) : FitFunc 165 Wave w,yw,xw 144 166 145 167 Variable inten … … 163 185 164 186 //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] 169 193 170 194 //cleanup waves 171 195 // Killwaves/Z form_CSS_SW,struct_CSS_SW 172 196 173 return ( inten)197 return (0) 174 198 End 175 199 … … 194 218 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)"} 195 219 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) 197 223 Display/K=1 ywave_CSS_SC vs xwave_CSS_SC 198 224 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 203 229 End 204 230 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 232 Proc 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) 211 238 Abort 212 239 endif 240 241 SetDataFolder $("root:"+str) 213 242 214 243 if (DataFolderExists("root:HayPenMSA")) … … 226 255 // output smeared intensity wave, dimensions are identical to experimental QSIG values 227 256 // make extra copy of experimental q-values for easy plotting 228 Duplicate/O $ gQvalssmeared_CSS_SC,smeared_qvals257 Duplicate/O $(str+"_q") smeared_CSS_SC,smeared_qvals 229 258 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 232 263 Display smeared_CSS_SC vs smeared_qvals 233 264 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 236 267 237 268 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: 271 End 272 273 274 Function CoreShell_SC(w,yw,xw) : FitFunc 275 Wave w,yw,xw 243 276 244 277 Variable inten … … 264 297 265 298 //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] 270 305 271 306 //cleanup waves 272 307 // Killwaves/Z form_CSS_SC,struct_CSS_SC 273 308 274 return ( inten)309 return (0) 275 310 End 276 311 … … 287 322 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)"} 288 323 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) 290 327 Display/K=1 ywave_CSS_SHS vs xwave_CSS_SHS 291 328 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 296 333 End 297 334 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 336 Proc 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) 304 342 Abort 305 343 endif 344 345 SetDataFolder $("root:"+str) 306 346 307 347 // Setup parameter table for model function … … 312 352 // output smeared intensity wave, dimensions are identical to experimental QSIG values 313 353 // make extra copy of experimental q-values for easy plotting 314 Duplicate/O $ gQvalssmeared_CSS_SHS,smeared_qvals354 Duplicate/O $(str+"_q") smeared_CSS_SHS,smeared_qvals 315 355 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 318 360 Display smeared_CSS_SHS vs smeared_qvals 319 361 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 322 364 323 365 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: 368 End 369 370 371 Function CoreShell_SHS(w,yw,xw) : FitFunc 372 Wave w,yw,xw 329 373 330 374 Variable inten … … 348 392 349 393 //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] 354 400 355 401 //cleanup waves 356 402 // Killwaves/Z form_CSS_SHS,struct_CSS_SHS 357 403 358 return ( inten)404 return (0) 359 405 End 360 406 … … 362 408 363 409 // 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) 410 Function 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) 378 417 End 379 418 380 419 // 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) 420 Function 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) 395 427 End 396 428 397 429 // 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) 430 Function 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) 412 437 End 413 438 414 439 // 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 440 Function 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) 447 End 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 // 454 Function 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) 472 End 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 // 479 Function 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) 497 End 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 // 504 Function 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) 522 End 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 // 529 Function 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) 547 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/CylinderForm.ipf
r49 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// … … 21 22 make/o/t parameters_cyl = {"scale","radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"} 22 23 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) 24 27 Display ywave_cyl vs xwave_cyl 25 28 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 28 31 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 29 32 End 33 30 34 /////////////////////////////////////////////////////////// 31 32 Proc PlotSmearedCylinderForm( )33 //no input parameters necessary, it MUST use the experimental q-values34 // from the experimental data read in from an AVE/QSIG data file35 36 // if no gQvals wave, data must not have been loaded=> abort37 if(ResolutionWavesMissing ())35 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 36 Proc 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) 38 42 Abort 39 43 endif 44 45 SetDataFolder $("root:"+str) 40 46 41 47 // Setup parameter table for model function … … 46 52 // output smeared intensity wave, dimensions are identical to experimental QSIG values 47 53 // make extra copy of experimental q-values for easy plotting 48 Duplicate/O $ gQvalssmeared_cyl,smeared_qvals54 Duplicate/O $(str+"_q") smeared_cyl,smeared_qvals 49 55 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 52 60 Display smeared_cyl vs smeared_qvals 53 61 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 55 63 Label left "Intensity (cm\\S-1\\M)" 56 64 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 65 66 SetDataFolder root: 67 End 68 69 // AAO verison 70 Function 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) 57 79 End 58 80 … … 60 82 // unsmeared model calculation 61 83 /////////////////////////// 62 Function CylinderForm(w,x) : FitFunc84 Function fCylinderForm(w,x) : FitFunc 63 85 Wave w 64 86 Variable x 65 66 String funcStr = SelectString(exists("CylinderFormX")==3,"", "CylinderFormX")67 if(strlen(funcStr) > 0)68 FUNCREF SANSModel_proto func=$funcStr69 return func(w,x)70 endif71 87 72 88 //The input variables are (and output) … … 190 206 191 207 // 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 208 Function 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) 215 End 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 // 223 Function 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) 241 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Cylinder_and_Struct.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // be sure to include all the necessary files... … … 21 22 make/o/t parameters_CYL_HS = {"volume fraction","radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"} 22 23 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) 24 27 Display ywave_CYL_HS vs xwave_CYL_HS 25 28 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 30 33 End 31 34 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 36 Proc 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) 38 42 Abort 39 43 endif 40 44 45 SetDataFolder $("root:"+str) 46 41 47 // Setup parameter table for model function 42 48 Make/O/D smear_coef_CYL_HS = {0.01,20.,400,3.0e-6,0.01} … … 46 52 // output smeared intensity wave, dimensions are identical to experimental QSIG values 47 53 // make extra copy of experimental q-values for easy plotting 48 Duplicate/O $ gQvalssmeared_CYL_HS,smeared_qvals54 Duplicate/O $(str+"_q") smeared_CYL_HS,smeared_qvals 49 55 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 52 60 Display smeared_CYL_HS vs smeared_qvals 53 61 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 56 64 57 65 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: 68 End 69 70 71 Function Cylinder_HS(w,yw,xw) : FitFunc 72 Wave w,yw,xw 63 73 64 74 Variable inten,rad,len … … 80 90 81 91 //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] 86 98 87 99 //cleanup waves (don't do this - it takes a lot of time...) 88 100 // Killwaves/Z form_CYL_HS,struct_CYL_HS 89 101 90 return ( inten)102 return (0) 91 103 End 92 104 … … 102 114 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)"} 103 115 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) 105 119 Display ywave_CYL_SW vs xwave_CYL_SW 106 120 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 111 125 End 112 126 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 128 Proc 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) 119 134 Abort 120 135 endif 136 137 SetDataFolder $("root:"+str) 121 138 122 139 // Setup parameter table for model function … … 127 144 // output smeared intensity wave, dimensions are identical to experimental QSIG values 128 145 // make extra copy of experimental q-values for easy plotting 129 Duplicate/O $ gQvalssmeared_CYL_SW,smeared_qvals146 Duplicate/O $(str+"_q") smeared_CYL_SW,smeared_qvals 130 147 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 133 152 Display smeared_CYL_SW vs smeared_qvals 134 153 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 137 156 138 157 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: 160 End 161 162 163 Function Cylinder_SW(w,yw,xw) : FitFunc 164 Wave w,yw,xw 144 165 145 166 Variable inten,rad,len … … 163 184 164 185 //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] 169 192 170 193 //cleanup waves 171 194 // Killwaves/Z form_CYL_SW,struct_CYL_SW 172 195 173 return ( inten)196 return (0) 174 197 End 175 198 … … 192 215 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)"} 193 216 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) 195 220 Display ywave_CYL_SC vs xwave_CYL_SC 196 221 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 201 226 End 202 227 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 229 Proc 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) 209 235 Abort 210 236 endif 211 237 238 SetDataFolder $("root:"+str) 239 212 240 if (DataFolderExists("root:HayPenMSA")) 213 241 Make/O/D/N=17 root:HayPenMSA:gMSAWave … … 224 252 // output smeared intensity wave, dimensions are identical to experimental QSIG values 225 253 // make extra copy of experimental q-values for easy plotting 226 Duplicate/O $ gQvalssmeared_CYL_SC,smeared_qvals254 Duplicate/O $(str+"_q") smeared_CYL_SC,smeared_qvals 227 255 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 230 260 Display smeared_CYL_SC vs smeared_qvals 231 261 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 234 264 235 265 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: 268 End 269 270 271 Function Cylinder_SC(w,yw,xw) : FitFunc 272 Wave w,yw,xw 241 273 242 274 Variable inten,rad,len … … 262 294 263 295 //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] 268 302 269 303 //cleanup waves 270 304 // Killwaves/Z form_CYL_SC,struct_CYL_SC 271 305 272 return ( inten)306 return (0) 273 307 End 274 308 … … 285 319 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)"} 286 320 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) 288 324 Display ywave_CYL_SHS vs xwave_CYL_SHS 289 325 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 294 330 End 295 331 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 333 Proc 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) 302 339 Abort 303 340 endif 341 342 SetDataFolder $("root:"+str) 304 343 305 344 // Setup parameter table for model function … … 310 349 // output smeared intensity wave, dimensions are identical to experimental QSIG values 311 350 // make extra copy of experimental q-values for easy plotting 312 Duplicate/O $ gQvalssmeared_CYL_SHS,smeared_qvals351 Duplicate/O $(str+"_q") smeared_CYL_SHS,smeared_qvals 313 352 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 316 357 Display smeared_CYL_SHS vs smeared_qvals 317 358 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 320 361 321 362 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: 365 End 366 367 368 Function Cylinder_SHS(w,yw,xw) : FitFunc 369 Wave w,yw,xw 327 370 328 371 Variable inten,rad,len … … 346 389 347 390 //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] 352 397 353 398 //cleanup waves 354 399 // Killwaves/Z form_CYL_SHS,struct_CYL_SHS 355 400 356 return ( inten)401 return (0) 357 402 End 358 403 … … 360 405 361 406 // 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) 407 Function 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) 376 414 End 377 415 378 416 // 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) 417 Function 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) 393 424 End 394 425 395 426 // 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) 427 Function 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) 410 434 End 411 435 412 436 // 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 437 Function 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) 444 End 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 // 451 Function 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) 469 End 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 // 476 Function 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) 494 End 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 // 501 Function 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) 519 End 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 // 526 Function 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) 544 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/DAB_model.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 //////////////////////////////////////////////////// 3 5 // C. Glinka, 11-22-98 4 6 //////////////// 7 8 9 //Debye-Anderson-Brumberger 10 5 11 6 12 Proc PlotDAB(num,qmin,qmax) … … 15 21 make/o/t parameters_DAB = {"Scale Factor, A ", "Correlation Length ()", "Incoherent Bgd (cm-1)"} 16 22 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) 18 26 Display ywave_DAB vs xwave_DAB 19 27 ModifyGraph marker=29, msize=2, mode=4 … … 23 31 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 24 32 End 33 25 34 //////////////////////////////////////////////////// 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 36 Proc PlotSmearedDAB(str) 37 String str 38 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 29 39 30 // if no gQvals wave, data must not have been loaded=> abort31 if(ResolutionWavesMissing ())40 // if any of the resolution waves are missing => abort 41 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 32 42 Abort 33 43 endif 44 45 SetDataFolder $("root:"+str) 34 46 35 47 // Setup parameter table for model function … … 40 52 // output smeared intensity wave, dimensions are identical to experimental QSIG values 41 53 // make extra copy of experimental q-values for easy plotting 42 Duplicate/O $ gQvalssmeared_DAB,smeared_qvals //54 Duplicate/O $(str+"_q") smeared_DAB,smeared_qvals // 43 55 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 46 60 Display smeared_DAB vs smeared_qvals // 47 61 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 49 63 Label left "Debye-Anderson-Brumberger Model (cm\\S-1\\M)" 50 64 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 51 End // end macro PlotSmearedDAB 65 66 SetDataFolder root: 67 End 52 68 53 Function DAB_model(w,x) : FitFunc 69 //AAO version 70 Function 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) 79 End 80 81 Function fDAB_model(w,x) : FitFunc 54 82 Wave w 55 83 Variable x … … 75 103 76 104 // this is all there is to the smeared calculation! 77 Function SmearedDAB_Model(w,x) :FitFunc 78 Wave w 79 Variable x 105 Function 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) 112 End 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 // 119 Function fSmearedDAB_Model(coefW,yW,xW) 120 Wave coefW,yW,xW 80 121 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+":" 86 124 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) 91 137 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/EffectiveDiameter.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 2 #pragma version=3.00 3 #pragma IgorVersion= 4.03 #pragma IgorVersion=6.0 4 4 5 5 // GaussUtils.ipf … … 28 28 // did not give sufficient accuracy. 29 29 // 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 55 Structure ResSmearAAOStruct 56 Wave coefW 57 Wave yW 58 Wave xW 59 Wave resW 60 String info 61 EndStructure 62 63 Function/S getHoldStr() 64 65 String str="0010" 66 return str 67 End 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. 75 Function/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) 93 End 94 30 95 31 96 Function Make5GaussPoints(w5,z5) … … 126 191 // printf "w[0],z[0] = %g %g\r", w20[0],z20[0] 127 192 End 128 129 130 131 193 132 194 Function Make76GaussPoints(w76,z76) … … 535 597 536 598 if(err) 537 DoAlert 0,"Some 6-column QSIG waves are missing. Re-load experimental data with LoadOneDDatamacro"599 DoAlert 0,"Some 6-column QSIG waves are missing. Re-load experimental data with 'Load SANS or USANS Data' macro" 538 600 endif 539 601 … … 541 603 end 542 604 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 613 Function 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) 626 end 627 628 /////////////////////////////////////////////////////////////// 629 630 // "backwards" wrapped to reduce redundant code 631 // there are only 4 choices of N (5,10,20,76) for smearing 632 Function Smear_Model_N(fcn,w,x,resW,wi,zi,nord) 633 FUNCREF SANSModelAAO_proto fcn 573 634 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 577 640 578 641 // 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 612 660 613 661 i_shad = interp(x,qvals,shad) … … 615 663 i_sigq = interp(x,qvals,sigq) 616 664 617 618 619 620 if (i _sigq >= 0)665 // set up the integration 666 // number of Gauss Quadrature points 667 668 if (isSANSResolution(i_sigq)) 621 669 622 670 // end points of integration … … 626 674 //integration from va to vb 627 675 628 nord = 76629 676 va = -3*i_sigq + i_qbar 630 677 if (va<0) … … 635 682 636 683 // Using 20 Gauss points 637 // remember to index from 0,size-1638 639 summ = 0.0 // initialize integral640 684 ii=0 // loop counter 685 // do the calculation as a single pass w/AAO function 686 Make/O/N=(nord) Resoln,yyy,xGauss 641 687 do 642 688 // calculate Gauss points on integration interval (q-value for evaluation) 643 zi = ( z76[ii]*(vb-va) + vb + va )/2.0689 xGauss[ii] = ( zi[ii]*(vb-va) + vb + va )/2.0 644 690 // 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 651 694 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 653 699 // calculate value of integral to return 654 answer = (vb-va)/2.0*sum m700 answer = (vb-va)/2.0*sum(yyy) 655 701 // all scaling, background addition... etc. is done in the model calculation 656 702 … … 674 720 endif 675 721 722 //killing these waves is cleaner, but MUCH SLOWER 723 // Killwaves/Z Resoln,yyy,xGauss 724 // Killwaves/Z sigQ,qbar,shad,qvals 676 725 Return (answer) 677 726 678 727 End 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 // 732 Function Smear_Model_5(fcn,w,x,resW) 733 FUNCREF SANSModelAAO_proto fcn 687 734 Wave w //coefficients of function fcn(w,x) 688 735 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" 701 743 702 744 // 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)704 745 if (WaveExists($weightStr) == 0) // wave reference is not valid, 705 Make/D/N= 20$weightStr,$zStr706 Wave w 20= $weightStr707 Wave z20= $zStr // wave references to pass708 Make 20GaussPoints(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) 709 750 else 710 751 if(exists(weightStr) > 1) 711 752 Abort "wave name is already in use" //executed only if name is in use elsewhere 712 753 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) 790 759 Return (answer) 791 760 792 761 End 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 // 766 Function Smear_Model_10(fcn,w,x,resW) 767 FUNCREF SANSModelAAO_proto fcn 804 768 Wave w //coefficients of function fcn(w,x) 805 769 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 812 772 String weightStr,zStr 813 814 weightStr = "gauss5wt" 815 zStr = "gauss5z" 773 Variable answer,nord=10 774 775 weightStr = "gauss10wt" 776 zStr = "gauss10z" 816 777 817 778 // if wt,z waves don't exist, create them (only check for weight, should really check for both) 818 // 5 Gauss points819 779 if (WaveExists($weightStr) == 0) // wave reference is not valid, 820 Make/D/N= 5$weightStr,$zStr821 Wave w 5= $weightStr822 Wave z5= $zStr // wave references to pass823 Make 5GaussPoints(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) 824 784 else 825 785 if(exists(weightStr) > 1) 826 786 Abort "wave name is already in use" //executed only if name is in use elsewhere 827 787 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 795 End 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 // 805 Function 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) 882 823 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) 901 832 Return (answer) 902 833 903 834 End 904 835 /////////////////////////////////////////////////////////////// 836 Function 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) 864 End 865 866 867 /////////////////////////////////////////////////////////////// 868 869 //typically, the first point (or any point) of sigQ is passed 870 // if negative, it's USANS data... 871 Function isSANSResolution(val) 872 Variable val 873 if(val>=0) 874 return(1) //true, SANS data 875 else 876 return(0) //false, USANS 877 endif 878 End 905 879 906 880 Function GenericQuadrature_proto(w,x,dum) … … 911 885 return(1) 912 886 end 913 887 914 888 // prototype function for smearing routines, Smear_Model_N 915 889 // and trapzd_USANS() and qtrap_USANS() … … 923 897 end 924 898 899 // prototype function for smearing routines, Smear_Model_N 900 // and trapzd_USANS() and qtrap_USANS() 901 // it intentionally does nothing 902 Function SANSModelAAO_proto(w,yw,xw) 903 Wave w,yw,xw 904 905 Print "in SANSModel_proto function" 906 return(1) 907 end 908 925 909 //Numerical Recipes routine to calculate the nn(th) stage 926 910 //refinement of a trapezoid integration … … 938 922 // 939 923 Function trapzd_USANS(fcn,aa,bb,nn) 940 FUNCREF SANSModel _proto fcn924 FUNCREF SANSModelAAO_proto fcn 941 925 Variable aa,bb,nn 942 926 … … 948 932 Wave cw=$cwStr 949 933 Variable temp=0 934 Make/O/N=2 tmp_xw,tmp_yw 950 935 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]) 954 940 sval = temp 955 941 return(sVal) … … 962 948 summ=0 963 949 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] 966 953 xx += del 967 954 endfor … … 969 956 return (sval) 970 957 endif 971 972 End 973 958 //KillWaves/Z tmp_xw,tmp_yw 959 End 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 974 1009 975 1010 // Numerical Recipes routine to calculate the integral of a … … 981 1016 // maxit typically 20 982 1017 Function qtrap_USANS(fcn,aa,bb,eps,maxIt) 983 FUNCREF SANSModel _proto fcn1018 FUNCREF SANSModelAAO_proto fcn 984 1019 Variable aa,bb,eps,maxit 985 1020 … … 1004 1039 End 1005 1040 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 1006 1072 Proc RRW() 1007 1073 ResetResolutionWaves() … … 1012 1078 String Str 1013 1079 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 1015 1084 String/G root:gQvals = str[0,strlen(str)-3]+"_q" 1016 1085 String/G root:gSig_Q = str[0,strlen(str)-3]+"sq" 1017 1086 String/G root:gQ_bar = str[0,strlen(str)-3]+"qb" 1018 1087 String/G root:gShadow = str[0,strlen(str)-3]+"fs" 1019 1020 1021 1088 1022 1089 //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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 2 #pragma IgorVersion = 6.0 3 4 // converted to Igor code by Paul Butler 5 // 3 6 Proc PlotHayterPenfoldMSA(num,qmin,qmax) 4 7 Variable num=128, qmin=.001, qmax=.3 … … 23 26 make/o/t parameters_hpmsa = {"Diameter (A)","Charge","Volume Fraction","Temperature(K)","monovalent salt conc. (M)","dielectric constant of solvent"} 24 27 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) 26 31 xdiamwave_hpmsa:=xwave_hpmsa*coef_hpmsa[0] 27 32 //Display ywave_hpmsa vs xdiamwave_hpmsa … … 33 38 End 34 39 40 //AAO version 41 Function 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) 50 End 51 35 52 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 36 53 // … … 44 61 // A POWER OF 2 45 62 // 46 47 Function HayterPenfoldMSA(w,x) : FitFunc 63 Function fHayterPenfoldMSA(w,x) : FitFunc 48 64 wave w 49 65 variable x … … 769 785 qcosk = qk*cosk 770 786 aqk = gMSAWave[0]*(sink-qcosk) 771 772 773 774 775 776 777 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 778 794 SofQ = 1.0/(1.0-e24*aqk) 779 795 endif -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/HardSphereStruct.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// … … 22 23 make/o/t parameters_hss = {"Radius (A)","vol fraction"} 23 24 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) 25 28 Display ywave_hss vs xwave_hss 26 29 ModifyGraph marker=29,msize=2,mode=4 … … 28 31 Label left "Structure Factor" 29 32 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 33 End 34 35 //AAO version 36 Function 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) 30 45 End 31 46 … … 36 51 // unsmeared model calculation 37 52 /////////////////////////// 38 Function HardSphereStruct(w,x) : FitFunc53 Function fHardSphereStruct(w,x) : FitFunc 39 54 Wave w 40 55 Variable x -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/HollowCylinders.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// … … 21 22 make/o/t parameters_Hcyl = {"scale","core radius (A)","shell radius (A)","length (A)","contrast (A^-2)","incoh. bkg (cm^-1)"} 22 23 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) 24 27 Display ywave_Hcyl vs xwave_Hcyl 25 28 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 28 31 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 29 32 End 33 30 34 /////////////////////////////////////////////////////////// 31 32 Proc PlotSmearedHollowCylinderForm( )33 //no input parameters necessary, it MUST use the experimental q-values34 // from the experimental data read in from an AVE/QSIG data file35 36 // if no gQvals wave, data must not have been loaded=> abort37 if(ResolutionWavesMissing ())35 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 36 Proc 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) 38 42 Abort 39 43 endif 44 45 SetDataFolder $("root:"+str) 40 46 41 47 // Setup parameter table for model function … … 46 52 // output smeared intensity wave, dimensions are identical to experimental QSIG values 47 53 // make extra copy of experimental q-values for easy plotting 48 Duplicate/O $ gQvalssmeared_Hcyl,smeared_qvals54 Duplicate/O $(str+"_q") smeared_Hcyl,smeared_qvals 49 55 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 52 60 Display smeared_Hcyl vs smeared_qvals 53 61 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 55 63 Label left "Intensity (cm\\S-1\\M)" 56 64 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 57 End 58 65 66 SetDataFolder root: 67 End 68 69 70 //AAO version 71 Function 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) 80 End 59 81 /////////////////////////////////////////////////////////////// 60 82 // unsmeared model calculation 61 83 /////////////////////////// 62 Function HollowCylinderForm(w,x) : FitFunc84 Function fHollowCylinder(w,x) : FitFunc 63 85 Wave w 64 86 Variable x … … 186 208 187 209 // 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 210 Function 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) 217 End 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 // 224 Function 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) 242 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Lorentz_model.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 //////////////////////////////////////////////////// 3 5 // J. Barker, 2-10-99 … … 14 16 make/o/t parameters_Lorentz = {"Scale Factor, I0 ", "Screening Length ()","Incoherent Bgd (cm-1)"} 15 17 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) 17 21 Display ywave_Lorentz vs xwave_Lorentz 18 22 ModifyGraph marker=29, msize=2, mode=4 … … 24 28 25 29 //////////////////////////////////////////////////// 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 31 Proc PlotSmeared_Lorentz(str) 32 String str 33 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 29 34 30 // if no gQvals wave, data must not have been loaded=> abort31 if(ResolutionWavesMissing ())35 // if any of the resolution waves are missing => abort 36 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 32 37 Abort 33 38 endif 39 40 SetDataFolder $("root:"+str) 34 41 35 42 // Setup parameter table for model function … … 40 47 // output smeared intensity wave, dimensions are identical to experimental QSIG values 41 48 // 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 46 55 Display smeared_Lorentz vs smeared_qvals // 47 56 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 49 58 Label left "Lorentz Model (cm\\S-1\\M)" 50 59 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 51 End // end macro PlotSmearedPeak_Lorentz 60 61 SetDataFolder root: 62 End 52 63 53 Function Lorentz_model(w,x) : FitFunc 64 65 //AAO version 66 Function 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) 75 End 76 77 Function fLorentz_model(w,x) : FitFunc 54 78 Wave w 55 79 Variable x … … 77 101 78 102 // 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) 103 Function Smeared_Lorentz_Model(s) :FitFunc 104 Struct ResSmearAAOStruct &s 91 105 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) 93 110 End 94 111 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 // 118 Function 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) 136 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Beaucage.ipf
r62 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 ///////////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/BimodalSchulzSpheres.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/BinaryHardSpheres.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Cylinder_PolyLength.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 #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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 #include "CylinderForm" -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Debye.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 /////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexCyl_EllipCross.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 #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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 #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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 #include "FlexibleCylinder" -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/FlexibleCylinder.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/Fractal.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 #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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 // 3 5 // 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarFF_HG.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarPS.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LamellarPS_HG.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/LogNormSpheres_and_Struct.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 // 3 5 // 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 #include "sphere" -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/MultiShell.ipf
r56 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/PolyCoreShellCylinder.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/SchulzSpheres.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //#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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 // 3 5 // 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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 //////////////////////////////////////////////////// 3 5 // … … 31 33 make/o/t parameters_shsSQ = {"Radius","volume fraction","perturbation parameter (0.1)","stickiness, tau"} //CH#3 32 34 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) 34 38 Display ywave_shsSQ vs xwave_shsSQ 35 39 ModifyGraph marker=29, msize=2, mode=4 … … 41 45 End 42 46 43 Function StickyHS_Struct(w,x) : FitFunc 47 //AAO function 48 Function 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) 57 End 58 59 Function fStickyHS_Struct(w,x) : FitFunc 44 60 Wave w 45 61 Variable x -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/NewModels_2006/TriaxialEllipsoid.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //#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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// -
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 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/OblateCS_and_Struct.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // be sure to include all of the necessary files … … 22 23 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)"} 23 24 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) 25 28 Display ywave_OEF_HS vs xwave_OEF_HS 26 29 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 31 34 End 32 35 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 37 Proc 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) 39 43 Abort 40 44 endif 45 46 SetDataFolder $("root:"+str) 41 47 42 48 // Setup parameter table for model function … … 47 53 // output smeared intensity wave, dimensions are identical to experimental QSIG values 48 54 // make extra copy of experimental q-values for easy plotting 49 Duplicate/O $ gQvalssmeared_OEF_HS,smeared_qvals55 Duplicate/O $(str+"_q") smeared_OEF_HS,smeared_qvals 50 56 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 53 61 Display smeared_OEF_HS vs smeared_qvals 54 62 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 57 65 58 66 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: 69 End 70 71 72 Function Oblate_HS(w,yw,xw) : FitFunc 73 Wave w,yw,xw 64 74 65 75 Variable inten,Ras,Rbs … … 84 94 85 95 //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] 90 102 91 103 //cleanup waves 92 104 // Killwaves/Z form_OEF_HS,struct_OEF_HS 93 105 94 return ( inten)106 return (0) 95 107 End 96 108 … … 106 118 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)"} 107 119 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) 109 123 Display ywave_OEF_SW vs xwave_OEF_SW 110 124 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 115 129 End 116 130 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 132 Proc 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) 123 138 Abort 124 139 endif 140 141 SetDataFolder $("root:"+str) 125 142 126 143 // Setup parameter table for model function … … 131 148 // output smeared intensity wave, dimensions are identical to experimental QSIG values 132 149 // make extra copy of experimental q-values for easy plotting 133 Duplicate/O $ gQvalssmeared_OEF_SW,smeared_qvals150 Duplicate/O $(str+"_q") smeared_OEF_SW,smeared_qvals 134 151 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 137 156 Display smeared_OEF_SW vs smeared_qvals 138 157 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 141 160 142 161 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: 164 End 165 166 167 Function Oblate_SW(w,yw,xw) : FitFunc 168 Wave w,yw,xw 148 169 149 170 Variable inten,Ras,Rbs … … 170 191 171 192 //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] 176 199 177 200 //cleanup waves 178 201 // Killwaves/Z form_OEF_SW,struct_OEF_SW 179 202 180 return ( inten)203 return (0) 181 204 End 182 205 … … 199 222 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)"} 200 223 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) 202 227 Display ywave_OEF_SC vs xwave_OEF_SC 203 228 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 208 233 End 209 234 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 236 Proc 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) 216 242 Abort 217 243 endif 218 244 245 SetDataFolder $("root:"+str) 246 219 247 if (DataFolderExists("root:HayPenMSA")) 220 248 Make/O/D/N=17 root:HayPenMSA:gMSAWave … … 231 259 // output smeared intensity wave, dimensions are identical to experimental QSIG values 232 260 // make extra copy of experimental q-values for easy plotting 233 Duplicate/O $ gQvalssmeared_OEF_SC,smeared_qvals261 Duplicate/O $(str+"_q") smeared_OEF_SC,smeared_qvals 234 262 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 237 267 Display smeared_OEF_SC vs smeared_qvals 238 268 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 241 271 242 272 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: 275 End 276 277 278 Function Oblate_SC(w,yw,xw) : FitFunc 279 Wave w,yw,xw 248 280 249 281 Variable inten,Ras,Rbs … … 272 304 273 305 //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] 278 312 279 313 //cleanup waves 280 314 // Killwaves/Z form_OEF_SC,struct_OEF_SC 281 315 282 return ( inten)316 return (0) 283 317 End 284 318 … … 295 329 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)"} 296 330 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) 298 334 Display ywave_OEF_SHS vs xwave_OEF_SHS 299 335 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 304 340 End 305 341 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 343 Proc 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) 312 349 Abort 313 350 endif 351 352 SetDataFolder $("root:"+str) 314 353 315 354 // Setup parameter table for model function … … 320 359 // output smeared intensity wave, dimensions are identical to experimental QSIG values 321 360 // make extra copy of experimental q-values for easy plotting 322 Duplicate/O $ gQvalssmeared_OEF_SHS,smeared_qvals361 Duplicate/O $(str+"_q") smeared_OEF_SHS,smeared_qvals 323 362 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 326 367 Display smeared_OEF_SHS vs smeared_qvals 327 368 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 330 371 331 372 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: 375 End 376 377 378 Function Oblate_SHS(w,yw,xw) : FitFunc 379 Wave w,yw,xw 337 380 338 381 Variable inten,Ras,Rbs … … 359 402 360 403 //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] 365 410 366 411 //cleanup waves 367 412 // Killwaves/Z form_OEF_SHS,struct_OEF_SHS 368 413 369 return ( inten)414 return (0) 370 415 End 371 416 372 417 373 418 // 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) 419 Function 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) 388 426 End 389 427 390 428 // 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) 429 Function 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) 405 436 End 406 437 407 438 // 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) 439 Function 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) 422 446 End 423 447 424 448 // 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 449 Function 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) 456 End 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 // 463 Function 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) 481 End 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 // 488 Function 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) 506 End 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 // 513 Function 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) 531 End 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 // 538 Function 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) 556 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/OblateForm.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 //////////////////////////////////////////////// … … 22 23 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)"} 23 24 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) 25 28 Display ywave_oef vs xwave_oef 26 29 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 29 32 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 30 33 End 34 31 35 /////////////////////////////////////////////////////////// 32 33 Proc PlotSmearedOblateForm( ) //**** name of your function34 //no input parameters necessary, it MUST use the experimental q-values35 // from the experimental data read in from an AVE/QSIG data file36 37 // if no gQvals wave, data must not have been loaded=> abort38 if(ResolutionWavesMissing ())36 // - sets up a dependency to a wrapper, not the actual SmearedModelFunction 37 Proc 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) 39 43 Abort 40 44 endif 45 46 SetDataFolder $("root:"+str) 41 47 42 48 // Setup parameter table for model function … … 47 53 // output smeared intensity wave, dimensions are identical to experimental QSIG values 48 54 // 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 53 61 Display smeared_oef vs smeared_qvals 54 62 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 56 64 Label left "Intensity (cm\\S-1\\M)" 57 65 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 66 67 SetDataFolder root: 68 End 69 70 71 //AAO version 72 Function 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) 58 81 End 59 82 … … 61 84 // unsmeared model calculation 62 85 /////////////////////////// 63 Function OblateForm(w,x) : FitFunc86 Function fOblateForm(w,x) : FitFunc 64 87 Wave w 65 88 Variable x … … 199 222 200 223 // 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 224 Function 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) 231 End 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 // 238 Function 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) 256 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Peak_Gauss_model.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 //////////////////////////////////////////////////// 3 5 // J. Barker, 2-10-99 … … 14 16 make/o/t parameters_Peak_Gauss = {"Scale Factor, I0 ", "Peak position (^-1)", "Std Dev (^-1)","Incoherent Bgd (cm-1)"} 15 17 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) 17 21 Display ywave_Peak_Gauss vs xwave_Peak_Gauss 18 22 ModifyGraph marker=29, msize=2, mode=4 … … 23 27 // 24 28 End 29 25 30 //////////////////////////////////////////////////// 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 32 Proc PlotSmearedPeak_Gauss(str) 33 String str 34 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 29 35 30 // if no gQvals wave, data must not have been loaded=> abort31 if(ResolutionWavesMissing ())36 // if any of the resolution waves are missing => abort 37 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 32 38 Abort 33 39 endif 40 41 SetDataFolder $("root:"+str) 34 42 35 43 // Setup parameter table for model function … … 40 48 // output smeared intensity wave, dimensions are identical to experimental QSIG values 41 49 // 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 46 56 Display smeared_Peak_Gauss vs smeared_qvals // 47 57 ModifyGraph log=1,marker=29,msize=2,mode=4 … … 49 59 Label left "Peak_Gauss Model (cm\\S-1\\M)" 50 60 AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 51 End // end macro PlotSmearedPeak_Gauss 61 62 SetDataFolder root: 63 End 52 64 53 Function Peak_Gauss_model(w,x) : FitFunc 65 66 67 //AAO version 68 Function 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) 77 End 78 79 Function fPeak_Gauss_model(w,x) : FitFunc 54 80 Wave w 55 81 Variable x … … 78 104 79 105 // this is all there is to the smeared calculation! 80 Function SmearedPeak_Gauss_Model(w,x) :FitFunc 81 Wave w 82 Variable x 106 Function 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) 113 End 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 // 120 Function fSmearedPeak_Gauss_Model(coefW,yW,xW) 121 Wave coefW,yW,xW 83 122 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+":" 89 125 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) 94 138 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/Peak_Lorentz_model.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 3 2 4 //////////////////////////////////////////////////// 3 5 // J. Barker, 2-10-99 … … 14 16 make/o/t parameters_Peak_Lorentz = {"Scale Factor, I0 ", "Peak position (^-1)", "Peak hwhm (^-1)","Incoherent Bgd (cm-1)"} 15 17 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) 17 21 Display ywave_Peak_Lorentz vs xwave_Peak_Lorentz 18 22 ModifyGraph marker=29, msize=2, mode=4 … … 23 27 // 24 28 End 29 25 30 //////////////////////////////////////////////////// 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 32 Proc PlotSmearedPeak_Lorentz(str) 33 String str 34 Prompt str,"Pick the data folder conatining the resolution you want",popup,getAList(4) 29 35 30 // if no gQvals wave, data must not have been loaded=> abort31 if(ResolutionWavesMissing ())36 // if any of the resolution waves are missing => abort 37 if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) 32 38 Abort 33 39 endif 40 41 SetDataFolder $("root:"+str) 34 42 35 43 // Setup parameter table for model function … … 40 48 // output smeared intensity wave, dimensions are identical to experimental QSIG values 41 49 // 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 44 55 45 smeared_Peak_Lorentz := SmearedPeak_Lorentz_Model(smear_coef_Peak_Lorentz,$gQvals) // SMEARED function name46 56 Display smeared_Peak_Lorentz vs smeared_qvals // 47 57 ModifyGraph log=1,marker=29,msize=2,mode=4 48 58 Label bottom "q (\\S-1\\M)" 49 59 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: 63 End 51 64 52 End // end macro PlotSmearedPeak_Lorentz53 65 54 Function Peak_Lorentz_model(w,x) : FitFunc 66 //AAO version 67 Function 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) 76 End 77 78 Function fPeak_Lorentz_model(w,x) : FitFunc 55 79 Wave w 56 80 Variable x … … 79 103 80 104 // this is all there is to the smeared calculation! 81 Function SmearedPeak_Lorentz_Model(w,x) :FitFunc 82 Wave w 83 Variable x 105 Function 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) 112 End 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 // 119 Function fSmearedPeak_Lorentz_Model(coefW,yW,xW) 120 Wave coefW,yW,xW 84 121 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+":" 90 124 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) 95 137 End -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/PlotUtilsMacro.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 2 #pragma version=3.00 3 #pragma IgorVersion= 4.03 #pragma IgorVersion=6.0 4 4 5 5 // This is to be used with the Analysis packages ONLY … … 22 22 23 23 // 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 25 25 // - multiple datasets can be automatically plotted on the same graph 26 26 // 27 27 //substantially easier to write this as a Proc rather than a function... 28 28 29 // 29 30 Proc A_LoadOneDData() 30 31 A_LoadOneDDataWithName("",1) //will prompt for file and plot data 32 End 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 // 48 Proc 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 31 55 //Load the waves, using default waveX names 32 56 //if no path or file is specified for LoadWave, the default Mac open dialog will appear 33 LoadWave/G/D/A 34 String file name = S_fileName35 36 if(V_flag==3)37 String w0,w1,w2,n0,n1,n2,wt38 Variable rr,gg,bb57 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 39 63 40 64 // put the names of the three loaded waves into local names … … 47 71 w1 = CleanupName((S_fileName + "_i"),0) 48 72 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) 60 88 endif 61 89 62 90 ////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 82 98 SetScale d,0,0,"1/cm",$w1 83 99 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 121 104 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 126 107 n0 = StringFromList(0, S_waveNames ,";" ) 127 108 n1 = StringFromList(1, S_waveNames ,";" ) … … 138 119 w4 = CleanupName((S_fileName + "qb"),0) 139 120 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) 151 136 endif 152 137 153 138 ////overwrite the existing data, if it exists 154 Duplicate/O $ n0, $w0155 Duplicate/O $ n1, $w1156 Duplicate/O $ n2, $w2157 Duplicate/O $ n3, $w3158 Duplicate/O $ n4, $w4159 Duplicate/O $ n5, $w5160 KillWaves $n0,$n1,$n2,$n3,$n4,$n5 161 162 Duplicate/o $w2 $wt163 $wt = 1/$w2 //assign the weighting wave164 165 // copy waves to global strings for use in the smearing calculation166 if(DataFolderExists("root:myGlobals"))167 String/G root:myGlobals:gLastFileName = filename168 endif169 String/G gQVals = w0170 String/G gSig_Q = w3171 String/G gQ_bar = w4172 String/G gShadow = w5173 174 // set data units for the waves175 // 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,$w0139 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 181 166 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 219 171 String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4 220 172 Variable rr,gg,bb … … 235 187 w4 = CleanupName((S_fileName+"_fit_ism"),0) 236 188 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) 259 221 // assign colors randomly 260 222 rr = abs(trunc(enoise(65535))) … … 262 224 bb = abs(trunc(enoise(65535))) 263 225 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 265 228 if(WinType("") == 1) 266 229 DoAlert 1,"Do you want to append this data to the current graph?" 267 230 if(V_Flag == 1) 268 231 AppendToGraph $w1 vs $w0 269 ModifyGraph mode =3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2232 ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb) 270 233 ErrorBars $w1 Y,wave=($w2,$w2) 271 234 else 272 235 //new graph 273 236 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 275 239 ErrorBars $w1 Y,wave=($w2,$w2) 276 240 Legend … … 279 243 // graph window was not target, make new one 280 244 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 282 247 ErrorBars $w1 Y,wave=($w2,$w2) 283 248 Legend 284 249 endif 285 286 250 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 255 End 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 // 264 Proc A_LoadNSEData() 265 A_LoadNSEDataWithName("",1) 266 End 267 268 Proc A_LoadNSEDataWithName(fileStr,doPlot) 269 295 270 //Load the waves, using default waveX names 296 271 //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 457 274 458 275 String w0,w1,w2,n0,n1,n2,wt,w3,n3 … … 471 288 w2 = CleanupName(("iqt_"+S_fileName),0) 472 289 w3 = CleanupName(("iqterr_"+S_fileName),0) 473 wt = CleanupName(("iqtwt_"+S_fileName),0) //create a name for the weighting wave474 290 475 291 if(exists(w0) !=0) … … 484 300 Rename $n2, $w2 485 301 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 504 325 Display $w2 vs $w1 505 ModifyGraph standoff=0,mode =3,marker=29,msize=2,rgb=(rr,gg,bb),grid=1,mirror=2,tickUnit=1326 ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 506 327 ErrorBars $w2 Y,wave=($w3,$w3) 507 328 Legend 508 329 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 332 End 563 333 564 334 //procedure for loading desmeared USANS data in the format (5-columns) 565 335 // qvals - I(q) - sig I - Ism(q) - fitted Ism(q) 566 336 //no weighting wave is created (not needed in IGOR 4) 337 // 338 // not really ever used... 339 // 567 340 Proc A_LoadUSANSData() 568 341 -
sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/PolyCSRatio_and_Struct.ipf
r42 r127 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 #pragma IgorVersion = 6.0 2 3 3 4 // be sure to include all the necessary files... … … 21 22 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)"} 22 23 &