- Timestamp:
- Apr 27, 2016 4:16:09 PM (7 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/NIST_XML_v40.ipf
r983 r994 1117 1117 end 1118 1118 1119 Function WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName, normTo,norm12,norm23,[res])1119 Function WriteNSORTedXMLFile(q3,i3,sig3,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34,[res]) 1120 1120 Wave q3,i3,sig3,res 1121 String firstFileName,secondFileName,thirdFileName, normTo1122 Variable norm12,norm23 1121 String firstFileName,secondFileName,thirdFileName,fourthFileName,normTo 1122 Variable norm12,norm23,norm34 1123 1123 1124 1124 Abort "XML function provided by XMLutils XOP is not available, get the XOP from : http://www.igorexchange.com/project/XMLutils (see http://www.smallangles.net/wgwiki/index.php/cansas1d_binding_IgorPro for details)" -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/WriteUSANSData.ipf
r739 r994 495 495 end 496 496 497 Function WriteXMLUSANSDesmeared( type,fullpath,lo,hi,dialog)498 String type,fullpath497 Function WriteXMLUSANSDesmeared(fullpath,lo,hi,dialog) 498 String fullpath 499 499 Variable lo,hi,dialog //=1 will present dialog for name 500 500 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_BeamCenter.ipf
r993 r994 23 23 // ModifyGraph width={Plan,1,bottom,left} 24 24 // 25 MacroDetectorPanelFit() : Panel25 Proc DetectorPanelFit() : Panel 26 26 PauseUpdate; Silent 1 // building window... 27 27 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf
r993 r994 270 270 Make/O/T/N=1 name = "NG3_VSANS" 271 271 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B 272 Make/O/D/N=(150,150) data = abs(gnoise(10))273 Make/O/D/N=(150,150) linear_data_error = 0.01*abs(gnoise(1 0))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 274 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR 275 Make/O/D/N=(48,128) data = abs(gnoise(10))276 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1 0))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 277 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML 278 Make/O/D/N=(48,128) data = abs(gnoise(10))279 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1 0))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 280 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT 281 Make/O/D/N=(128,48) data = abs(gnoise(10))282 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1 0))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 283 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB 284 Make/O/D/N=(128,48) data = abs(gnoise(10))285 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1 0))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 286 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR 287 Make/O/D/N=(48,128) data = abs(gnoise(10))288 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1 0))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 289 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL 290 Make/O/D/N=(48,128) data = abs(gnoise(10))291 Make/O/D/N=(48,128) linear_data_error = 0.01*abs(gnoise(1 0))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 292 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT 293 Make/O/D/N=(128,48) data = abs(gnoise(10))294 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1 0))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 295 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB 296 Make/O/D/N=(128,48) data = abs(gnoise(10))297 Make/O/D/N=(128,48) linear_data_error = 0.01*abs(gnoise(1 0))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 298 299 299 SetDataFolder root: -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_UtilityProcedures.ipf
r993 r994 436 436 437 437 438 //////// function to take VCALC information and439 // fill in the simulated information as needed to make a "fake" data file440 //441 // TODO:442 // -- identify all of the necessary bits to change443 // -- maybe want a panel to make it easier to decide what inputs to change in the file444 // -- decide if it's better to write wholesale, or as individual waves445 //446 Macro Copy_VCALC_to_VSANSFile()447 448 String fileName = V_DoSaveFileDialog("pick the file to write to")449 print fileName450 //451 if(strlen(fileName) > 0)452 writeVCALC_to_file(fileName)453 endif454 End455 456 //457 // TODO -- fill this in as needed to get fake data that's different458 //459 Function writeVCALC_to_file(fileName)460 String fileName461 462 463 // the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels464 // the data itself (as INT32)465 // the front SDD (correct units)466 // the middle SDD (correct units)467 // the back SDD (correct units)468 Variable ii,val469 String detStr470 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1)471 detStr = StringFromList(ii, ksDetectorListAll, ";")472 Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData473 Redimension/I tmpData474 tmpData = (tmpData == 2147483647) ? 0 : tmpData //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer475 V_writeDetectorData(fileName,detStr,tmpData)476 477 val = VCALC_getTopBottomSDDOffset(detStr)/10 + VCALC_getSDD(detStr)*100 // make sure value is in cm478 print val479 V_writeDet_distance(fileName,detStr,val)480 481 // x and y pixel sizes for each detector should be correct in the "base" file - but if not...482 //Function VCALC_getPixSizeX(type) // returns the pixel X size, in [cm]483 //Function VCALC_getPixSizeY(type)484 V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10) // data file is expecting mm485 V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10)486 487 // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels()488 V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr))489 V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr))490 491 492 493 // the calibration data for each detector (except B) is already correct in the "base" file494 //V_writeDetTube_spatialCalib(fname,detStr,inW)495 // and for "B"496 //V_writeDet_cal_x(fname,detStr,inW)497 //V_writeDet_cal_y(fname,detStr,inW)498 499 500 // the dead time for each detector is already correct in the "base" file501 // V_writeDetector_deadtime(fname,detStr,inW)502 // TODO: need a new, separate function to write the single deadtime value in/out of "B"503 504 endfor505 506 507 //? other detector geometry - lateral separation?508 509 // the wavelength510 // Variable lam = V_getWavelength("VCALC") //doesn't work, the corresponding folder in VCALC has not been defined511 V_writeWavelength(fileName,VCALC_getWavelength())512 513 // description of the sample514 515 // sample information516 // name, title, etc517 518 // fake the information about the count setup, so I have different numbers to read519 // count time = fake time of 100 s520 V_writeCount_time(fileName,100)521 522 // monitor count (= imon)523 // returns the number of neutrons on the sample524 //Function VCALC_getImon()525 526 // ?? anything else that I'd like to see on the catalog - I could change them here to see different values527 // different collimation types?528 //529 530 return(0)531 end532 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf
r993 r994 327 327 // 328 328 // TESTING ONLY 329 MacroMakeFakeCalibrationWaves()329 Proc MakeFakeCalibrationWaves() 330 330 // make these in the RAW data folder, before converting to a work folder 331 331 // - then they will be "found" by get() … … 1018 1018 //check before re-implementing 1019 1019 // 1020 MacroDIV_a_Workfile(type)1020 Proc DIV_a_Workfile(type) 1021 1021 String type 1022 1022 Prompt type,"WORK data type",popup,"SAM;EMP;BGD;ADJ;" -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf
r993 r994 26 26 27 27 // passing null file string presents a dialog 28 MacroLoadFakeDIVData()28 Proc LoadFakeDIVData() 29 29 V_LoadHDF5Data("","DIV") 30 30 End 31 31 32 32 // passing null file string presents a dialog 33 MacroLoadFakeMASKData()33 Proc LoadFakeMASKData() 34 34 V_LoadHDF5Data("","MSK") 35 35 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf
r993 r994 1426 1426 End 1427 1427 1428 // TODO - be sure this is defined correctly 1429 // -- only returns for T/B detectors 1430 Function V_getDet_TBSetback(fname,detStr) 1431 String fname,detStr 1432 1433 if(cmpstr(detStr,"B") == 0) 1434 return(0) 1435 endif 1436 if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0) 1437 return(0) 1438 endif 1439 if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) 1440 return(0) 1441 endif 1442 1443 String path = "entry:instrument:detector_"+detStr+":setback" 1444 return(V_getRealValueFromHDF5(fname,path)) 1445 1446 1447 End 1448 1428 1449 //Function V_getDet_VerticalOffset(fname,detStr) 1429 1450 // String fname,detStr -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf
r993 r994 3933 3933 End 3934 3934 3935 3936 // TODO - be sure that this is defined correctly 3937 // -- it needs to exist in the data file, and only for TB detector panels 3938 Function V_writeDet_TBSetback(fname,detStr,val) 3939 String fname,detStr 3940 Variable val 3941 3942 // String path = "entry:instrument:detector_"+detStr+":setback" 3943 3944 if(cmpstr(detStr,"B") == 0) 3945 return(0) 3946 endif 3947 if(cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0) 3948 return(0) 3949 endif 3950 if(cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) 3951 return(0) 3952 endif 3953 3954 Make/O/D/N=1 wTmpWrite 3955 // Make/O/R/N=1 wTmpWrite 3956 String groupName = "/entry/instrument/detector_"+detStr 3957 String varName = "setback" 3958 wTmpWrite[0] = val 3959 3960 variable err 3961 err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 3962 if(err) 3963 Print "HDF write err = ",err 3964 endif 3965 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 3966 // err = V_KillNamedDataFolder(fname) 3967 // if(err) 3968 // Print "DataFolder kill err = ",err 3969 // endif 3970 return(err) 3971 End 3972 3973 3974 3975 3935 3976 //Function V_writeDet_VerticalOffset(fname,detStr,val) 3936 3977 // String fname,detStr -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf
r993 r994 20 20 21 21 22 22 // TODO-- decide whether to automatically read in the mask, or not 23 // -- there could be a default mask, or look for the mask that is speficied in the 24 // next file that is read in from the path 23 25 Proc PickPath_MainButtonProc(ctrlName) : ButtonControl 24 26 String ctrlName … … 49 51 50 52 53 // 51 54 // this will only load the data into RAW, overwriting whatever is there. no copy is put in rawVSANS 52 55 // … … 54 57 String ctrlName 55 58 56 Variable err= V_LoadHDF5Data("","RAW") // load the data into RawVSANS storage folder (why am I doing this?)59 Variable err= V_LoadHDF5Data("","RAW") // load the data 57 60 // Print "Load err = "+num2str(err) 58 61 if(!err) … … 62 65 // this (in SANS) just passes directly to fRawWindowHook() 63 66 UpdateDisplayInformation("RAW") // plot the data in whatever folder type 67 68 FakeRestorePanelsButtonClick() //so the panels display correctly 64 69 65 70 endif -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Menu.ipf
r984 r994 21 21 Submenu "In Progress Panels" 22 22 "VSANS Preferences",Show_VSANSPreferences_Panel() 23 23 "Beam Center Panel",DetectorPanelFit() 24 24 End 25 Submenu "Work Files" 26 "Convert to WORK",Convert_to_Workfile() 27 "Load Fake DIV Data" 28 "DIV a work file",DIV_a_Workfile() 29 "Load Fake MASK Data" 30 End 31 25 32 End 26 33 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf
r993 r994 130 130 Button button_status,pos={607,146},size={70,20},proc=StatusButtonProc,title="Status" 131 131 Button button_IvsQ,pos={689,113},size={70,20},proc=IvsQPanelButtonProc,title="I vs. Q" 132 Button button_file_m,pos={619,55},size={50,20},proc=File_m _ButtonProc,title="File <"133 Button button_file_p,pos={679,55},size={50,20},proc=File_p _ButtonProc,title="File >"132 Button button_file_m,pos={619,55},size={50,20},proc=File_minus_ButtonProc,title="File <" 133 Button button_file_p,pos={679,55},size={50,20},proc=File_plus_ButtonProc,title="File >" 134 134 Button button_log,pos={689,146},size={70,20},proc=LogLinButtonProc,title="isLin",userData="0" 135 135 Button button_tab_p,pos={648,81},size={50,20},proc=Tab_p_ButtonProc,title="Tab >" … … 563 563 End 564 564 565 // fake restore panels button click 566 Function FakeRestorePanelsButtonClick() 567 568 STRUCT WMButtonAction ba 569 ba.eventCode = 2 570 RestorePanelButtonProc(ba) 571 572 return(0) 573 End 574 575 565 576 // fake status button click 566 577 Function FakeStatusButtonClick() … … 591 602 // move one file number back 592 603 // 593 Function File_m_ButtonProc(ba) : ButtonControl 594 STRUCT WMButtonAction &ba 595 596 switch( ba.eventCode ) 597 case 2: // mouse up 598 // click code here 604 Function File_minus_ButtonProc(ba) : ButtonControl 605 STRUCT WMButtonAction &ba 606 607 switch( ba.eventCode ) 608 case 2: // mouse up 609 // click code here 610 V_LoadPlotAndDisplayRAW(-1) 611 599 612 break 600 613 case -1: // control being killed … … 609 622 // move one file number forward 610 623 // 611 Function File_p_ButtonProc(ba) : ButtonControl 612 STRUCT WMButtonAction &ba 613 614 switch( ba.eventCode ) 615 case 2: // mouse up 616 // click code here 624 Function File_plus_ButtonProc(ba) : ButtonControl 625 STRUCT WMButtonAction &ba 626 627 switch( ba.eventCode ) 628 case 2: // mouse up 629 // click code here 630 V_LoadPlotAndDisplayRAW(1) 631 617 632 break 618 633 case -1: // control being killed … … 640 655 endif 641 656 FakeTabClick(V_Value) 657 642 658 break 643 659 case -1: // control being killed -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Testing_Data_Procs.ipf
r993 r994 1 1 #pragma TextEncoding = "MacRoman" 2 2 #pragma rtGlobals=3 // Use modern global access method and strict wave access. 3 4 5 6 //////// function to take VCALC information and 7 // fill in the simulated information as needed to make a "fake" data file 8 // 9 // TODO: 10 // -- identify all of the necessary bits to change 11 // -- maybe want a panel to make it easier to decide what inputs to change in the file 12 // -- decide if it's better to write wholesale, or as individual waves 13 // 14 Macro Copy_VCALC_to_VSANSFile() 15 16 String fileName = V_DoSaveFileDialog("pick the file to write to") 17 print fileName 18 // 19 if(strlen(fileName) > 0) 20 writeVCALC_to_file(fileName) 21 endif 22 End 23 24 // 25 // TODO -- fill this in as needed to get fake data that's different 26 // 27 Function writeVCALC_to_file(fileName) 28 String fileName 29 30 31 // the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels 32 // the data itself (as INT32) 33 // the front SDD (correct units) 34 // the middle SDD (correct units) 35 // the back SDD (correct units) 36 Variable ii,val 37 String detStr 38 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 39 detStr = StringFromList(ii, ksDetectorListAll, ";") 40 Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData 41 Redimension/I tmpData 42 tmpData = (tmpData == 2147483647) ? 0 : tmpData //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer 43 V_writeDetectorData(fileName,detStr,tmpData) 44 45 val = VCALC_getTopBottomSDDOffset(detStr)/10 + VCALC_getSDD(detStr)*100 // make sure value is in cm 46 print val 47 V_writeDet_distance(fileName,detStr,val) 48 49 // x and y pixel sizes for each detector should be correct in the "base" file - but if not... 50 //Function VCALC_getPixSizeX(type) // returns the pixel X size, in [cm] 51 //Function VCALC_getPixSizeY(type) 52 V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10) // data file is expecting mm 53 V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10) 54 55 // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels() 56 V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr)) 57 V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr)) 58 59 60 61 // the calibration data for each detector (except B) is already correct in the "base" file 62 //V_writeDetTube_spatialCalib(fname,detStr,inW) 63 // and for "B" 64 //V_writeDet_cal_x(fname,detStr,inW) 65 //V_writeDet_cal_y(fname,detStr,inW) 66 67 68 // the dead time for each detector is already correct in the "base" file 69 // V_writeDetector_deadtime(fname,detStr,inW) 70 // TODO: need a new, separate function to write the single deadtime value in/out of "B" 71 72 endfor 73 74 75 //? other detector geometry - lateral separation? 76 77 // the wavelength 78 // Variable lam = V_getWavelength("VCALC") //doesn't work, the corresponding folder in VCALC has not been defined 79 V_writeWavelength(fileName,VCALC_getWavelength()) 80 81 // description of the sample 82 83 // sample information 84 // name, title, etc 85 86 // fake the information about the count setup, so I have different numbers to read 87 // count time = fake time of 100 s 88 V_writeCount_time(fileName,100) 89 90 // monitor count (= imon) 91 // returns the number of neutrons on the sample 92 //Function VCALC_getImon() 93 94 // ?? anything else that I'd like to see on the catalog - I could change them here to see different values 95 // different collimation types? 96 // 97 98 return(0) 99 end 100 101 3 102 4 103 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf
r987 r994 49 49 Prompt type,"WORK data type to display",popup,"RAW;SAM;EMP;BGD;ADJ;" 50 50 51 UpdateDisplayInformation(type) 52 End 53 51 // make sure that data exists before passing this on... 52 53 if(DataExists(type) > 0) 54 UpdateDisplayInformation(type) 55 else 56 DoAlert 0,"No data in "+type 57 endif 58 End 59 60 // TODO 61 // 62 // very simple function to look for something in a work folder 63 // -- only checks for FR data to exist, assumes everything else is there 64 // -- can't use the V_get() functions, these will try to load data if it's not there! 65 Function DataExists(type) 66 String type 67 68 Wave/Z w = $("root:Packages:NIST:VSANS:"+type+":entry:instrument:detector_FR:data") 69 70 return(WaveExists(w)) 71 end 54 72 // 55 73 // tests if two values are close enough to each other … … 204 222 205 223 224 225 // 226 // previous/next button needs these functions 227 // as well as many other utilities that manipulate the data file names 228 // and parse run numbers. 229 // 230 231 232 // TODO 233 // x- load in the proper file 234 // x- re-click the I(q) button 235 // x- be sure that the globals are updated w/ filename 236 // -- getting the file_name from the root: global is a poor choice. 237 // Need a better, more reliable solution than this 238 // -- make a copy of "oldName" that is local and not the SVAR, as the SVAR changes 239 // when the next file is loaded in (if it's not in RawVSANS), resulting in a "skipped" file number 240 // 241 //displays next (or previous) file in series of run numbers 242 //file is read from disk, if path is set and the file number is present 243 //increment +1, adds 1 to run number, -1 subtracts one 244 // 245 // will automatically step a gap of 10 run numbers, but nothing larger. Don't want to loop too long 246 // trying to find a file (frustrating), don't want to look past the end of the run numbers (waste) 247 // -- may find a more elegant solution later. 248 // 249 Function V_LoadPlotAndDisplayRAW(increment) 250 Variable increment 251 252 Variable i,val 253 String filename,tmp,curFileName 254 //take the currently displayed RAW file 255 SVAR oldName = root:file_name 256 oldname = V_RemoveAllSpaces(oldname) // 257 curFileName = oldName 258 // print oldName 259 260 filename = oldname 261 // for (i = 0; i < abs(increment); i += 1) 262 // filename = GetPrevNextRawFile(filename,increment/abs(increment)) 263 // endfor 264 i = 1 265 val = increment 266 do 267 // print filename,val 268 filename = V_GetPrevNextRawFile(filename,val) 269 // print "new= ",filename 270 271 val = i*increment 272 i+=1 273 tmp = ParseFilePath(0, filename, ":", 1, 0) 274 275 // print val,strlen(tmp),strlen(oldname) 276 // print cmpstr(tmp,oldname) 277 278 if(strlen(tmp) == 0) //in some cases, a null string can be returned - handle gracefully 279 return(0) 280 endif 281 282 while( (cmpstr(tmp,curFileName) == 0) && i < 11) 283 // print filename 284 285 // display the specified RAW data file 286 // this is the set of steps done in DisplayMainButtonProc(ctrlName) : ButtonControl 287 Variable err= V_LoadHDF5Data(filename,"RAW") // load the data, set the global w/file name loaded 288 // Print "Load err = "+num2str(err) 289 if(!err) 290 SVAR hdfDF = root:file_name // last file loaded, may not be the safest way to pass 291 String folder = StringFromList(0,hdfDF,".") 292 293 // this (in SANS) just passes directly to fRawWindowHook() 294 Execute "UpdateDisplayInformation(\"RAW\")" // plot the data in whatever folder type 295 296 FakeRestorePanelsButtonClick() //so the panels display correctly 297 298 endif 299 300 // TODO 301 // -- update the 1D plotting as needed. these are SANS calls (OK for now, but will need to be better) 302 //do the average and plot (either the default, or what is on the panel currently) 303 V_PlotData_Panel() 304 305 306 return(0) 307 End 308 309 310 // Return the full path:filename that represents the previous or next file. 311 // Input is current filename and increment. 312 // Increment should be -1 or 1 313 // -1 => previous file 314 // 1 => next file 315 Function/S V_GetPrevNextRawFile(curfilename, prevnext) 316 String curfilename 317 Variable prevnext 318 319 String filename 320 321 //get the run number 322 Variable num = V_GetRunNumFromFile(curfilename) 323 324 //find the next specified file by number 325 fileName = V_FindFileFromRunNumber(num+prevnext) 326 327 if(cmpstr(fileName,"")==0) 328 //null return, do nothing 329 fileName = V_FindFileFromRunNumber(num) //returns the full path, not just curFileName 330 Endif 331 332 Return filename 333 End 334 335 336 //returns a string containing the full path to the file containing the 337 //run number "num". The null string is returned if no valid file can be found 338 //the path "catPathName" used and is hard-wired, will abort if this path does not exist 339 //the file returned will be a RAW SANS data file, other types of files are 340 //filtered out. 341 // 342 // called by Buttons.ipf and Transmission.ipf, and locally by parsing routines 343 // 344 Function/S V_FindFileFromRunNumber(num) 345 Variable num 346 347 String fullName="",partialName="",item="" 348 //get list of raw data files in folder that match "num" (add leading zeros) 349 if( (num>9999) || (num<=0) ) 350 Print "error in FindFileFromRunNumber(num), file number too large or too small" 351 Return ("") 352 Endif 353 //make a four character string of the run number 354 String numStr="" 355 if(num<10) 356 numStr = "000"+num2str(num) 357 else 358 if(num<100) 359 numStr = "00"+num2str(num) 360 else 361 if(num<1000) 362 numstr = "0"+num2str(num) 363 else 364 numStr = num2str(num) 365 endif 366 Endif 367 Endif 368 //Print "numstr = ",numstr 369 370 //make sure that path exists 371 PathInfo catPathName 372 String path = S_path 373 if (V_flag == 0) 374 Abort "folder path does not exist - use Pick Path button" 375 Endif 376 String list="",newList="",testStr="" 377 378 list = IndexedFile(catPathName,-1,"????") //get all files in folder 379 //find (the) one with the number in the run # location in the name 380 Variable numItems,ii,runFound,isRAW 381 numItems = ItemsInList(list,";") //get the new number of items in the list 382 ii=0 383 do 384 //parse through the list in this order: 385 // 1 - does item contain run number (as a string) "TTTTTnnn.SAn_XXX_Tyyy" 386 // 2 - exclude by isRaw? (to minimize disk access) 387 item = StringFromList(ii, list ,";" ) 388 if(strlen(item) != 0) 389 //find the run number, if it exists as a three character string 390 testStr = V_GetRunNumStrFromFile(item) 391 runFound= cmpstr(numStr,testStr) //compare the three character strings, 0 if equal 392 if(runFound == 0) 393 //the run Number was found 394 //build valid filename 395 partialName = V_FindValidFileName(item) 396 if(strlen(partialName) != 0) //non-null return from FindValidFileName() 397 fullName = path + partialName 398 //check if RAW, if so,this must be the file! 399 isRAW = V_CheckIfRawData(fullName) 400 if(isRaw) 401 //stop here 402 return(fullname) 403 Endif 404 Endif 405 Endif 406 Endif 407 ii+=1 408 while(ii<numItems) //process all items in list 409 Return ("") //null return if file not found in list 410 End 411 412 // 413 // TODO -- for VSANS Nexus files, how do I quickly identify if a file is 414 // RAW VSANS data? I don't want to generate any errors, but I want to quickly 415 // weed out the reduced data sets, etc. from file catalogs. 416 // 417 //function to test a binary file to see if it is a RAW binary SANS file 418 //first checks the total bytes in the file (which for raw data is 33316 bytes) 419 //**note that the "DIV" file will also show up as a raw file by the run field 420 //should be listed in CAT/SHORT and in patch windows 421 // 422 //Function then checks the file fname (full path:file) for "RAW" run.type field 423 //if not found, the data is not raw data and zero is returned 424 // 425 // called by many procedures (both external and local) 426 // 427 // TODO -- as was written by SANS, this function is expecting fname to be the path:fileName 428 // - but are the V_get() functions OK with getting a full path, and what do they 429 // do when they fail? I don't want them to spit up another open file dialog 430 // 431 Function V_CheckIfRawData(fname) 432 String fname 433 434 Variable refnum,totalBytes 435 String testStr="" 436 437 testStr = V_getInstrumentName(fname) 438 439 if(cmpstr(testStr,"") != 0) 440 //testStr exists, ASSUMING it's a raw VSANS data file 441 Return(1) 442 else 443 //some other file 444 Return(0) 445 Endif 446 End 447 448 449 Function V_GetRunNumFromFile(item) 450 String item 451 452 String str = V_GetRunNumStrFromFile(item) 453 454 return(str2num(str)) 455 end 456 457 458 // TODO -- the file name structure for VSANS file is undecided 459 // so some of these base functions will need to change 460 // 461 //given a filename of a VSANS data filename of the form 462 // sansNNNN.nxs.ngv 463 //returns the run number "NNNN" as a STRING of FOUR characters 464 //returns "ABCD" as an invalid file number 465 // 466 // local function to aid in locating files by run number 467 // 468 Function/S V_GetRunNumStrFromFile(item) 469 String item 470 String invalid = "ABCD" //"ABCD" is not a valid run number, since it's text 471 Variable num=-1 472 473 //find the "dot" 474 String runStr="" 475 Variable numChar = 4 476 Variable pos = strsearch(item,".",0) 477 if(pos == -1) 478 //"dot" not found 479 return (invalid) 480 else 481 //found, get the four characters preceeding it 482 if (pos <= numChar-1) 483 //not enough characters 484 return (invalid) 485 else 486 runStr = item[pos-numChar,pos-1] 487 return (runStr) 488 Endif 489 Endif 490 End 491 492 //Function attempts to find valid filename from partial name by checking for 493 // the existence of the file on disk. 494 // - checks as is 495 // - strips spaces 496 // - permutations of upper/lowercase 497 // 498 // added 11/99 - uppercase and lowercase versions of the file are tried, if necessary 499 // since from marquee, the filename field (textread[0]) must be used, and can be a mix of //02JUL13 500 // upper/lowercase letters, while the filename on the server (should) be all caps 501 // now makes repeated calls to ValidFileString() 502 // 503 // returns a valid filename (No path prepended) or a null string 504 // 505 // called by any functions, both external and local 506 // 507 Function/S V_FindValidFilename(partialName) 508 String PartialName 509 510 String retStr="" 511 512 //try name with no changes - to allow for ABS files that have spaces in the names 12APR04 513 retStr = V_ValidFileString(partialName) 514 if(cmpstr(retStr,"") !=0) 515 //non-null return 516 return(retStr) 517 Endif 518 519 //if the partial name is derived from the file header, there can be spaces at the beginning 520 //or in the middle of the filename - depending on the prefix and initials used 521 // 522 //remove any leading spaces from the name before starting 523 partialName = V_RemoveAllSpaces(partialName) 524 525 //try name with no spaces 526 retStr = V_ValidFileString(partialName) 527 if(cmpstr(retStr,"") !=0) 528 //non-null return 529 return(retStr) 530 Endif 531 532 //try all UPPERCASE 533 partialName = UpperStr(partialName) 534 retStr = V_ValidFileString(partialName) 535 if(cmpstr(retStr,"") !=0) 536 //non-null return 537 return(retStr) 538 Endif 539 540 //try all lowercase (ret null if failure) 541 partialName = LowerStr(partialName) 542 retStr = V_ValidFileString(partialName) 543 if(cmpstr(retStr,"") !=0) 544 //non-null return 545 return(retStr) 546 else 547 return(retStr) 548 Endif 549 End 550 551 552 // Function checks for the existence of a file 553 // partialName;vers (to account for VAX filenaming conventions) 554 // The partial name is tried first with no version number 555 // 556 // *** the PATH is hard-wired to catPathName (which is assumed to exist) 557 // version numers up to ;10 are tried 558 // only the "name;vers" is returned if successful. The path is not prepended 559 // 560 // local function 561 // 562 // TODO -- is this really necessary anymore for the NON-VAX files of VSANS. 563 // -- can this be made a pass-through, or will there be another function that is needed for VSANS? 564 // 565 Function/S V_ValidFileString(partialName) 566 String partialName 567 568 String tempName = "",msg="" 569 Variable ii,refnum 570 571 ii=0 572 do 573 if(ii==0) 574 //first pass, try the partialName 575 tempName = partialName 576 Open/Z/R/T="????TEXT"/P=catPathName refnum tempName //Does open file (/Z flag) 577 if(V_flag == 0) 578 //file exists 579 Close refnum //YES needed, 580 break 581 endif 582 else 583 tempName = partialName + ";" + num2str(ii) 584 Open/Z/R/T="????TEXT"/P=catPathName refnum tempName 585 if(V_flag == 0) 586 //file exists 587 Close refnum 588 break 589 endif 590 Endif 591 ii+=1 592 //print "ii=",ii 593 while(ii<11) 594 //go get the selected bits of information, using tempName, which exists 595 if(ii>=11) 596 //msg = partialName + " not found. is version number > 11?" 597 //DoAlert 0, msg 598 //PathInfo catPathName 599 //Print S_Path 600 Return ("") //use null string as error condition 601 Endif 602 603 Return (tempName) 604 End 605 606 //function to remove all spaces from names when searching for filenames 607 //the filename (as saved) will never have interior spaces (TTTTTnnn_AB _Bnnn) 608 //but the text field in the header WILL, if less than 3 characters were used for the 609 //user's initials, and can have leading spaces if prefix was less than 5 characters 610 // 611 //returns a string identical to the original string, except with the interior spaces removed 612 // 613 // local function for file name manipulation 614 // 615 Function/S V_RemoveAllSpaces(str) 616 String str 617 618 String tempstr = str 619 Variable ii,spc,len //should never be more than 2 or 3 trailing spaces in a filename 620 ii=0 621 do 622 len = strlen(tempStr) 623 spc = strsearch(tempStr," ",0) //is the last character a space? 624 if (spc == -1) 625 break //no more spaces found, get out 626 endif 627 str = tempstr 628 tempStr = str[0,(spc-1)] + str[(spc+1),(len-1)] //remove the space from the string 629 While(1) //should never be more than 2 or 3 630 631 If(strlen(tempStr) < 1) 632 tempStr = "" //be sure to return a null string if problem found 633 Endif 634 635 //Print strlen(tempstr) 636 637 Return(tempStr) 638 639 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf
r993 r994 304 304 // line fails (but reports no error), then DuplicateDataFolder fails, and reports an error. Trying 305 305 // to simplify this condition, I can't reproduce the bug for WM... 306 MacroConvert_to_Workfile(newtype, doadd)306 Proc Convert_to_Workfile(newtype, doadd) 307 307 String newtype,doadd 308 308 Prompt newtype,"WORK data type",popup,"SAM;EMP;BGD;ADJ;"
Note: See TracChangeset
for help on using the changeset viewer.