Changeset 965 for sans/Dev/trunk/NCNR_User_Procedures/Reduction
- Timestamp:
- Nov 2, 2015 10:28:35 AM (7 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_ReadWrite_HDF5.ipf
r963 r965 150 150 // depricated? in HDF5 - store all of the values as real? 151 151 // Igor sees no difference in real and integer variables (waves are different) 152 // BUT-- Igor 7 will have integer variables 152 153 // 153 154 // truncate to integer before returning?? … … 174 175 // -- if not, read the file in, then return the value 175 176 // 176 // TODO -- string ischecked for length, but returned right or wrong177 // TODO -- string could be checked for length, but returned right or wrong 177 178 // 178 179 Function/S V_getStringFromHDF5(fname,path,num) … … 205 206 206 207 208 // 207 209 //Write Wave 'wav' to hdf5 file 'fname' 208 210 //Based on code from ANSTO (N. Hauser. nha 8/1/09) 211 // 212 // TODO: 213 // -- figure out if this will write in the native format of the 214 // wave as passed in, or if it will only write as DP. 215 // -- do I need to write separate functions for real, integer, etc.? 216 // 217 // -- change the /P=home to the user-defined data path (which may be home) 218 // 209 219 Function V_WriteWaveToHDF(fname, groupName, varName, wav) 210 220 String fname, groupName, varName … … 216 226 217 227 try 218 HDF5OpenFile /Z fileID as fname //open file read-write228 HDF5OpenFile/P=home /Z fileID as fname //open file read-write 219 229 if(!fileID) 220 230 err = 1 … … 268 278 269 279 endtry 270 280 281 // it is not necessary to close the group here. HDF5CloseFile will close the group as well 271 282 if(groupID) 272 283 HDF5CloseGroup /Z groupID … … 311 322 endif 312 323 313 // TODO SRK -- skipping the concatenation of the NXentry_name - may add back in the future, but this324 // TODO SRK -- ??? un-did this... skipping the concatenation of the NXentry_name - may add back in the future, but this 314 325 // prevents me from accessing the file name which I put on the top node (which may be incorrect style) 315 326 // … … 318 329 // 319 330 //concatenate NXentry node name and groupName 320 //groupName = "/" + NXentry_name + groupName331 groupName = "/" + NXentry_name + groupName 321 332 Print "groupName = ",groupName 322 333 … … 366 377 367 378 368 369 370 371 372 //transmission is at byte 158 373 Function V_getSampleTrans(fname) 374 String fname 375 376 String path = "Run1:Sample:TRNS" 377 return(V_getRealValueFromHDF5(fname,path)) 378 end 379 380 //sample transmission is a real value at byte 158 379 ////////////////////////////////////////////// 380 ////////////////////////////////// 381 // for TESTING of the get functions - to quickly access and se if there are errors 382 // 383 // -- not sure how to test the string functions -- can't seem to get a FUNCREF to a string function 384 // to work -- maybe it's not alllowed? 385 // 386 // -- Not sure how to test the "write" functions. writing the wrong data type to the wrong data field will be a disaster 387 // Writing odd, dummy values will also be a mess - no way to know if I'm doing anything correctly 388 // 389 Function proto_V_get_FP(str) 390 String str 391 return(0) 392 end 393 394 //Function/S proto_V_get_STR(str) 395 // String str 396 // return("") 397 //end 398 399 Function Test_V_get_FP(str,fname) 400 String str,fname 401 402 Variable ii,num 403 String list,item 404 405 406 list=FunctionList(str,";","NPARAMS:1") //,VALTYPE:1 407 Print list 408 num = ItemsInlist(list) 409 410 411 for(ii=0;ii<num;ii+=1) 412 item = StringFromList(ii, list , ";") 413 FUNCREF proto_V_get_FP f = $item 414 Print item ," = ", f(fname) 415 endfor 416 417 return(0) 418 end 419 420 421 //Function Test_V_get_STR(str,fname) 422 // String str,fname 423 // 424 // Variable ii,num 425 // String list,item 426 // 427 // 428 // list=FunctionList(str,";","NPARAMS:1,VALTYPE:4") 429 // Print list 430 // num = ItemsInlist(list) 431 // 432 // 433 // for(ii=0;ii<num;ii+=1) 434 // item = StringFromList(ii, list , ";") 435 // FUNCREF proto_V_get_STR f = $item 436 // Print item ," = ", f(fname) 437 // endfor 438 // 439 // return(0) 440 //end 441 442 /////////////////////////////////////// 443 444 445 ////////////////////////////////////////////// 446 447 448 /////////////////////// 449 // 450 // *These are the specific bits of information to retrieve (or write) to the data file 451 // *These functions use the path to the file as input, and each has the specific 452 // path to the variable srting, or wave hard-coded into the access function 453 // *They call the generic worker functions to get the values, either from the local copy if present, 454 // or the full file is loaded. 455 // 456 // *Since the path is the important bit, these are written as get/write pairs to make it easier to 457 // keep up with any changes in path 458 // 459 // 460 // TODO -- verify the paths, and add more as needed 461 // 462 463 464 //////// TOP LEVEL 465 //////// TOP LEVEL 466 //////// TOP LEVEL 467 468 469 470 //////// CONTROL 471 //////// CONTROL 472 //////// CONTROL 473 474 //monitor count 475 Function V_getMonitorCount(fname) 476 String fname 477 478 String path = "entry:control:monitor_counts" 479 return(V_getRealValueFromHDF5(fname,path)) 480 end 481 482 483 //////// INSTRUMENT 484 //////// INSTRUMENT 485 //////// INSTRUMENT 486 487 //wavelength 488 Function V_getWavelength(fname) 489 String fname 490 491 String path = "entry:instrument:beam:monochromator:wavelength" 492 return(V_getRealValueFromHDF5(fname,path)) 493 end 494 495 //wavelength spread 496 Function V_getWavelengthSpread(fname) 497 String fname 498 499 String path = "entry:instrument:beam:monochromator:wavelength_spread" 500 return(V_getRealValueFromHDF5(fname,path)) 501 end 502 503 // reactor power (MW) 504 Function V_getReactorPower(fname) 505 String fname 506 507 String path = "entry:instrument:source:power" 508 return(V_getRealValueFromHDF5(fname,path)) 509 end 510 511 512 //////// SAMPLE 513 //////// SAMPLE 514 //////// SAMPLE 515 516 517 // sample transmission 518 Function V_getSampleTransmission(fname) 519 String fname 520 521 String path = "entry:sample:transmission" 522 // String path = "QKK0037737:data:Transmission" 523 return(V_getRealValueFromHDF5(fname,path)) 524 end 525 526 // sample transmission 381 527 Function V_WriteTransmissionToHeader(fname,trans) 382 528 String fname … … 384 530 385 531 Make/O/D/N=1 wTmpWrite 386 String groupName = "/Sample" // /Run1/Sample becomes groupName /Run1/Run1/Sample 387 String varName = "TRNS" 532 String groupName = "/sample" // skip "entry" - /entry/sample becomes groupName /entry/entry/sample 533 String varName = "transmission" 534 // Make/O/R/N=1 wTmpWrite 535 // String groupName = "/data" // skip "entry" - /entry/sample becomes groupName /entry/entry/sample 536 // String varName = "Transmission" 388 537 wTmpWrite[0] = trans // 389 538 390 539 variable err 391 540 err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 392 // Print "HDF write err = ",err 393 541 if(err) 542 Print "HDF write err = ",err 543 endif 394 544 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 395 545 err = V_KillNamedDataFolder(fname) 396 // Print "DataFolder kill err = ",err 397 398 return(0) 399 End 400 401 // sample label (60 characters @ byte 98) 546 if(err) 547 Print "DataFolder kill err = ",err 548 endif 549 return(err) 550 End 551 552 553 //transmission error (one sigma) 554 Function V_getSampleTransError(fname) 555 String fname 556 557 String path = "entry:sample:transmission_error" 558 return(V_getRealValueFromHDF5(fname,path)) 559 end 560 561 562 // sample label 563 // TODO: value of num is currently not used 564 // 402 565 Function/S V_getSampleLabel(fname) 403 566 String fname 404 567 405 String path = " Run1:runLabel"568 String path = "entry:sample:description" 406 569 Variable num=60 407 570 return(V_getStringFromHDF5(fname,path,num)) … … 409 572 410 573 411 // sample label , starts at byte 98574 // sample label 412 575 // 413 576 // TODO … … 426 589 427 590 Make/O/T/N=1 tmpTW 428 String groupName = "/ Run1" //explicitly state the group429 String varName = " runLabel"591 String groupName = "/sample" // /entry is automatically prepended -- so just explicitly state the group 592 String varName = "description" 430 593 tmpTW[0] = str // 431 594 432 595 variable err 433 596 err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW) 434 // Print "HDF write err = ",err 597 if(err) 598 Print "HDF write err = ",err 599 endif 435 600 436 601 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 437 602 err = V_KillNamedDataFolder(fname) 438 // Print "DataFolder kill err = ",err 439 440 return(0) 441 End 603 if(err) 604 Print "DataFolder kill err = ",err 605 endif 606 607 return(err) 608 End 609 610 //Sample Thickness 611 Function V_getSampleThickness(fname) 612 String fname 613 614 String path = "entry:sample:thickness" 615 return(V_getRealValueFromHDF5(fname,path)) 616 end 617 618 //Sample Rotation Angle is at byte 170 619 Function V_getSampleRotationAngle(fname) 620 String fname 621 622 String path = "entry:sample:rotation_angle" 623 return(V_getRealValueFromHDF5(fname,path)) 624 end 625 626 //Sample position in changer 627 Function V_getSamplePosition(fname) 628 String fname 629 630 String path = "entry:sample:changer_position" 631 return(V_getRealValueFromHDF5(fname,path)) 632 end 633 634 635 636 637 638 ///////// REDUCTION 639 ///////// REDUCTION 640 ///////// REDUCTION 641 642 643 //box counts 644 Function V_getBoxCounts(fname) 645 String fname 646 647 String path = "entry:reduction:box_count" 648 return(V_getRealValueFromHDF5(fname,path)) 649 end 650 651 //box counts error 652 Function V_getBoxCountsError(fname) 653 String fname 654 655 String path = "entry:reduction:box_count_error" 656 return(V_getRealValueFromHDF5(fname,path)) 657 end 658 659 660 //whole detector trasmission 661 Function V_getSampleTransWholeDetector(fname) 662 String fname 663 664 String path = "entry:reduction:whole_trans" 665 return(V_getRealValueFromHDF5(fname,path)) 666 end 667 668 //whole detector trasmission error 669 Function V_getSampleTransWholeDetErr(fname) 670 String fname 671 672 String path = "entry:reduction:whole_trans_error" 673 return(V_getRealValueFromHDF5(fname,path)) 674 end 675 442 676 443 677 … … 460 694 461 695 696 ////////////////////////////// 697 ////////////////////////////// 462 698 ////////////////////////////// 463 699 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_TubeAdjustments.ipf
r964 r965 32 32 // FillMatrix_Pix_Center(ind) 33 33 // 34 // 35 // -or- (note that the pack_image wave that is generated here is for display ONLY) 36 // --since it is interpolated 37 // 38 // Interpolate_mm_tubes() 39 34 40 35 41 // The function most used externally is: … … 414 420 415 421 416 417 418 419 420 422 // set the (linear) range of the y-axis of the matrix to be the 423 // range of the 1st tube. This is completely arbitrary 424 // 425 Proc Interpolate_mm_tubes() 426 427 Duplicate/O pack pack_image 428 429 Variable ii,numTubes=8 430 Variable p1,p2 431 p1 = tube1_mm[0] 432 p2 = tube1_mm[numpnts(tube1_mm)-1] 433 434 SetScale/I y p1,p2,"", pack_image 435 436 // then make a temporary 1D wave to help with the interpolation 437 Duplicate/O tube1_mm lin_mm,lin_val 438 SetScale/I x p1,p2,"", lin_mm 439 lin_mm = x //fill with the linear mm spacing 440 lin_val=0 441 442 ii=1 443 do 444 lin_val = interp(lin_mm, $("tube"+num2str(ii)+"_mm"), $("tube"+num2str(ii))) 445 pack_image[ii-1][] = lin_val[q] 446 447 ii+=1 448 while(ii<=numTubes) 449 450 display;appendimage pack_image 451 ModifyImage pack_image ctab= {*,*,ColdWarm,0} 452 453 End 421 454 422 455
Note: See TracChangeset
for help on using the changeset viewer.