Changeset 461
- Timestamp:
- Dec 4, 2008 5:16:42 PM (14 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Models/NewModels_2008/Core_and_NShells_v40.ipf
r451 r461 4 4 //////////////////////////////////////////////// 5 5 // 6 // this function is for the form factor of a with some6 // this function is for the form factor of a sphere with some 7 7 // number of shells around a central core (currently 1-2-3) 8 8 // … … 19 19 // 03 MAR 04 SRK 20 20 //////////////////////////////////////////////// 21 // Four shell model added and polyCore versions written in separate ipf (polyCore_and_NShells.ipf) 22 // 23 // Four shell model added at request of H Wacklin to model lipid vesicles with varying deuteration 24 // 25 // DEC 2008 AJJ 26 ////////////////////////////////////////////// 21 27 22 28 //this macro sets up all the necessary parameters and waves that are -
sans/Dev/trunk/NCNR_User_Procedures/Common/NIST_XML_v40.ipf
r420 r461 6 6 7 7 8 // The function is called "LoadNISTXMLData" but is actually more generic 9 // and will load any canSAS XML v1 dataset 10 // Dec 2008 : 11 // Caveats - Assumes Q in /A and I in /cm 8 12 function LoadNISTXMLData(filestr,doPlot) 9 13 String filestr … … 23 27 SetDataFolder xmlReaderFolder 24 28 25 Variable i 29 Variable i,j,numDataSets 30 Variable np 31 32 String w0,w1,w2,basestr,fileName 33 String xmlDataFolder,xmlDataSetFolder 34 35 26 36 27 37 for (i = 0; i < CountObjects(xmlReaderFolder,4); i+=1) 38 39 xmlDataFolder = xmlReaderFolder+GetIndexedObjName(xmlReaderFolder,4,i)+":" 40 numDataSets = CountObjects(xmlDataFolder,4) 41 if (numDataSets > 0) 42 //Multiple SASData sets in this SASEntry 43 for (j = 0; j < numDataSets; j+=1) 44 45 xmlDataSetFolder = xmlDataFolder+GetIndexedObjName(xmlDataFolder,4,j)+":" 46 47 SetDataFolder xmlDataSetFolder 48 49 basestr = CleanupName(getXMLDataSetTitle(xmlDataSetFolder,j),0) 50 //String basestr = ParseFilePath(3, ParseFilePath(5,filestr,":",0,0),":",0,0) 51 fileName = ParseFilePath(0,ParseFilePath(5,filestr,":",0,0),":",1,0) 52 53 //print "In NIST XML Loader" 54 //print "fileStr: ",fileStr 55 //print "basestr: ",basestr 56 //print "fileName: ",fileName 57 //remove the semicolon AND period from files from the VAX 58 w0 = basestr + "_q" 59 w1 = basestr + "_i" 60 w2 = basestr + "_s" 61 62 if(DataFolderExists("root:"+baseStr)) 63 DoAlert 1,"The data set " + basestr + " from file "+fileName+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 64 if(V_flag==2) //user selected No, don't load the data 65 SetDataFolder root: 66 if(DataFolderExists("root:Packages:NIST")) 67 String/G root:Packages:NIST:gLastFileName = filename 68 endif //set the last file loaded to the one NOT loaded 69 return 0 //quits the macro 70 endif 71 SetDataFolder $("root:"+baseStr) 72 else 73 NewDataFolder/S $("root:"+baseStr) 74 endif 75 76 Duplicate/O $(xmlDataSetFolder+"Qsas") $w0 77 Duplicate/O $(xmlDataSetFolder+"Isas") $w1 78 Duplicate/O $(xmlDataSetFolder+"Idev") $w2 79 80 81 82 if (exists(xmlDataSetFolder+"Qdev")) 83 Wave Qsas = $(xmlDataSetFolder+"Qsas") 84 Wave Qdev = $(xmlDataSetFolder+"Qdev") 85 86 // make a resolution matrix for SANS data 87 np=numpnts($w0) 88 Make/D/O/N=(np,4) $(baseStr+"_res") 89 Wave reswave = $(baseStr+"_res") 90 91 reswave[][0] = Qdev[p] //sigQ 92 reswave[][3] = Qsas[p] //Qvalues 93 if(exists(xmlDataSetFolder+"Qmean")) 94 Wave Qmean = $(xmlDataSetFolder+"Qmean") 95 reswave[][1] = Qmean[p] //qBar 96 endif 97 if(exists(xmlDataSetFolder+"Shadowfactor")) 98 Wave Shadowfactor = $(xmlDataSetFolder+"Shadowfactor") 99 reswave[][2] = Shadowfactor[p] //fShad 100 endif 101 elseif(exists(xmlDataSetFolder+"dQl")) 102 //USAS Data 103 Wave dQl = $(xmlDataSetFolder+"dQl") 104 dQv = dQl[0] 105 106 USANS_CalcWeights(baseStr,dQv) 107 else 108 //No resolution data 109 endif 110 //get rid of the resolution waves that are in the matrix 111 112 SetScale d,0,0,"1/A",$w0 113 SetScale d,0,0,"1/cm",$w1 114 115 28 116 29 String xmlDataFolder = xmlReaderFolder+GetIndexedObjName(xmlReaderFolder,4,i)+":" 30 31 SetDataFolder xmlDataFolder 32 33 String w0,w1,w2 34 35 String basestr = CleanupName(getXMLDataSetTitle(xmlDataFolder),0) 36 //String basestr = ParseFilePath(3, ParseFilePath(5,filestr,":",0,0),":",0,0) 37 String fileName = ParseFilePath(0,ParseFilePath(5,filestr,":",0,0),":",1,0) 38 39 //print "In NIST XML Loader" 40 //print "fileStr: ",fileStr 41 //print "basestr: ",basestr 42 //print "fileName: ",fileName 43 //remove the semicolon AND period from files from the VAX 44 w0 = basestr + "_q" 45 w1 = basestr + "_i" 46 w2 = basestr + "_s" 117 ////// 118 if(DataFolderExists("root:Packages:NIST")) 119 String/G root:Packages:NIST:gLastFileName = filename 120 endif 121 122 123 //plot if desired 124 if(doPlot) 125 // assign colors randomly 126 rr = abs(trunc(enoise(65535))) 127 gg = abs(trunc(enoise(65535))) 128 bb = abs(trunc(enoise(65535))) 129 130 // if target window is a graph, and user wants to append, do so 131 DoWindow/B Plot_Manager 132 if(WinType("") == 1) 133 DoAlert 1,"Do you want to append this data to the current graph?" 134 if(V_Flag == 1) 135 AppendToGraph $w1 vs $w0 136 ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb),tickUnit=1 137 ErrorBars $w1 Y,wave=($w2,$w2) 138 ModifyGraph tickUnit(left)=1 139 else 140 //new graph 141 Display $w1 vs $w0 142 ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 143 ModifyGraph grid=1,mirror=2,standoff=0 144 ErrorBars $w1 Y,wave=($w2,$w2) 145 ModifyGraph tickUnit(left)=1 146 Legend 147 endif 148 else 149 // graph window was not target, make new one 150 Display $w1 vs $w0 151 ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 152 ModifyGraph grid=1,mirror=2,standoff=0 153 ErrorBars $w1 Y,wave=($w2,$w2) 154 ModifyGraph tickUnit(left)=1 155 Legend 156 endif 157 endif 158 159 endfor 160 161 162 else 163 //No multiple SASData sets for this SASEntry 164 SetDataFolder xmlDataFolder 165 166 basestr = CleanupName(getXMLDataSetTitle(xmlDataFolder,0),0) 167 //String basestr = ParseFilePath(3, ParseFilePath(5,filestr,":",0,0),":",0,0) 168 fileName = ParseFilePath(0,ParseFilePath(5,filestr,":",0,0),":",1,0) 169 170 //print "In NIST XML Loader" 171 //print "fileStr: ",fileStr 172 //print "basestr: ",basestr 173 //print "fileName: ",fileName 174 w0 = basestr + "_q" 175 w1 = basestr + "_i" 176 w2 = basestr + "_s" 177 178 if(DataFolderExists("root:"+baseStr)) 179 DoAlert 1,"The data set " + basestr + " from file "+fileName+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 180 if(V_flag==2) //user selected No, don't load the data 181 SetDataFolder root: 182 if(DataFolderExists("root:Packages:NIST")) 183 String/G root:Packages:NIST:gLastFileName = filename 184 endif //set the last file loaded to the one NOT loaded 185 return 0 //quits the macro 186 endif 187 SetDataFolder $("root:"+baseStr) 188 else 189 NewDataFolder/S $("root:"+baseStr) 190 endif 191 192 Duplicate/O $(xmlDataFolder+"Qsas") $w0 193 Duplicate/O $(xmlDataFolder+"Isas") $w1 194 Duplicate/O $(xmlDataFolder+"Idev") $w2 195 196 197 198 if (exists(xmlDataFolder+"Qdev")) 199 Wave Qsas = $(xmlDataFolder+"Qsas") 200 Wave Qdev = $(xmlDataFolder+"Qdev") 201 202 // make a resolution matrix for SANS data 203 np=numpnts($w0) 204 Make/D/O/N=(np,4) $(baseStr+"_res") 205 Wave reswave = $(baseStr+"_res") 206 207 reswave[][0] = Qdev[p] //sigQ 208 reswave[][3] = Qsas[p] //Qvalues 209 if(exists(xmlDataFolder+"Qmean")) 210 Wave Qmean = $(xmlDataFolder+"Qmean") 211 reswave[][1] = Qmean[p] //qBar 212 endif 213 if(exists(xmlDataFolder+"Shadowfactor")) 214 Wave Shadowfactor = $(xmlDataFolder+"Shadowfactor") 215 reswave[][2] = Shadowfactor[p] //fShad 216 endif 217 elseif(exists(xmlDataFolder+"dQl")) 218 //USAS Data 219 Wave dQl = $(xmlDataFolder+"dQl") 220 dQv = dQl[0] 221 222 USANS_CalcWeights(baseStr,dQv) 223 else 224 //No resolution data 225 endif 226 //get rid of the resolution waves that are in the matrix 47 227 48 if(DataFolderExists("root:"+baseStr)) 49 DoAlert 1,"The data set " + basestr + " from file "+fileName+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" 50 if(V_flag==2) //user selected No, don't load the data 51 SetDataFolder root: 52 if(DataFolderExists("root:Packages:NIST")) 53 String/G root:Packages:NIST:gLastFileName = filename 54 endif //set the last file loaded to the one NOT loaded 55 return 0 //quits the macro 56 endif 57 SetDataFolder $("root:"+baseStr) 58 else 59 NewDataFolder/S $("root:"+baseStr) 60 endif 61 62 Duplicate/O $(xmlDataFolder+"Qsas") $w0 63 Duplicate/O $(xmlDataFolder+"Isas") $w1 64 Duplicate/O $(xmlDataFolder+"Idev") $w2 65 66 67 68 if (exists(xmlDataFolder+"Qdev")) 69 Wave Qsas = $(xmlDataFolder+"Qsas") 70 Wave Qdev = $(xmlDataFolder+"Qdev") 228 SetScale d,0,0,"1/A",$w0 229 SetScale d,0,0,"1/cm",$w1 230 231 232 233 ////// 234 if(DataFolderExists("root:Packages:NIST")) 235 String/G root:Packages:NIST:gLastFileName = filename 236 endif 71 237 72 // make a resolution matrix for SANS data 73 Variable np=numpnts($w0) 74 Make/D/O/N=(np,4) $(baseStr+"_res") 75 Wave reswave = $(baseStr+"_res") 76 77 reswave[][0] = Qdev[p] //sigQ 78 reswave[][3] = Qsas[p] //Qvalues 79 if(exists(xmlDataFolder+"Qmean")) 80 Wave Qmean = $(xmlDataFolder+"Qmean") 81 reswave[][1] = Qmean[p] //qBar 82 endif 83 if(exists(xmlDataFolder+"Shadowfactor")) 84 Wave Shadowfactor = $(xmlDataFolder+"Shadowfactor") 85 reswave[][2] = Shadowfactor[p] //fShad 86 endif 87 elseif(exists(xmlDataFolder+"dQl")) 88 //USAS Data 89 Wave dQl = $(xmlDataFolder+"dQl") 90 dQv = dQl[0] 91 92 USANS_CalcWeights(baseStr,dQv) 93 else 94 //No resolution data 95 endif 96 //get rid of the resolution waves that are in the matrix 97 98 SetScale d,0,0,"1/A",$w0 99 SetScale d,0,0,"1/cm",$w1 100 101 102 103 ////// 104 if(DataFolderExists("root:Packages:NIST")) 105 String/G root:Packages:NIST:gLastFileName = filename 106 endif 107 108 109 //plot if desired 110 if(doPlot) 111 // assign colors randomly 112 rr = abs(trunc(enoise(65535))) 113 gg = abs(trunc(enoise(65535))) 114 bb = abs(trunc(enoise(65535))) 115 116 // if target window is a graph, and user wants to append, do so 117 DoWindow/B Plot_Manager 118 if(WinType("") == 1) 119 DoAlert 1,"Do you want to append this data to the current graph?" 120 if(V_Flag == 1) 121 AppendToGraph $w1 vs $w0 122 ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb),tickUnit=1 123 ErrorBars $w1 Y,wave=($w2,$w2) 124 ModifyGraph tickUnit(left)=1 238 239 //plot if desired 240 if(doPlot) 241 // assign colors randomly 242 rr = abs(trunc(enoise(65535))) 243 gg = abs(trunc(enoise(65535))) 244 bb = abs(trunc(enoise(65535))) 245 246 // if target window is a graph, and user wants to append, do so 247 DoWindow/B Plot_Manager 248 if(WinType("") == 1) 249 DoAlert 1,"Do you want to append this data to the current graph?" 250 if(V_Flag == 1) 251 AppendToGraph $w1 vs $w0 252 ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb),tickUnit=1 253 ErrorBars $w1 Y,wave=($w2,$w2) 254 ModifyGraph tickUnit(left)=1 255 else 256 //new graph 257 Display $w1 vs $w0 258 ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 259 ModifyGraph grid=1,mirror=2,standoff=0 260 ErrorBars $w1 Y,wave=($w2,$w2) 261 ModifyGraph tickUnit(left)=1 262 Legend 263 endif 125 264 else 126 // new graph265 // graph window was not target, make new one 127 266 Display $w1 vs $w0 128 267 ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 … … 132 271 Legend 133 272 endif 134 else135 // graph window was not target, make new one136 Display $w1 vs $w0137 ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1138 ModifyGraph grid=1,mirror=2,standoff=0139 ErrorBars $w1 Y,wave=($w2,$w2)140 ModifyGraph tickUnit(left)=1141 Legend142 273 endif 274 143 275 endif 144 276 endfor … … 153 285 154 286 155 function/S getXMLDataSetTitle(xmlDF )287 function/S getXMLDataSetTitle(xmlDF,dsNum) 156 288 String xmlDF 289 Variable dsNum 290 291 SVAR title = root:myGlobals:gXMLLoader_Title 292 157 293 158 294 String mdstring = xmlDF+"metadata" 159 print mdstring160 295 161 296 Wave/T meta = $mdstring 162 FindValue/TEXT="Run"/TXOP=4/Z meta 163 164 String title = meta[V_Value][1] 297 //Check for value when there are multiple datasets 298 FindValue/TEXT="Title"/TXOP=4/Z meta 299 title = meta[V_Value][1] 300 301 //Check for Run value 302 FindValue/TEXT="Run_"+num2str(dsNum)/TXOP=4/Z meta 303 if (V_Value >= 0) 304 title = title+" "+meta[V_Value][1] 305 else 306 FindValue/TEXT="Run"/TXOP=4/Z meta 307 title = title+" "+meta[V_Value][1] 308 endif 309 310 if (strlen(title) > 28) 311 //Prompt title, "Set New Sample Name" 312 //DoPrompt "Sample Name Is Too Long", title 313 do 314 Execute "getXMLShorterTitle()" 315 while (strlen(title) > 28) 316 endif 165 317 166 318 return title … … 181 333 182 334 end 335 336 337 Proc getXMLShorterTitle() 338 339 //NVAR title = root:myGlobals:gXMLLoader_Title 340 341 DoWindow/K getNewTitle 342 getNewTitle() 343 344 PauseforUser getNewTitle 345 end 346 347 Window getNewTitle() 348 349 PauseUpdate; Silent 1 // building window... 350 NewPanel /W=(166,90,666,230) as "Sample Title Too Long!" 351 SetDrawLayer UserBack 352 DrawText 11,22,"The sample title is too long." 353 DrawText 11,42,"Please enter a new one with a maximum length 28 characters" 354 DrawText 11,72,"Current Sample Title:" 355 GroupBox group0 pos={8,55},size={484,50} 356 TitleBox tb_CurrentTitle,pos={150,57}, variable=:myGlobals:gXMLLoader_Title,fSize=12,frame=0 357 SetVariable sv_NewTitle,pos={11,77},size={476,18},title="New Sample Title" 358 SetVariable sv_NewTitle,fSize=12,value=root:myGlobals:gXMLLoader_Title 359 Button btn_SetNewTitle title="Set New Title",pos={150,110},size={200,20} 360 Button btn_SetNewTitle proc=SetNewTitleButtonProc 361 362 EndMacro 363 364 365 Proc SetNewTitleButtonProc(ctrlName) : ButtonControl 366 String ctrlName 367 368 DoWindow/K getNewTitle 369 370 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Initialize.ipf
r418 r461 115 115 Variable/G root:myGlobals:isDemoVersion = isDemo() 116 116 117 //set XML globals 118 String/G root:myGlobals:gXMLLoader_Title = "" 119 120 117 121 Return(0) 118 122 End
Note: See TracChangeset
for help on using the changeset viewer.