Changeset 737
- Timestamp:
- Sep 14, 2010 11:46:07 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf
r710 r737 1647 1647 Make/O/T/N=8 root:myGlobals:Protocols:SIMProtocol 1648 1648 Wave/T SIMProtocol = $"root:myGlobals:Protocols:SIMProtocol" 1649 SVAR funcStr = root:Packages:NIST:SAS:gFuncStr 1649 1650 String junk="****SIMULATED DATA****" 1651 1650 1652 //stick in the fake protocol... 1651 1653 NVAR ctTime = root:Packages:NIST:SAS:gCntTime … … 1655 1657 NVAR mScat = root:Packages:NIST:SAS:g_MultScattFraction 1656 1658 1657 SIMProtocol[0] = junk1659 SIMProtocol[0] = "*** SIMULATED DATA from "+funcStr+" ***" 1658 1660 SIMProtocol[1] = "\tCounting time (s) = "+num2str(ctTime) 1659 1661 SIMProtocol[2] = "\tTotal detector counts = "+num2str(totalCts) … … 1662 1664 SIMProtocol[5] = "\tFraction of multiple coherent scattering = "+num2str(mScat) 1663 1665 SIMProtocol[6] = "" 1664 SIMProtocol[7] = " "1666 SIMProtocol[7] = "*** SIMULATED DATA ***" 1665 1667 //set the global 1666 1668 String/G root:myGlobals:Protocols:gProtoStr = "SIMProtocol" … … 1668 1670 1669 1671 1670 //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 1671 WAVE intw=$(destStr + ":integersRead") 1672 WAVE rw=$(destStr + ":realsRead") 1673 WAVE/T textw=$(destStr + ":textRead") 1674 WAVE qvals =$(destStr + ":qval") 1675 WAVE inten=$(destStr + ":aveint") 1676 WAVE sig=$(destStr + ":sigave") 1677 WAVE qbar = $(destStr + ":QBar") 1678 WAVE sigmaq = $(destStr + ":SigmaQ") 1679 WAVE fsubs = $(destStr + ":fSubS") 1680 1681 SVAR gProtoStr = root:myGlobals:Protocols:gProtoStr 1682 Wave/T proto=$("root:myGlobals:Protocols:"+gProtoStr) 1683 1684 //check each wave 1685 If(!(WaveExists(intw))) 1686 Abort "intw DNExist Save_1DSimData()" 1687 Endif 1688 If(!(WaveExists(rw))) 1689 Abort "rw DNExist Save_1DSimData()" 1690 Endif 1691 If(!(WaveExists(textw))) 1692 Abort "textw DNExist Save_1DSimData()" 1693 Endif 1694 If(!(WaveExists(qvals))) 1695 Abort "qvals DNExist Save_1DSimData()" 1696 Endif 1697 If(!(WaveExists(inten))) 1698 Abort "inten DNExist Save_1DSimData()" 1699 Endif 1700 If(!(WaveExists(sig))) 1701 Abort "sig DNExist Save_1DSimData()" 1702 Endif 1703 If(!(WaveExists(qbar))) 1704 Abort "qbar DNExist Save_1DSimData()" 1705 Endif 1706 If(!(WaveExists(sigmaq))) 1707 Abort "sigmaq DNExist Save_1DSimData()" 1708 Endif 1709 If(!(WaveExists(fsubs))) 1710 Abort "fsubs DNExist Save_1DSimData()" 1711 Endif 1712 If(!(WaveExists(proto))) 1713 Abort "current protocol wave DNExist Save_1DSimData()" 1714 Endif 1715 1716 //strings can be too long to print-- must trim to 255 chars 1717 Variable ii,num=8 1718 Make/O/T/N=(num) tempShortProto 1719 for(ii=0;ii<num;ii+=1) 1720 tempShortProto[ii] = (proto[ii])[0,240] 1721 endfor 1722 1723 if(dialog) 1724 PathInfo/S catPathName 1725 fullPath = DoSaveFileDialog("Save data as") 1726 If(cmpstr(fullPath,"")==0) 1727 //user cancel, don't write out a file 1728 Close/A 1729 Abort "no data file was written" 1730 Endif 1731 //Print "dialog fullpath = ",fullpath 1732 Endif 1733 1734 NVAR monCt = root:Packages:NIST:SAS:gImon 1735 NVAR thick = root:Packages:NIST:SAS:gThick 1736 NVAR trans = root:Packages:NIST:SAS:gSamTrans //for 1D, default value 1737 1738 1739 1740 hdrStr1 = num2str(monCt)+" "+num2str(rw[26])+" "+num2str(rw[19])+" "+num2str(rw[18]) 1741 hdrStr1 += " "+num2str(trans)+" "+num2str(thick) + ave +" "+num2str(step) + "\r\n" 1742 1743 hdrStr2 = num2str(rw[16])+" "+num2str(rw[17])+" "+num2str(rw[23])+" "+num2str(rw[24])+" " 1744 hdrStr2 += num2str(rw[25])+" "+num2str(rw[27])+" "+num2str(rw[21])+" "+"ORNL " + "\r\n" 1745 1746 //actually open the file here 1747 Open refNum as fullpath 1748 1749 //write out the standard header information 1750 fprintf refnum,"FILE: %s\t\t CREATED: %s\r\n","SIMULATED DATA",(date() +" "+ time()) 1751 fprintf refnum,"LABEL: %s\r\n","SIMULATED DATA" 1752 fprintf refnum,"MON CNT LAMBDA DET ANG DET DIST TRANS THICK AVE STEP\r\n" 1753 fprintf refnum,hdrStr1 1754 fprintf refnum,"BCENT(X,Y) A1(mm) A2(mm) A1A2DIST(m) DL/L BSTOP(mm) DET_TYP \r\n" 1755 fprintf refnum,hdrStr2 1756 // fprintf refnum,headerFormat,rw[0],rw[26],rw[19],rw[18],rw[4],rw[5],ave,step 1757 1758 //insert protocol information here 1759 //-1 list of sample files 1760 //0 - bkg 1761 //1 - emp 1762 //2 - div 1763 //3 - mask 1764 //4 - abs params c2-c5 1765 //5 - average params 1766 fprintf refnum, "SAM: %s\r\n",tempShortProto[0] 1767 fprintf refnum, "BGD: %s\r\n",tempShortProto[1] 1768 fprintf refnum, "EMP: %s\r\n",tempShortProto[2] 1769 fprintf refnum, "DIV: %s\r\n",tempShortProto[3] 1770 fprintf refnum, "MASK: %s\r\n",tempShortProto[4] 1771 fprintf refnum, "ABS: %s\r\n",tempShortProto[5] 1772 fprintf refnum, "Average Choices: %s\r\n",tempShortProto[6] 1773 1774 //write out the data columns 1775 fprintf refnum,"The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n" 1776 wfprintf refnum, formatStr, qvals,inten,sig,sigmaq,qbar,fsubs 1777 1778 Close refnum 1779 1780 SetDataFolder root: //(redundant) 1781 1782 //write confirmation of write operation to history area 1783 Print "Averaged File written: ", GetFileNameFromPathNoSemi(fullPath) 1784 KillWaves/Z tempShortProto 1785 1786 //clear the stuff that was created for case of saving files 1787 If(1) 1788 Killwaves/Z root:myGlobals:Protocols:SIMProtocol 1789 String/G root:myGlobals:Protocols:gProtoStr = "" 1790 Endif 1791 1672 NVAR useXMLOutput = root:Packages:NIST:gXML_Write 1673 1674 if (useXMLOutput == 1) 1675 WriteXMLWaves_W_Protocol(type,"",1) 1676 else 1677 WriteWaves_W_Protocol(type,"",1) //"" is an empty path, 1 will force a dialog 1678 endif 1679 1680 // 1681 // //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 1682 // WAVE intw=$(destStr + ":integersRead") 1683 // WAVE rw=$(destStr + ":realsRead") 1684 // WAVE/T textw=$(destStr + ":textRead") 1685 // WAVE qvals =$(destStr + ":qval") 1686 // WAVE inten=$(destStr + ":aveint") 1687 // WAVE sig=$(destStr + ":sigave") 1688 // WAVE qbar = $(destStr + ":QBar") 1689 // WAVE sigmaq = $(destStr + ":SigmaQ") 1690 // WAVE fsubs = $(destStr + ":fSubS") 1691 // 1692 // SVAR gProtoStr = root:myGlobals:Protocols:gProtoStr 1693 // Wave/T proto=$("root:myGlobals:Protocols:"+gProtoStr) 1694 // 1695 // //check each wave 1696 // If(!(WaveExists(intw))) 1697 // Abort "intw DNExist Save_1DSimData()" 1698 // Endif 1699 // If(!(WaveExists(rw))) 1700 // Abort "rw DNExist Save_1DSimData()" 1701 // Endif 1702 // If(!(WaveExists(textw))) 1703 // Abort "textw DNExist Save_1DSimData()" 1704 // Endif 1705 // If(!(WaveExists(qvals))) 1706 // Abort "qvals DNExist Save_1DSimData()" 1707 // Endif 1708 // If(!(WaveExists(inten))) 1709 // Abort "inten DNExist Save_1DSimData()" 1710 // Endif 1711 // If(!(WaveExists(sig))) 1712 // Abort "sig DNExist Save_1DSimData()" 1713 // Endif 1714 // If(!(WaveExists(qbar))) 1715 // Abort "qbar DNExist Save_1DSimData()" 1716 // Endif 1717 // If(!(WaveExists(sigmaq))) 1718 // Abort "sigmaq DNExist Save_1DSimData()" 1719 // Endif 1720 // If(!(WaveExists(fsubs))) 1721 // Abort "fsubs DNExist Save_1DSimData()" 1722 // Endif 1723 // If(!(WaveExists(proto))) 1724 // Abort "current protocol wave DNExist Save_1DSimData()" 1725 // Endif 1726 // 1727 // //strings can be too long to print-- must trim to 255 chars 1728 // Variable ii,num=8 1729 // Make/O/T/N=(num) tempShortProto 1730 // for(ii=0;ii<num;ii+=1) 1731 // tempShortProto[ii] = (proto[ii])[0,240] 1732 // endfor 1733 // 1734 // if(dialog) 1735 // PathInfo/S catPathName 1736 // fullPath = DoSaveFileDialog("Save data as") 1737 // If(cmpstr(fullPath,"")==0) 1738 // //user cancel, don't write out a file 1739 // Close/A 1740 // Abort "no data file was written" 1741 // Endif 1742 // //Print "dialog fullpath = ",fullpath 1743 // Endif 1744 // 1745 // NVAR monCt = root:Packages:NIST:SAS:gImon 1746 // NVAR thick = root:Packages:NIST:SAS:gThick 1747 // NVAR trans = root:Packages:NIST:SAS:gSamTrans //for 1D, default value 1748 // 1749 // 1750 // 1751 // hdrStr1 = num2str(monCt)+" "+num2str(rw[26])+" "+num2str(rw[19])+" "+num2str(rw[18]) 1752 // hdrStr1 += " "+num2str(trans)+" "+num2str(thick) + ave +" "+num2str(step) + "\r\n" 1753 // 1754 // hdrStr2 = num2str(rw[16])+" "+num2str(rw[17])+" "+num2str(rw[23])+" "+num2str(rw[24])+" " 1755 // hdrStr2 += num2str(rw[25])+" "+num2str(rw[27])+" "+num2str(rw[21])+" "+"ORNL " + "\r\n" 1756 // 1757 // //actually open the file here 1758 // Open refNum as fullpath 1759 // 1760 // //write out the standard header information 1761 // fprintf refnum,"FILE: %s\t\t CREATED: %s\r\n","SIMULATED DATA",(date() +" "+ time()) 1762 // fprintf refnum,"LABEL: %s\r\n","SIMULATED DATA" 1763 // fprintf refnum,"MON CNT LAMBDA DET ANG DET DIST TRANS THICK AVE STEP\r\n" 1764 // fprintf refnum,hdrStr1 1765 // fprintf refnum,"BCENT(X,Y) A1(mm) A2(mm) A1A2DIST(m) DL/L BSTOP(mm) DET_TYP \r\n" 1766 // fprintf refnum,hdrStr2 1767 //// fprintf refnum,headerFormat,rw[0],rw[26],rw[19],rw[18],rw[4],rw[5],ave,step 1768 // 1769 // //insert protocol information here 1770 // //-1 list of sample files 1771 // //0 - bkg 1772 // //1 - emp 1773 // //2 - div 1774 // //3 - mask 1775 // //4 - abs params c2-c5 1776 // //5 - average params 1777 // fprintf refnum, "SAM: %s\r\n",tempShortProto[0] 1778 // fprintf refnum, "BGD: %s\r\n",tempShortProto[1] 1779 // fprintf refnum, "EMP: %s\r\n",tempShortProto[2] 1780 // fprintf refnum, "DIV: %s\r\n",tempShortProto[3] 1781 // fprintf refnum, "MASK: %s\r\n",tempShortProto[4] 1782 // fprintf refnum, "ABS: %s\r\n",tempShortProto[5] 1783 // fprintf refnum, "Average Choices: %s\r\n",tempShortProto[6] 1784 // 1785 // //write out the data columns 1786 // fprintf refnum,"The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n" 1787 // wfprintf refnum, formatStr, qvals,inten,sig,sigmaq,qbar,fsubs 1788 // 1789 // Close refnum 1790 // 1791 // SetDataFolder root: //(redundant) 1792 // 1793 // //write confirmation of write operation to history area 1794 // Print "Averaged File written: ", GetFileNameFromPathNoSemi(fullPath) 1795 // KillWaves/Z tempShortProto 1796 // 1797 // //clear the stuff that was created for case of saving files 1798 // If(1) 1799 // Killwaves/Z root:myGlobals:Protocols:SIMProtocol 1800 // String/G root:myGlobals:Protocols:gProtoStr = "" 1801 // Endif 1802 // 1792 1803 1793 1804 return(0)
Note: See TracChangeset
for help on using the changeset viewer.