- Timestamp:
- Nov 13, 2015 4:03:38 PM (7 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf
r942 r969 2065 2065 // IndexForHistogram(data1,data2,myhist) 2066 2066 // Wave index=SavedIndex 2067 // JointHistogram(data1,data2,myHist,index)2067 // EV_JointHistogram(data1,data2,myHist,index) 2068 2068 // NewImage myHist 2069 2069 // … … 2073 2073 2074 2074 2075 Function JointHistogram(w0,w1,hist,index)2075 Function EV_JointHistogram(w0,w1,hist,index) 2076 2076 wave w0,w1,hist,index 2077 2077 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf
r961 r969 2 2 3 3 // 4 // This file has lots of utility procedures to be able to read/write 5 // test HDF5 files for SANS and VSANS in Nexus format 6 // 7 // It doesn't have the NICE logs, but has everything that I 8 // can think of here. 9 // 4 // This file has utility procedures to be able to read/write 5 // test HDF5 (from Igor) for SANS and VSANS in Nexus format 6 // 7 // It is predominantly to be able to WRITE a full Nexus file from Igor 8 // -- this is only necessary to be able to write out "fake" VSANS files from VCALC 9 // since I need a "template" of the Nexus folder structure to start from and fill in 10 // 11 // It doesn't reproduce the NICE logs, but will leave a spece for them if 12 // it is read in and is part of the xref. 13 // 14 // It may be easier to hard-wire my own folder definition (NewDataFolder) 15 // that is MY Nexus file to write out and use that as the base case 16 // rather than rely on Pete's code, which is terribly slow for writing. 17 // Attributes are the issue, but it may be unimportant if they are missing. 18 // 19 20 10 21 11 22 // -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf
r967 r969 1 1 #pragma rtGlobals=3 // Use modern global access method and strict wave access. 2 2 3 4 5 // 6 // Start to build up and test the r/w accessors for VSANS 7 // (SANS has a template, VSANS does not, so just start from scratch here, since the 8 // file structure will be different) 9 // 10 // 3 // 4 // The base functions for R/W from HDF5 files. 5 // All of the specific "get" and "write" functions call these base functions which are responsible 6 // for all of the open/close mechanics. 7 // 8 // These VSANS file-specific functions are in: 9 // V_HDF5_Read.ipf 10 // and 11 // V_HDF5_Write.ipf 12 // 13 11 14 12 15 13 16 // thought this would be useful, but the file name (folder) is stuck in the middle... 14 Strconstant ksPathPrefix = "root:(folder):entry:entry1:"17 //Strconstant ksPathPrefix = "root:(folder):entry:entry1:" 15 18 16 19 … … 152 155 End 153 156 157 // Returns a wave reference, not just a single value 158 // ---then you pick what you need from the wave 159 // 160 // - fname passed in is the full path to the file on disk 161 // - path is the path to the value in the HDF tree 162 // 163 // check to see if the value exists (It will be a wave) 164 // -- if it does, return the value from the local folder 165 // -- if not, read the file in, then return the value 166 // 167 Function/WAVE V_getTextWaveFromHDF5(fname,path) 168 String fname,path 169 170 String folderStr="" 171 Variable valExists=0 172 173 folderStr = V_RemoveDotExtension(V_GetFileNameFromPathNoSemi(fname)) 174 175 if(Exists("root:"+folderStr+":"+path)) 176 valExists=1 177 endif 178 179 if(!valExists) 180 //then read in the file 181 V_LoadHDF5_NoAtt(fname) 182 endif 183 184 // this should exist now - if not, I need to see the error 185 Wave/T wOut = $("root:"+folderStr+":"+path) 186 187 return wOut 188 189 End 190 191 154 192 // 155 193 // TODO … … 159 197 // 160 198 // truncate to integer before returning?? 199 // 200 // TODO 201 // write a "getIntegerWave" function?? 161 202 // 162 203 ////// integer values … … 390 431 return err 391 432 end 433 434 ////////////////////////////// 435 ////////////////////////////// 436 ////////////////////////////// 437 438 Function V_KillNamedDataFolder(fname) 439 String fname 440 441 Variable err=0 442 443 String folderStr = V_GetFileNameFromPathNoSemi(fname) 444 folderStr = V_RemoveDotExtension(folderStr) 445 446 KillDataFolder/Z $("root:"+folderStr) 447 err = V_flag 448 449 return(err) 450 end 451 452 //given a filename of a SANS data filename of the form 453 // name.anything 454 //returns the name as a string without the ".fbdfasga" extension 455 // 456 // returns the input string if a"." can't be found (maybe it wasn't there" 457 Function/S V_RemoveDotExtension(item) 458 String item 459 String invalid = item // 460 Variable num=-1 461 462 //find the "dot" 463 String runStr="" 464 Variable pos = strsearch(item,".",0) 465 if(pos == -1) 466 //"dot" not found 467 return (invalid) 468 else 469 //found, get all of the characters preceeding it 470 runStr = item[0,pos-1] 471 return (runStr) 472 Endif 473 End 474 475 //returns a string containing filename (WITHOUT the ;vers) 476 //the input string is a full path to the file (Mac-style, still works on Win in IGOR) 477 //with the folders separated by colons 478 // 479 // called by MaskUtils.ipf, ProtocolAsPanel.ipf, WriteQIS.ipf 480 // 481 Function/S V_GetFileNameFromPathNoSemi(fullPath) 482 String fullPath 483 484 Variable offset1,offset2 485 String filename="" 486 //String PartialPath 487 offset1 = 0 488 do 489 offset2 = StrSearch(fullPath, ":", offset1) 490 if (offset2 == -1) // no more colons ? 491 fileName = FullPath[offset1,strlen(FullPath) ] 492 //PartialPath = FullPath[0, offset1-1] 493 break 494 endif 495 offset1 = offset2+1 496 while (1) 497 498 //remove version number from name, if it's there - format should be: filename;N 499 filename = StringFromList(0,filename,";") //returns null if error 500 501 Return filename 502 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf
r967 r969 1080 1080 // so the FHWM will be different in each direction. May need to return 1081 1081 // "dummy" value for "B" detector if pixels there are square 1082 Function V_getDet_PixelFWHM (fname,detStr)1083 String fname,detStr 1084 1085 String path = "entry:instrument:detector_"+detStr+":PixelFWHM "1082 Function V_getDet_PixelFWHM_X(fname,detStr) 1083 String fname,detStr 1084 1085 String path = "entry:instrument:detector_"+detStr+":PixelFWHM_X" 1086 1086 1087 1087 // TODO -- different behavior for "B" … … 1093 1093 End 1094 1094 1095 // TODO -- write and X and Y version of this. Pixels are not square 1096 // so the FHWM will be different in each direction. May need to return 1097 // "dummy" value for "B" detector if pixels there are square 1098 Function V_getDet_PixelFWHM_Y(fname,detStr) 1099 String fname,detStr 1100 1101 String path = "entry:instrument:detector_"+detStr+":PixelFWHM_Y" 1102 1103 // TODO -- different behavior for "B" 1104 if(cmpstr(detStr,"B") == 0) 1105 return(V_getRealValueFromHDF5(fname,path)) 1106 else 1107 return(V_getRealValueFromHDF5(fname,path)) 1108 endif 1109 End 1110 1095 1111 Function V_getDet_PixelNumX(fname,detStr) 1096 1112 String fname,detStr … … 1468 1484 1469 1485 String path = "entry:instrument:sample_aperture:shape:size" 1486 WAVE w = V_getRealWaveFromHDF5(fname,path) 1487 1488 outW = w 1489 return(0) 1490 End 1491 1492 /////// sample_aperture_2 (data folder) 1493 1494 Function/S V_getSampleAp2_Description(fname) 1495 String fname 1496 1497 String path = "entry:instrument:sample_aperture_2:description" 1498 Variable num=60 1499 return(V_getStringFromHDF5(fname,path,num)) 1500 End 1501 1502 Function V_getSampleAp2_distance(fname) 1503 String fname 1504 1505 String path = "entry:instrument:sample_aperture_2:distance" 1506 return(V_getRealValueFromHDF5(fname,path)) 1507 End 1508 // shape (data folder) 1509 1510 Function/S V_getSampleAp2_shape(fname) 1511 String fname 1512 1513 String path = "entry:instrument:sample_aperture_2:shape:shape" 1514 Variable num=60 1515 return(V_getStringFromHDF5(fname,path,num)) 1516 End 1517 1518 // TODO -- this needs to return a WAVE, since the shape may be circle, or rectangle 1519 // and will need to return more than a single dimension 1520 // TODO -- be careful of the UNITS 1521 Function V_getSampleAp2_size(fname,outW) 1522 String fname 1523 Wave outW 1524 1525 String path = "entry:instrument:sample_aperture_2:shape:size" 1470 1526 WAVE w = V_getRealWaveFromHDF5(fname,path) 1471 1527 … … 1613 1669 1614 1670 1615 Function V_getSample_rotationAngle(fname)1616 String fname1617 1618 String path = "entry:sample:rotation_angle"1619 return(V_getRealValueFromHDF5(fname,path))1620 end1621 1622 1623 1671 //Sample Rotation Angle 1624 1672 Function V_getSampleRotationAngle(fname) … … 1666 1714 1667 1715 1668 1669 1670 1671 // sample label1672 //1673 // TODO1674 // limit to 60 characters?? do I need to do this with HDF5?1675 //1676 // do I need to pad to 60 characters?1677 //1678 Function V_WriteSamLabelToHeader(fname,str)1679 String fname,str1680 1681 // if(strlen(str) > 60)1682 // str = str[0,59]1683 // endif1684 1685 Make/O/T/N=1 tmpTW1686 String groupName = "/sample" // /entry is automatically prepended -- so just explicitly state the group1687 String varName = "description"1688 tmpTW[0] = str //1689 1690 variable err1691 err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW)1692 if(err)1693 Print "HDF write err = ",err1694 endif1695 1696 // now be sure to kill the data folder to force a re-read of the data next time this file is read in1697 err = V_KillNamedDataFolder(fname)1698 if(err)1699 Print "DataFolder kill err = ",err1700 endif1701 1702 return(err)1703 End1704 1705 // sample transmission1706 Function V_WriteTransmissionToHeader(fname,trans)1707 String fname1708 Variable trans1709 1710 Make/O/D/N=1 wTmpWrite1711 String groupName = "/sample" // skip "entry" - /entry/sample becomes groupName /entry/entry/sample1712 String varName = "transmission"1713 // Make/O/R/N=1 wTmpWrite1714 // String groupName = "/data" // skip "entry" - /entry/sample becomes groupName /entry/entry/sample1715 // String varName = "Transmission"1716 wTmpWrite[0] = trans //1717 1718 variable err1719 err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite)1720 if(err)1721 Print "HDF write err = ",err1722 endif1723 // now be sure to kill the data folder to force a re-read of the data next time this file is read in1724 err = V_KillNamedDataFolder(fname)1725 if(err)1726 Print "DataFolder kill err = ",err1727 endif1728 return(err)1729 End1730 1716 1731 1717 … … 1905 1891 End 1906 1892 1893 Function/S V_getTransmissionFileName(fname) 1894 String fname 1895 1896 String path = "entry:reduction:transmission_file_name" 1897 Variable num=60 1898 return(V_getStringFromHDF5(fname,path,num)) 1899 End 1900 1901 Function/S V_getEmptyBeamFileName(fname) 1902 String fname 1903 1904 String path = "entry:reduction:empty_beam_file_name" 1905 Variable num=60 1906 return(V_getStringFromHDF5(fname,path,num)) 1907 End 1908 1907 1909 1908 1910 //whole detector trasmission … … 2000 2002 2001 2003 2002 //////////////////////////////2003 //////////////////////////////2004 //////////////////////////////2005 2006 Function V_KillNamedDataFolder(fname)2007 String fname2008 2009 Variable err=02010 2011 String folderStr = V_GetFileNameFromPathNoSemi(fname)2012 folderStr = V_RemoveDotExtension(folderStr)2013 2014 KillDataFolder/Z $("root:"+folderStr)2015 err = V_flag2016 2017 return(err)2018 end2019 2020 //given a filename of a SANS data filename of the form2021 // name.anything2022 //returns the name as a string without the ".fbdfasga" extension2023 //2024 // returns the input string if a"." can't be found (maybe it wasn't there"2025 Function/S V_RemoveDotExtension(item)2026 String item2027 String invalid = item //2028 Variable num=-12029 2030 //find the "dot"2031 String runStr=""2032 Variable pos = strsearch(item,".",0)2033 if(pos == -1)2034 //"dot" not found2035 return (invalid)2036 else2037 //found, get all of the characters preceeding it2038 runStr = item[0,pos-1]2039 return (runStr)2040 Endif2041 End2042 2043 //returns a string containing filename (WITHOUT the ;vers)2044 //the input string is a full path to the file (Mac-style, still works on Win in IGOR)2045 //with the folders separated by colons2046 //2047 // called by MaskUtils.ipf, ProtocolAsPanel.ipf, WriteQIS.ipf2048 //2049 Function/S V_GetFileNameFromPathNoSemi(fullPath)2050 String fullPath2051 2052 Variable offset1,offset22053 String filename=""2054 //String PartialPath2055 offset1 = 02056 do2057 offset2 = StrSearch(fullPath, ":", offset1)2058 if (offset2 == -1) // no more colons ?2059 fileName = FullPath[offset1,strlen(FullPath) ]2060 //PartialPath = FullPath[0, offset1-1]2061 break2062 endif2063 offset1 = offset2+12064 while (1)2065 2066 //remove version number from name, if it's there - format should be: filename;N2067 filename = StringFromList(0,filename,";") //returns null if error2068 2069 Return filename2070 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf
r967 r969 3012 3012 // so the FHWM will be different in each direction. May need to return 3013 3013 // "dummy" value for "B" detector if pixels there are square 3014 Function V_writeDet_PixelFWHM (fname,detStr)3014 Function V_writeDet_PixelFWHM_X(fname,detStr,val) 3015 3015 String fname,detStr 3016 3017 String path = "entry:instrument:detector_"+detStr+":PixelFWHM" 3018 3019 // TODO -- different behavior for "B" 3020 if(cmpstr(detStr,"B") == 0) 3021 // return(V_writeRealValueFromHDF5(fname,path)) 3022 return(-99999) 3023 else 3024 // return(V_writeRealValueFromHDF5(fname,path)) 3025 return(-99999) 3026 endif 3027 End 3016 Variable val 3017 3018 // String path = "entry:instrument:detector_"+detStr+":PixelFWHM_X" 3019 3020 Make/O/D/N=1 wTmpWrite 3021 // Make/O/R/N=1 wTmpWrite 3022 String groupName = "/entry/instrument/detector_"+detStr 3023 String varName = "PixelFWHM_X" 3024 wTmpWrite[0] = val 3025 3026 variable err 3027 err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 3028 if(err) 3029 Print "HDF write err = ",err 3030 endif 3031 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 3032 err = V_KillNamedDataFolder(fname) 3033 if(err) 3034 Print "DataFolder kill err = ",err 3035 endif 3036 return(err) 3037 End 3038 3039 3040 // TODO -- write and X and Y version of this. Pixels are not square 3041 // so the FHWM will be different in each direction. May need to return 3042 // "dummy" value for "B" detector if pixels there are square 3043 Function V_writeDet_PixelFWHM_Y(fname,detStr,val) 3044 String fname,detStr 3045 Variable val 3046 3047 // String path = "entry:instrument:detector_"+detStr+":PixelFWHM_Y" 3048 3049 Make/O/D/N=1 wTmpWrite 3050 // Make/O/R/N=1 wTmpWrite 3051 String groupName = "/entry/instrument/detector_"+detStr 3052 String varName = "PixelFWHM_Y" 3053 wTmpWrite[0] = val 3054 3055 variable err 3056 err = V_WriteWaveToHDF(fname, groupName, varName, wTmpWrite) 3057 if(err) 3058 Print "HDF write err = ",err 3059 endif 3060 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 3061 err = V_KillNamedDataFolder(fname) 3062 if(err) 3063 Print "DataFolder kill err = ",err 3064 endif 3065 return(err) 3066 End 3067 3028 3068 3029 3069 Function V_writeDet_PixelNumX(fname,detStr,val) … … 5070 5110 End 5071 5111 5112 Function V_writeTransmissionFileName(fname,str) 5113 String fname,str 5114 5115 // String path = "entry:reduction:transmission_file_name" 5116 5117 Make/O/T/N=1 tmpTW 5118 String groupName = "/entry/reduction" 5119 String varName = "transmission_file_name" 5120 tmpTW[0] = str // 5121 5122 variable err 5123 err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW) 5124 if(err) 5125 Print "HDF write err = ",err 5126 endif 5127 5128 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 5129 err = V_KillNamedDataFolder(fname) 5130 if(err) 5131 Print "DataFolder kill err = ",err 5132 endif 5133 5134 return(err) 5135 End 5136 5137 Function V_writeEmptyBeamFileName(fname,str) 5138 String fname,str 5139 5140 // String path = "entry:reduction:empty_beam_file_name" 5141 5142 Make/O/T/N=1 tmpTW 5143 String groupName = "/entry/reduction" 5144 String varName = "empty_beam_file_name" 5145 tmpTW[0] = str // 5146 5147 variable err 5148 err = V_WriteTextWaveToHDF(fname, groupName, varName, tmpTW) 5149 if(err) 5150 Print "HDF write err = ",err 5151 endif 5152 5153 // now be sure to kill the data folder to force a re-read of the data next time this file is read in 5154 err = V_KillNamedDataFolder(fname) 5155 if(err) 5156 Print "DataFolder kill err = ",err 5157 endif 5158 5159 return(err) 5160 End 5161 5072 5162 5073 5163 //whole detector transmission -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_NexusFromIgor.ipf
r963 r969 5 5 ////////////////////////////// 6 6 // 7 // THIS IS DEPRICATED -- LOAD A NEXUS FILE INSTEAD AS A TEMPLATE 7 // This is not really used anymore - but may still be used in the future. I need somenthing like this 8 // to be able to write a full Nexus file from Igor, but I still don't know the best way to 9 // do the setup to match the "real" NICE-generated file structure. Modifying the DataFolderTree.ipf 10 // to generate the NewDataFolder and Make statements may be a reliable way to reproduce the correct 11 // structure from NICE, with the exception that NOT EVERY field is written out from NICE, depending 12 // on the experiment setup!!! 8 13 // 9 14 // AUG 2015 15 // NOV 2015 10 16 // 11 17 //////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.