Changeset 1019 for sans/Dev/trunk
- Timestamp:
- Jan 17, 2017 8:37:19 AM (6 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf
r999 r1019 1188 1188 // just like in CircSectAve.ipf 1189 1189 // TODO: 1190 // -- Errors were NOT properly acculumated above, so this loop of calculations is NOT MEANINGFUL (yet) 1190 // -- 2D Errors were NOT properly acculumated above, so this loop of calculations is NOT MEANINGFUL (yet) 1191 // x- the error on the 1D intensity, is correctly calculated as the standard error of the mean. 1191 1192 for(ii=0;ii<nq;ii+=1) 1192 1193 if(nBin_qxqy[ii] == 0) … … 1203 1204 else 1204 1205 //assume that the intensity in each pixel in annuli is normally distributed about mean... 1206 // -- this is correctly calculating the error as the standard error of the mean, as 1207 // was always done for SANS as well. 1205 1208 iBin_qxqy[ii] /= nBin_qxqy[ii] 1206 1209 avesq = iBin_qxqy[ii]^2 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf
r1002 r1019 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 3 // 4 // ******** 5 // TODO -- figure out how much of this file is really used, and how much is 6 // simply garbage now. I make "fake" data files by starting with a real data file 7 // written from NICE, and then I re-write proper values and data arrays to it from 8 // simulations in VCALC. So I do not need to define the structure myself. 9 // 10 // JAN 2017 11 // 12 // 13 // 14 // 15 // 2 16 3 17 // … … 200 214 201 215 202 // TODO 203 // currently, there are no dummy fill values or attributes for the fake DIV file 204 // 205 Proc Setup_VSANS_DIV_Struct() 206 207 // lays out the tree and fills with dummy values 208 H_Setup_VSANS_DIV_Structure() 209 210 // writes in the attributes 211 // H_Fill_VSANS_Attributes() 212 213 // fill in with VCALC simulation bits 214 // H_Fill_VSANS_wSim() 215 216 End 217 218 Proc Save_VSANS_DIV_Nexus(fileName) 219 String fileName="Test_VSANS_DIV_file" 220 221 // save as HDF5 (no attributes saved yet) 222 Save_VSANS_file("root:VSANS_DIV_file", fileName+".h5") 223 224 // // read in a data file using the gateway-- reads from the home path 225 // H_HDF5Gate_Read_Raw(fileName+".h5") 226 // 227 // // after reading in a "partial" file using the gateway (to generate the xref) 228 // // Save the xref to disk (for later use) 229 // Save_HDF5___xref("root:"+fileName,"HDF5___xref") 230 // 231 // // after you've generated the HDF5___xref, load it in and copy it 232 // // to the necessary folder location. 233 // Copy_HDF5___xref("root:VSANS_DIV_file", "HDF5___xref") 234 // 235 // // writes out the contents of a data folder using the gateway 236 // H_HDF5Gate_Write_Raw("root:VSANS_DIV_file", fileName+".h5") 237 // 238 // // re-load the data file using the gateway-- reads from the home path 239 // // now with attributes 240 // H_HDF5Gate_Read_Raw(fileName+".h5") 241 242 End 243 244 ////////////// fake DIV file tests 245 // 246 // 247 // Make/O/T/N=1 file_name = "VSANS_DIV_test.h5" 248 // 249 // simple generation of a fake div file. for sans, nothing other than the creation date was written to the 250 // file header. nothing more is needed (possibly) 251 // 252 // TODO -- I want to re-visit the propagation of errors in the DIV file. No errors are ever calculated/saved 253 // during the generation of the file, but there's no reason it couldn't. the idea is that the plex 254 // is counted so long that the errors are insignificant compared to the data errors, but that may not 255 // always be the case. A bit of math may prove this. or not. Plus, the situation for VSANS may be different. 256 // 257 // 258 // TODO -- make the number of pixels GLOBAL 259 // TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the 260 // 9 data sets to become the DIV file contents. More complexity here than for the simple SANS case. 261 // 262 Proc H_Setup_VSANS_DIV_Structure() 263 264 NewDataFolder/O/S root:VSANS_DIV_file 265 266 NewDataFolder/O/S root:VSANS_DIV_file:entry 267 Make/O/T/N=1 title = "This is a fake DIV file for VSANS" 268 Make/O/T/N=1 start_date = "2015-02-28T08:15:30-5:00" 269 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument 270 Make/O/T/N=1 name = "NG3_VSANS" 271 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B 272 Make/O/D/N=(150,150) data = 1 + (enoise(0.1)) 273 Make/O/D/N=(150,150) linear_data_error = 0.01*abs(gnoise(1)) 274 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR 275 Make/O/D/N=(48,128) data = 1 + (enoise(0.1)) 276 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1)) 277 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML 278 Make/O/D/N=(48,128) data = 1 + (enoise(0.1)) 279 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1)) 280 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT 281 Make/O/D/N=(128,48) data = 1 + (enoise(0.1)) 282 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1)) 283 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB 284 Make/O/D/N=(128,48) data = 1 + (enoise(0.1)) 285 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1)) 286 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR 287 Make/O/D/N=(48,128) data = 1 + (enoise(0.1)) 288 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1)) 289 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL 290 Make/O/D/N=(48,128) data = 1 + (enoise(0.1)) 291 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1)) 292 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT 293 Make/O/D/N=(128,48) data = 1 + (enoise(0.1)) 294 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1)) 295 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB 296 Make/O/D/N=(128,48) data = 1 + (enoise(0.1)) 297 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1)) 298 299 SetDataFolder root: 300 301 End 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 // 317 // saves a specified folder, with a given filename. 318 // saves to the home path 319 // 320 Proc Save_VSANS_file(dfPath, filename) 321 String dfPath ="root:VSANS_file" // e.g., "root:FolderA" or ":" 322 String filename = "Test_VSANS_file.h5" 323 324 H_NXSANS_SaveGroupAsHDF5(dfPath, filename) 325 End 326 327 328 // 329 // this is my procedure to save the folders to HDF5, once I've filled the folder tree 330 // 331 // this does NOT save attributes, but gets the folder structure correct 332 // 333 Function H_NXSANS_SaveGroupAsHDF5(dfPath, filename) 334 String dfPath // e.g., "root:FolderA" or ":" 335 String filename 336 337 Variable result = 0 // 0 means no error 338 339 Variable fileID 340 HDF5CreateFile/P=home /O /Z fileID as filename 341 if (V_flag != 0) 342 Print "HDF5CreateFile failed" 343 return -1 344 endif 345 346 HDF5SaveGroup /IGOR=0 /O /R /Z $dfPath, fileID, "." 347 // HDF5SaveGroup /O /R /Z $dfPath, fileID, "." 348 if (V_flag != 0) 349 Print "HDF5SaveGroup failed" 350 result = -1 351 endif 352 353 HDF5CloseFile fileID 354 355 return result 356 End 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 357 231 358 232 // passing null file string presents a dialog -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf
r1002 r1019 62 62 #include "V_MaskUtils" 63 63 64 // DIV files 65 #include "V_DIVUtils" 66 64 67 // more functionality 65 68 #include "V_FileCatalog" 66 #include "V_PatchFiles" //still in progress and won't compile 69 #include "V_PatchFiles" 70 #include "V_ShowDataTree" 71 72 #include "V_Correct" -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf
r999 r1019 1108 1108 //before proceeding 1109 1109 1110 //DoAlert 0,"This has not yet been updated for VSANS"1110 Abort "This has not yet been updated for VSANS" 1111 1111 1112 1112 Variable err … … 1167 1167 data /= div_data 1168 1168 1169 //data_err /= div_data1169 data_err /= div_data 1170 1170 1171 1171 Return(0) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf
r1018 r1019 22 22 return(0) 23 23 end 24 24 25 Function proto_V_get_FP2(str,str2) 25 26 String str,str2 26 27 return(0) 27 28 end 29 28 30 //Function/S proto_V_get_STR(str) 29 31 // String str -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf
r1012 r1019 305 305 End 306 306 307 308 Proc DataTree_MainButtonProc(ctrlName) : ButtonControl 309 String ctrlName 310 311 V_ShowDataFolderTree() 312 End 313 307 314 //////////////////////////////////////////////// 308 315 //************* NEW version of Main control Panel ***************** … … 348 355 Button MainButton_0e,pos={15,210},size={130,20},proc=CatSort_MainButtonProc,title="Sort Catalog" 349 356 Button MainButton_0e,help={"Sort the Data Catalog, courtesy of ANSTO"} 350 357 Button MainButton_0f,pos={170,90},size={90,20},proc=DataTree_MainButtonProc,title="Data Tree" 358 Button MainButton_0f,help={"Show the header and data tree"} 351 359 352 360 … … 434 442 Button MainButton_4b,disable=1 435 443 Button MainButton_4c,disable=1 436 Button MainButton_4d,disable=1444 // Button MainButton_4d,disable=1 437 445 Button MainButton_4e,disable=1 438 446 Button MainButton_4f,disable=1 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_NexusFromIgor.ipf
r985 r1019 3278 3278 3279 3279 3280 3281 3282 3283 ////////// 3284 // 3285 // These procedures are needed to write out MASK and DIV files 3286 // 3287 //////// 3288 3289 3290 // 3291 // saves a specified folder, with a given filename. 3292 // saves to the home path 3293 // 3294 Proc Save_VSANS_file(dfPath, filename) 3295 String dfPath ="root:VSANS_file" // e.g., "root:FolderA" or ":" 3296 String filename = "Test_VSANS_file.h5" 3297 3298 H_NXSANS_SaveGroupAsHDF5(dfPath, filename) 3299 End 3300 3301 3302 // 3303 // this is my procedure to save the folders to HDF5, once I've filled the folder tree 3304 // 3305 // this does NOT save attributes, but gets the folder structure correct 3306 // 3307 Function H_NXSANS_SaveGroupAsHDF5(dfPath, filename) 3308 String dfPath // e.g., "root:FolderA" or ":" 3309 String filename 3310 3311 Variable result = 0 // 0 means no error 3312 3313 Variable fileID 3314 HDF5CreateFile/P=home /O /Z fileID as filename 3315 if (V_flag != 0) 3316 Print "HDF5CreateFile failed" 3317 return -1 3318 endif 3319 3320 HDF5SaveGroup /IGOR=0 /O /R /Z $dfPath, fileID, "." 3321 // HDF5SaveGroup /O /R /Z $dfPath, fileID, "." 3322 if (V_flag != 0) 3323 Print "HDF5SaveGroup failed" 3324 result = -1 3325 endif 3326 3327 HDF5CloseFile fileID 3328 3329 return result 3330 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_PatchFiles.ipf
r1018 r1019 150 150 NewPanel /W=(533,50,1140,588)/K=2 as "Patch Raw VSANS Data Files" 151 151 DoWindow/C V_Patch_Panel 152 ShowTools/A152 // ShowTools/A 153 153 SetDataFolder root:Packages:NIST:VSANS:Globals:Patch: 154 154 … … 187 187 CheckBox check2,pos={138,80},size={40,15},title="SDD",value= 0,mode=1,proc=V_MatchCheckProc 188 188 189 PopupMenu popup_0,pos={450,85},size={109,20},title="Detector Panel",proc=V_PatchPopMenuProc 190 PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;B;\"" 191 189 192 190 193 TabControl PatchTab,pos={20,120},size={570,400} … … 201 204 // put these in a tabbed? section for the 9 different panels 202 205 // will it be able to patch all "FL" with the proper values, then all "FR", etc. to batchwise correct files? 203 // PopupMenu popup_0,pos={30,base-step-10},size={109,20},title="Detector Panel",proc=PatchPopMenuProc204 // PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;B;\""205 206 206 207 // TODO: add functions for these, make the intent a popup (since it's an enumerated type) … … 494 495 // fill list boxes based on the tab 495 496 // 497 // TODO -- 496 498 // DETECTORS 497 499 // … … 512 514 fname = S_path + fname 513 515 514 Variable nRows = 3516 Variable nRows = 12 515 517 Redimension/N=(nRows,3) ListWave 516 518 Redimension/N=(nRows,3) selWave … … 521 523 SelWave[][2] = 2^1 // 3rd column editable 522 524 523 524 listWave[0][1] = "count_time" 525 listWave[0][2] = num2str(V_getCount_time(fname)) 525 ControlInfo popup_0 // which detector panel? 526 String detStr = S_value 527 528 listWave[0][1] = "beam_center_x" 529 listWave[0][2] = num2str(V_getDet_Beam_center_x(fname,detStr)) 530 531 listWave[1][1] = "beam_center_y" 532 listWave[1][2] = num2str(V_getDet_Beam_center_y(fname,detStr)) 533 534 listWave[2][1] = "distance (nominal)" 535 listWave[2][2] = num2str(V_getDet_NominalDistance(fname,detStr)) 536 537 listWave[3][1] = "integrated_count" 538 listWave[3][2] = num2str(V_getDet_IntegratedCount(fname,detStr)) 539 540 listWave[4][1] = "pixel_fwhm_x" 541 listWave[4][2] = num2str(V_getDet_pixel_fwhm_x(fname,detStr)) 542 543 listWave[5][1] = "pixel_fwhm_y" 544 listWave[5][2] = num2str(V_getDet_pixel_fwhm_y(fname,detStr)) 545 546 listWave[6][1] = "pixel_num_x" 547 listWave[6][2] = num2str(V_getDet_pixel_num_x(fname,detStr)) 548 549 listWave[7][1] = "pixel_num_y" 550 listWave[7][2] = num2str(V_getDet_pixel_num_y(fname,detStr)) 551 552 listWave[8][1] = "setback" 553 listWave[8][2] = num2str(V_getDet_TBSetback(fname,detStr)) 554 555 if(cmpstr(detStr,"B") == 0 ||cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0 || cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) 556 listWave[9][1] = "lateral_offset" // "B" detector drops here 557 listWave[9][2] = num2str(V_getDet_LateralOffset(fname,detStr)) 558 else 559 listWave[9][1] = "vertical_offset" 560 listWave[9][2] = num2str(V_getDet_VerticalOffset(fname,detStr)) 561 endif 562 563 listWave[10][1] = "x_pixel_size" 564 listWave[10][2] = num2str(V_getDet_x_pixel_size(fname,detStr)) 565 566 listWave[11][1] = "y_pixel_size" 567 listWave[11][2] = num2str(V_getDet_y_pixel_size(fname,detStr)) 568 526 569 527 570 return(0) … … 531 574 // fill list boxes based on the tab 532 575 // 576 // TODO -- 533 577 // PolSANS 534 578 // … … 1294 1338 End 1295 1339 1296 // TODO -- not yet implemented1340 // DETECTOR 1297 1341 Function V_WriteHeaderForPatch_4(fname) 1298 1342 String fname 1343 1344 Variable val,err 1345 String str 1346 1347 Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave 1348 Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave 1349 1350 ControlInfo popup_0 1351 String detStr = S_Value 1352 1353 // test bit 4 to see if the checkbox is selected 1354 if ((selWave[0][0] & 2^4) != 0) // Test if bit 4 is set 1355 val = str2num(listWave[0][2]) // "beam_center_x" 1356 err = V_writeDet_beam_center_x(fname,detStr,val) 1357 endif 1358 1359 if ((selWave[1][0] & 2^4) != 0) // "beam_center_y" 1360 val = str2num(listWave[1][2]) 1361 err = V_writeDet_beam_center_y(fname,detStr,val) 1362 endif 1363 1364 if ((selWave[2][0] & 2^4) != 0) //"distance (nominal)" 1365 val = str2num(listWave[2][2]) 1366 err = V_writeDet_distance(fname,detStr,val) 1367 endif 1368 1369 if ((selWave[3][0] & 2^4) != 0) //"integrated_count" 1370 val = str2num(listWave[3][2]) 1371 err = V_writeDet_IntegratedCount(fname,detStr,val) 1372 endif 1373 1374 if ((selWave[4][0] & 2^4) != 0) //"pixel_fwhm_x" 1375 val = str2num(listWave[4][2]) 1376 err = V_writeDet_pixel_fwhm_x(fname,detStr,val) 1377 endif 1378 1379 if ((selWave[5][0] & 2^4) != 0) //"pixel_fwhm_y" 1380 val = str2num(listWave[5][2]) 1381 err = V_writeDet_pixel_fwhm_y(fname,detStr,val) 1382 endif 1383 1384 if ((selWave[6][0] & 2^4) != 0) //"pixel_num_x" 1385 val = str2num(listWave[6][2]) 1386 err = V_writeDet_pixel_num_x(fname,detStr,val) 1387 endif 1388 1389 if ((selWave[7][0] & 2^4) != 0) //"pixel_num_y" 1390 val = str2num(listWave[7][2]) 1391 err = V_writeDet_pixel_num_y(fname,detStr,val) 1392 endif 1393 1394 if ((selWave[8][0] & 2^4) != 0) //"setback" -- only for TB detectors 1395 val = str2num(listWave[8][2]) 1396 if(cmpstr(detStr,"FT") == 0 || cmpstr(detStr,"FB") == 0 || cmpstr(detStr,"MT") == 0 || cmpstr(detStr,"MB") == 0) 1397 err = V_writeDet_TBSetback(fname,detStr,val) 1398 endif 1399 endif 1400 1401 if ((selWave[9][0] & 2^4) != 0) //"lateral_offset" or "vertical_offset" 1402 val = str2num(listWave[9][2]) 1403 if(cmpstr(detStr,"B") == 0 ||cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0 || cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) 1404 err = V_writeDet_LateralOffset(fname,detStr,val) 1405 else 1406 err = V_writeDet_VerticalOffset(fname,detStr,val) 1407 endif 1408 endif 1409 1410 if ((selWave[10][0] & 2^4) != 0) //"x_pixel_size" 1411 val = str2num(listWave[10][2]) 1412 err = V_writeDet_x_pixel_size(fname,detStr,val) 1413 endif 1414 1415 if ((selWave[11][0] & 2^4) != 0) //"y_pixel_size" 1416 val = str2num(listWave[11][2]) 1417 err = V_writeDet_y_pixel_size(fname,detStr,val) 1418 endif 1419 1420 1421 1299 1422 1300 1423 return(0) … … 1463 1586 1464 1587 1588 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1589 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1590 /////////////// 1591 // 1592 // this is a block to patch waves to the file headers, and can patch multiple files 1593 // 1594 // uses a simple panel to show what the table of values is. 1595 // "read" will read only the first run number contents. 1596 // 1597 // TODO -- need to clear out the contents from RawVSANS, or else re-reading to check the values 1598 // will read locally, and it will look like nothing was written. Executing "save" will also 1599 // trigger a cleanout. 1600 // 1601 // TODO - link this to a panel somewhere - a button? menu item? will there be a lot more of these little panels? 1602 // 1603 Proc V_PatchDetectorDeadtime(firstFile,lastFile,detStr,deadtimeStr) 1604 Variable firstFile=1,lastFile=100 1605 String detStr = "FL",deadtimeStr="deadTimeWave" 1606 1607 V_fPatchDetectorDeadtime(firstFile,lastFile,detStr,$deadtimeStr) 1608 1609 End 1610 1611 Proc V_ReadDetectorDeadtime(firstFile,lastFile,detStr) 1612 Variable firstFile=1,lastFile=100 1613 String detStr = "FL" 1614 1615 V_fReadDetectorDeadtime(firstFile,lastFile,detStr) 1616 End 1617 1618 // simple utility to patch the detector deadtime in the file headers 1619 // pass in the account name as a string 1620 // lo is the first file number 1621 // hi is the last file number (inclusive) 1622 // 1623 Function V_fPatchDetectorDeadtime(lo,hi,detStr,deadtimeW) 1624 Variable lo,hi 1625 String detStr 1626 Wave deadtimeW 1627 1628 Variable ii 1629 String fname 1630 1631 //loop over all files 1632 for(ii=lo;ii<=hi;ii+=1) 1633 fname = V_FindFileFromRunNumber(ii) 1634 if(strlen(fname) != 0) 1635 V_writeDetector_deadtime(fname,detStr,deadtimeW) 1636 else 1637 printf "run number %d not found\r",ii 1638 endif 1639 endfor 1640 1641 return(0) 1642 End 1643 1644 // simple utility to read the detector deadtime stored in the file header 1645 Function V_fReadDetectorDeadtime(lo,hi,detStr) 1646 Variable lo,hi 1647 String detStr 1648 1649 String fname 1650 Variable ii 1651 1652 for(ii=lo;ii<=hi;ii+=1) 1653 fname = V_FindFileFromRunNumber(ii) 1654 if(strlen(fname) != 0) 1655 Wave deadtimeW = V_getDetector_deadtime(fname,detStr) 1656 Duplicate/O deadTimeW root:Packages:NIST:VSANS:Globals:Patch:deadtimeWave 1657 // printf "File %d: Detector Dead time (s) = %g\r",ii,deadtime 1658 else 1659 printf "run number %d not found\r",ii 1660 endif 1661 endfor 1662 1663 return(0) 1664 End 1665 1666 1667 1668 Macro V_PatchDetectorDeadtimePanel() 1669 DoWindow/F Patch_Deadtime 1670 if(V_flag==0) 1671 1672 NewDataFolder/O/S root:Packages:NIST:VSANS:Globals:Patch 1673 1674 Make/O/D/N=48 deadTimeWave 1675 1676 SetDataFolder root: 1677 1678 Execute "V_DeadtimePatchPanel()" 1679 endif 1680 End 1681 1682 1683 // 1684 // TODO - needs some minor adjustment to be of practical use, but a proof of concept 1685 // 1686 Proc V_DeadtimePatchPanel() : Panel 1687 PauseUpdate; Silent 1 // building window... 1688 1689 1690 NewPanel /W=(600,400,1000,1000)/N=DeadtimePanel/K=1 1691 // ShowTools/A 1692 1693 PopupMenu popup_0,pos={20,20},size={109,20},title="Detector Panel" 1694 PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;\"" 1695 1696 Button button0,pos={22.00,62.00},size={50.00,20.00},proc=V_ReadDTButtonProc,title="Read" 1697 Button button0_1,pos={95.00,62.00},size={50.00,20.00},proc=V_WriteDTButtonProc,title="Write" 1698 SetVariable setvar0,pos={19.00,128.00},size={100.00,14.00},title="first" 1699 SetVariable setvar0,value= K0 1700 SetVariable setvar1,pos={20.00,154.00},size={100.00,14.00},title="last" 1701 SetVariable setvar1,value= K1 1702 1703 1704 1705 // display the wave 1706 Edit/W=(180,40,380,550)/HOST=# root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave 1707 ModifyTable width(Point)=0 1708 ModifyTable width(root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave)=120 1709 RenameWindow #,T0 1710 SetActiveSubwindow ## 1711 1712 1713 EndMacro 1714 1715 1716 Function V_ReadDTButtonProc(ba) : ButtonControl 1717 STRUCT WMButtonAction &ba 1718 1719 switch( ba.eventCode ) 1720 case 2: // mouse up 1721 // click code here 1722 1723 ControlInfo popup_0 1724 String detStr = S_Value 1725 ControlInfo setvar0 1726 Variable lo=V_Value 1727 Variable hi=lo 1728 1729 V_fReadDetectorDeadtime(lo,hi,detStr) 1730 1731 break 1732 case -1: // control being killed 1733 break 1734 endswitch 1735 1736 return 0 1737 End 1738 1739 Function V_WriteDTButtonProc(ba) : ButtonControl 1740 STRUCT WMButtonAction &ba 1741 1742 switch( ba.eventCode ) 1743 case 2: // mouse up 1744 // click code here 1745 1746 ControlInfo popup_0 1747 String detStr = S_Value 1748 ControlInfo setvar0 1749 Variable lo=V_Value 1750 ControlInfo setvar1 1751 Variable hi=V_Value 1752 Wave deadTimeW = root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave 1753 1754 V_fPatchDetectorDeadtime(lo,hi,detStr,deadtimeW) 1755 1756 break 1757 case -1: // control being killed 1758 break 1759 endswitch 1760 1761 return 0 1762 End 1763 1764 ////////////////////////////////////////////////////////////////////////////////////////////////// 1765 ////////////////////////////////////////////////////////////////////////////////////////////////// 1766 1767 1768 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1769 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1770 /////////////// 1771 // 1772 // this is a block to patch beam centers to the file headers 1773 // it will patch the headers for all 9 detectors 1774 // and can patch multiple files 1775 // 1776 // uses a simple panel to show what the table of values is. 1777 // "read" will read only the first run number contents. this is the "good" set of XY 1778 // that you want to write out to other files. 1779 // 1780 // TODO -- need to clear out the contents from RawVSANS, or else re-reading to check the values 1781 // will read locally, and it will look like nothing was written. Executing "save" will also 1782 // trigger a cleanout. 1783 // 1784 // TODO - link this to a panel somewhere - a button? menu item? will there be a lot more of these little panels? 1785 // 1786 Proc V_PatchDet_xyCenters(firstFile,lastFile) 1787 Variable firstFile=1,lastFile=100 1788 1789 V_fPatchDet_xyCenters(firstFile,lastFile) 1790 1791 End 1792 1793 Proc V_ReadDet_xyCenters(firstFile,lastFile) 1794 Variable firstFile=1,lastFile=100 1795 1796 1797 V_fReadDet_xyCenters(firstFile,lastFile) 1798 End 1799 1800 // simple utility to patch the xy center in the file headers 1801 // lo is the first file number 1802 // hi is the last file number (inclusive) 1803 // 1804 Function V_fPatchDet_xyCenters(lo,hi) 1805 Variable lo,hi 1806 1807 1808 Variable ii,jj 1809 String fname,detStr 1810 1811 Wave xCtr_pix = root:Packages:NIST:VSANS:Globals:Patch:xCtr_pix 1812 Wave yCtr_pix = root:Packages:NIST:VSANS:Globals:Patch:yCtr_pix 1813 Wave/T panelW = root:Packages:NIST:VSANS:Globals:Patch:panelW 1814 1815 //loop over all files 1816 for(jj=lo;jj<=hi;jj+=1) 1817 fname = V_FindFileFromRunNumber(jj) 1818 if(strlen(fname) != 0) 1819 1820 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 1821 detStr = panelW[ii] 1822 V_writeDet_beam_center_x(fname,detStr,xCtr_pix[ii]) 1823 V_writeDet_beam_center_y(fname,detStr,yCtr_pix[ii]) 1824 endfor 1825 1826 else 1827 printf "run number %d not found\r",ii 1828 endif 1829 endfor 1830 1831 return(0) 1832 End 1833 1834 // simple utility to read the detector xy centers stored in the file header 1835 Function V_fReadDet_xyCenters(lo,hi) 1836 Variable lo,hi 1837 1838 1839 String fname,detStr 1840 Variable ii,jj 1841 1842 Wave xCtr_pix = root:Packages:NIST:VSANS:Globals:Patch:xCtr_pix 1843 Wave yCtr_pix = root:Packages:NIST:VSANS:Globals:Patch:yCtr_pix 1844 Wave/T panelW = root:Packages:NIST:VSANS:Globals:Patch:panelW 1845 1846 for(jj=lo;jj<=hi;jj+=1) 1847 fname = V_FindFileFromRunNumber(jj) 1848 if(strlen(fname) != 0) 1849 1850 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 1851 detStr = StringFromList(ii, ksDetectorListAll, ";") 1852 panelW[ii] = detStr 1853 xCtr_pix[ii] = V_getDet_beam_center_x(fname,detStr) 1854 yCtr_pix[ii] = V_getDet_beam_center_y(fname,detStr) 1855 endfor 1856 1857 1858 else 1859 printf "run number %d not found\r",jj 1860 endif 1861 1862 endfor 1863 1864 1865 return(0) 1866 End 1867 1868 1869 1870 Macro V_PatchDet_xyCenters_Panel() 1871 DoWindow/F Patch_Deadtime 1872 if(V_flag==0) 1873 1874 NewDataFolder/O/S root:Packages:NIST:VSANS:Globals:Patch 1875 1876 Make/O/D/N=9 xCtr_pix,yCtr_pix 1877 Make/O/T/N=9 panelW 1878 1879 SetDataFolder root: 1880 1881 Execute "V_Patch_xyCtr_Panel()" 1882 endif 1883 End 1884 1885 1886 // 1887 // TODO - document, make setVar controls larger, make cleaner 1888 // 1889 // TODO - link to main panel? link to Patch Panel? 1890 // 1891 Proc V_Patch_xyCtr_Panel() : Panel 1892 PauseUpdate; Silent 1 // building window... 1893 1894 1895 NewPanel /W=(600,400,1150,800)/N=Patch_XY_Panel/K=1 1896 // ShowTools/A 1897 1898 // PopupMenu popup_0,pos={20,20},size={109,20},title="Detector Panel" 1899 // PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;B;\"" 1900 1901 Button button0,pos={22.00,62.00},size={50.00,20.00},proc=V_ReadXYButtonProc,title="Read" 1902 Button button0_1,pos={95.00,62.00},size={50.00,20.00},proc=V_WriteXYButtonProc,title="Write" 1903 SetVariable setvar0,pos={19.00,128.00},size={100.00,14.00},title="first" 1904 SetVariable setvar0,value= K0 1905 SetVariable setvar1,pos={20.00,154.00},size={100.00,14.00},title="last" 1906 SetVariable setvar1,value= K1 1907 1908 1909 SetDataFolder root:Packages:NIST:VSANS:Globals:Patch 1910 // display the wave 1911 Edit/W=(180,40,480,350)/HOST=# panelW,xCtr_pix,yCtr_pix 1912 ModifyTable width(Point)=0 1913 ModifyTable width(panelW)=80 1914 ModifyTable width(xCtr_pix)=100 1915 ModifyTable width(yCtr_pix)=100 1916 RenameWindow #,T0 1917 SetActiveSubwindow ## 1918 1919 SetDataFolder root: 1920 1921 EndMacro 1922 1923 1924 Function V_ReadXYButtonProc(ba) : ButtonControl 1925 STRUCT WMButtonAction &ba 1926 1927 switch( ba.eventCode ) 1928 case 2: // mouse up 1929 // click code here 1930 1931 // ControlInfo popup_0 1932 // String detStr = S_Value 1933 ControlInfo setvar0 1934 Variable lo=V_Value 1935 Variable hi=lo 1936 1937 V_fReadDet_xyCenters(lo,hi) 1938 1939 break 1940 case -1: // control being killed 1941 break 1942 endswitch 1943 1944 return 0 1945 End 1946 1947 Function V_WriteXYButtonProc(ba) : ButtonControl 1948 STRUCT WMButtonAction &ba 1949 1950 switch( ba.eventCode ) 1951 case 2: // mouse up 1952 // click code here 1953 1954 // ControlInfo popup_0 1955 // String detStr = S_Value 1956 ControlInfo setvar0 1957 Variable lo=V_Value 1958 ControlInfo setvar1 1959 Variable hi=V_Value 1960 // Wave deadTimeW = root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave 1961 1962 V_fPatchDet_xyCenters(lo,hi) 1963 1964 break 1965 case -1: // control being killed 1966 break 1967 endswitch 1968 1969 return 0 1970 End 1971 1972 ////////////////////////////////////////////////////////////////////////////////////////////////// 1973 ////////////////////////////////////////////////////////////////////////////////////////////////// -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf
r1018 r1019 49 49 // 50 50 // TODO -- at what stage do I make copies of data in linear/log forms for data display? 51 // -- do I need to make copies, if I'm displaying with the lookup wave (no copy needed if this works) 51 52 // -- when do I make the 2D error waves? 52 53 // … … 121 122 //////// 122 123 // see the help entry for IndexedDir for help on (possibly) how to do this faster 123 // -- see the functionFunction ScanDirectories(pathName, printDirNames)124 // -- see Function ScanDirectories(pathName, printDirNames) 124 125 // 125 126 … … 131 132 // 132 133 // 133 Proc V_CopyWorkFolder Test(dataFolderStr, fromStr, toStr, level, sNBName, recurse)134 Proc V_CopyWorkFolderProc(dataFolderStr, fromStr, toStr, level, sNBName, recurse) 134 135 String dataFolderStr="root:Packages:NIST:VSANS:RAW" 135 136 String fromStr = "RAW" … … 175 176 NewDataFolder/O $(RemoveEnding(toDF,":")) // remove trailing semicolon if it's there 176 177 177 V_WriteBrowserInfo (sString, 1, sNBName)178 V_WriteBrowserInfo_test(sString, 1, sNBName) 178 179 endif 179 180 … … 196 197 Duplicate/O $(dfName+name),$(toDF+name) 197 198 198 V_WriteBrowserInfo (sString, 2, sNBName)199 V_WriteBrowserInfo_test(sString, 2, sNBName) 199 200 endfor 200 201 … … 203 204 name = GetIndexedObjNameDFR(dfr, 2, i) 204 205 sPrintf sString, "%s%s (numeric variable)\r", indentStr, name 205 V_WriteBrowserInfo (sString, 3, sNBName)206 V_WriteBrowserInfo_test(sString, 3, sNBName) 206 207 endfor 207 208 … … 210 211 name = GetIndexedObjNameDFR(dfr, 3, i) 211 212 sPrintf sString, "%s%s (string variable)\r", indentStr, name 212 V_WriteBrowserInfo (sString, 4, sNBName)213 V_WriteBrowserInfo_test(sString, 4, sNBName) 213 214 endfor 214 215 … … 225 226 226 227 227 V_WriteBrowserInfo (sString, 1, sNBName)228 V_WriteBrowserInfo_test(sString, 1, sNBName) 228 229 DFREF childDFR = dfr:$(name) 229 230 V_DuplicateDataFolder(childDFR, fromStr, toStr, level+1, sNBName, recurse) … … 231 232 endif 232 233 233 //when finished walking tree, save as RTF with dialog 234 // if(level == 0 && strlen(sNBName) != 0) 235 // SaveNotebook /I /S=4 $sNBName 236 // endif 234 237 235 End 238 236 239 Function V_WriteBrowserInfo (sString, vType, sNBName)237 Function V_WriteBrowserInfo_test(sString, vType, sNBName) 240 238 String sString 241 239 Variable vType … … 551 549 Wave w = V_getDetectorDataW(fname,detStr) 552 550 Wave w_err = V_getDetectorDataErrW(fname,detStr) 551 553 552 // TransmissionCorrection(fill this in) 554 553
Note: See TracChangeset
for help on using the changeset viewer.