Changeset 1039 for sans/Dev/trunk
- Timestamp:
- May 18, 2017 11:34:30 AM (6 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtilsMacro_v40.ipf
r1017 r1039 986 986 str = RemoveFromList("USAXS", str, ";") 987 987 str = RemoveFromList("RAW;SAM;EMP;BGD;DIV;MSK;ABS;CAL;COR;STO;SUB;DRK;SAS;", str ,";") //root level folders present in old reduction experiments 988 str = RemoveFromList("ToTrim", str , ";" ) //from VSANS 988 989 endif 989 990 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Combine_1D.ipf
r1038 r1039 3 3 4 4 5 // 6 // 7 // Preliminary routines for adjusting, masking, and combining 1D VSANS data sets. 8 // 9 // ideas taken from USANS to mask data sets 10 // avoiding duplication of NSORT, since autoscale is not in favor, and there may be anywhere 11 // from 3 to 9 data sets to combine 12 // 13 // masking waves are saved in the "Combine_1D" folder, BUT the masking may eventually be part 14 // of the data reduction protocol - and anything in work folders will be lost 15 // 16 17 18 //ksWorkFolderList 19 20 // String str,winStr="V_1D_Data" 21 // sprintf str,"(\"%s\",%d,\"%s\")",type,popNum,winStr 22 // 23 // Execute ("V_Back_IQ_Graph"+str) 24 // Execute ("V_Middle_IQ_Graph"+str) 25 // Execute ("V_Front_IQ_Graph"+str) 26 27 28 // draws the graph, but does not draw anything on it yet 5 6 7 29 8 // 30 9 // TODO: 31 // -- make the data folder list for the popup 32 // -- make the data folder popup do the work of plotting (test for failure) 33 // 34 // -- make a button to show the default table, and set up dependencies to link to the graph display 10 // x- make the data folder list for the popup 11 // x- make the data folder popup do the work of plotting 12 // 13 // x- (done by invoking the panel) 14 // x-make a button to show the default table, and set up dependencies to link to the graph display 15 // 35 16 // -- have an "active" data set to trim, or make duplicates for all of the data sets 36 17 // 37 18 // -- button to convert the points to strings that can be used and written to data files? 38 // 39 // -- table is continually duplicated 19 // -- is this really necessary? if the save button is clicked, the strings are automatically generated 20 // -- but what if it's not? What if I do something else to send the strings to a protocol? or to a file? 21 // 22 // -- find a better way to be sure that the dependency does not generate errors if it is not 23 // properly killed 24 // 25 // -- help file 26 // 27 // x- larger panel 28 // 29 // x- error checking if the binType and the data present don't match. (test for failure) 30 // -- do I really need the binType popup? How else would I know what data sets to plot/remove? 31 // 32 // x- table is continually duplicated 40 33 // -- AutoPosition the windows next to each other 41 // -- (different)(not ugly) color for the control bar so it's distinguishable from the regular data plot 42 // -- "Done" button that kills the root:ToTrim folder (may need to kill the dependency first) 43 // 44 Proc V_CombineDataGraph() 45 34 // x- (different)(not ugly) color for the control bar so it's distinguishable from the regular data plot 35 // x- "Done" button that kills the root:ToTrim folder (may need to kill the dependency first) 36 // 37 Macro V_CombineDataGraph() 38 39 // this is the "initialization" step 40 NewDataFolder/O root:ToTrim 41 46 42 DoWindow/F V_1D_Combine 43 44 Variable num,ii 45 String detStr 46 47 47 if(V_flag==0) 48 Variable num,ii 49 String detStr 50 51 Display /W=(277,526,748,938)/N=V_1D_Combine/K=1 48 49 Display /W=(277,526,879,1069)/N=V_1D_Combine /K=2 52 50 53 51 ControlBar 70 54 52 ModifyGraph cbRGB=(44000,44000,44000) 55 53 56 PopupMenu popup1,pos={15,5},size={90,20},title="Data Folder" 54 Button button2,pos={15,5},size={70,20},proc=V_Load_ITX_button,title="Load Data" 55 Button button2,help={"Load an ITX file"} 56 57 PopupMenu popup1,pos={125,5},size={90,20},title="Data Folder" 57 58 PopupMenu popup1,help={"data folder"} 58 59 PopupMenu popup1,value= GetAList(4),proc=V_DataFolderPlotPop 59 60 60 PopupMenu popup0,pos={ 200,5},size={70,20},title="Bin Type"61 PopupMenu popup0,pos={320,5},size={70,20},title="Bin Type" 61 62 PopupMenu popup0,help={"binning type"} 62 63 PopupMenu popup0,value= ksBinTypeStr 63 // PopupMenu popup0,mode=1,proc=V_BinningModePopup 64 65 Button button3,pos={544.00,5},size={30.00,20.00},title="?" 66 Button button3,help={"help file for combining 1D data"} 64 67 65 68 CheckBox check0,pos={18.00,36.00},size={57.00,16.00},proc=V_Plot1D_LogCheckProc,title="Log Axes" 66 69 CheckBox check0,value= 1 67 70 68 Button AllQ,pos={ 320,28},size={70,20},proc=V_AllQ_Plot_1D_ButtonProc,title="All Q"71 Button AllQ,pos={100,36},size={70,20},proc=V_AllQ_Plot_1D_ButtonProc,title="All Q" 69 72 Button AllQ,help={"Show the full q-range of the dataset"} 73 74 Button button1,pos={225,36},size={100,20},proc=V_TrimWaves2StringButton,title="Wave 2 Str" 75 Button button1,help={"Convert the waves to global strings"} 70 76 77 Button button4,pos={388,36},size={90.00,20.00},title="Trim & Save" 78 Button button4,help={"combine and save 1D data"},proc=V_SaveTrimmed_Button 79 80 Button button0,pos={524,36},size={70,20},proc=V_DoneCombine1D_ButtonProc,title="Done" 81 Button button0,help={"Close the panel and kill the temporary folder"} 82 71 83 Legend/C/N=text0/J/X=72.00/Y=60.00 72 84 73 //trust that the table is present? No, but don't overwrite the data in the waves 74 // unless any one of the three doesn't exist 75 if(exists("PanelNameW") == 0 || exists("Beg_pts") == 0 || exists("End_pts") == 0) 76 Make/O/T/N=(ItemsInList(ksPanelBinTypeList)) PanelNameW 77 Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) Beg_pts 78 Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) End_pts 85 endif 86 87 88 //trust that the table is present? No, but don't overwrite the data in the waves 89 // unless any one of the three doesn't exist 90 91 SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols 92 93 if(exists("PanelNameW") == 0 || exists("Beg_pts") == 0 || exists("End_pts") == 0) 94 Make/O/T/N=(ItemsInList(ksPanelBinTypeList)) PanelNameW 95 Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) Beg_pts 96 Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) End_pts 97 98 num = ItemsInList(ksPanelBinTypeList) 99 ii=0 100 do 101 detStr = StringFromList(ii, ksPanelBinTypeList) 102 Beg_pts[ii] = NumberByKey(detStr, ksBinTrimBegDefault,"=",";") 103 End_pts[ii] = NumberByKey(detStr, ksBinTrimEndDefault,"=",";") 104 PanelNameW[ii] = detStr 105 ii += 1 106 while(ii<num) 79 107 80 num = ItemsInList(ksPanelBinTypeList) 81 ii=0 82 do 83 detStr = StringFromList(ii, ksPanelBinTypeList) 84 Beg_pts[ii] = NumberByKey(detStr, ksBinTrimBegDefault,"=",";") 85 End_pts[ii] = NumberByKey(detStr, ksBinTrimEndDefault,"=",";") 86 PanelNameW[ii] = detStr 87 ii += 1 88 while(ii<num) 89 90 endif 108 endif 109 // now make sure that the table is present 110 DoWindow/F V_TrimPointsTable 111 112 if(V_flag==0) 113 Edit/K=0/N=V_TrimPointsTable PanelNameW,Beg_pts,End_pts 114 endif 115 116 // last, set up the dependency 117 Make/O/D/N=1 trimUpdate 118 trimUpdate := V_TrimTestUpdate(Beg_pts, End_pts) 119 120 121 SetDataFolder root: 91 122 92 Edit/K=0 root:PanelNameW,root:Beg_pts,root:End_pts93 94 Make/O/D/N=1 trimUpdate95 trimUpdate := V_DummyUpdate(Beg_pts, End_pts)96 97 // PopupMenu ymodel,pos={150,5},size={71,20},title="y-axis"98 // PopupMenu ymodel,help={"This popup selects how the y-axis will be linearized based on the chosen data"}99 // PopupMenu ymodel,value= #"\"I;log(I);ln(I);1/I;I^a;Iq^a;I^a q^b;1/sqrt(I);ln(Iq);ln(Iq^2)\""100 // PopupMenu ymodel,mode=NumVarOrDefault("root:Packages:NIST:VSANS:Globals:Plot_1d:gYMode", 1 ),proc=V_YMode_PopMenuProc101 // PopupMenu xmodel,pos={220,5},size={74,20},title="x-axis"102 // PopupMenu xmodel,help={"This popup selects how the x-axis will be linearized given the chosen data"}103 // PopupMenu xmodel,value= #"\"q;log(q);q^2;q^c\""104 // PopupMenu xmodel,mode=NumVarOrDefault("root:Packages:NIST:VSANS:Globals:Plot_1d:gXMode", 1 ),proc=V_XMode_PopMenuProc105 //// Button Rescale,pos={281,5},size={70,20},proc=V_Rescale_Plot_1D_ButtonProc,title="Rescale"106 //// Button Rescale,help={"Rescale the x and y-axes of the data"},disable=1107 //108 // SetVariable expa,pos={120,28},size={80,15},title="pow \"a\""109 // SetVariable expa,help={"This sets the exponent \"a\" for some y-axis formats. The value is ignored if the model does not use an adjustable exponent"}110 // SetVariable expa,limits={-2,10,0},value= root:Packages:NIST:VSANS:Globals:Plot_1d:gExpA111 // SetVariable expb,pos={120,46},size={80,15},title="pow \"b\""112 // SetVariable expb,help={"This sets the exponent \"b\" for some x-axis formats. The value is ignored if the model does not use an adjustable exponent"}113 // SetVariable expb,limits={0,10,0},value= root:Packages:NIST:VSANS:Globals:Plot_1d:gExpB114 //115 // SetVariable expc,pos={220,28},size={80,15},title="pow \"c\""116 // SetVariable expc,help={"This sets the exponent \"c\" for some x-axis formats. The value is ignored if the model does not use \"c\" as an adjustable exponent"}117 // SetVariable expc,limits={-10,10,0},value= root:Packages:NIST:VSANS:Globals:Plot_1d:gExpC118 119 endif120 121 122 123 End 123 124 124 Function V_DummyUpdate(Beg_pts, End_pts) 125 126 // function that is a simple dependency, and updates the trimmed waves 127 // that are displayed 128 // 129 // does not actually modify the real data, makes a copy, and is only a visual 130 // 131 // 132 Function V_TrimTestUpdate(Beg_pts, End_pts) 125 133 Wave Beg_pts,End_pts 126 134 … … 129 137 // won't hurt to set twice... 130 138 131 Wave/T panelStr = root:PanelNameW 132 Wave begW = root:Beg_pts 133 Wave endW = root:End_pts 134 135 SetDataFolder root:ToTrim 136 137 Variable num,ii 139 Wave/T panelStr = root:Packages:NIST:VSANS:Globals:Protocols:PanelNameW 140 Wave begW = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts 141 Wave endW = root:Packages:NIST:VSANS:Globals:Protocols:End_pts 142 143 // in case the dependency is still active, and the folder was killed 144 if(DataFolderExists("root:ToTrim") == 0) 145 return(0) 146 endif 147 148 // SetDataFolder root:ToTrim 149 ControlInfo/W=V_1D_Combine popup1 150 String dataFldrStr = S_Value 151 152 Variable num,ii,p1,p2 138 153 String str,detStr 139 154 num=numpnts(panelStr) … … 141 156 for(ii=0;ii<num;ii+=1) 142 157 detStr = panelStr[ii] 143 Wave/Z iw = $("iBin_qxqy_"+detStr+"_trim") 158 Wave/Z iw = $("root:ToTrim:iBin_qxqy_"+detStr+"_trim") 159 Wave/Z iw_orig = $("root:"+dataFldrStr+":iBin_qxqy_"+detStr) 144 160 // Wave/Z iw = $("iBin_qxqy_"+detStr) 145 161 // Wave/Z ew = $("eBin_qxqy_"+detStr) 146 if(WaveExists(iw) )162 if(WaveExists(iw) && WaveExists(iw_orig)) 147 163 148 164 // DeletePoints 0,nBeg, qw,iw,ew 149 iw[0,begW[ii]-1] = NaN 165 // start fresh 166 iw = iw_orig 167 168 p1 = begW[ii] 169 iw[0,p1-1] = NaN 150 170 151 171 Variable npt 152 172 npt = numpnts(iw) 153 173 // DeletePoints npt-nEnd,nEnd, qw,iw,ew 154 iw[npt-endW[ii],npt-1] = NaN 174 p2 = EndW[ii] 175 iw[npt-p2,npt-1] = NaN 155 176 156 177 endif … … 163 184 End 164 185 165 186 // TODO 187 // x- verify that the proper waves exist for the binning type 188 // 189 // x- the logic here is wrong. if the ToTrim folder is empty (As on startup) 190 // then the waves are always missing - and the function returns an error - every time 191 // 192 // 166 193 Function V_DataFolderPlotPop(ctrlName,popNum,popStr) : PopupMenuControl 167 194 String ctrlName … … 175 202 binType = V_BinTypeStr2Num(S_Value) 176 203 204 205 // TODO: x- need to update this to make sure that the data waves are present before plotting. This 206 // currently looks in the ToTrim folder, but the binning could be wrong in the data folder 207 // and will be an error... 208 209 // be sure that the data is present in the ToTrim folder before trying to plot 210 Variable err = V_itxWavesExist(popStr,binType) 211 if(err) 212 DoAlert 0,"wrong bin type selected" 213 return(0) 214 endif 215 216 177 217 //dataType now needs to be the full path to the folder 218 // Plot the "real" data. data copy to trim will be plotted later 219 // 178 220 dataType = "root:"+popStr 221 222 //remove EVERYTHING from the graph, no matter what 223 String type,list,item 224 list = TraceNameList(winStr,";",1) 225 for(ii=0;ii<ItemsInList(list);ii+=1) 226 item = StringFromList(ii, list, ";") 227 // CheckDisplayed/W=$winStr $(item) 228 // if(V_flag==1) 229 RemoveFromGraph/Z/W=$winStr $(item) 230 // endif 231 endfor 232 179 233 180 234 sprintf str,"(\"%s\",%d,\"%s\")",dataType,binType,winStr … … 190 244 191 245 //remove all of the "toTrim" data from the graph, if it's there 192 String type193 194 246 SetDataFolder root:ToTrim 195 196 247 for(ii=0;ii<ItemsInList(ksPanelBinTypeList);ii+=1) 197 248 type = StringFromList(ii, ksPanelBinTypeList, ";") … … 200 251 RemoveFromGraph/W=$winStr $("iBin_qxqy_"+type+"_trim") 201 252 endif 253 endfor 254 SetDataFolder root: 255 256 257 //then kill the data folder, so it can be duplicated 258 259 // 260 // // duplicate all of the data into the new folder 261 SetDataFolder $dataType 262 list = WaveList("*",";","") //must be in the correct data folder 263 SetDataFolder root: 264 // Print list 265 num = ItemsInList(list) 266 for(ii=0;ii<num;ii+=1) 267 str = StringFromList(ii,list) 268 Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim") 202 269 endfor 203 270 204 SetDataFolder root: 205 206 // ClearIQIfDisplayed_AllFldr("B_trim",winStr) 207 // ClearIQIfDisplayed_AllFldr("ML_trim",winStr) 208 // ClearIQIfDisplayed_AllFldr("MR_trim",winStr) 209 // ClearIQIfDisplayed_AllFldr("MT_trim",winStr) 210 // ClearIQIfDisplayed_AllFldr("MB_trim",winStr) 211 // ClearIQIfDisplayed_AllFldr("FL_trim",winStr) 212 // ClearIQIfDisplayed_AllFldr("FR_trim",winStr) 213 // ClearIQIfDisplayed_AllFldr("FT_trim",winStr) 214 // ClearIQIfDisplayed_AllFldr("FB_trim",winStr) 215 // ClearIQIfDisplayed_AllFldr("MLR_trim",winStr) 216 // ClearIQIfDisplayed_AllFldr("MTB_trim",winStr) 217 // ClearIQIfDisplayed_AllFldr("FLR_trim",winStr) 218 // ClearIQIfDisplayed_AllFldr("FTB_trim",winStr) 219 // ClearIQIfDisplayed_AllFldr("MLRTB_trim",winStr) 220 // ClearIQIfDisplayed_AllFldr("FLRTB_trim",winStr) 221 222 //then kill the data folder, so it can be duplicated 223 224 // 225 // // rename all of the data in the new folder 271 // be sure that the data is present in the ToTrim folder before trying to plot 272 err = V_TrimWavesExist(binType) 273 if(err) 274 DoAlert 0,"wrong bin type selected" 275 return(0) 276 endif 277 278 279 // plot the linked data 280 sprintf str,"(\"%s\",%d,\"%s\")","root:ToTrim",binType,winStr 281 282 Execute ("V_Back_IQ_Graph_trim"+str) 283 Execute ("V_Middle_IQ_Graph_trim"+str) 284 Execute ("V_Front_IQ_Graph_trim"+str) 285 // and link the data to the table with a dependency? 286 // done in the panel macro? 287 288 // last, force the dependency to update so that the trimmed points are shown 289 Wave w = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts 290 w[0] += 1 291 w[0] -= 1 292 293 294 return(0) 295 End 296 297 // kill the dependency, 298 // kill the panel, then the associated ToTrim folder 299 // do not kill the beg/end waves 300 // 301 Function V_DoneCombine1D_ButtonProc(ctrlName) : ButtonControl 302 String ctrlName 303 304 Wave trimUpdate = root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate 305 trimUpdate = 1 //kills the dependency 306 DoWindow/K V_1D_Combine 307 308 KillDataFolder/Z root:ToTrim 309 310 return(0) 311 End 312 313 // TODO 314 // -- verify that this works for all binning cases 315 // -- see V_Trim1DDataStr to see if they can be combined 316 // 317 Function V_SaveTrimmed_Button(ctrlName) : ButtonControl 318 String ctrlName 319 320 String detListStr,dataType,str 321 Variable bintype,num,ii 322 323 ControlInfo popup0 324 binType = V_BinTypeStr2Num(S_Value) 325 326 327 if(binType == 1) 328 detListStr = ksBinType1 329 endif 330 if(binType == 2) 331 detListStr = ksBinType2 332 endif 333 if(binType == 3) 334 detListStr = ksBinType3 335 endif 336 if(binType == 4) 337 detListStr = ksBinType4 338 endif 339 if(strlen(detListStr)==0) 340 return(0) 341 endif 342 343 // set the global strings 344 V_TrimWaves2String() //in case the button wasn't clicked 345 SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr 346 SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr 347 348 // get a fresh copy of the data 349 // duplicate all of the data into the new folder 350 ControlInfo popup1 351 dataType = "root:"+S_Value 352 226 353 SetDataFolder $dataType 227 354 String list = WaveList("*",";","") //must be in the correct data folder … … 233 360 Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim") 234 361 endfor 235 // plot the linked data 236 sprintf str,"(\"%s\",%d,\"%s\")","root:ToTrim",binType,winStr 237 238 Execute ("V_Back_IQ_Graph_trim"+str) 239 Execute ("V_Middle_IQ_Graph_trim"+str) 240 Execute ("V_Front_IQ_Graph_trim"+str) 241 // and link the data to the table with a dependency 242 // 243 244 245 return(0) 362 363 364 // trim each data set 365 Variable nBeg,nEnd,npt 366 String detstr 367 368 SetDataFolder root:ToTrim 369 num = ItemsInList(detListStr) 370 for(ii=0;ii<num;ii+=1) 371 detStr = StringFromList(ii, detListStr) 372 nBeg = NumberByKey(detStr, gBegPtsStr,"=",";") 373 nEnd = NumberByKey(detStr, gEndPtsStr,"=",";") 374 375 // V_TrimOneSet(folderStr,detStr,nBeg,nEnd) 376 Wave/Z qw = $("qBin_qxqy_"+detStr+"_trim") 377 Wave/Z iw = $("iBin_qxqy_"+detStr+"_trim") 378 Wave/Z ew = $("eBin_qxqy_"+detStr+"_trim") 379 380 DeletePoints 0,nBeg, qw,iw,ew 381 382 npt = numpnts(qw) 383 DeletePoints npt-nEnd,nEnd, qw,iw,ew 384 // 385 endfor 386 387 388 // remove Q=0 from "B" if it's present 389 SetDataFolder root:ToTrim 390 WAVE/Z qBin = qBin_qxqy_B_trim 391 WAVE/Z iBin = iBin_qxqy_B_trim 392 WAVE/Z eBin = eBin_qxqy_B_trim 393 // WAVE/Z nBin = nBin_qxqy_B_trim 394 // WAVE/Z iBin2 = iBin2_qxqy_B_trim 395 396 if(qBin[0] == 0) 397 DeletePoints 0, 1, qBin,iBin,eBin//,nBin,iBin2 398 endif 399 400 401 // concatenate 402 V_1DConcatenate("root:","ToTrim","_trim",binType) 403 404 // sort the waves - concatenation creates tmp_q, tmp_i, tmp_s 405 // so this call will work (doesn't need the "_trim" tag) 406 V_TmpSort1D("root:","ToTrim") 407 408 // write out the data to disk 409 410 Execute "V_GetNameForSave()" 411 SVAR newName = root:saveName 412 String saveName = newName 413 414 //will write out the tmp_q, tmp_i, tmp_s waves 415 V_Write1DData("root:","ToTrim",saveName) //don't pass the full path, just the name 416 417 418 // put a fresh copy of the data back into the folder since the data was actually trimmed 419 // duplicate all of the data into the new folder 420 ControlInfo popup1 421 dataType = "root:"+S_Value 422 423 SetDataFolder $dataType 424 list = WaveList("*",";","") //must be in the correct data folder 425 SetDataFolder root: 426 // Print list 427 num = ItemsInList(list) 428 for(ii=0;ii<num;ii+=1) 429 str = StringFromList(ii,list) 430 Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim") 431 endfor 432 433 434 SetDataFolder root: 435 436 return(0) 246 437 End 247 438 248 439 249 440 250 251 252 253 254 255 256 257 441 // 442 // dialog to select and load an itx format data file 443 // 444 Function V_Load_ITX_Button(ctrlName) : ButtonControl 445 String ctrlName 446 447 Execute "V_Load_Data_ITX()" 448 449 return(0) 450 End 451 452 453 // TODO 454 // -- document 455 Function V_TrimWaves2StringButton(ctrlName) : ButtonControl 456 String ctrlName 457 458 V_TrimWaves2String() 459 460 return(0) 461 End 462 463 // for each of the binning types, be sure that the corresponding waves in the 464 // root:ToTrim folder actually do exist. 465 // return 0 for OK, 1 if error 466 Function V_TrimWavesExist(binType) 467 Variable binType 468 469 String binStr="",str 470 Variable num,ii 471 472 if(binType == 1) 473 binStr = ksBinType1 474 endif 475 if(binType == 2) 476 binStr = ksBinType2 477 endif 478 if(binType == 3) 479 binStr = ksBinType3 480 endif 481 if(binType == 4) 482 binStr = ksBinType4 483 endif 484 485 num = ItemsInList(binStr) 486 for(ii=0;ii<num;ii+=1) 487 str = StringFromList(ii,binStr) 488 if(exists("root:ToTrim:iBin_qxqy_"+Str+"_trim") == 0) // not in use = error 489 return(1) 490 endif 491 endfor 492 493 return(0) //everything checked out OK, no error 494 495 end 496 497 // for each of the binning types, be sure that the corresponding waves in the 498 // root:ToTrim folder actually do exist. 499 // return 0 for OK, 1 if error 500 Function V_itxWavesExist(folderStr,binType) 501 String folderStr 502 Variable binType 503 504 String binStr="",str 505 Variable num,ii 506 507 if(binType == 1) 508 binStr = ksBinType1 509 endif 510 if(binType == 2) 511 binStr = ksBinType2 512 endif 513 if(binType == 3) 514 binStr = ksBinType3 515 endif 516 if(binType == 4) 517 binStr = ksBinType4 518 endif 519 520 num = ItemsInList(binStr) 521 for(ii=0;ii<num;ii+=1) 522 str = StringFromList(ii,binStr) 523 if(exists("root:"+folderStr+":iBin_qxqy_"+Str) == 0) // not in use = error 524 return(1) 525 endif 526 endfor 527 528 return(0) //everything checked out OK, no error 529 530 end 531 532 533 534 // 535 // take the waves, and convert to strings that can be added to the protocol 536 // 537 // TODO: 538 // x- get the variables out of root:, and move it to Protocols 539 // -- get the waves out of root:, and move it to Protocols 540 // x- be sure that the variables are initialized (done in main initialization 541 // -- link this to the panel? 542 // 543 Function V_TrimWaves2String() 544 545 546 SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr 547 SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr 548 549 Wave/T PanelNameW = root:Packages:NIST:VSANS:Globals:Protocols:PanelNameW 550 Wave Beg_pts = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts 551 Wave End_pts = root:Packages:NIST:VSANS:Globals:Protocols:End_pts 552 553 // ksPanelBinTypeList = "B;FT;FB;FL;FR;MT;MB;ML;MR;FTB;FLR;MTB;MLR;FLRTB;MLRTB;" 554 // ksBinTrimBegDefault = "B=5;FT=6;FB=6;FL=6;FR=6;MT=6;MB=6;ML=6;MR=6;FTB=7;FLR=7;MTB=7;MLR=7;FLRTB=8;MLRTB=8;" 555 // ksBinTrimEndDefault 556 557 // wipe out the "old" global strings 558 gBegPtsStr = ksBinTrimBegDefault 559 gEndPtsStr = ksBinTrimEndDefault 560 561 Variable num, ii,nBeg,nEnd 562 String item,panelStr 563 564 num = numpnts(PanelNameW) 565 for(ii=0;ii<num;ii+=1) 566 panelStr = PanelNameW[ii] 567 gBegPtsStr = ReplaceNumberByKey(panelStr, gBegPtsStr, Beg_pts[ii],"=",";") 568 gEndPtsStr = ReplaceNumberByKey(panelStr, gEndPtsStr, End_pts[ii],"=",";") 569 endfor 570 571 return(0) 572 End 258 573 259 574 … … 279 594 //////////////// Below is unused -- it was started, but seems like the wrong approach, 280 595 //////////////// so I have abandoned it for now 281 596 // 597 // 598 // ((this approach using USANS ideas has temporarily been abandoned...)) 599 // 600 // Preliminary routines for adjusting, masking, and combining 1D VSANS data sets. 601 // 602 // ideas taken from USANS to mask data sets 603 // avoiding duplication of NSORT, since autoscale is not in favor, and there may be anywhere 604 // from 3 to 9 data sets to combine 605 // 606 // masking waves are saved in the "Combine_1D" folder, BUT the masking may eventually be part 607 // of the data reduction protocol - and anything in work folders will be lost 608 // 282 609 283 610 … … 314 641 // 315 642 // 316 317 318 StrConstant ksCombine1DFolder = "root:Packages:NIST:VSANS:Globals:Combine_1D" 319 320 // main entry routine 321 Macro V_Combine_1D() 322 323 //check for the correct folder, initialize if necessary 324 // 325 if(DataFolderExists(ksCombine1DFolder) == 0) 326 Execute "V_Init_Combine_1D()" 327 endif 328 329 SetDataFolder root: 330 331 DoWindow/F V_Combine_1D_Graph 332 if(V_flag==0) 333 Execute "V_Combine_1D_Graph()" 334 endif 335 End 336 337 Proc V_Init_Combine_1D() 338 339 //set up the folder(s) needed 340 NewDataFolder/O $(ksCombine1DFolder) 341 342 SetDataFolder $(ksCombine1DFolder) 343 344 String/G gCurFile="" 345 String/G gStr1="" 346 Variable/G gFreshMask=1 347 Variable/G gNq=0 348 349 SetDataFolder root: 350 End 351 352 353 //// 354 // 355 // 356 Proc V_Combine_1D_Graph() 357 358 PauseUpdate; Silent 1 // building window... 359 Display /W=(699,45,1328,779) /K=1 360 ModifyGraph cbRGB=(51664,44236,58982) 361 ModifyGraph tickUnit=1 362 DoWindow/C V_Combine_1D_Graph 363 ControlBar 160 364 // break into tabs 365 TabControl C1D_Tab,pos={5,3},size={392,128},proc=C1D_TabProc 366 TabControl C1D_Tab,labelBack=(49151,49152,65535),tabLabel(0)="Load" 367 TabControl C1D_Tab,tabLabel(1)="Mask",tabLabel(2)="Rescale",value=0 368 369 //always visible - revert and save 370 //maybe the wrong place here? 371 Button C1DControlA,pos={225,135},size={80,20},proc=C1D_RevertButtonProc,title="Revert" 372 Button C1DControlA,help={"Revert the data to its original state and start over"} 373 Button C1DControlB,pos={325,135},size={50,20},proc=C1D_SaveButtonProc,title="Save" 374 Button C1DControlB,help={"Save the masked and scaled data set"} 375 Button C1DControlC,pos={25,135},size={50,20},proc=C1D_HelpButtonProc,title="Help" 376 Button C1DControlC,help={"Show the help file for combining VSANS data sets"} 377 378 // add the controls to each tab ---- all names start with "C1DControl_" 379 380 //tab(0) Load - initially visible 381 Button C1DControl_0a,pos={23,39},size={80,20},proc=C1D_LoadButtonProc,title="Load Data" 382 Button C1DControl_0a,help={"Load slit-smeared USANS data = \".cor\" files"} 383 CheckBox C1DControl_0b,pos={26,74},size={80,14},proc=C1D_LoadCheckProc,title="Log Axes?" 384 CheckBox C1DControl_0b,help={"Toggle Log/Lin Q display"},value= 1 385 TitleBox C1DControl_0c,pos={120,37},size={104,19},font="Courier",fSize=10 386 TitleBox C1DControl_0c,variable= $(ksCombine1DFolder+":gStr1") 387 PopupMenu C1DControl_0d,pos={120,75},size={71,20},title="Bin Type" 388 PopupMenu C1DControl_0d,help={"This popup selects how the y-axis will be linearized based on the chosen data"} 389 PopupMenu C1DControl_0d,value= ksBinTypeStr 390 PopupMenu C1DControl_0d,mode=1,proc=V_CombineModePopup 391 PopupMenu C1DControl_0e,pos={120,100},size={109,20},title="Data Source" 392 PopupMenu C1DControl_0e,mode=1,popvalue="RAW",value= #"\"RAW;SAM;EMP;BGD;COR;ABS;\"" 393 Button C1DControl_0f,pos={200,39},size={120,20},proc=C1D_ConcatButtonProc,title="Concatenate" 394 Button C1DControl_0f,help={"Load slit-smeared USANS data = \".cor\" files"} 395 396 397 //tab(1) Mask 398 Button C1DControl_1a,pos={20,35},size={90,20},proc=C1D_MyMaskProc,title="Mask Point" //bMask 399 Button C1DControl_1a,help={"Toggles the masking of the selected data point"} 400 Button C1DControl_1a,disable=1 401 Button C1DControl_1b,pos={20,65},size={140,20},proc=C1D_MaskGTCursor,title="Mask Q >= Cursor" //bMask 402 Button C1DControl_1b,help={"Toggles the masking of all q-values GREATER than the current cursor location"} 403 Button C1DControl_1b,disable=1 404 Button C1DControl_1c,pos={20,95},size={140,20},proc=C1D_MaskLTCursor,title="Mask Q <= Cursor" //bMask 405 Button C1DControl_1c,help={"Toggles the masking of all q-values LESS than the current cursor location"} 406 Button C1DControl_1c,disable=1 407 Button C1DControl_1d,pos={180,35},size={90,20},proc=C1D_ClearMaskProc,title="Clear Mask" //bMask 408 Button C1DControl_1d,help={"Clears all mask points"} 409 Button C1DControl_1d,disable=1 410 Button C1DControl_1e,pos={180,65},size={90,20},proc=C1D_MaskPercent,title="Percent Mask" //bMask 411 Button C1DControl_1e,help={"Clears all mask points"} 412 Button C1DControl_1e,disable=1 413 414 415 // Button C1DControl_1b,pos={144,66},size={110,20},proc=C1D_MaskDoneButton,title="Done Masking" 643 // 644 // 645 //StrConstant ksCombine1DFolder = "root:Packages:NIST:VSANS:Globals:Combine_1D" 646 // 647 //// main entry routine 648 //Proc V_Combine_1D() 649 // 650 // //check for the correct folder, initialize if necessary 651 // // 652 // if(DataFolderExists(ksCombine1DFolder) == 0) 653 // Execute "V_Init_Combine_1D()" 654 // endif 655 // 656 // SetDataFolder root: 657 // 658 // DoWindow/F V_Combine_1D_Graph 659 // if(V_flag==0) 660 // Execute "V_Combine_1D_Graph()" 661 // endif 662 //End 663 // 664 //Proc V_Init_Combine_1D() 665 // 666 // //set up the folder(s) needed 667 // NewDataFolder/O $(ksCombine1DFolder) 668 // 669 // SetDataFolder $(ksCombine1DFolder) 670 // 671 // String/G gCurFile="" 672 // String/G gStr1="" 673 // Variable/G gFreshMask=1 674 // Variable/G gNq=0 675 // 676 // SetDataFolder root: 677 //End 678 // 679 // 680 ////// 681 //// 682 //// 683 //Proc V_Combine_1D_Graph() 684 // 685 // PauseUpdate; Silent 1 // building window... 686 // Display /W=(699,45,1328,779) /K=1 687 // ModifyGraph cbRGB=(51664,44236,58982) 688 // ModifyGraph tickUnit=1 689 // DoWindow/C V_Combine_1D_Graph 690 // ControlBar 160 691 // // break into tabs 692 // TabControl C1D_Tab,pos={5,3},size={392,128},proc=C1D_TabProc 693 // TabControl C1D_Tab,labelBack=(49151,49152,65535),tabLabel(0)="Load" 694 // TabControl C1D_Tab,tabLabel(1)="Mask",tabLabel(2)="Rescale",value=0 695 // 696 // //always visible - revert and save 697 // //maybe the wrong place here? 698 // Button C1DControlA,pos={225,135},size={80,20},proc=C1D_RevertButtonProc,title="Revert" 699 // Button C1DControlA,help={"Revert the data to its original state and start over"} 700 // Button C1DControlB,pos={325,135},size={50,20},proc=C1D_SaveButtonProc,title="Save" 701 // Button C1DControlB,help={"Save the masked and scaled data set"} 702 // Button C1DControlC,pos={25,135},size={50,20},proc=C1D_HelpButtonProc,title="Help" 703 // Button C1DControlC,help={"Show the help file for combining VSANS data sets"} 704 // 705 // // add the controls to each tab ---- all names start with "C1DControl_" 706 // 707 // //tab(0) Load - initially visible 708 // Button C1DControl_0a,pos={23,39},size={80,20},proc=C1D_LoadButtonProc,title="Load Data" 709 // Button C1DControl_0a,help={"Load slit-smeared USANS data = \".cor\" files"} 710 // CheckBox C1DControl_0b,pos={26,74},size={80,14},proc=C1D_LoadCheckProc,title="Log Axes?" 711 // CheckBox C1DControl_0b,help={"Toggle Log/Lin Q display"},value= 1 712 // TitleBox C1DControl_0c,pos={120,37},size={104,19},font="Courier",fSize=10 713 // TitleBox C1DControl_0c,variable= $(ksCombine1DFolder+":gStr1") 714 // PopupMenu C1DControl_0d,pos={120,75},size={71,20},title="Bin Type" 715 // PopupMenu C1DControl_0d,help={"This popup selects how the y-axis will be linearized based on the chosen data"} 716 // PopupMenu C1DControl_0d,value= ksBinTypeStr 717 // PopupMenu C1DControl_0d,mode=1,proc=V_CombineModePopup 718 // PopupMenu C1DControl_0e,pos={120,100},size={109,20},title="Data Source" 719 // PopupMenu C1DControl_0e,mode=1,popvalue="RAW",value= #"\"RAW;SAM;EMP;BGD;COR;ABS;\"" 720 // Button C1DControl_0f,pos={200,39},size={120,20},proc=C1D_ConcatButtonProc,title="Concatenate" 721 // Button C1DControl_0f,help={"Load slit-smeared USANS data = \".cor\" files"} 722 // 723 // 724 // //tab(1) Mask 725 // Button C1DControl_1a,pos={20,35},size={90,20},proc=C1D_MyMaskProc,title="Mask Point" //bMask 726 // Button C1DControl_1a,help={"Toggles the masking of the selected data point"} 727 // Button C1DControl_1a,disable=1 728 // Button C1DControl_1b,pos={20,65},size={140,20},proc=C1D_MaskGTCursor,title="Mask Q >= Cursor" //bMask 729 // Button C1DControl_1b,help={"Toggles the masking of all q-values GREATER than the current cursor location"} 416 730 // Button C1DControl_1b,disable=1 417 418 // //tab(2) Rescale 419 Button C1DControl_2a,pos={31,42},size={90,20},proc=C1D_ExtrapolateButtonProc,title="Extrapolate" 420 Button C1DControl_2a,help={"Extrapolate the high-q region with a power-law"} 421 Button C1DControl_2a,disable=1 422 SetVariable C1DControl_2b,pos={31,70},size={100,15},title="# of points" 423 SetVariable C1DControl_2b,help={"Set the number of points for the power-law extrapolation"} 424 SetVariable C1DControl_2b,limits={5,100,1},value=_NUM:123 425 SetVariable C1DControl_2b,disable=1 426 CheckBox C1DControl_2c,pos={157,45},size={105,14},proc=C1D_ExtrapolationCheckProc,title="Show Extrapolation" 427 CheckBox C1DControl_2c,help={"Show or hide the high q extrapolation"},value= 1 428 CheckBox C1DControl_2c,disable=1 429 SetVariable C1DControl_2d,pos={31,96},size={150,15},title="Power Law Exponent" 430 SetVariable C1DControl_2d,help={"Power Law exponent from the fit = the DESMEARED slope - override as needed"} 431 SetVariable C1DControl_2d format="%5.2f" 432 SetVariable C1DControl_2d,limits={-inf,inf,0},value=_NUM:123 433 SetVariable C1DControl_2d,disable=1 434 435 Legend/C/N=text0/J/X=72.00/Y=60.00 436 437 438 SetDataFolder root: 439 EndMacro 440 441 // 442 // recalculate the I(q) binning. no need to adjust model function or views 443 // just rebin 444 // 445 // see V_BinningModePopup() in V_DataPlotting.ipf for a duplicate verison of this function 446 Function V_CombineModePopup(ctrlName,popNum,popStr) : PopupMenuControl 447 String ctrlName 448 Variable popNum // which item is currently selected (1-based) 449 String popStr // contents of current popup item as string 450 451 // TODO 452 // x- replace the type with selection from the panel - don't use the current display type 453 ControlInfo C1DControl_0e 454 String type = S_Value 455 456 SVAR gStr1 = $(ksCombine1DFolder+":gStr1") 457 gStr1 = type 458 459 460 V_QBinAllPanels(type,popNum) 461 462 463 String str,winStr="V_Combine_1D_Graph" 464 sprintf str,"(\"%s\",%d,\"%s\")",type,popNum,winStr 465 466 // TODO: 467 // x- replace these calls -- they work with the 1d plot, not this panel. I want them to do basically the same 468 // exact things, but with a different target window 469 // *** these calls now take the target window as a parameter - so that there is only one version 470 Execute ("V_Back_IQ_Graph"+str) 471 Execute ("V_Middle_IQ_Graph"+str) 472 Execute ("V_Front_IQ_Graph"+str) 473 474 475 return(0) 476 End 477 478 479 // function to control the drawing of buttons in the TabControl on the main panel 480 // Naming scheme for the buttons MUST be strictly adhered to... else buttons will 481 // appear in odd places... 482 // all buttons are named C1DControl_NA where N is the tab number and A is the letter denoting 483 // the button's position on that particular tab. 484 // in this way, buttons will always be drawn correctly :-) 485 // 486 Function C1D_TabProc(ctrlName,tab) //: TabControl 487 String ctrlName 488 Variable tab 489 490 String ctrlList = ControlNameList("",";"),item="",nameStr="" 491 Variable num = ItemsinList(ctrlList,";"),ii,onTab 492 for(ii=0;ii<num;ii+=1) 493 //items all start w/"C1DControl_" //11 characters 494 item=StringFromList(ii, ctrlList ,";") 495 nameStr=item[0,10] 496 if(cmpstr(nameStr,"C1DControl_")==0) 497 onTab = str2num(item[11]) //12th is a number 498 ControlInfo $item 499 switch(abs(V_flag)) 500 case 1: 501 Button $item,disable=(tab!=onTab) 502 break 503 case 2: 504 CheckBox $item,disable=(tab!=onTab) 505 break 506 case 5: 507 SetVariable $item,disable=(tab!=onTab) 508 break 509 case 10: 510 TitleBox $item,disable=(tab!=onTab) 511 break 512 case 4: 513 ValDisplay $item,disable=(tab!=onTab) 514 break 515 case 3: 516 PopupMenu $item,disable=(tab!=onTab) 517 break 518 // add more items to the switch if different control types are used 519 endswitch 520 521 endif 522 endfor 523 524 // remove the mask if I go back to the data? 525 if(tab==0) 526 RemoveMask() 527 // RemoveConcatenated() 528 endif 529 530 // masking 531 if(tab==1) 532 C1D_ClearMaskProc("") //starts with a blank mask 533 C1D_MyMaskProc("") //start masking if you click on the tab 534 else 535 C1D_MaskDoneButton("") //masking is done if you click off the tab 536 endif 537 538 // rescaling 539 if(tab == 2) 540 // TODO 541 // -- fill this in 542 // -- this is still in the thought process at this point 543 544 // do rescaling of the different sections of the data set 545 546 endif 547 548 return 0 549 End 550 551 552 Proc AppendConcatenated() 553 554 if( strsearch(TraceNameList("V_Combine_1D_Graph", "", 1),"I_exp_orig",0,2) == -1) //Igor 5 555 SetDataFolder $(ksCombine1DFolder) 556 AppendToGraph/W=V_Combine_1D_Graph I_exp_orig vs Q_exp_orig 557 ModifyGraph mode(I_exp_orig)=3,marker(I_exp_orig)=19,msize(I_exp_orig)=2,opaque(I_exp_orig)=1 558 ModifyGraph rgb(I_exp_orig)=(0,0,0) 559 560 ModifyGraph tickUnit=1,log=1 561 Modifygraph grid=1,mirror=2 562 563 ErrorBars/T=0 I_exp_orig Y,wave=(S_exp_orig,S_exp_orig) 564 565 setdatafolder root: 566 endif 567 end 568 569 Function RemoveConcatenated() 570 571 SetDataFolder $(ksCombine1DFolder) 572 RemoveFromGraph/W=V_Combine_1D_Graph/Z I_exp_orig 573 setdatafolder root: 574 end 575 576 Proc AppendMask() 577 578 if( strsearch(TraceNameList("V_Combine_1D_Graph", "", 1),"MaskData",0,2) == -1) //Igor 5 579 SetDataFolder $(ksCombine1DFolder) 580 AppendToGraph/W=V_Combine_1D_Graph MaskData vs Q_exp_orig 581 ModifyGraph mode(MaskData)=3,marker(MaskData)=8,msize(MaskData)=2.5,opaque(MaskData)=1 582 ModifyGraph rgb(MaskData)=(65535,16385,16385) 583 584 setdatafolder root: 585 endif 586 end 587 588 589 590 Function RemoveMask() 591 592 SetDataFolder $(ksCombine1DFolder) 593 RemoveFromGraph/W=V_Combine_1D_Graph/Z MaskData 594 setdatafolder root: 595 end 596 597 598 // concatenate the data, and replace the multiple data sets with the concatenated set 599 // - then you can proceed to the mask tab 600 // 601 Function C1D_ConcatButtonProc(ctrlName) : ButtonControl 602 String ctrlName 603 604 605 ControlInfo C1DControl_0e 606 String folderStr = S_Value 607 608 SVAR gStr1 = $(ksCombine1DFolder+":gStr1") 609 gStr1 = folderStr 610 611 612 ControlInfo C1DControl_0d 613 Variable binType = V_BinTypeStr2Num(S_Value) 614 615 V_1DConcatenate(folderStr,binType) 616 617 // sort the data set 618 V_TmpSort1D(folderStr) 619 620 // now copy the concatenated data over to the combine folder 621 Duplicate/O $("root:Packages:NIST:VSANS:"+folderStr+":tmp_q") $(ksCombine1DFolder+":Q_exp") 622 Duplicate/O $("root:Packages:NIST:VSANS:"+folderStr+":tmp_i") $(ksCombine1DFolder+":I_exp") 623 Duplicate/O $("root:Packages:NIST:VSANS:"+folderStr+":tmp_s") $(ksCombine1DFolder+":S_exp") 624 wave Q_exp = $(ksCombine1DFolder+":Q_exp") 625 Wave I_exp = $(ksCombine1DFolder+":I_exp") 626 Wave S_exp = $(ksCombine1DFolder+":S_exp") 627 628 629 // 630 Duplicate/O $(ksCombine1DFolder+":Q_exp") $(ksCombine1DFolder+":Q_exp_orig") 631 Duplicate/O $(ksCombine1DFolder+":I_exp") $(ksCombine1DFolder+":I_exp_orig") 632 Duplicate/O $(ksCombine1DFolder+":S_exp") $(ksCombine1DFolder+":S_exp_orig") 633 wave I_exp_orig = $(ksCombine1DFolder+":I_exp_orig") 634 635 Variable nq = numpnts($(ksCombine1DFolder+":Q_exp")) 636 // 637 638 // // append the (blank) wave note to the intensity wave 639 // Note I_exp,"BOX=0;SPLINE=0;" 640 // Note I_exp_orig,"BOX=0;SPLINE=0;" 641 // 642 // //add data to the graph 643 Execute "AppendConcatenated()" 644 645 // TODO: 646 // -- do I clear off the old data here, or somewhere else? 647 // clear off the old data from the individual panels 648 // use ClearAllIQIfDisplayed() 649 ClearIQIfDisplayed_AllBin(folderStr,"V_Combine_1D_Graph") 650 651 RemoveMask() 652 653 return(0) 654 End 655 656 // step (1) - get the data from a WORK folder, and plot it 657 // clear out all of the "old" waves, remove them from the graph first 658 // 659 // ??produces Q_exp, I_exp, S_exp waves (and originals "_orig") 660 // add a dummy wave note that can be changed on later steps 661 // 662 Function C1D_LoadButtonProc(ctrlName) : ButtonControl 663 String ctrlName 664 665 666 String qStr,iStr,sStr,sqStr 667 Variable nq,dqv,numBad,val 668 669 // remove any of the old traces on the graph and delete the waves and reset the global strings 670 CleanUpJunk() 671 672 SetDataFolder root: 673 674 // go get the new data 675 Execute "A_LoadOneDDataWithName(\"\",0)" 676 677 // TODO: 678 // x-Missing something here from the loader - go back to the LakeDesmearing ipf 679 SVAR fname = root:Packages:NIST:gLastFileName //this is the 1D file loaded 680 681 // 682 qStr = CleanupName((fName + "_q"),0) //the q-wave 683 iStr = CleanupName((fName + "_i"),0) //the i-wave 684 sStr = CleanupName((fName + "_s"),0) //the s-wave 685 // sqStr = CleanupName((fName + "sq"),0) //the sq-wave 686 // 687 String DFStr= CleanupName(fname,0) 688 // 689 Duplicate/O $("root:"+DFStr+":"+qStr) $(ksCombine1DFolder+":Q_exp") 690 Duplicate/O $("root:"+DFStr+":"+iStr) $(ksCombine1DFolder+":I_exp") 691 Duplicate/O $("root:"+DFStr+":"+sStr) $(ksCombine1DFolder+":S_exp") 692 wave Q_exp = $(ksCombine1DFolder+":Q_exp") 693 Wave I_exp = $(ksCombine1DFolder+":I_exp") 694 Wave S_exp = $(ksCombine1DFolder+":S_exp") 695 696 697 // 698 Duplicate/O $(ksCombine1DFolder+":Q_exp") $(ksCombine1DFolder+":Q_exp_orig") 699 Duplicate/O $(ksCombine1DFolder+":I_exp") $(ksCombine1DFolder+":I_exp_orig") 700 Duplicate/O $(ksCombine1DFolder+":S_exp") $(ksCombine1DFolder+":S_exp_orig") 701 wave I_exp_orig = $(ksCombine1DFolder+":I_exp_orig") 702 703 nq = numpnts($(ksCombine1DFolder+":Q_exp")) 704 // 705 706 // // append the (blank) wave note to the intensity wave 707 // Note I_exp,"BOX=0;SPLINE=0;" 708 // Note I_exp_orig,"BOX=0;SPLINE=0;" 709 // 710 // //add data to the graph 711 Execute "AppendConcatenated()" 712 713 SetDataFolder root: 714 End 715 716 // remove any q-values <= val 717 Function RemoveBadQPoints(qw,iw,sw,val) 718 Wave qw,iw,sw 719 Variable val 720 721 Variable ii,num,numBad,qval 722 num = numpnts(qw) 723 724 ii=0 725 numBad=0 726 do 727 qval = qw[ii] 728 if(qval <= val) 729 numBad += 1 730 else //keep the points 731 qw[ii-numBad] = qval 732 iw[ii-numBad] = iw[ii] 733 sw[ii-numBad] = sw[ii] 734 endif 735 ii += 1 736 while(ii<num) 737 //trim the end of the waves 738 DeletePoints num-numBad, numBad, qw,iw,sw 739 return(numBad) 740 end 741 742 // if mw = Nan, keep the point, if a numerical value, delete it 743 Function RemoveMaskedPoints(mw,qw,iw,sw) 744 Wave mw,qw,iw,sw 745 746 Variable ii,num,numBad,mask 747 num = numpnts(qw) 748 749 ii=0 750 numBad=0 751 do 752 mask = mw[ii] 753 if(numtype(mask) != 2) //if not NaN 754 numBad += 1 755 else //keep the points that are NaN 756 qw[ii-numBad] = qw[ii] 757 iw[ii-numBad] = iw[ii] 758 sw[ii-numBad] = sw[ii] 759 endif 760 ii += 1 761 while(ii<num) 762 //trim the end of the waves 763 DeletePoints num-numBad, numBad, qw,iw,sw 764 return(numBad) 765 end 766 767 // produces the _msk waves that have the new number of data points 768 // 769 Function C1D_MaskDoneButton(ctrlName) : ButtonControl 770 String ctrlName 771 772 773 Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 774 if(!aExists) 775 return(1) //possibly reverted data, no cursor, no Mask wave 776 endif 777 778 Duplicate/O $(ksCombine1DFolder+":Q_exp_orig"),$(ksCombine1DFolder+":Q_msk") 779 Duplicate/O $(ksCombine1DFolder+":I_exp_orig"),$(ksCombine1DFolder+":I_msk") 780 Duplicate/O $(ksCombine1DFolder+":S_exp_orig"),$(ksCombine1DFolder+":S_msk") 781 Wave Q_msk=$(ksCombine1DFolder+":Q_msk") 782 Wave I_msk=$(ksCombine1DFolder+":I_msk") 783 Wave S_msk=$(ksCombine1DFolder+":S_msk") 784 785 //finish up - trim the data sets and reassign the working set 786 Wave MaskData=$(ksCombine1DFolder+":MaskData") 787 788 RemoveMaskedPoints(MaskData,Q_msk,I_msk,S_msk) 789 790 //reset the number of points 791 NVAR gNq = $(ksCombine1DFolder+":gNq") 792 gNq = numpnts(Q_msk) 793 794 Cursor/K A 795 HideInfo 796 797 return(0) 798 End 799 800 801 // not quite the same as revert 802 Function C1D_ClearMaskProc(ctrlName) : ButtonControl 803 String ctrlName 804 805 SetDataFolder $ksCombine1DFolder 806 807 Wave Q_exp_orig 808 Duplicate/O Q_exp_orig MaskData 809 MaskData = NaN //use all data 810 811 SetDataFolder root: 812 813 return(0) 814 end 815 816 // when the mask tab is selected, A must be on the graph 817 // Displays MaskData wave on the graph 818 // 819 Function C1D_MyMaskProc(ctrlName) : ButtonControl 820 String ctrlName 821 822 823 Wave data=$(ksCombine1DFolder+":I_exp_orig") 824 825 SetDataFolder $ksCombine1DFolder 826 827 Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 828 829 if(aExists) //mask the selected point 830 // toggle NaN (keep) or Data value (= masked) 831 Wave MaskData 832 MaskData[pcsr(A)] = (numType(MaskData[pcsr(A)])==0) ? NaN : data[pcsr(A)] //if NaN, doesn't plot 833 else 834 Wave I_exp_orig,Q_exp_orig 835 Cursor /A=1/H=1/L=1/P/W=V_Combine_1D_Graph A I_exp_orig leftx(I_exp_orig) 836 ShowInfo 837 //if the mask wave does not exist, make one 838 if(exists("MaskData") != 1) 839 Duplicate/O Q_exp_orig MaskData 840 MaskData = NaN //use all data 841 endif 842 Execute "AppendMask()" 843 endif 844 845 SetDataFolder root: 846 847 return(0) 848 End 849 850 // when the mask button is pressed, A must be on the graph 851 // Displays MaskData wave on the graph 852 // 853 Function C1D_MaskLTCursor(ctrlName) : ButtonControl 854 String ctrlName 855 856 857 Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 858 859 if(!aExists) 860 return(1) 861 endif 862 // need to get rid of old smoothed data if data is re-masked 863 // Execute "RemoveSmoothed()" 731 // Button C1DControl_1c,pos={20,95},size={140,20},proc=C1D_MaskLTCursor,title="Mask Q <= Cursor" //bMask 732 // Button C1DControl_1c,help={"Toggles the masking of all q-values LESS than the current cursor location"} 733 // Button C1DControl_1c,disable=1 734 // Button C1DControl_1d,pos={180,35},size={90,20},proc=C1D_ClearMaskProc,title="Clear Mask" //bMask 735 // Button C1DControl_1d,help={"Clears all mask points"} 736 // Button C1DControl_1d,disable=1 737 // Button C1DControl_1e,pos={180,65},size={90,20},proc=C1D_MaskPercent,title="Percent Mask" //bMask 738 // Button C1DControl_1e,help={"Clears all mask points"} 739 // Button C1DControl_1e,disable=1 740 // 741 // 742 //// Button C1DControl_1b,pos={144,66},size={110,20},proc=C1D_MaskDoneButton,title="Done Masking" 743 //// Button C1DControl_1b,disable=1 744 // 745 //// //tab(2) Rescale 746 // Button C1DControl_2a,pos={31,42},size={90,20},proc=C1D_ExtrapolateButtonProc,title="Extrapolate" 747 // Button C1DControl_2a,help={"Extrapolate the high-q region with a power-law"} 748 // Button C1DControl_2a,disable=1 749 // SetVariable C1DControl_2b,pos={31,70},size={100,15},title="# of points" 750 // SetVariable C1DControl_2b,help={"Set the number of points for the power-law extrapolation"} 751 // SetVariable C1DControl_2b,limits={5,100,1},value=_NUM:123 752 // SetVariable C1DControl_2b,disable=1 753 // CheckBox C1DControl_2c,pos={157,45},size={105,14},proc=C1D_ExtrapolationCheckProc,title="Show Extrapolation" 754 // CheckBox C1DControl_2c,help={"Show or hide the high q extrapolation"},value= 1 755 // CheckBox C1DControl_2c,disable=1 756 // SetVariable C1DControl_2d,pos={31,96},size={150,15},title="Power Law Exponent" 757 // SetVariable C1DControl_2d,help={"Power Law exponent from the fit = the DESMEARED slope - override as needed"} 758 // SetVariable C1DControl_2d format="%5.2f" 759 // SetVariable C1DControl_2d,limits={-inf,inf,0},value=_NUM:123 760 // SetVariable C1DControl_2d,disable=1 761 // 762 // Legend/C/N=text0/J/X=72.00/Y=60.00 763 // 764 // 765 // SetDataFolder root: 766 //EndMacro 767 // 768 //// 769 //// recalculate the I(q) binning. no need to adjust model function or views 770 //// just rebin 771 //// 772 //// see V_BinningModePopup() in V_DataPlotting.ipf for a duplicate verison of this function 773 //Function V_CombineModePopup(ctrlName,popNum,popStr) : PopupMenuControl 774 // String ctrlName 775 // Variable popNum // which item is currently selected (1-based) 776 // String popStr // contents of current popup item as string 777 // 778 //// TODO 779 //// x- replace the type with selection from the panel - don't use the current display type 780 // ControlInfo C1DControl_0e 781 // String type = S_Value 782 // 783 // SVAR gStr1 = $(ksCombine1DFolder+":gStr1") 784 // gStr1 = type 785 // 786 // 787 // V_QBinAllPanels(type,popNum) 788 // 789 // 790 // String str,winStr="V_Combine_1D_Graph" 791 // sprintf str,"(\"%s\",%d,\"%s\")",type,popNum,winStr 792 // 793 //// TODO: 794 //// x- replace these calls -- they work with the 1d plot, not this panel. I want them to do basically the same 795 //// exact things, but with a different target window 796 //// *** these calls now take the target window as a parameter - so that there is only one version 797 // Execute ("V_Back_IQ_Graph"+str) 798 // Execute ("V_Middle_IQ_Graph"+str) 799 // Execute ("V_Front_IQ_Graph"+str) 800 // 801 // 802 // return(0) 803 //End 804 // 805 // 806 //// function to control the drawing of buttons in the TabControl on the main panel 807 //// Naming scheme for the buttons MUST be strictly adhered to... else buttons will 808 //// appear in odd places... 809 //// all buttons are named C1DControl_NA where N is the tab number and A is the letter denoting 810 //// the button's position on that particular tab. 811 //// in this way, buttons will always be drawn correctly :-) 812 //// 813 //Function C1D_TabProc(ctrlName,tab) //: TabControl 814 // String ctrlName 815 // Variable tab 816 // 817 // String ctrlList = ControlNameList("",";"),item="",nameStr="" 818 // Variable num = ItemsinList(ctrlList,";"),ii,onTab 819 // for(ii=0;ii<num;ii+=1) 820 // //items all start w/"C1DControl_" //11 characters 821 // item=StringFromList(ii, ctrlList ,";") 822 // nameStr=item[0,10] 823 // if(cmpstr(nameStr,"C1DControl_")==0) 824 // onTab = str2num(item[11]) //12th is a number 825 // ControlInfo $item 826 // switch(abs(V_flag)) 827 // case 1: 828 // Button $item,disable=(tab!=onTab) 829 // break 830 // case 2: 831 // CheckBox $item,disable=(tab!=onTab) 832 // break 833 // case 5: 834 // SetVariable $item,disable=(tab!=onTab) 835 // break 836 // case 10: 837 // TitleBox $item,disable=(tab!=onTab) 838 // break 839 // case 4: 840 // ValDisplay $item,disable=(tab!=onTab) 841 // break 842 // case 3: 843 // PopupMenu $item,disable=(tab!=onTab) 844 // break 845 // // add more items to the switch if different control types are used 846 // endswitch 847 // 848 // endif 849 // endfor 850 // 851 // // remove the mask if I go back to the data? 852 // if(tab==0) 853 // RemoveMask() 854 //// RemoveConcatenated() 855 // endif 856 // 857 // // masking 858 // if(tab==1) 859 // C1D_ClearMaskProc("") //starts with a blank mask 860 // C1D_MyMaskProc("") //start masking if you click on the tab 861 // else 862 // C1D_MaskDoneButton("") //masking is done if you click off the tab 863 // endif 864 // 865 // // rescaling 866 // if(tab == 2) 867 // // TODO 868 // // -- fill this in 869 // // -- this is still in the thought process at this point 870 // 871 //// do rescaling of the different sections of the data set 872 // 873 // endif 874 // 875 // return 0 876 //End 877 // 878 // 879 //Proc AppendConcatenated() 880 // 881 // if( strsearch(TraceNameList("V_Combine_1D_Graph", "", 1),"I_exp_orig",0,2) == -1) //Igor 5 882 // SetDataFolder $(ksCombine1DFolder) 883 // AppendToGraph/W=V_Combine_1D_Graph I_exp_orig vs Q_exp_orig 884 // ModifyGraph mode(I_exp_orig)=3,marker(I_exp_orig)=19,msize(I_exp_orig)=2,opaque(I_exp_orig)=1 885 // ModifyGraph rgb(I_exp_orig)=(0,0,0) 886 // 887 // ModifyGraph tickUnit=1,log=1 888 // Modifygraph grid=1,mirror=2 889 // 890 // ErrorBars/T=0 I_exp_orig Y,wave=(S_exp_orig,S_exp_orig) 891 // 892 // setdatafolder root: 893 // endif 894 //end 895 // 896 //Function RemoveConcatenated() 897 // 864 898 // SetDataFolder $(ksCombine1DFolder) 865 // Killwaves/Z I_smth,Q_smth,S_smth 866 867 SetDataFolder $(ksCombine1DFolder) 868 869 Wave data=I_exp_orig 870 871 Variable pt,ii 872 pt = pcsr(A) 873 for(ii=pt;ii>=0;ii-=1) 874 // toggle NaN (keep) or Data value (= masked) 875 Wave MaskData 876 MaskData[ii] = (numType(MaskData[ii])==0) ? NaN : data[ii] //if NaN, doesn't plot 877 endfor 878 879 SetDataFolder root: 880 return(0) 881 End 882 883 // when the mask button is pressed, A must be on the graph 884 // Displays MaskData wave on the graph 885 // 886 Function C1D_MaskGTCursor(ctrlName) : ButtonControl 887 String ctrlName 888 889 Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 890 891 if(!aExists) 892 return(1) 893 endif 894 // need to get rid of old smoothed data if data is re-masked 895 // Execute "RemoveSmoothed()" 899 // RemoveFromGraph/W=V_Combine_1D_Graph/Z I_exp_orig 900 // setdatafolder root: 901 //end 902 // 903 //Proc AppendMask() 904 // 905 // if( strsearch(TraceNameList("V_Combine_1D_Graph", "", 1),"MaskData",0,2) == -1) //Igor 5 906 // SetDataFolder $(ksCombine1DFolder) 907 // AppendToGraph/W=V_Combine_1D_Graph MaskData vs Q_exp_orig 908 // ModifyGraph mode(MaskData)=3,marker(MaskData)=8,msize(MaskData)=2.5,opaque(MaskData)=1 909 // ModifyGraph rgb(MaskData)=(65535,16385,16385) 910 // 911 // setdatafolder root: 912 // endif 913 //end 914 // 915 // 916 // 917 //Function RemoveMask() 918 // 896 919 // SetDataFolder $(ksCombine1DFolder) 897 // Killwaves/Z I_smth,Q_smth,S_smth 898 899 SetDataFolder $(ksCombine1DFolder) 900 901 Wave data=I_exp_orig 902 903 Wave MaskData 904 905 Variable pt,ii,endPt 906 endPt=numpnts(MaskData) 907 pt = pcsr(A) 908 for(ii=pt;ii<endPt;ii+=1) 909 // toggle NaN (keep) or Data value (= masked) 910 Wave MaskData 911 MaskData[ii] = (numType(MaskData[ii])==0) ? NaN : data[ii] //if NaN, doesn't plot 912 endfor 913 914 SetDataFolder root: 915 916 return(0) 917 End 918 919 // when the mask button is pressed, A must be on the graph 920 // Displays MaskData wave on the graph 921 // 922 Function C1D_MaskPercent(ctrlName) : ButtonControl 923 String ctrlName 924 925 Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 926 927 if(!aExists) 928 return(1) 929 endif 930 931 932 SetDataFolder $(ksCombine1DFolder) 933 934 Wave data=I_exp_orig 935 Wave s_orig = S_exp_orig 936 Wave MaskData 937 938 939 Variable pct,ii,endPt 940 endPt=numpnts(MaskData) 941 942 pct = 0.05 943 944 for(ii=0;ii<endPt;ii+=1) 945 // toggle NaN (keep) or Data value (= masked) 946 947 MaskData[ii] = (abs(s_orig[ii]/data[ii]) < pct) ? NaN : data[ii] //if NaN, doesn't plot 948 endfor 949 950 951 SetDataFolder root: 952 953 return(0) 954 End 955 956 957 958 959 Function CleanUpJunk() 960 961 // clean up the old junk on the graph, /Z for no error 962 // TODO: 963 // -- activate both of these functions to clean old data off of the graph 964 // Execute "RemoveOldData()" 965 Execute "RemoveMask()" 966 967 //remove the cursor 968 Cursor/K A 969 970 //always re-initialize these 971 String/G $(ksCombine1DFolder+":gStr1") = "" 972 973 // clean up the old waves from smoothing and desmearing steps 974 SetDataFolder $(ksCombine1DFolder) 975 Killwaves/Z MaskData,Q_msk,I_msk,S_msk 976 SetDataFolder root: 977 End 978 979 980 981 // I_dsm is the desmeared data 982 // 983 // step (7) - desmearing is done, write out the result 984 // 985 Function C1D_SaveButtonProc(ctrlName) : ButtonControl 986 String ctrlName 987 988 989 String saveStr 990 SVAR curFile = $(ksCombine1DFolder+":gCurFile") 991 saveStr = CleanupName((curFile),0) //the output filename 992 // 993 994 V_Write_VSANSMasked1D(saveStr,0,0,1) //use the full set (lo=hi=0) and present a dialog 995 996 SetDataFolder root: 997 return(0) 998 End 999 1000 Function C1D_HelpButtonProc(ctrlName) : ButtonControl 1001 String ctrlName 1002 1003 DisplayHelpTopic/Z/K=1 "Combining VSANS Data" 1004 if(V_flag !=0) 1005 DoAlert 0,"The Combining VSANS Data Help file could not be found" 1006 endif 1007 return(0) 1008 End 1009 1010 1011 //toggles the log/lin display of the loaded data set 1012 Function C1D_LoadCheckProc(ctrlName,checked) : CheckBoxControl 1013 String ctrlName 1014 Variable checked 1015 1016 ModifyGraph log=(checked) 1017 return(0) 1018 End 1019 1020 1021 1022 1023 1024 // TODO: 1025 // -- either update this to be correct for VSANS, or dispatch to some other data writer. 1026 // 1027 Function V_Write_VSANSMasked1D(fullpath,lo,hi,dialog) 1028 String fullpath 1029 Variable lo,hi,dialog //=1 will present dialog for name 1030 1031 1032 String termStr="\r\n" 1033 String destStr = ksCombine1DFolder 1034 String formatStr = "%15.6g %15.6g %15.6g %15.6g %15.6g %15.6g"+termStr 1035 1036 Variable refNum,integer,realval 1037 1038 //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 1039 WAVE Q_msk=$(destStr + ":Q_msk") 1040 WAVE I_msk=$(destStr + ":I_msk") 1041 WAVE S_msk=$(destStr + ":S_msk") 1042 1043 //check each wave 1044 If(!(WaveExists(Q_msk))) 1045 Abort "Q_msk DNExist in WriteUSANSDesmeared()" 1046 Endif 1047 If(!(WaveExists(I_msk))) 1048 Abort "I_msk DNExist in WriteUSANSDesmeared()" 1049 Endif 1050 If(!(WaveExists(S_msk))) 1051 Abort "S_msk DNExist in WriteUSANSDesmeared()" 1052 Endif 1053 1054 // TODO: 1055 // -- this remnant from desmearing creates fake resolution waves!!! 1056 // -- correctly handle the input resolution waves 1057 // make dummy waves to hold the "fake" resolution, and write it as the last 3 columns 1058 // 1059 Duplicate/O Q_msk,res1,res2,res3 1060 res3 = 1 // "fake" beamstop shadowing 1061 res1 /= 100 //make the sigmaQ so small that there is no smearing 1062 1063 if(dialog) 1064 Open/D refnum as fullpath+".cmb" //won't actually open the file 1065 If(cmpstr(S_filename,"")==0) 1066 //user cancel, don't write out a file 1067 Close/A 1068 Abort "no data file was written" 1069 Endif 1070 fullpath = S_filename 1071 Endif 1072 1073 //write out partial set? 1074 Duplicate/O Q_msk,tq,ti,te 1075 ti=I_msk 1076 te=S_msk 1077 if( (lo!=hi) && (lo<hi)) 1078 redimension/N=(hi-lo+1) tq,ti,te,res1,res2,res3 //lo to hi, inclusive 1079 tq=Q_msk[p+lo] 1080 ti=I_msk[p+lo] 1081 te=S_msk[p+lo] 1082 endif 1083 1084 //tailor the output given the type of data written out... 1085 String samStr="",dateStr="",str1,str2 1086 1087 1088 samStr = fullpath 1089 dateStr="CREATED: "+date()+" at "+time() 1090 1091 1092 1093 //actually open the file 1094 Open refNum as fullpath 1095 1096 fprintf refnum,"%s"+termStr,samStr 1097 // fprintf refnum,"%s"+termStr,str1 1098 // fprintf refnum,"%s"+termStr,str2 1099 fprintf refnum,"%s"+termStr,dateStr 1100 1101 wfprintf refnum, formatStr, tq,ti,te,res1,res2,res3 1102 1103 Close refnum 1104 1105 Killwaves/Z ti,tq,te,res1,res2,res3 1106 1107 Return(0) 1108 End 1109 1110 1111 1112 1113 Function V_GetScalingInOverlap(num2,wave1q,wave1i,wave2q,wave2i) 1114 Variable num2 //largest point number of wave2 in overlap region 1115 Wave wave1q,wave1i,wave2q,wave2i //1 = first dataset, 2= second dataset 1116 1117 Variable ii,ival1,newi,ratio 1118 ratio=0 1119 ii=0 1120 do 1121 //get scaling factor at each point of wave 2 in the overlap region 1122 newi = interp(wave2q[ii],wave1q,wave1i) //get the intensity of wave1 at an overlap point 1123 ratio += newi/wave2i[ii] //get the scale factor 1124 //Print "ratio = ",ratio 1125 ii+=1 1126 while(ii<=num2) 1127 Variable val 1128 val = ratio/(num2+1) // +1 counts for point zero 1129 //Print "val = ",val 1130 1131 Variable tol=1.05 //5% is the preferred number (for Andrew and Lionel, at least) 1132 1133 // ControlInfo/W=NSORT_Panel WarningCheck 1134 // if(( V_Value==1 ) && ( (val > tol) || (val < 1/tol) ) ) 1135 // String str="" 1136 // sprintf str,"The scaling factor is more than a factor of %g from 1. Proceed with caution.\r",tol 1137 // DoAlert 0,str 920 // RemoveFromGraph/W=V_Combine_1D_Graph/Z MaskData 921 // setdatafolder root: 922 //end 923 // 924 // 925 //// concatenate the data, and replace the multiple data sets with the concatenated set 926 //// - then you can proceed to the mask tab 927 //// 928 //Function C1D_ConcatButtonProc(ctrlName) : ButtonControl 929 // String ctrlName 930 // 931 // 932 // ControlInfo C1DControl_0e 933 // String folderStr = S_Value 934 // 935 // SVAR gStr1 = $(ksCombine1DFolder+":gStr1") 936 // gStr1 = folderStr 937 // 938 // 939 // ControlInfo C1DControl_0d 940 // Variable binType = V_BinTypeStr2Num(S_Value) 941 // 942 // V_1DConcatenate("root:Packages:NIST:VSANS:",folderStr,"",binType) 943 // 944 //// sort the data set 945 // V_TmpSort1D("root:Packages:NIST:VSANS:",folderStr) 946 // 947 //// now copy the concatenated data over to the combine folder 948 // Duplicate/O $("root:Packages:NIST:VSANS:"+folderStr+":tmp_q") $(ksCombine1DFolder+":Q_exp") 949 // Duplicate/O $("root:Packages:NIST:VSANS:"+folderStr+":tmp_i") $(ksCombine1DFolder+":I_exp") 950 // Duplicate/O $("root:Packages:NIST:VSANS:"+folderStr+":tmp_s") $(ksCombine1DFolder+":S_exp") 951 // wave Q_exp = $(ksCombine1DFolder+":Q_exp") 952 // Wave I_exp = $(ksCombine1DFolder+":I_exp") 953 // Wave S_exp = $(ksCombine1DFolder+":S_exp") 954 // 955 // 956 //// 957 // Duplicate/O $(ksCombine1DFolder+":Q_exp") $(ksCombine1DFolder+":Q_exp_orig") 958 // Duplicate/O $(ksCombine1DFolder+":I_exp") $(ksCombine1DFolder+":I_exp_orig") 959 // Duplicate/O $(ksCombine1DFolder+":S_exp") $(ksCombine1DFolder+":S_exp_orig") 960 // wave I_exp_orig = $(ksCombine1DFolder+":I_exp_orig") 961 // 962 // Variable nq = numpnts($(ksCombine1DFolder+":Q_exp")) 963 //// 964 // 965 //// // append the (blank) wave note to the intensity wave 966 //// Note I_exp,"BOX=0;SPLINE=0;" 967 //// Note I_exp_orig,"BOX=0;SPLINE=0;" 968 //// 969 //// //add data to the graph 970 // Execute "AppendConcatenated()" 971 // 972 // // TODO: 973 // // -- do I clear off the old data here, or somewhere else? 974 // // clear off the old data from the individual panels 975 // // use ClearAllIQIfDisplayed() 976 // ClearIQIfDisplayed_AllBin(folderStr,"V_Combine_1D_Graph") 977 // 978 // RemoveMask() 979 // 980 // return(0) 981 //End 982 // 983 //// step (1) - get the data from a WORK folder, and plot it 984 //// clear out all of the "old" waves, remove them from the graph first 985 //// 986 //// ??produces Q_exp, I_exp, S_exp waves (and originals "_orig") 987 //// add a dummy wave note that can be changed on later steps 988 //// 989 //Function C1D_LoadButtonProc(ctrlName) : ButtonControl 990 // String ctrlName 991 // 992 // 993 // String qStr,iStr,sStr,sqStr 994 // Variable nq,dqv,numBad,val 995 // 996 // // remove any of the old traces on the graph and delete the waves and reset the global strings 997 // CleanUpJunk() 998 // 999 // SetDataFolder root: 1000 // 1001 // // go get the new data 1002 // Execute "A_LoadOneDDataWithName(\"\",0)" 1003 // 1004 //// TODO: 1005 // // x-Missing something here from the loader - go back to the LakeDesmearing ipf 1006 // SVAR fname = root:Packages:NIST:gLastFileName //this is the 1D file loaded 1007 // 1008 //// 1009 // qStr = CleanupName((fName + "_q"),0) //the q-wave 1010 // iStr = CleanupName((fName + "_i"),0) //the i-wave 1011 // sStr = CleanupName((fName + "_s"),0) //the s-wave 1012 //// sqStr = CleanupName((fName + "sq"),0) //the sq-wave 1013 //// 1014 // String DFStr= CleanupName(fname,0) 1015 //// 1016 // Duplicate/O $("root:"+DFStr+":"+qStr) $(ksCombine1DFolder+":Q_exp") 1017 // Duplicate/O $("root:"+DFStr+":"+iStr) $(ksCombine1DFolder+":I_exp") 1018 // Duplicate/O $("root:"+DFStr+":"+sStr) $(ksCombine1DFolder+":S_exp") 1019 // wave Q_exp = $(ksCombine1DFolder+":Q_exp") 1020 // Wave I_exp = $(ksCombine1DFolder+":I_exp") 1021 // Wave S_exp = $(ksCombine1DFolder+":S_exp") 1022 // 1023 // 1024 //// 1025 // Duplicate/O $(ksCombine1DFolder+":Q_exp") $(ksCombine1DFolder+":Q_exp_orig") 1026 // Duplicate/O $(ksCombine1DFolder+":I_exp") $(ksCombine1DFolder+":I_exp_orig") 1027 // Duplicate/O $(ksCombine1DFolder+":S_exp") $(ksCombine1DFolder+":S_exp_orig") 1028 // wave I_exp_orig = $(ksCombine1DFolder+":I_exp_orig") 1029 // 1030 // nq = numpnts($(ksCombine1DFolder+":Q_exp")) 1031 //// 1032 // 1033 //// // append the (blank) wave note to the intensity wave 1034 //// Note I_exp,"BOX=0;SPLINE=0;" 1035 //// Note I_exp_orig,"BOX=0;SPLINE=0;" 1036 //// 1037 //// //add data to the graph 1038 // Execute "AppendConcatenated()" 1039 // 1040 // SetDataFolder root: 1041 //End 1042 // 1043 //// remove any q-values <= val 1044 //Function RemoveBadQPoints(qw,iw,sw,val) 1045 // Wave qw,iw,sw 1046 // Variable val 1047 // 1048 // Variable ii,num,numBad,qval 1049 // num = numpnts(qw) 1050 // 1051 // ii=0 1052 // numBad=0 1053 // do 1054 // qval = qw[ii] 1055 // if(qval <= val) 1056 // numBad += 1 1057 // else //keep the points 1058 // qw[ii-numBad] = qval 1059 // iw[ii-numBad] = iw[ii] 1060 // sw[ii-numBad] = sw[ii] 1061 // endif 1062 // ii += 1 1063 // while(ii<num) 1064 // //trim the end of the waves 1065 // DeletePoints num-numBad, numBad, qw,iw,sw 1066 // return(numBad) 1067 //end 1068 // 1069 //// if mw = Nan, keep the point, if a numerical value, delete it 1070 //Function RemoveMaskedPoints(mw,qw,iw,sw) 1071 // Wave mw,qw,iw,sw 1072 // 1073 // Variable ii,num,numBad,mask 1074 // num = numpnts(qw) 1075 // 1076 // ii=0 1077 // numBad=0 1078 // do 1079 // mask = mw[ii] 1080 // if(numtype(mask) != 2) //if not NaN 1081 // numBad += 1 1082 // else //keep the points that are NaN 1083 // qw[ii-numBad] = qw[ii] 1084 // iw[ii-numBad] = iw[ii] 1085 // sw[ii-numBad] = sw[ii] 1086 // endif 1087 // ii += 1 1088 // while(ii<num) 1089 // //trim the end of the waves 1090 // DeletePoints num-numBad, numBad, qw,iw,sw 1091 // return(numBad) 1092 //end 1093 // 1094 //// produces the _msk waves that have the new number of data points 1095 //// 1096 //Function C1D_MaskDoneButton(ctrlName) : ButtonControl 1097 // String ctrlName 1098 // 1099 // 1100 // Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 1101 // if(!aExists) 1102 // return(1) //possibly reverted data, no cursor, no Mask wave 1138 1103 // endif 1139 1140 Return val 1141 End 1104 // 1105 // Duplicate/O $(ksCombine1DFolder+":Q_exp_orig"),$(ksCombine1DFolder+":Q_msk") 1106 // Duplicate/O $(ksCombine1DFolder+":I_exp_orig"),$(ksCombine1DFolder+":I_msk") 1107 // Duplicate/O $(ksCombine1DFolder+":S_exp_orig"),$(ksCombine1DFolder+":S_msk") 1108 // Wave Q_msk=$(ksCombine1DFolder+":Q_msk") 1109 // Wave I_msk=$(ksCombine1DFolder+":I_msk") 1110 // Wave S_msk=$(ksCombine1DFolder+":S_msk") 1111 // 1112 // //finish up - trim the data sets and reassign the working set 1113 // Wave MaskData=$(ksCombine1DFolder+":MaskData") 1114 // 1115 // RemoveMaskedPoints(MaskData,Q_msk,I_msk,S_msk) 1116 // 1117 // //reset the number of points 1118 // NVAR gNq = $(ksCombine1DFolder+":gNq") 1119 // gNq = numpnts(Q_msk) 1120 // 1121 // Cursor/K A 1122 // HideInfo 1123 // 1124 // return(0) 1125 //End 1126 // 1127 // 1128 //// not quite the same as revert 1129 //Function C1D_ClearMaskProc(ctrlName) : ButtonControl 1130 // String ctrlName 1131 // 1132 // SetDataFolder $ksCombine1DFolder 1133 // 1134 // Wave Q_exp_orig 1135 // Duplicate/O Q_exp_orig MaskData 1136 // MaskData = NaN //use all data 1137 // 1138 // SetDataFolder root: 1139 // 1140 // return(0) 1141 //end 1142 // 1143 //// when the mask tab is selected, A must be on the graph 1144 //// Displays MaskData wave on the graph 1145 //// 1146 //Function C1D_MyMaskProc(ctrlName) : ButtonControl 1147 // String ctrlName 1148 // 1149 // 1150 // Wave data=$(ksCombine1DFolder+":I_exp_orig") 1151 // 1152 // SetDataFolder $ksCombine1DFolder 1153 // 1154 // Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 1155 // 1156 // if(aExists) //mask the selected point 1157 // // toggle NaN (keep) or Data value (= masked) 1158 // Wave MaskData 1159 // MaskData[pcsr(A)] = (numType(MaskData[pcsr(A)])==0) ? NaN : data[pcsr(A)] //if NaN, doesn't plot 1160 // else 1161 // Wave I_exp_orig,Q_exp_orig 1162 // Cursor /A=1/H=1/L=1/P/W=V_Combine_1D_Graph A I_exp_orig leftx(I_exp_orig) 1163 // ShowInfo 1164 // //if the mask wave does not exist, make one 1165 // if(exists("MaskData") != 1) 1166 // Duplicate/O Q_exp_orig MaskData 1167 // MaskData = NaN //use all data 1168 // endif 1169 // Execute "AppendMask()" 1170 // endif 1171 // 1172 // SetDataFolder root: 1173 // 1174 // return(0) 1175 //End 1176 // 1177 //// when the mask button is pressed, A must be on the graph 1178 //// Displays MaskData wave on the graph 1179 //// 1180 //Function C1D_MaskLTCursor(ctrlName) : ButtonControl 1181 // String ctrlName 1182 // 1183 // 1184 // Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 1185 // 1186 // if(!aExists) 1187 // return(1) 1188 // endif 1189 //// need to get rid of old smoothed data if data is re-masked 1190 //// Execute "RemoveSmoothed()" 1191 //// SetDataFolder $(ksCombine1DFolder) 1192 //// Killwaves/Z I_smth,Q_smth,S_smth 1193 // 1194 // SetDataFolder $(ksCombine1DFolder) 1195 // 1196 // Wave data=I_exp_orig 1197 // 1198 // Variable pt,ii 1199 // pt = pcsr(A) 1200 // for(ii=pt;ii>=0;ii-=1) 1201 // // toggle NaN (keep) or Data value (= masked) 1202 // Wave MaskData 1203 // MaskData[ii] = (numType(MaskData[ii])==0) ? NaN : data[ii] //if NaN, doesn't plot 1204 // endfor 1205 // 1206 // SetDataFolder root: 1207 // return(0) 1208 //End 1209 // 1210 //// when the mask button is pressed, A must be on the graph 1211 //// Displays MaskData wave on the graph 1212 //// 1213 //Function C1D_MaskGTCursor(ctrlName) : ButtonControl 1214 // String ctrlName 1215 // 1216 // Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 1217 // 1218 // if(!aExists) 1219 // return(1) 1220 // endif 1221 //// need to get rid of old smoothed data if data is re-masked 1222 //// Execute "RemoveSmoothed()" 1223 //// SetDataFolder $(ksCombine1DFolder) 1224 //// Killwaves/Z I_smth,Q_smth,S_smth 1225 // 1226 // SetDataFolder $(ksCombine1DFolder) 1227 // 1228 // Wave data=I_exp_orig 1229 // 1230 // Wave MaskData 1231 // 1232 // Variable pt,ii,endPt 1233 // endPt=numpnts(MaskData) 1234 // pt = pcsr(A) 1235 // for(ii=pt;ii<endPt;ii+=1) 1236 // // toggle NaN (keep) or Data value (= masked) 1237 // Wave MaskData 1238 // MaskData[ii] = (numType(MaskData[ii])==0) ? NaN : data[ii] //if NaN, doesn't plot 1239 // endfor 1240 // 1241 // SetDataFolder root: 1242 // 1243 // return(0) 1244 //End 1245 // 1246 //// when the mask button is pressed, A must be on the graph 1247 //// Displays MaskData wave on the graph 1248 //// 1249 //Function C1D_MaskPercent(ctrlName) : ButtonControl 1250 // String ctrlName 1251 // 1252 // Variable aExists= strlen(CsrInfo(A)) > 0 //Igor 5 1253 // 1254 // if(!aExists) 1255 // return(1) 1256 // endif 1257 // 1258 // 1259 // SetDataFolder $(ksCombine1DFolder) 1260 // 1261 // Wave data=I_exp_orig 1262 // Wave s_orig = S_exp_orig 1263 // Wave MaskData 1264 // 1265 // 1266 // Variable pct,ii,endPt 1267 // endPt=numpnts(MaskData) 1268 // 1269 // pct = 0.05 1270 // 1271 // for(ii=0;ii<endPt;ii+=1) 1272 // // toggle NaN (keep) or Data value (= masked) 1273 // 1274 // MaskData[ii] = (abs(s_orig[ii]/data[ii]) < pct) ? NaN : data[ii] //if NaN, doesn't plot 1275 // endfor 1276 // 1277 // 1278 // SetDataFolder root: 1279 // 1280 // return(0) 1281 //End 1282 // 1283 // 1284 // 1285 // 1286 //Function CleanUpJunk() 1287 // 1288 // // clean up the old junk on the graph, /Z for no error 1289 // // TODO: 1290 // // -- activate both of these functions to clean old data off of the graph 1291 //// Execute "RemoveOldData()" 1292 // Execute "RemoveMask()" 1293 // 1294 // //remove the cursor 1295 // Cursor/K A 1296 // 1297 // //always re-initialize these 1298 // String/G $(ksCombine1DFolder+":gStr1") = "" 1299 // 1300 // // clean up the old waves from smoothing and desmearing steps 1301 // SetDataFolder $(ksCombine1DFolder) 1302 // Killwaves/Z MaskData,Q_msk,I_msk,S_msk 1303 // SetDataFolder root: 1304 //End 1305 // 1306 // 1307 // 1308 //// I_dsm is the desmeared data 1309 //// 1310 //// step (7) - desmearing is done, write out the result 1311 //// 1312 //Function C1D_SaveButtonProc(ctrlName) : ButtonControl 1313 // String ctrlName 1314 // 1315 // 1316 // String saveStr 1317 // SVAR curFile = $(ksCombine1DFolder+":gCurFile") 1318 // saveStr = CleanupName((curFile),0) //the output filename 1319 // // 1320 // 1321 // V_Write_VSANSMasked1D(saveStr,0,0,1) //use the full set (lo=hi=0) and present a dialog 1322 // 1323 // SetDataFolder root: 1324 // return(0) 1325 //End 1326 // 1327 //Function C1D_HelpButtonProc(ctrlName) : ButtonControl 1328 // String ctrlName 1329 // 1330 // DisplayHelpTopic/Z/K=1 "Combining VSANS Data" 1331 // if(V_flag !=0) 1332 // DoAlert 0,"The Combining VSANS Data Help file could not be found" 1333 // endif 1334 // return(0) 1335 //End 1336 // 1337 // 1338 ////toggles the log/lin display of the loaded data set 1339 //Function C1D_LoadCheckProc(ctrlName,checked) : CheckBoxControl 1340 // String ctrlName 1341 // Variable checked 1342 // 1343 // ModifyGraph log=(checked) 1344 // return(0) 1345 //End 1346 // 1347 // 1348 // 1349 // 1350 // 1351 //// TODO: 1352 //// -- either update this to be correct for VSANS, or dispatch to some other data writer. 1353 //// 1354 //Function V_Write_VSANSMasked1D(fullpath,lo,hi,dialog) 1355 // String fullpath 1356 // Variable lo,hi,dialog //=1 will present dialog for name 1357 // 1358 // 1359 // String termStr="\r\n" 1360 // String destStr = ksCombine1DFolder 1361 // String formatStr = "%15.6g %15.6g %15.6g %15.6g %15.6g %15.6g"+termStr 1362 // 1363 // Variable refNum,integer,realval 1364 // 1365 // //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 1366 // WAVE Q_msk=$(destStr + ":Q_msk") 1367 // WAVE I_msk=$(destStr + ":I_msk") 1368 // WAVE S_msk=$(destStr + ":S_msk") 1369 // 1370 // //check each wave 1371 // If(!(WaveExists(Q_msk))) 1372 // Abort "Q_msk DNExist in WriteUSANSDesmeared()" 1373 // Endif 1374 // If(!(WaveExists(I_msk))) 1375 // Abort "I_msk DNExist in WriteUSANSDesmeared()" 1376 // Endif 1377 // If(!(WaveExists(S_msk))) 1378 // Abort "S_msk DNExist in WriteUSANSDesmeared()" 1379 // Endif 1380 // 1381 // // TODO: 1382 // // -- this remnant from desmearing creates fake resolution waves!!! 1383 // // -- correctly handle the input resolution waves 1384 // // make dummy waves to hold the "fake" resolution, and write it as the last 3 columns 1385 // // 1386 // Duplicate/O Q_msk,res1,res2,res3 1387 // res3 = 1 // "fake" beamstop shadowing 1388 // res1 /= 100 //make the sigmaQ so small that there is no smearing 1389 // 1390 // if(dialog) 1391 // Open/D refnum as fullpath+".cmb" //won't actually open the file 1392 // If(cmpstr(S_filename,"")==0) 1393 // //user cancel, don't write out a file 1394 // Close/A 1395 // Abort "no data file was written" 1396 // Endif 1397 // fullpath = S_filename 1398 // Endif 1399 // 1400 // //write out partial set? 1401 // Duplicate/O Q_msk,tq,ti,te 1402 // ti=I_msk 1403 // te=S_msk 1404 // if( (lo!=hi) && (lo<hi)) 1405 // redimension/N=(hi-lo+1) tq,ti,te,res1,res2,res3 //lo to hi, inclusive 1406 // tq=Q_msk[p+lo] 1407 // ti=I_msk[p+lo] 1408 // te=S_msk[p+lo] 1409 // endif 1410 // 1411 // //tailor the output given the type of data written out... 1412 // String samStr="",dateStr="",str1,str2 1413 // 1414 // 1415 // samStr = fullpath 1416 // dateStr="CREATED: "+date()+" at "+time() 1417 // 1418 // 1419 // 1420 // //actually open the file 1421 // Open refNum as fullpath 1422 // 1423 // fprintf refnum,"%s"+termStr,samStr 1424 //// fprintf refnum,"%s"+termStr,str1 1425 //// fprintf refnum,"%s"+termStr,str2 1426 // fprintf refnum,"%s"+termStr,dateStr 1427 // 1428 // wfprintf refnum, formatStr, tq,ti,te,res1,res2,res3 1429 // 1430 // Close refnum 1431 // 1432 // Killwaves/Z ti,tq,te,res1,res2,res3 1433 // 1434 // Return(0) 1435 //End 1436 // 1437 // 1438 // 1439 // 1440 //Function V_GetScalingInOverlap(num2,wave1q,wave1i,wave2q,wave2i) 1441 // Variable num2 //largest point number of wave2 in overlap region 1442 // Wave wave1q,wave1i,wave2q,wave2i //1 = first dataset, 2= second dataset 1443 // 1444 // Variable ii,ival1,newi,ratio 1445 // ratio=0 1446 // ii=0 1447 // do 1448 // //get scaling factor at each point of wave 2 in the overlap region 1449 // newi = interp(wave2q[ii],wave1q,wave1i) //get the intensity of wave1 at an overlap point 1450 // ratio += newi/wave2i[ii] //get the scale factor 1451 // //Print "ratio = ",ratio 1452 // ii+=1 1453 // while(ii<=num2) 1454 // Variable val 1455 // val = ratio/(num2+1) // +1 counts for point zero 1456 // //Print "val = ",val 1457 // 1458 // Variable tol=1.05 //5% is the preferred number (for Andrew and Lionel, at least) 1459 // 1460 //// ControlInfo/W=NSORT_Panel WarningCheck 1461 //// if(( V_Value==1 ) && ( (val > tol) || (val < 1/tol) ) ) 1462 //// String str="" 1463 //// sprintf str,"The scaling factor is more than a factor of %g from 1. Proceed with caution.\r",tol 1464 //// DoAlert 0,str 1465 //// endif 1466 // 1467 // Return val 1468 //End 1469 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DataPlotting.ipf
r1038 r1039 460 460 461 461 // clear EVERYTHING 462 // ClearIQIfDisplayed_AllFldr("MLRTB") 463 // ClearIQIfDisplayed_AllFldr("MLR") 464 // ClearIQIfDisplayed_AllFldr("MTB") //this returns to root: 465 // ClearIQIfDisplayed_AllFldr("MT") 466 // ClearIQIfDisplayed_AllFldr("ML") 467 // ClearIQIfDisplayed_AllFldr("MR") 468 // ClearIQIfDisplayed_AllFldr("MB") 462 469 463 470 464 if(binType==1) … … 921 915 if(binType==1 || binType==2 || binType==3) 922 916 923 ClearIQIfDisplayed_AllFldr("B_trim",winNameStr) 917 // ClearIQIfDisplayed_AllFldr("B_trim",winNameStr) 918 CheckDisplayed/W=$winNameStr $("iBin_qxqy_B_trim") 919 if(V_flag==1) 920 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_B_trim") 921 endif 924 922 SetDataFolder $(fullPathToFolder) 925 923 CheckDisplayed/W=$winNameStr iBin_qxqy_B_trim … … 958 956 if(binType==4) 959 957 960 ClearIQIfDisplayed_AllFldr("B_trim",winNameStr) 958 // ClearIQIfDisplayed_AllFldr("B_trim",winNameStr) 959 CheckDisplayed/W=$winNameStr $("iBin_qxqy_B_trim") 960 if(V_flag==1) 961 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_B_trim") 962 endif 961 963 SetDataFolder $("root:Packages:NIST:VSANS:"+type) 962 964 CheckDisplayed/W=$winNameStr iBin_qxqy_B_trim … … 994 996 SetDataFolder $(fullPathToFolder) 995 997 996 // clear EVERYTHING 997 // ClearIQIfDisplayed_AllFldr("MLRTB") 998 // ClearIQIfDisplayed_AllFldr("MLR") 999 // ClearIQIfDisplayed_AllFldr("MTB") //this returns to root: 1000 // ClearIQIfDisplayed_AllFldr("MT") 1001 // ClearIQIfDisplayed_AllFldr("ML") 1002 // ClearIQIfDisplayed_AllFldr("MR") 1003 // ClearIQIfDisplayed_AllFldr("MB") 998 String midList = "ML;MR;MT;MB;MLR;MTB;MLRTB;" 999 String type 1000 Variable ii 1001 1004 1002 1005 1003 if(binType==1) 1006 ClearIQIfDisplayed_AllFldr("MLRTB_trim",winNameStr) 1007 ClearIQIfDisplayed_AllFldr("MLR_trim",winNameStr) 1008 ClearIQIfDisplayed_AllFldr("MTB_trim",winNameStr) //this returns to root: 1009 ClearIQIfDisplayed_AllFldr("MT_trim",winNameStr) 1010 ClearIQIfDisplayed_AllFldr("ML_trim",winNameStr) 1011 ClearIQIfDisplayed_AllFldr("MR_trim",winNameStr) 1012 ClearIQIfDisplayed_AllFldr("MB_trim",winNameStr) 1004 ii=0 1005 do 1006 type = StringFromList(ii, midlist, ";") 1007 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1008 if(V_flag==1) 1009 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1010 endif 1011 ii+=1 1012 while(ii<ItemsInList(midList)) 1013 1014 1013 1015 SetDataFolder $(fullPathToFolder) 1014 1016 CheckDisplayed/W=$winNameStr iBin_qxqy_ML_trim … … 1046 1048 if(binType==2) 1047 1049 // clear EVERYTHING 1048 ClearIQIfDisplayed_AllFldr("MLRTB_trim",winNameStr) 1049 ClearIQIfDisplayed_AllFldr("MLR_trim",winNameStr) 1050 ClearIQIfDisplayed_AllFldr("MTB_trim",winNameStr) //this returns to root: 1051 ClearIQIfDisplayed_AllFldr("MT_trim",winNameStr) 1052 ClearIQIfDisplayed_AllFldr("ML_trim",winNameStr) 1053 ClearIQIfDisplayed_AllFldr("MR_trim",winNameStr) 1054 ClearIQIfDisplayed_AllFldr("MB_trim",winNameStr) 1055 1056 // ClearIQIfDisplayed_AllFldr("MLRTB") 1057 // ClearIQIfDisplayed_AllFldr("MT") 1058 // ClearIQIfDisplayed_AllFldr("ML") 1059 // ClearIQIfDisplayed_AllFldr("MR") 1060 // ClearIQIfDisplayed_AllFldr("MB") 1050 ii=0 1051 do 1052 type = StringFromList(ii, midlist, ";") 1053 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1054 if(V_flag==1) 1055 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1056 endif 1057 ii+=1 1058 while(ii<ItemsInList(midList)) 1059 1060 1061 1061 1062 1062 … … 1089 1089 if(binType==3) 1090 1090 // clear EVERYTHING 1091 ClearIQIfDisplayed_AllFldr("MLRTB_trim",winNameStr) 1092 ClearIQIfDisplayed_AllFldr("MLR_trim",winNameStr) 1093 ClearIQIfDisplayed_AllFldr("MTB_trim",winNameStr) //this returns to root: 1094 ClearIQIfDisplayed_AllFldr("MT_trim",winNameStr) 1095 ClearIQIfDisplayed_AllFldr("ML_trim",winNameStr) 1096 ClearIQIfDisplayed_AllFldr("MR_trim",winNameStr) 1097 ClearIQIfDisplayed_AllFldr("MB_trim",winNameStr) 1098 1099 // ClearIQIfDisplayed_AllFldr("MLR") 1100 // ClearIQIfDisplayed_AllFldr("MTB") 1101 // ClearIQIfDisplayed_AllFldr("MT") 1102 // ClearIQIfDisplayed_AllFldr("ML") 1103 // ClearIQIfDisplayed_AllFldr("MR") 1104 // ClearIQIfDisplayed_AllFldr("MB") 1091 ii=0 1092 do 1093 type = StringFromList(ii, midlist, ";") 1094 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1095 if(V_flag==1) 1096 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1097 endif 1098 ii+=1 1099 while(ii<ItemsInList(midList)) 1100 1105 1101 1106 1102 SetDataFolder $(fullPathToFolder) … … 1126 1122 if(binType==4) // slit aperture binning - MT, ML, MR, MB are averaged 1127 1123 // clear EVERYTHING 1128 ClearIQIfDisplayed_AllFldr("MLRTB_trim",winNameStr) 1129 ClearIQIfDisplayed_AllFldr("MLR_trim",winNameStr) 1130 ClearIQIfDisplayed_AllFldr("MTB_trim",winNameStr) //this returns to root: 1131 ClearIQIfDisplayed_AllFldr("MT_trim",winNameStr) 1132 ClearIQIfDisplayed_AllFldr("ML_trim",winNameStr) 1133 ClearIQIfDisplayed_AllFldr("MR_trim",winNameStr) 1134 ClearIQIfDisplayed_AllFldr("MB_trim",winNameStr) 1135 1136 1137 // ClearIQIfDisplayed_AllFldr("MLRTB") 1138 // ClearIQIfDisplayed_AllFldr("MLR") 1139 // ClearIQIfDisplayed_AllFldr("MTB") 1124 ii=0 1125 do 1126 type = StringFromList(ii, midlist, ";") 1127 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1128 if(V_flag==1) 1129 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1130 endif 1131 ii+=1 1132 while(ii<ItemsInList(midList)) 1133 1134 1140 1135 1141 1136 SetDataFolder $(fullPathToFolder) … … 1190 1185 1191 1186 1187 String frontList = "FL;FR;FT;FB;FLR;FTB;FLRTB;" 1188 String type 1189 Variable ii 1192 1190 // binType = V_GetBinningPopMode() 1193 1191 SetDataFolder $(fullPathToFolder) 1194 1192 1195 // clear EVERYTHING 1196 // ClearIQIfDisplayed_AllFldr("FLRTB") 1197 // 1198 // ClearIQIfDisplayed_AllFldr("FLR") 1199 // ClearIQIfDisplayed_AllFldr("FTB") 1200 // 1201 // ClearIQIfDisplayed_AllFldr("FT") 1202 // ClearIQIfDisplayed_AllFldr("FL") 1203 // ClearIQIfDisplayed_AllFldr("FR") 1204 // ClearIQIfDisplayed_AllFldr("FB") 1193 1205 1194 1206 1195 if(binType==1) 1207 ClearIQIfDisplayed_AllFldr("FLRTB_trim",winNameStr) 1208 1209 ClearIQIfDisplayed_AllFldr("FLR_trim",winNameStr) 1210 ClearIQIfDisplayed_AllFldr("FTB_trim",winNameStr) 1211 1212 ClearIQIfDisplayed_AllFldr("FT_trim",winNameStr) 1213 ClearIQIfDisplayed_AllFldr("FL_trim",winNameStr) 1214 ClearIQIfDisplayed_AllFldr("FR_trim",winNameStr) 1215 ClearIQIfDisplayed_AllFldr("FB_trim",winNameStr) 1196 ii=0 1197 do 1198 type = StringFromList(ii, frontList, ";") 1199 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1200 if(V_flag==1) 1201 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1202 endif 1203 ii+=1 1204 while(ii<ItemsInList(frontList)) 1205 1206 1216 1207 1217 1208 SetDataFolder $(fullPathToFolder) … … 1252 1243 if(binType==2) 1253 1244 // clear EVERYTHING 1254 ClearIQIfDisplayed_AllFldr("FLRTB_trim",winNameStr) 1255 1256 ClearIQIfDisplayed_AllFldr("FLR_trim",winNameStr) 1257 ClearIQIfDisplayed_AllFldr("FTB_trim",winNameStr) 1258 1259 ClearIQIfDisplayed_AllFldr("FT_trim",winNameStr) 1260 ClearIQIfDisplayed_AllFldr("FL_trim",winNameStr) 1261 ClearIQIfDisplayed_AllFldr("FR_trim",winNameStr) 1262 ClearIQIfDisplayed_AllFldr("FB_trim",winNameStr) 1263 // ClearIQIfDisplayed_AllFldr("FLRTB") 1264 // ClearIQIfDisplayed_AllFldr("FT") 1265 // ClearIQIfDisplayed_AllFldr("FL") 1266 // ClearIQIfDisplayed_AllFldr("FR") 1267 // ClearIQIfDisplayed_AllFldr("FB") 1245 ii=0 1246 do 1247 type = StringFromList(ii, frontList, ";") 1248 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1249 if(V_flag==1) 1250 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1251 endif 1252 ii+=1 1253 while(ii<ItemsInList(frontList)) 1254 1255 1268 1256 1269 1257 SetDataFolder $(fullPathToFolder) … … 1295 1283 if(binType==3) 1296 1284 // clear EVERYTHING 1297 ClearIQIfDisplayed_AllFldr("FLRTB_trim",winNameStr) 1298 1299 ClearIQIfDisplayed_AllFldr("FLR_trim",winNameStr) 1300 ClearIQIfDisplayed_AllFldr("FTB_trim",winNameStr) 1301 1302 ClearIQIfDisplayed_AllFldr("FT_trim",winNameStr) 1303 ClearIQIfDisplayed_AllFldr("FL_trim",winNameStr) 1304 ClearIQIfDisplayed_AllFldr("FR_trim",winNameStr) 1305 ClearIQIfDisplayed_AllFldr("FB_trim",winNameStr) 1306 1307 // ClearIQIfDisplayed_AllFldr("FLR") 1308 // ClearIQIfDisplayed_AllFldr("FTB") 1309 // ClearIQIfDisplayed_AllFldr("FT") 1310 // ClearIQIfDisplayed_AllFldr("FL") 1311 // ClearIQIfDisplayed_AllFldr("FR") 1312 // ClearIQIfDisplayed_AllFldr("FB") 1285 ii=0 1286 do 1287 type = StringFromList(ii, frontList, ";") 1288 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1289 if(V_flag==1) 1290 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1291 endif 1292 ii+=1 1293 while(ii<ItemsInList(frontList)) 1294 1295 1313 1296 1314 1297 SetDataFolder $(fullPathToFolder) … … 1334 1317 if(binType==4) // slit aperture binning - MT, ML, MR, MB are averaged 1335 1318 // clear EVERYTHING 1336 ClearIQIfDisplayed_AllFldr("FLRTB_trim",winNameStr) 1337 1338 ClearIQIfDisplayed_AllFldr("FLR_trim",winNameStr) 1339 ClearIQIfDisplayed_AllFldr("FTB_trim",winNameStr) 1340 1341 ClearIQIfDisplayed_AllFldr("FT_trim",winNameStr) 1342 ClearIQIfDisplayed_AllFldr("FL_trim",winNameStr) 1343 ClearIQIfDisplayed_AllFldr("FR_trim",winNameStr) 1344 ClearIQIfDisplayed_AllFldr("FB_trim",winNameStr) 1345 1346 1347 // ClearIQIfDisplayed_AllFldr("FLRTB") 1348 // ClearIQIfDisplayed_AllFldr("FLR") 1349 // ClearIQIfDisplayed_AllFldr("FTB") 1319 ii=0 1320 do 1321 type = StringFromList(ii, frontList, ";") 1322 CheckDisplayed/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1323 if(V_flag==1) 1324 RemoveFromGraph/W=$winNameStr $("iBin_qxqy_"+type+"_trim") 1325 endif 1326 ii+=1 1327 while(ii<ItemsInList(frontList)) 1328 1329 1350 1330 1351 1331 SetDataFolder $(fullPathToFolder) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf
r1034 r1039 6364 6364 ///////// REDUCTION 6365 6365 ///////// REDUCTION 6366 6367 6368 // TODO 6369 // -- come up with a scheme to write the entire protocol to the data file? 6370 // -- or a scheme to write just the missing bits? 6371 6372 6373 // TODO -- needs to be a WAVE, and of the proper size and type!!! 6374 // -- this is a test where I write a wave to a field that does not exist... 6375 Function V_write_TrimWave(fname,inW) 6376 String fname 6377 Wave inW 6378 6379 // String path = "entry:reduction:absolute_scaling" 6380 6381 Duplicate/O inW wTmpWrite 6382 // then use redimension as needed to cast the wave to write to the specified type 6383 // see WaveType for the proper codes 6384 // Redimension/T=() wTmpWrite 6385 // -- May also need to check the dimension(s) before writing (don't trust the input) 6386 String groupName = "/entry/reduction" 6387 String varName = "trim_wave" 6388 6389 variable err 6390 err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 6391 if(err) 6392 Print "HDF write err = ",err 6393 endif 6394 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 6395 // err = V_KillNamedDataFolder(fname) 6396 // if(err) 6397 // Print "DataFolder kill err = ",err 6398 // endif 6399 return(err) 6400 end 6401 6402 6366 6403 6367 6404 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf
r1038 r1039 153 153 // uses the current display if type=="" 154 154 // 155 Function V_ConcatenateForSave( type,binType)156 String type155 Function V_ConcatenateForSave(pathStr,type,tagStr,binType) 156 String pathStr,type,tagStr 157 157 Variable binType 158 158 … … 172 172 // TODO x- figure out which binning was used (this is done in V_1DConcatenate()) 173 173 // clear the old tmp waves first, if they still exist 174 SetDataFolder $("root:Packages:NIST:VSANS:"+type) 174 // SetDataFolder $("root:Packages:NIST:VSANS:"+type) 175 SetDataFolder $(pathStr+type) 175 176 Killwaves/Z tmp_q,tmp_i,tmp_s 176 177 setDataFolder root: 177 V_1DConcatenate( type,binType)178 V_1DConcatenate(pathStr,type,tagStr,binType) 178 179 179 180 // sort the data set 180 V_TmpSort1D( type)181 V_TmpSort1D(pathStr,type) 181 182 182 183 return(0) … … 187 188 // so the type is the currently displayed type, and the binning is from the panel 188 189 // 189 Function V_SimpleSave1DData( type,saveName)190 String type,saveName190 Function V_SimpleSave1DData(pathStr,type,tagStr,saveName) 191 String pathStr,type,tagStr,saveName 191 192 192 193 // … … 195 196 Variable binType = V_GetBinningPopMode() 196 197 197 V_ConcatenateForSave( curType,binType)198 V_ConcatenateForSave(pathStr,curType,tagStr,binType) 198 199 199 200 // write out the data set to a file … … 204 205 endif 205 206 206 V_Write1DData( curtype,saveName)207 V_Write1DData(pathStr,curtype,saveName) 207 208 208 209 End … … 262 263 // otherwise the value is assumed good (from a protocol) 263 264 // 264 // 265 // 266 Function V_1DConcatenate(folderStr,binType) 267 String folderStr 265 // pathStr must have the trailing colon 266 // tagStr is normally null, but is "_trim" for data to be trimmed 267 // 268 Function V_1DConcatenate(pathStr,folderStr,tagStr,binType) 269 String pathStr,folderStr,tagStr 268 270 Variable binType 269 271 … … 272 274 endif 273 275 274 SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 276 // SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 277 SetDataFolder $(pathStr+folderStr) 275 278 276 279 //kill these waves before starting, or the new concatenation will be added to the old … … 280 283 if(binType == 1) 281 284 // q-values 282 waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 283 waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 285 waveListStr = "qBin_qxqy_B" + tagStr + ";" 286 waveListStr += "qBin_qxqy_MB" + tagStr + ";" 287 waveListStr += "qBin_qxqy_MT" + tagStr + ";" 288 waveListStr += "qBin_qxqy_ML" + tagStr + ";" 289 waveListStr += "qBin_qxqy_MR" + tagStr + ";" 290 waveListStr += "qBin_qxqy_FB" + tagStr + ";" 291 waveListStr += "qBin_qxqy_FT" + tagStr + ";" 292 waveListStr += "qBin_qxqy_FL" + tagStr + ";" 293 waveListStr += "qBin_qxqy_FR" + tagStr + ";" 284 294 285 295 Concatenate/NP/O waveListStr, tmp_q 286 296 287 297 //intensity 288 waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 289 waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 298 waveListStr = "iBin_qxqy_B" + tagStr + ";" 299 waveListStr += "iBin_qxqy_MB" + tagStr + ";" 300 waveListStr += "iBin_qxqy_MT" + tagStr + ";" 301 waveListStr += "iBin_qxqy_ML" + tagStr + ";" 302 waveListStr += "iBin_qxqy_MR" + tagStr + ";" 303 waveListStr += "iBin_qxqy_FB" + tagStr + ";" 304 waveListStr += "iBin_qxqy_FT" + tagStr + ";" 305 waveListStr += "iBin_qxqy_FL" + tagStr + ";" 306 waveListStr += "iBin_qxqy_FR" + tagStr + ";" 307 // waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 308 // waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 290 309 291 310 Concatenate/NP/O waveListStr, tmp_i 292 311 293 312 //error 294 waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 295 waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 313 waveListStr = "eBin_qxqy_B" + tagStr + ";" 314 waveListStr += "eBin_qxqy_MB" + tagStr + ";" 315 waveListStr += "eBin_qxqy_MT" + tagStr + ";" 316 waveListStr += "eBin_qxqy_ML" + tagStr + ";" 317 waveListStr += "eBin_qxqy_MR" + tagStr + ";" 318 waveListStr += "eBin_qxqy_FB" + tagStr + ";" 319 waveListStr += "eBin_qxqy_FT" + tagStr + ";" 320 waveListStr += "eBin_qxqy_FL" + tagStr + ";" 321 waveListStr += "eBin_qxqy_FR" + tagStr + ";" 322 // waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 323 // waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 296 324 297 325 Concatenate/NP/O waveListStr, tmp_s … … 300 328 if(binType == 2) 301 329 // q-values 302 waveListStr = "qBin_qxqy_B;qBin_qxqy_MTB;qBin_qxqy_MLR;" 303 waveListStr += "qBin_qxqy_FTB;qBin_qxqy_FLR;" 330 waveListStr = "qBin_qxqy_B" + tagStr + ";" 331 waveListStr += "qBin_qxqy_MTB" + tagStr + ";" 332 waveListStr += "qBin_qxqy_MLR" + tagStr + ";" 333 waveListStr += "qBin_qxqy_FTB" + tagStr + ";" 334 waveListStr += "qBin_qxqy_FLR" + tagStr + ";" 335 336 // waveListStr = "qBin_qxqy_B;qBin_qxqy_MTB;qBin_qxqy_MLR;" 337 // waveListStr += "qBin_qxqy_FTB;qBin_qxqy_FLR;" 304 338 305 339 Concatenate/NP/O waveListStr, tmp_q 306 340 307 341 //intensity 308 waveListStr = "iBin_qxqy_B;iBin_qxqy_MTB;iBin_qxqy_MLR;" 309 waveListStr += "iBin_qxqy_FTB;iBin_qxqy_FLR;" 342 waveListStr = "iBin_qxqy_B" + tagStr + ";" 343 waveListStr += "iBin_qxqy_MTB" + tagStr + ";" 344 waveListStr += "iBin_qxqy_MLR" + tagStr + ";" 345 waveListStr += "iBin_qxqy_FTB" + tagStr + ";" 346 waveListStr += "iBin_qxqy_FLR" + tagStr + ";" 347 348 // waveListStr = "iBin_qxqy_B;iBin_qxqy_MTB;iBin_qxqy_MLR;" 349 // waveListStr += "iBin_qxqy_FTB;iBin_qxqy_FLR;" 310 350 311 351 Concatenate/NP/O waveListStr, tmp_i 312 352 313 353 //error 314 waveListStr = "eBin_qxqy_B;eBin_qxqy_MTB;eBin_qxqy_MLR;" 315 waveListStr += "eBin_qxqy_FTB;eBin_qxqy_FLR;" 354 waveListStr = "eBin_qxqy_B" + tagStr + ";" 355 waveListStr += "eBin_qxqy_MTB" + tagStr + ";" 356 waveListStr += "eBin_qxqy_MLR" + tagStr + ";" 357 waveListStr += "eBin_qxqy_FTB" + tagStr + ";" 358 waveListStr += "eBin_qxqy_FLR" + tagStr + ";" 359 360 // waveListStr = "eBin_qxqy_B;eBin_qxqy_MTB;eBin_qxqy_MLR;" 361 // waveListStr += "eBin_qxqy_FTB;eBin_qxqy_FLR;" 316 362 317 363 Concatenate/NP/O waveListStr, tmp_s … … 320 366 if(binType == 3) 321 367 // q-values 322 waveListStr = "qBin_qxqy_B;qBin_qxqy_MLRTB;qBin_qxqy_FLRTB;" 368 waveListStr = "qBin_qxqy_B" + tagStr + ";" 369 waveListStr += "qBin_qxqy_MLRTB" + tagStr + ";" 370 waveListStr += "qBin_qxqy_FLRTB" + tagStr + ";" 371 372 // waveListStr = "qBin_qxqy_B;qBin_qxqy_MLRTB;qBin_qxqy_FLRTB;" 323 373 324 374 Concatenate/NP/O waveListStr, tmp_q 325 375 326 376 //intensity 327 waveListStr = "iBin_qxqy_B;iBin_qxqy_MLRTB;iBin_qxqy_FLRTB;" 377 waveListStr = "iBin_qxqy_B" + tagStr + ";" 378 waveListStr += "iBin_qxqy_MLRTB" + tagStr + ";" 379 waveListStr += "iBin_qxqy_FLRTB" + tagStr + ";" 380 381 // waveListStr = "iBin_qxqy_B;iBin_qxqy_MLRTB;iBin_qxqy_FLRTB;" 328 382 329 383 Concatenate/NP/O waveListStr, tmp_i 330 384 331 385 //error 332 waveListStr = "eBin_qxqy_B;eBin_qxqy_MLRTB;eBin_qxqy_FLRTB;" 386 waveListStr = "eBin_qxqy_B" + tagStr + ";" 387 waveListStr += "eBin_qxqy_MLRTB" + tagStr + ";" 388 waveListStr += "eBin_qxqy_FLRTB" + tagStr + ";" 389 390 // waveListStr = "eBin_qxqy_B;eBin_qxqy_MLRTB;eBin_qxqy_FLRTB;" 333 391 334 392 Concatenate/NP/O waveListStr, tmp_s … … 341 399 if(binType == 4) 342 400 // q-values 343 waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 344 waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 401 waveListStr = "qBin_qxqy_B" + tagStr + ";" 402 waveListStr += "qBin_qxqy_MB" + tagStr + ";" 403 waveListStr += "qBin_qxqy_MT" + tagStr + ";" 404 waveListStr += "qBin_qxqy_ML" + tagStr + ";" 405 waveListStr += "qBin_qxqy_MR" + tagStr + ";" 406 waveListStr += "qBin_qxqy_FB" + tagStr + ";" 407 waveListStr += "qBin_qxqy_FT" + tagStr + ";" 408 waveListStr += "qBin_qxqy_FL" + tagStr + ";" 409 waveListStr += "qBin_qxqy_FR" + tagStr + ";" 410 // waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" 411 // waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" 345 412 346 413 Concatenate/NP/O waveListStr, tmp_q 347 414 348 415 //intensity 349 waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 350 waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 416 waveListStr = "iBin_qxqy_B" + tagStr + ";" 417 waveListStr += "iBin_qxqy_MB" + tagStr + ";" 418 waveListStr += "iBin_qxqy_MT" + tagStr + ";" 419 waveListStr += "iBin_qxqy_ML" + tagStr + ";" 420 waveListStr += "iBin_qxqy_MR" + tagStr + ";" 421 waveListStr += "iBin_qxqy_FB" + tagStr + ";" 422 waveListStr += "iBin_qxqy_FT" + tagStr + ";" 423 waveListStr += "iBin_qxqy_FL" + tagStr + ";" 424 waveListStr += "iBin_qxqy_FR" + tagStr + ";" 425 // waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" 426 // waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" 351 427 352 428 Concatenate/NP/O waveListStr, tmp_i 353 429 354 430 //error 355 waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 356 waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 431 waveListStr = "eBin_qxqy_B" + tagStr + ";" 432 waveListStr += "eBin_qxqy_MB" + tagStr + ";" 433 waveListStr += "eBin_qxqy_MT" + tagStr + ";" 434 waveListStr += "eBin_qxqy_ML" + tagStr + ";" 435 waveListStr += "eBin_qxqy_MR" + tagStr + ";" 436 waveListStr += "eBin_qxqy_FB" + tagStr + ";" 437 waveListStr += "eBin_qxqy_FT" + tagStr + ";" 438 waveListStr += "eBin_qxqy_FL" + tagStr + ";" 439 waveListStr += "eBin_qxqy_FR" + tagStr + ";" 440 // waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" 441 // waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" 357 442 358 443 Concatenate/NP/O waveListStr, tmp_s … … 375 460 // how to combine the resolution waves (they also need to be concatenated, which is currently not done) 376 461 // 377 Function V_TmpSort1D( folderStr)378 String folderStr379 380 SetDataFolder $( "root:Packages:NIST:VSANS:"+folderStr)462 Function V_TmpSort1D(pathStr,folderStr) 463 String pathStr,folderStr 464 465 SetDataFolder $(pathStr+folderStr) 381 466 382 467 Wave qw = tmp_q … … 395 480 396 481 // TODO 482 // (appears to be unused, in favor of the version that uses the global strings) 397 483 // needs: 398 484 // -- trim the beamstop out (based on shadow?) … … 642 728 // -- AND WILL OVERWITE DATA WITH THE SAME NAME 643 729 // 644 Function V_Write1DData( folderStr,saveName)645 String folderStr,saveName730 Function V_Write1DData(pathStr,folderStr,saveName) 731 String pathStr,folderStr,saveName 646 732 647 733 String formatStr="",fullpath="" 648 734 Variable refnum,dialog=1 649 735 650 SetDataFolder $( "root:Packages:NIST:VSANS:"+folderStr)736 SetDataFolder $(pathStr+folderStr) 651 737 652 738 Wave qw = tmp_q … … 702 788 fprintf refnum,"Combined data written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 703 789 704 // TODO -- make this work for 6-columns 790 // TODO -- make this work for 6-columns (or??) 705 791 // formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n" 706 792 // fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n" … … 715 801 716 802 // KillWaves/Z sigQ,qbar,fs 803 Print "Data written to: ",fullpath 717 804 718 805 SetDataFolder root: … … 728 815 // 729 816 // this will bypass save dialogs 730 // -- AND WILL OVERW ITE DATA WITH THE SAME NAME731 // 732 Function V_Write1DData_NoConcat( folderStr,saveName,binType)733 String folderStr,saveName817 // -- AND WILL OVERWRITE DATA WITH THE SAME NAME 818 // 819 Function V_Write1DData_NoConcat(pathStr,folderStr,saveName,binType) 820 String pathStr,folderStr,saveName 734 821 Variable binType 735 822 … … 737 824 Variable refnum,dialog=1 738 825 739 SetDataFolder $( "root:Packages:NIST:VSANS:"+folderStr)826 SetDataFolder $(pathStr+folderStr) 740 827 741 828 … … 1003 1090 1004 1091 // given strings of the number of points to remove, loop over the detectors 1092 // 1093 // TODO 1094 // -- currently uses global strings or default strings 1095 // -- if proper strings (non-null) are passed in, they are used, otherwise global, then default 1005 1096 Function V_Trim1DDataStr(folderStr,binType,nBegStr,nEndStr) 1006 1097 String folderStr … … 1024 1115 return(0) 1025 1116 endif 1026 1027 //use default values if null string passed in 1117 1118 1119 //use global, then default values if null string passed in 1028 1120 if(strlen(nBegStr)==0) 1029 nBegStr = ksBinTrimBegDefault 1030 nEndStr = ksBinTrimEndDefault 1121 SVAR/Z gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr 1122 SVAR/Z gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr 1123 1124 if(!SVAR_exists(gBegPtsStr) || !SVAR_exists(gEndPtsStr) || strlen(gBegPtsStr)==0 || strlen(gEndPtsStr)==0) 1125 nBegStr = ksBinTrimBegDefault 1126 nEndStr = ksBinTrimEndDefault 1127 else 1128 nBegStr = gBegPtsStr 1129 nEndStr = gEndPtsStr 1130 endif 1031 1131 endif 1032 1132 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf
r1023 r1039 302 302 String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr = "AVTYPE=Circular;SAVE=Yes;NAME=Auto;PLOT=Yes;" 303 303 304 String/G root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr="" 305 String/G root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr="" 306 304 307 Return(0) 305 308 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf
r1033 r1039 113 113 String ctrlName 114 114 115 ShowNSORTPanel() 115 // ShowNSORTPanel() 116 V_CombineDataGraph() 116 117 End 117 118 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf
r1038 r1039 2437 2437 // TODO: 2438 2438 // -- fill in all of the cases, default is only the "standard" circular average I(q) 2439 // -- get the trim strings from somewhere-- from the file or from the protocol?? 2440 // then replace the null strings being passed 2439 2441 2440 2442 if(cmpstr(saveType,"Yes - Concatenate")==0) 2441 V_Trim1DDataStr(activeType,binType,"","") // TODO -- passing null strings uses default trimmings2443 V_Trim1DDataStr(activeType,binType,"","") // TODO -- passing null strings uses global or default trim values 2442 2444 // V_Trim1DData(activeType,binType,nBeg,nEnd) 2443 V_ConcatenateForSave( activeType,binType) // this removes q=0 point, concatenates, sorts2444 V_Write1DData( activeType,newFileName+"."+exten) //don't pass the full path, just the name2445 V_ConcatenateForSave("root:Packages:NIST:VSANS:",activeType,"",binType) // this removes q=0 point, concatenates, sorts 2446 V_Write1DData("root:Packages:NIST:VSANS:",activeType,newFileName+"."+exten) //don't pass the full path, just the name 2445 2447 else 2446 2448 // remove the q=0 point from the back detector, if it's there 2447 // does not need to know binType2448 2449 // does not trim any of the data 2449 2450 V_RemoveQ0_B(activeType) 2450 V_Write1DData_NoConcat( activeType,newFileName,binType)2451 V_Write1DData_NoConcat("root:Packages:NIST:VSANS:",activeType,newFileName,binType) 2451 2452 endif 2452 2453 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf
r1035 r1039 999 999 // click code here 1000 1000 1001 V_SimpleSave1DData(" ","")1001 V_SimpleSave1DData("root:Packages:NIST:VSANS:","","","") 1002 1002 1003 1003 break
Note: See TracChangeset
for help on using the changeset viewer.