- Timestamp:
- 09/06/13 20:40:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r17060 r17123 18 18 #include "DimWriteStatistics.h" 19 19 #include "externals/PixelMap.h" 20 #include "externals/Interpolator2D.h" 20 21 21 22 #include "tools.h" … … 1731 1732 // ======================================================= 1732 1733 1733 struct weight 1734 { 1735 int idx; 1736 int i[3]; 1737 double w[3]; 1738 }; 1739 1740 static vector<weight> fWeights; 1741 if (fWeights.empty()) 1742 { 1743 ifstream fin("temp-interpolator.txt"); 1744 int cnt = 0; 1734 static vector<pair<double,double>> fPositionsSensors; 1735 static vector<pair<double,double>> fPositionsBias; 1736 1737 if (fPositionsSensors.empty()) 1738 { 1739 ifstream fin1("sensor-pos.txt"); 1745 1740 while (1) 1746 1741 { 1747 weight w; 1748 fin >> w.idx; 1749 fin >> w.i[0]; 1750 fin >> w.i[1]; 1751 fin >> w.i[2]; 1752 fin >> w.w[0]; 1753 fin >> w.w[1]; 1754 fin >> w.w[2]; 1755 if (!fin) 1742 double x, y; 1743 fin1 >> x; 1744 fin1 >> y; 1745 if (!fin1) 1756 1746 break; 1757 1747 1758 if (w.idx != cnt++) 1759 { 1760 Fatal("Reading interpolator failed ("+to_string(w.idx)+"|"+to_string(cnt)+")"); 1761 fWeights.clear(); 1748 fPositionsSensors.emplace_back(x, y); 1749 } 1750 1751 if (fPositionsSensors.size() != 31) 1752 Fatal("Reading sensor positions failed ("+to_string(fPositionsSensors.size())+")"); 1753 } 1754 1755 if (fPositionsBias.empty()) 1756 { 1757 ifstream fin1("bias-positions.txt"); 1758 while (1) 1759 { 1760 double x, y; 1761 fin1 >> x; 1762 fin1 >> y; 1763 if (!fin1) 1762 1764 break; 1763 } 1764 1765 fWeights.emplace_back(w); 1765 1766 fPositionsBias.emplace_back(x, y); 1766 1767 } 1767 1768 1768 if (fWeights.size() && fWeights.size() != 160) 1769 if (fPositionsBias.size() != 320) 1770 Fatal("Reading bias positions failed ("+to_string(fPositionsBias.size())+")"); 1771 } 1772 1773 if (!fPositionsBias.size()==320 || !fPositionsSensors.size()==31) 1774 return GetCurrentState(); 1775 1776 vector<double> temp; 1777 vector<Interpolator2D::vec> xy; 1778 for (int i=0; i<31; i++) 1779 if (ptr[i]!=0) 1769 1780 { 1770 Fatal("Reading interpolator failed ("+to_string(fWeights.size())+")");1771 fWeights.clear();1781 temp.emplace_back(ptr[i]); 1782 xy.emplace_back(fPositionsSensors[i].first, fPositionsSensors[i].second); 1772 1783 } 1773 } 1774 1775 if (fWeights.size()==160) 1776 { 1777 vector<float> temp(160); 1778 vector<float> cpy(ptr, ptr+31); 1779 1780 cpy[8] = (cpy[4] +cpy[6] +cpy[7] +cpy[10]+cpy[11])/5; 1781 cpy[19] = (cpy[7] +cpy[11]+cpy[16]+cpy[17]+cpy[21])/5; 1782 cpy[15] = (cpy[14]+cpy[16]+cpy[18])/3; 1783 1784 double pavg = 0; 1785 for (int i=0; i<160; i++) 1786 { 1787 const double T = 1788 fWeights[i].w[0]*cpy[fWeights[i].i[0]]+ 1789 fWeights[i].w[1]*cpy[fWeights[i].i[1]]+ 1790 fWeights[i].w[2]*cpy[fWeights[i].i[2]]; 1791 1792 temp[i] = T; 1793 pavg += T; 1794 } 1795 1796 WriteCam(d, "cam-fsccontrol-temperature", temp, 3, pavg/160-1.5); 1797 } 1784 1785 Interpolator2D inter(xy); 1786 if (!inter.SetOutputGrid(fPositionsBias)) 1787 return GetCurrentState(); 1788 1789 const vector<double> T = inter.Interpolate(temp); 1790 1791 vector<double> tout(320); 1792 double pavg = 0; 1793 for (int i=0; i<320; i++) 1794 { 1795 const int idx = (fPixelMap.hv(i).hw()/9)*2+fPixelMap.hv(i).group(); 1796 tout[idx] = T[i]; 1797 pavg += T[i]; 1798 } 1799 1800 WriteCam(d, "cam-fsccontrol-temperature", tout, 3, pavg/320-1.5); 1798 1801 1799 1802 return GetCurrentState();
Note:
See TracChangeset
for help on using the changeset viewer.