Changeset 116 for sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/Transmission.ipf
- Timestamp:
- May 31, 2007 12:58:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/Transmission.ipf
r47 r116 250 250 String fname,sname 251 251 252 Variable isTrans, xTol= -5 253 254 String textstr,temp,labelStr,date_time,suffix,assoc 255 Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten 256 Variable lastPoint, beamstop, Whole 257 258 isTrans = CheckIfBeamstopOut(fname, xTol) 252 Variable isTrans 253 254 Variable lastPoint 255 256 isTrans = isTransFile(fname) 259 257 // decalre the correct set of waves 260 258 // S_Whole is only a place holder so the waves are of equal length … … 283 281 lastPoint = numpnts(GLambda) 284 282 285 Open/R refNum as fname286 287 283 InsertPoints lastPoint,1,G_TRANS_Filenames 288 284 G_TRANS_Filenames[lastPoint]="" … … 292 288 293 289 //read the file suffix 294 FSetPos refNum,19295 FReadLine/N=4 refNum,suffix296 //print suffix297 290 InsertPoints lastPoint,1,GSuffix 298 GSuffix[lastPoint]= suffix291 GSuffix[lastPoint]=getSuffix(fname) 299 292 300 293 //read any suffix that this file is associated with 301 //FSetPos refNum,91 //wrong position302 FSetPos refNum,404303 FReadLine/N=4 refNum,assoc304 //print isTrans, assoc305 294 InsertPoints lastPoint,1,GSuffices 306 GSuffices[lastPoint]= assoc295 GSuffices[lastPoint]=getAssociatedFileSuffix(fname) 307 296 308 297 // read the sample.label text field 309 FSetPos refNum,98 //will start reading at byte 99310 FReadLine/N=60 refNum,labelStr311 298 InsertPoints lastPoint,1,GLabels 312 GLabels[lastPoint]=labelStr 313 314 Close refNum 299 GLabels[lastPoint]=getSampleLabel(fname) 315 300 316 //read the reals with GBLoadWave 317 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 318 String strToExecute 319 301 320 302 //Transmission 321 strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\""322 Execute strToExecute323 Wave w=$"tempGBWave0"324 trans = w[0]325 303 InsertPoints lastPoint,1,GTransmission 326 GTransmission[lastPoint]=trans 327 328 //Whole Transmission 329 strToExecute = GBLoadStr + "/S=392/U=1" + "\"" + fname + "\"" 330 Execute strToExecute 331 Wave w=$"tempGBWave0" 332 Whole = w[0] 304 GTransmission[lastPoint]=getSampleTrans(fname) 305 306 //Whole detector Transmission 333 307 InsertPoints lastPoint,1,GWhole 334 GWhole[lastPoint]= Whole308 GWhole[lastPoint]=getSampleTransWholeDetector(fname) 335 309 336 310 //SDD 337 strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\""338 Execute strToExecute339 sdd = w[0]340 311 InsertPoints lastPoint,1,GSDD 341 GSDD[lastPoint]= sdd312 GSDD[lastPoint]=getSDD(fname) 342 313 343 314 //wavelength 344 strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\""345 Execute strToExecute346 lambda = w[0]347 315 InsertPoints lastPoint,1,GLambda 348 GLambda[lastPoint]=lambda 349 350 // InsertPoints lastPoint,1,GWhole 351 // GWhole[lastPoint]=1 352 353 KillWaves/Z w 354 316 GLambda[lastPoint]=getWavelength(fname) 317 318 return(0) 355 319 End 356 320 … … 533 497 suffix=T_GSuffix[jj] 534 498 filename = pathname + T_GFilenames[ii] 535 Open/A/T="????TEXT" refnum as filename 536 //FSetPos refnum,91 //wrong position 537 FSetPos refnum,404 538 FBinWrite refnum, suffix 539 FStatus refnum 540 FSetPos refnum,V_logEOF 541 Close refnum 499 WriteAssocFileSuffixToHeader(filename,suffix) 542 500 endif 543 501 jj+=1 … … 556 514 suffix=T_GSuffix[jj] 557 515 filename = pathname + S_GFilenames[ii] 558 Open/A/T="????TEXT" refnum as filename 559 //FSetPos refnum,91 //wrong position 560 FSetPos refnum,404 561 FBinWrite refnum, suffix 562 FStatus refnum 563 FSetPos refnum,V_logEOF 564 Close refnum 516 WriteAssocFileSuffixToHeader(filename,suffix) 565 517 endif 566 518 jj+=1 … … 601 553 suffix=T_GSuffix[jj] 602 554 filename = pathname + T_GFilenames[ii] 603 Open/A/T="????TEXT" refnum as filename 604 //FSetPos refnum,91 //wrong position 605 FSetPos refnum,404 606 FBinWrite refnum, suffix 607 FStatus refnum 608 FSetPos refnum,V_logEOF 609 Close refnum 555 WriteAssocFileSuffixToHeader(filename,suffix) 610 556 endif 611 557 jj+=1 … … 662 608 663 609 // write in zeros for the box coordinates 664 Open/A/T="????TEXT" refnum as filename 665 FSetPos refnum,478 666 FBinWrite/F=3/B=3 refNum, zero 667 FBinWrite/F=3/B=3 refNum, zero 668 FBinWrite/F=3/B=3 refNum, zero 669 FBinWrite/F=3/B=3 refNum, zero 670 FStatus refnum //move to the end of the file before closing 671 FSetPos refnum,V_logEOF 672 Close refnum 673 610 WriteXYBoxToHeader(filename,0,0,0,0) 611 674 612 // write in a null suffix 675 Open/A/T="????TEXT" refnum as filename 676 FSetPos refnum,404 //suffix start byte is 404 677 FBinWrite refnum, suffix 678 FStatus refnum 679 FSetPos refnum,V_logEOF 680 Close refnum 613 WriteAssocFileSuffixToHeader(filename,suffix) 681 614 682 //write a trans==1 to the file header of the raw data (open/close done in function) 683 ReWriteReal(filename,1,158) //transmission start byte is 158 684 ReWriteReal(filename,1,392) //WholeTrans start byte is 392 615 //write a trans==1 to the file header of the raw data 616 WriteTransmissionToHeader(filename,1) //sample trans 617 618 WriteWholeTransToHeader(filename,1) //WholeTrans start byte is 392 685 619 686 620 //then update the table that is displayed … … 693 627 endif 694 628 695 // // Write suffix of empty beam file into transmission files696 // ii= 0697 // do698 // if (cmpstr(T_EMP_Filenames[ii],"")!=0)699 // jj=0700 // do701 // if (cmpstr(T_EMP_Filenames[ii],T_GFilenames[jj])==0)702 // suffix=T_GSuffix[jj]703 // filename = pathname + T_GFilenames[ii]704 // Open/A/T="????TEXT" refnum as filename705 // //FSetPos refnum,91 //wrong position706 // FSetPos refnum,404707 // FBinWrite refnum, suffix708 // FStatus refnum709 // FSetPos refnum,V_logEOF710 // Close refnum711 // endif712 // jj+=1713 // while(jj<num_t_files)714 // endif715 // ii+=1716 // while(ii<num_t_files)717 629 718 630 if(target == 1) … … 721 633 do 722 634 filename = pathname + S_GFilenames[ii] 723 Open/A/T="????TEXT" refnum as filename 724 //FSetPos refnum,91 //wrong position 725 FSetPos refnum,404 726 FBinWrite refnum, suffix 727 FStatus refnum 728 FSetPos refnum,V_logEOF 729 Close refnum 635 // write in a null suffix 636 WriteAssocFileSuffixToHeader(filename,suffix) 730 637 731 638 //write a trans==1 to the file header of the raw data (open/close done in function) 732 ReWriteReal(filename,1,158) //transmission start byte is 158639 WriteTransmissionToHeader(filename,1) //sample trans 733 640 734 641 //then update the table that is displayed … … 742 649 return(0) 743 650 End 744 745 746 // assigns both the empty file to the trans file747 // and the trans file to the scattering file748 // - writes out 4 characters to the file headers @ byte 404749 //750 // assignments are only permanently made when the transmissions751 // are actually calculated752 //753 // NOT USED - AssignSelTransFilestoData(first,last) has been generalized to take a range754 // 3/31/04 SRK755 //Function AssignTransFilesToData()756 //757 // Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames"758 // Wave/T T_GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices"759 // Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames"760 // Wave/T T_GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix"761 //762 // Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames"763 // Wave/T S_GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices"764 // Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames"765 // Wave/T S_GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix"766 //767 // Variable num_s_files, num_t_files, ii, jj768 // Variable refnum769 // num_t_files = numpnts(T_GFilenames)770 // num_s_files = numpnts(S_GFilenames)771 // String suffix = ""772 // PathInfo catPathName773 // String pathname = S_path774 // String filename775 //776 // // Write suffix of empty beam file into transmission files777 // ii= 0778 // do779 // if (cmpstr(T_EMP_Filenames[ii],"")!=0)780 // jj=0781 // do782 // if (cmpstr(T_EMP_Filenames[ii],T_GFilenames[jj])==0)783 // suffix=T_GSuffix[jj]784 // filename = pathname + T_GFilenames[ii]785 // Open/A/T="????TEXT" refnum as filename786 // //FSetPos refnum,91 //wrong position787 // FSetPos refnum,404788 // FBinWrite refnum, suffix789 // FStatus refnum790 // FSetPos refnum,V_logEOF791 // Close refnum792 // endif793 // jj+=1794 // while(jj<num_t_files)795 // endif796 // ii+=1797 // while(ii<num_t_files)798 //799 // // Write suffix of transmission files into scattering files800 // ii= 0801 // do802 // if (cmpstr(S_TRANS_Filenames[ii],"")!=0)803 // jj=0804 // do805 // if (cmpstr(S_TRANS_Filenames[ii],T_GFilenames[jj])==0)806 // suffix=T_GSuffix[jj]807 // filename = pathname + S_GFilenames[ii]808 // Open/A/T="????TEXT" refnum as filename809 // //FSetPos refnum,91 //wrong position810 // FSetPos refnum,404811 // FBinWrite refnum, suffix812 // FStatus refnum813 // FSetPos refnum,V_logEOF814 // Close refnum815 // endif816 // jj+=1817 // while(jj<num_t_files)818 // endif819 // ii+=1820 // while(ii<num_s_files)821 //822 // return(0)823 //End824 825 826 827 // NOT USED --- CalcSelTransFromHeader(first,last) has been generalized to accept a selection828 // and modified to account for different attenuation factors. 3/31/04 SRK829 //830 //Function CalcTransFromHeader()831 // String filename832 // Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames"833 // Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames"834 //835 // Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames"836 // Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames"837 // Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission"838 //839 // Variable num_s_files, num_t_files, ii, jj840 // Variable refnum, transCts, emptyCts841 // num_t_files = numpnts(T_GFilenames)842 // num_s_files = numpnts(S_GFilenames)843 // String suffix = ""844 // PathInfo catPathName845 // String pathname = S_path846 // String textStr="",abortStr=""847 // String emptyFile, transFile848 //849 // ii= 0850 // do851 // if (cmpstr(S_TRANS_Filenames[ii],"")!=0)852 // jj=0853 // do854 // if (cmpstr(S_TRANS_Filenames[ii],T_GFilenames[jj])==0)855 // //Look for an empty beam for the transmission then856 // if (cmpstr(T_EMP_Filenames[jj],"")!=0)//Do the transmission calculation857 // textStr = ""858 // filename=pathname+S_GFilenames[ii]859 // emptyFile = pathname+T_EMP_Filenames[jj]860 // transFile = pathname+T_GFilenames[jj]861 // //////////862 // // check the empty beam file for previously selected coordinates863 // //if they exist, set the xy string , save the normalized counts somewhere864 // //the value was written to an unused r*4 header analysis.factor (@b494)865 // Variable x1,x2,y1,y2,err866 // Open/R refnum as emptyFile867 // FSetPos refnum,478868 // FBinRead/F=3/B=3 refnum, x1869 // FBinRead/F=3/B=3 refnum, x2870 // FBinRead/F=3/B=3 refnum, y1871 // FBinRead/F=3/B=3 refnum, y2872 // Close refnum873 // //read the real count value874 // String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q"875 // String strToExecute876 // strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\""877 // Execute strToExecute878 // Wave w=$"tempGBWave0"879 // Variable/G root:myGlobals:Patch:gTransCts = w[0]880 // emptyCts = w[0]881 //882 // //883 // if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction884 // //no region selected885 // //prompt user to select box w/marquee886 // DoWindow/F TransFileTable887 // Abort "Use \"Set BCENT File\", then \"SetXYBox\" to select XY range in empty beam file "+T_EMP_Filenames[jj]888 // //from here the Marquee menu selection must handle the task of setting the box889 // //and updating the information in the file header890 // Endif891 //892 // //read in trans file to add to SAM893 // ReadHeaderAndData(transFile)894 // //adds to SAM895 // err = Raw_to_work("SAM")896 // //sum region in SAM897 // transCts = SumCountsInBox(x1,x2,y1,y2,"SAM")898 //899 // //calculate trans based on empty beam value900 // Variable trans= transCts/emptyCts901 //902 // //write out counts and transmission903 // textstr += " Trans counts = "+num2str(transCts) + " Trans = "+num2str(trans)904 // Print S_GFilenames[ii], textstr905 // //Print ii,jj906 // //Print "Empty counts = ",emptycts, "Trans counts = "+num2str(transCts) + " Trans = "+num2str(trans)907 //908 // //write the trans to the file header of the raw data (open/close done in function)909 // Variable start = 158 //transmission start byte910 // ReWriteReal(filename,trans,start)911 //912 // //then update the global that is displayed913 // S_GTransmission[ii] = trans914 //915 // else // There is no empty assigned916 // abortStr = "Empty beam file not assigned properly for " + T_GFilenames[jj]917 // Print abortStr918 // //Abort abortStr919 // return(1)920 // endif921 // endif922 // jj+=1923 // while(jj<num_t_files)924 // else //no transmission file925 // abortStr = "Transmission beam file not assigned properly for " + S_GFilenames[ii]926 // Print abortStr927 // endif928 // ii+=1929 // while(ii<num_s_files)930 // print "done"931 // return(0)932 //End933 934 935 651 936 652 //given a selection of scattering files, calculates the transmission … … 997 713 //if they exist, set the xy string , save the normalized counts somewhere 998 714 //the value was written to an unused r*4 header analysis.factor (@b494) 999 Open/R refnum as emptyFile 1000 FSetPos refnum,478 1001 FBinRead/F=3/B=3 refnum, x1 1002 FBinRead/F=3/B=3 refnum, x2 1003 FBinRead/F=3/B=3 refnum, y1 1004 FBinRead/F=3/B=3 refnum, y2 1005 Close refnum 715 GetXYBoxFromFile(emptyFile,x1,x2,y1,y2) 716 1006 717 //read the real count value 1007 strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\"" 1008 Execute strToExecute 1009 Wave w=$"tempGBWave0" 1010 // Variable/G root:myGlobals:Patch:gTransCts = w[0] 1011 emptyCts = w[0] 718 emptyCts = getBoxCounts(emptyFile) 1012 719 // read the attenuator number of the empty beam file 1013 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + emptyFile + "\"" 1014 Execute strToExecute 1015 attenEmp = w[3] 720 attenEmp = getAttenNumber(emptyFile) 1016 721 // 1017 722 if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction … … 1046 751 endif 1047 752 //write the trans to the file header of the raw data (open/close done in function) 1048 ReWriteReal(filename,trans,158) //transmission start byte is 158753 WriteTransmissionToHeader(filename,trans) 1049 754 1050 755 //then update the global that is displayed … … 1117 822 //if they exist, set the xy string , save the normalized counts somewhere 1118 823 //the value was written to an unused r*4 header analysis.factor (@b494) 1119 Open/R refnum as emptyFile 1120 FSetPos refnum,478 1121 FBinRead/F=3/B=3 refnum, x1 1122 FBinRead/F=3/B=3 refnum, x2 1123 FBinRead/F=3/B=3 refnum, y1 1124 FBinRead/F=3/B=3 refnum, y2 1125 Close refnum 824 getXYBoxFromFile(emptyFile,x1,x2,y1,y2) 825 1126 826 //read the real count value 1127 strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\"" 1128 Execute strToExecute 1129 Wave w=$"tempGBWave0" 1130 // Variable/G root:myGlobals:Patch:gTransCts = w[0] 1131 emptyCts = w[0] 827 emptyCts = getBoxCounts(emptyFile) 1132 828 // read the attenuator number of the empty beam file 1133 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + emptyFile + "\"" 1134 Execute strToExecute 1135 attenEmp = w[3] 829 attenEmp = getAttenNumber(emptyFile) 1136 830 // 1137 831 if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction … … 1168 862 endif 1169 863 //write the trans to the file header of the raw data (open/close done in function) 1170 ReWriteReal(filename,trans,158) //transmission start byte is 158864 WriteTransmissionToHeader(filename,trans) //transmission start byte is 158 1171 865 1172 866 //then update the global that is displayed … … 1195 889 // For the calculation of the Transmission using only the whole detector 1196 890 // Used to compute the transmission for the TransmissionFiles table using 1197 // the entire computer. For comparison with the "box" trans1198 // updated: 5/11/2006 b oBryan Greenwald891 // the entire detector. For comparison with the "box" trans 892 // updated: 5/11/2006 by Bryan Greenwald 1199 893 Function CalcWholeTrans(startRow,endRow) 1200 894 Variable startRow,endRow 1201 895 // GetSelection table,ScatterFileTable,1 1202 896 897 NVAR pixelsX = root:myGlobals:gNPixelsX 898 NVAR pixelsY = root:myGlobals:gNPixelsY 899 1203 900 String filename 1204 901 Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" … … 1239 936 //if they exist, set the xy string , save the normalized counts somewhere 1240 937 //the value was written to an unused r*4 header analysis.factor (@b494) 1241 Open/R refnum as emptyFile 1242 FSetPos refnum,478 1243 FBinRead/F=3/B=3 refnum, x1 1244 FBinRead/F=3/B=3 refnum, x2 1245 FBinRead/F=3/B=3 refnum, y1 1246 FBinRead/F=3/B=3 refnum, y2 1247 Close refnum 938 939 getXYBoxFromFile(emptyFile,x1,x2,y1,y2) 1248 940 //read the real count value 1249 strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\"" 1250 Execute strToExecute 1251 Wave w=$"tempGBWave0" 1252 // Variable/G root:myGlobals:Patch:gTransCts = w[0] 1253 emptyCts = w[0] 941 emptyCts = getBoxCounts(emptyFile) 1254 942 // read the attenuator number of the empty beam file 1255 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + emptyFile + "\"" 1256 Execute strToExecute 1257 attenEmp = w[3] 943 attenEmp = getAttenNumber(emptyFile) 1258 944 // 1259 945 if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction … … 1269 955 err = Raw_to_work("SAM") 1270 956 //sum region in SAM 1271 transCts = Sum TotalCounts("SAM")957 transCts = SumCountsInBox(0,pixelsX-1,0,pixelsY-1,"SAM") 1272 958 // get the attenuator, lambda, and sample string (to get the instrument) 1273 959 WAVE/T samText = $"root:SAM:textRead" … … 1295 981 endif 1296 982 //write the trans to the file header of the raw data (open/close done in function) 1297 ReWriteReal(filename,trans,392) //WholeTrans start byte is 392983 WriteWholeTransToHeader(filename,trans) 1298 984 1299 985 //then update the global that is displayed … … 1480 1166 //the value was written to an unused r*4 header analysis.factor (@b494) 1481 1167 Variable refnum,x1,x2,y1,y2,err 1482 Open/R refnum as filename 1483 FSetPos refnum,478 1484 FBinRead/F=3/B=3 refnum, x1 1485 FBinRead/F=3/B=3 refnum, x2 1486 FBinRead/F=3/B=3 refnum, y1 1487 FBinRead/F=3/B=3 refnum, y2 1488 Close refnum 1489 //read the real count value 1490 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 1491 String strToExecute 1492 strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + filename + "\"" 1493 Execute strToExecute 1494 Wave w=$"tempGBWave0" 1495 Variable/G root:myGlobals:gTransCts = w[0] //***NOTE this is NOT in the Trans sub-folder 1168 getXYBoxFromFile(filename,x1,x2,y1,y2) 1169 1170 //read the real count value, assign to a global 1171 Variable/G root:myGlobals:gTransCts = getBoxCounts(filename) //***NOTE this is NOT in the Trans sub-folder 1496 1172 // 1497 1173 if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction … … 1544 1220 1545 1221 UpdateBoxCoordinates() 1546 KillWaves/Z w1547 1222 Return (0) 1548 1223 End … … 1610 1285 End 1611 1286 1612 // b BGtoFix -comment to describe the workings of the function1613 // since it's different than calculating the regular transmission1614 1287 // 1615 1288 // I am not sure what the difference is inthe function of CalcTotalTrans and CalcWholeTrans ? 1616 1289 // do they really do anything different? 1290 // is it a useful calculation at all? 1617 1291 // 1618 1292 Function TotalTrans(ctrlName) : ButtonControl … … 1620 1294 1621 1295 Variable transTableExists 1622 transTableExists = WinType(" ScatterFileTable") // b BGtoFix -checking for the existence of the wrong table1296 transTableExists = WinType("TransFileTable") 1623 1297 if (transTableExists != 0) 1624 1298 GetSelection table,transFileTable,1 … … 1629 1303 CalcWholeTrans(V_StartRow,V_EndRow) 1630 1304 Else 1631 DoAlert 0,"No selection from Scattering Files table" // b BGtoFix - really looking for files from the Trans Table...1305 DoAlert 0,"No selection from Trans Files table" 1632 1306 Endif 1633 1307 Else 1634 DoAlert 0,"No file selected from Scattering Files table or no Scattering Files table available" // b BGtoFix - really looking for files from the Trans Table...1308 DoAlert 0,"No file selected from Trans Files table or no Trans Files table available" 1635 1309 Endif 1636 1310 End … … 1652 1326 End 1653 1327 1654 1655 //function to check the header of a raw data file (full path specified by fname)1656 //checks the field of the x-position of the beamstop during data collection1657 //if the x-position is more negatice (farther to the left) than xTol(input)1658 //the the beamstop is "out" and the file is a transmission run and not a scattering run1659 //xtol typically set at -5 (cm) - trans runs have bs(x) at -10 to -15 cm1660 // function returns 1 if beamstop is out, 0 if beamstop is in1661 //1662 Function CheckIfBeamstopOut(fName,xTol)1663 String fname1664 Variable xTol1665 1666 Variable refnum,xpos1667 //pos = 369, read one real value1668 1669 SetDataFolder root:1670 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q"1671 String strToExecute=""1672 // 1 R*4 value1673 strToExecute = GBLoadStr + "/S=368/U=1" + "\"" + fname + "\""1674 Execute strToExecute1675 Wave w=$"root:tempGBWave0"1676 xPos = w[0]1677 KillWaves/Z w1678 //Print "xPos = ",xpos1679 1680 if(xpos<=xTol)1681 //xpos is farther left (more negative) than xtol (currently -5 cm)1682 Return(1)1683 else1684 //some other file1685 Return(0)1686 Endif1687 End1688 1328 1689 1329 //function to update the box coordinates of the file selected as the … … 1711 1351 1712 1352 Variable refnum,x1,x2,y1,y2,err 1713 Open/R refnum as filename 1714 FSetPos refnum,478 1715 FBinRead/F=3/B=3 refnum, x1 1716 FBinRead/F=3/B=3 refnum, x2 1717 FBinRead/F=3/B=3 refnum, y1 1718 FBinRead/F=3/B=3 refnum, y2 1719 Close refnum 1720 1353 GetXYBoxFromFile(filename,x1,x2,y1,y2) 1354 1721 1355 //and update the global string 1722 1356 String msgStr="" … … 1807 1441 End 1808 1442 1809 //****************** 1810 //lookup tables for attenuator transmissions 1811 //NG3 and NG7 attenuators are physically different, so the transmissions are slightly different 1812 //NG1 - (8m SANS) is not supported 1813 1814 Proc MakeNG3AttenTable() 1815 1816 NewDataFolder/O root:myGlobals:Attenuators 1817 //do explicitly to avoid data folder problems, redundant, but it must work without fail 1818 Make/O/N=9 root:myGlobals:Attenuators:ng3att0 1819 Make/O/N=9 root:myGlobals:Attenuators:ng3att1 1820 Make/O/N=9 root:myGlobals:Attenuators:ng3att2 1821 Make/O/N=9 root:myGlobals:Attenuators:ng3att3 1822 Make/O/N=9 root:myGlobals:Attenuators:ng3att4 1823 Make/O/N=9 root:myGlobals:Attenuators:ng3att5 1824 Make/O/N=9 root:myGlobals:Attenuators:ng3att6 1825 Make/O/N=9 root:myGlobals:Attenuators:ng3att7 1826 Make/O/N=9 root:myGlobals:Attenuators:ng3att8 1827 Make/O/N=9 root:myGlobals:Attenuators:ng3att9 1828 Make/O/N=9 root:myGlobals:Attenuators:ng3att10 1829 1830 //each wave has 8 elements, the transmission of att# at the wavelengths 1831 //lambda = 5,6,7,8,10,12,14,17 1832 Make/O/N=9 root:myGlobals:Attenuators:ng3lambda={5,6,7,8,10,12,14,17,20} 1833 root:myGlobals:Attenuators:ng3att0 = {1, 1, 1, 1, 1, 1, 1, 1,1 } 1834 root:myGlobals:Attenuators:ng3att1 = {0.421, 0.394, 0.371, 0.349, 0.316, 0.293, 0.274, 0.245,0.220} 1835 root:myGlobals:Attenuators:ng3att2 = {0.187, 0.164, 0.145, 0.130, 0.106, 0.0916, 0.0808, 0.0651,0.0531} 1836 root:myGlobals:Attenuators:ng3att3 = {0.0777, 0.0636, 0.0534, 0.0446, 0.0330, 0.0262, 0.0217, 0.0157 ,0.0116} 1837 root:myGlobals:Attenuators:ng3att4 = {0.0328, 0.0252, 0.0195, 0.0156, 0.0104, 7.68e-3, 5.98e-3, 3.91e-3,0.00262} 1838 root:myGlobals:Attenuators:ng3att5 = {0.0139, 9.94e-3, 7.34e-3, 5.44e-3, 3.29e-3, 2.25e-3, 1.66e-3, 9.95e-4, 6.12e-4} 1839 root:myGlobals:Attenuators:ng3att6 = {5.95e-3, 3.97e-3, 2.77e-3, 1.95e-3, 1.06e-3, 6.81e-4, 4.71e-4, 2.59e-4 , 1.45e-4} 1840 root:myGlobals:Attenuators:ng3att7 = {1.07e-3, 6.24e-4, 3.90e-4, 2.44e-4, 1.14e-4, 6.55e-5, 4.10e-5, 1.64e-5 , 7.26e-6} 1841 root:myGlobals:Attenuators:ng3att8 = {1.90e-4, 9.84e-5, 5.60e-5, 3.25e-5, 1.55e-5, 6.60e-6, 3.42e-6, 1.04e-6 , 3.48e-7} 1842 root:myGlobals:Attenuators:ng3att9 = {3.61e-5, 1.74e-5, 9.90e-6, 6.45e-6, 2.35e-6, 6.35e-7, 2.86e-7, 6.61e-8 , 1.73e-8} 1843 root:myGlobals:Attenuators:ng3att10 = {7.60e-6, 3.99e-6, 2.96e-6, 2.03e-6, 3.34e-7, 6.11e-8, 2.39e-8, 4.19e-9 , 8.60e-10} 1844 1845 End 1846 1847 Proc MakeNG7AttenTable() 1848 1849 NewDataFolder/O root:myGlobals:Attenuators 1850 1851 Make/O/N=9 root:myGlobals:Attenuators:ng7att0 1852 Make/O/N=9 root:myGlobals:Attenuators:ng7att1 1853 Make/O/N=9 root:myGlobals:Attenuators:ng7att2 1854 Make/O/N=9 root:myGlobals:Attenuators:ng7att3 1855 Make/O/N=9 root:myGlobals:Attenuators:ng7att4 1856 Make/O/N=9 root:myGlobals:Attenuators:ng7att5 1857 Make/O/N=9 root:myGlobals:Attenuators:ng7att6 1858 Make/O/N=9 root:myGlobals:Attenuators:ng7att7 1859 Make/O/N=9 root:myGlobals:Attenuators:ng7att8 1860 Make/O/N=9 root:myGlobals:Attenuators:ng7att9 1861 Make/O/N=9 root:myGlobals:Attenuators:ng7att10 1862 1863 //each wave has 8 elements, the transmission of att# at the wavelengths 1864 //lambda = 5,6,7,8,10,12,14,17 1865 Make/O/N=9 root:myGlobals:Attenuators:ng7lambda={5,6,7,8,10,12,14,17,20} 1866 root:myGlobals:Attenuators:ng7att0 = {1, 1, 1, 1, 1, 1, 1, 1 ,1} 1867 root:myGlobals:Attenuators:ng7att1 = {0.418, 0.393, 0.369, 0.347, 0.313, 0.291, 0.271, 0.244, 0.219 } 1868 root:myGlobals:Attenuators:ng7att2 = {0.189, 0.167, 0.148, 0.132, 0.109, 0.0945, 0.0830, 0.0681, 0.0560} 1869 root:myGlobals:Attenuators:ng7att3 = {0.0784, 0.0651, 0.0541, 0.0456, 0.0340, 0.0273, 0.0223, 0.0164 , 0.0121} 1870 root:myGlobals:Attenuators:ng7att4 = {0.0328, 0.0256, 0.0200, 0.0159, 0.0107, 7.98e-3, 6.14e-3, 4.09e-3 , 0.00274} 1871 root:myGlobals:Attenuators:ng7att5 = {0.0139, 0.0101, 7.43e-3, 5.58e-3, 3.42e-3, 2.36e-3, 1.70e-3, 1.03e-3 , 6.27e-4} 1872 root:myGlobals:Attenuators:ng7att6 = {5.90e-3, 4.07e-3, 2.79e-3, 1.99e-3, 1.11e-3, 7.13e-4, 4.91e-4, 2.59e-4 , 1.42e-4} 1873 root:myGlobals:Attenuators:ng7att7 = {1.04e-3, 6.37e-4, 3.85e-4, 2.46e-4, 1.16e-4, 6.86e-5, 4.10e-5, 1.64e-5 ,7.02e-6} 1874 root:myGlobals:Attenuators:ng7att8 = {1.90e-4, 1.03e-4, 5.71e-5, 3.44e-5, 1.65e-5, 6.60e-6, 3.42e-6, 1.04e-6 , 3.48e-7} 1875 root:myGlobals:Attenuators:ng7att9 = {3.58e-5, 1.87e-5, 1.05e-5, 7.00e-6, 2.35e-6, 6.35e-7, 2.86e-7, 6.61e-8 , 1.73e-8} 1876 root:myGlobals:Attenuators:ng7att10 = {7.76e-6, 4.56e-6, 3.25e-6, 2.03e-6, 3.34e-7, 6.11e-8, 2.39e-8, 4.19e-9, 8.60e-10} 1877 1878 End 1879 1880 //returns the transmission of the attenuator (at NG3) given the attenuator number 1881 //which must be an integer(to select the wave) and given the wavelength. 1882 //the wavelength may be any value between 5 and 20 (A), and is interpolated 1883 //between calibrated wavelengths for a given attenuator 1884 Function LookupAttenNG3(lambda,attenNo) 1885 Variable lambda, attenNo 1886 1887 Variable trans 1888 String attStr="root:myGlobals:Attenuators:ng3att"+num2str(trunc(attenNo)) 1889 String lamStr = "root:myGlobals:Attenuators:ng3lambda" 1890 1891 if(attenNo == 0) 1892 return (1) //no attenuation, return trans == 1 1893 endif 1894 1895 if( (lambda < 5) || (lambda > 20 ) ) 1896 Abort "Wavelength out of calibration range (5,20). You must manually enter the absolute parameters" 1897 Endif 1898 1899 if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 1900 Execute "MakeNG3AttenTable()" 1901 Endif 1902 //just in case creating the tables fails.... 1903 if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 1904 Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" 1905 Endif 1906 1907 //lookup the value by interpolating the wavelength 1908 //the attenuator must always be an integer 1909 Wave att = $attStr 1910 Wave lam = $lamstr 1911 trans = interp(lambda,lam,att) 1912 1913 // Print "trans = ",trans 1914 1915 return trans 1916 End 1917 1918 //returns the transmission of the attenuator (at NG7) given the attenuator number 1919 //which must be an integer(to select the wave) and given the wavelength. 1920 //the wavelength may be any value between 5 and 20 (A), and is interpolated 1921 //between calibrated wavelengths for a given attenuator 1922 // 1923 // this set of tables is also used for NG5 (NG1) SANS instrument - as the attenuator has yet to be calibrated 1924 Function LookupAttenNG7(lambda,attenNo) 1925 Variable lambda, attenNo 1926 1927 Variable trans 1928 String attStr="root:myGlobals:Attenuators:ng7att"+num2str(trunc(attenNo)) 1929 String lamStr = "root:myGlobals:Attenuators:ng7lambda" 1930 1931 if(attenNo == 0) 1932 return (1) //no attenuation, return trans == 1 1933 endif 1934 1935 if( (lambda < 5) || (lambda > 20 ) ) 1936 Abort "Wavelength out of calibration range (5,20). You must manually enter the absolute parameters" 1937 Endif 1938 1939 if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 1940 Execute "MakeNG7AttenTable()" 1941 Endif 1942 //just in case creating the tables fails.... 1943 if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 1944 Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" 1945 Endif 1946 1947 //lookup the value by interpolating the wavelength 1948 //the attenuator must always be an integer 1949 Wave att = $attStr 1950 Wave lam = $lamstr 1951 trans = interp(lambda,lam,att) 1952 1953 //Print "trans = ",trans 1954 1955 return trans 1956 1957 End 1958 1959 //returns the proper attenuation factor based on the instrument (NG3, NG5, or NG7) 1960 //NG5 values are taken from the NG7 tables (there is very little difference in the 1961 //values, and NG5 attenuators have not been calibrated (as of 8/01) 1962 //filestr as passed is textread[3], the default directory 1963 Function AttenuationFactor(fileStr,lam,attenNo) 1964 String fileStr 1965 Variable lam,attenNo 1966 1967 Variable attenFactor=1,loc 1968 String instr=fileStr[1,3] //filestr is "[NGnSANSn] " or "[NGnSANSnn]" (11 characters total) 1969 1970 strswitch(instr) 1971 case "NG3": 1972 attenFactor = LookupAttenNG3(lam,attenNo) 1973 break 1974 case "NG5": 1975 //using NG7 lookup Table 1976 attenFactor = LookupAttenNG7(lam,attenNo) 1977 break 1978 case "NG7": 1979 attenFactor = LookupAttenNG7(lam,attenNo) 1980 break 1981 default: 1982 //return error? 1983 attenFactor=1 1984 endswitch 1985 // print "instr, lambda, attenNo,attenFactor = ",instr,lam,attenNo,attenFactor 1986 return(attenFactor) 1987 End 1443 1988 1444 1989 1445 //******************* … … 2011 1467 2012 1468 Variable start 2013 //x-position starts after byte 368 2014 //ReWriteReal() takes care of open/close on its own 2015 start = 368 //BS x-position 2016 ReWriteReal(fname,xpos,start) 1469 //x-position starts after byte 368 in VAX files 1470 WriteBSXPosToHeader(fname,xpos) 2017 1471 return(0) 2018 1472 End
Note: See TracChangeset
for help on using the changeset viewer.