Changeset 1810 for trunk/MagicSoft/Cosy/gui
- Timestamp:
- 03/11/03 13:52:48 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r1760 r1810 195 195 aaz *= d2r; 196 196 197 const double el = TMath::Pi()/2-pzd; 198 197 199 const double dphi2 = aaz/2.; 198 200 const double cos2 = cos(dphi2)*cos(dphi2); 199 201 const double sin2 = sin(dphi2)*sin(dphi2); 200 const double d = cos(azd)*cos2 - cos(2* pzd+azd)*sin2;202 const double d = cos(azd)*cos2 - cos(2*el+azd)*sin2; 201 203 202 204 double dist = acos(d); … … 250 252 251 253 UpdateCross(x, y); 252 UpdateText(pos.Zd(), acc. Az(), acc.Zd());254 UpdateText(pos.Zd(), acc.Zd(), acc.Az()); 253 255 254 256 SetModified(); -
trunk/MagicSoft/Cosy/gui/MGPngReader.cc
r1802 r1810 3 3 #include <fstream.h> // ifstream 4 4 #include <iostream.h> // cout 5 #include <iomanip.h> // cout 5 6 6 7 #include <TTimer.h> 7 8 8 9 #include <TGMenu.h> 10 #include <TGLabel.h> 9 11 #include <TSystem.h> 10 12 #include <TGSplitter.h> // TGHorizontal3DLine … … 13 15 #include "MGImage.h" 14 16 #include "MGCoordinates.h" 17 #include "MGDispCoordinates.h" 15 18 16 19 #include "coord.h" … … 255 258 fList->Add(fLimMag); 256 259 257 fSao->SetLimitMag( 8.0);260 fSao->SetLimitMag(7.0); 258 261 259 262 fInterpol = new MGPopupMenu(p); … … 314 317 fList->Add(fCRaDec); 315 318 316 fCZdAz = new MGCoordinates(this, kETypeZdAz );319 fCZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 317 320 fCZdAz->Move(240+12+10, fMenu->GetDefaultHeight()+584); 318 321 AddFrame(fCZdAz); 319 322 fList->Add(fCZdAz); 320 323 324 fPZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 325 fPZdAz->Move(240+12+10, fMenu->GetDefaultHeight()+630); 326 AddFrame(fPZdAz); 327 fList->Add(fPZdAz); 328 329 TGLabel *l = new TGLabel(this, "Arb.-Sky Pos"); 330 l->SetTextJustify(kTextLeft); 331 l->Move(480+32, fMenu->GetDefaultHeight()+590); 332 AddFrame(l); 333 fList->Add(l); 334 335 l = new TGLabel(this, "arcsec/pix"); 336 l->SetTextJustify(kTextLeft); 337 l->Move(605, fMenu->GetDefaultHeight()+619); 338 AddFrame(l); 339 fList->Add(l); 340 341 l = new TGLabel(this, "Pointing Pos"); 342 l->SetTextJustify(kTextLeft); 343 l->Move(480+32, fMenu->GetDefaultHeight()+655); 344 AddFrame(l); 345 fList->Add(l); 346 321 347 const Double_t pixsize = 23.4; 322 348 … … 328 354 fPixSize = new TGTextEntry(this, txt, IDM_kPixSize); 329 355 fPixSize->SetAlignment(kTextCenterX); 330 fPixSize->Move( 600, fMenu->GetDefaultHeight()+584);356 fPixSize->Move(547, fMenu->GetDefaultHeight()+617); 331 357 AddFrame(fPixSize); 332 358 fList->Add(fPixSize); … … 357 383 MapSubwindows(); 358 384 MapWindow(); 385 386 //------------------------------------------------------------ 387 // XY xy(3.819444, 24.05333); 388 // fCRaDec->SetCoordinates(xy); 389 // fRaDec->Set(xy.X()*360/24, xy.Y()); 390 //------------------------------------------------------------ 359 391 } 360 392 361 393 MGPngReader::MGPngReader(MObservatory::LocationName_t obs) 362 : TGMainFrame(gClient->GetRoot(), 768, 7 00), fFile(NULL), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2)394 : TGMainFrame(gClient->GetRoot(), 768, 740), fFile(NULL), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2) 363 395 { 364 396 fSao = new StarCatalog(obs); … … 811 843 } 812 844 813 void MGPngReader::CalcTrackingError(MStarList &spots, MStarList &stars) 814 { 845 ZdAz MGPngReader::TrackingError(TArrayF &x, TArrayF &y, TArrayF &mag) const 846 { 847 // 848 // Viewable area (FIXME: AZ) 849 // 850 TH2F h("Hist", "dX/dY", 77, -768/2-.5, 768/2+.5, 58, -576/2-.5, 576/2+.5); // 3 851 852 /* 853 TH1F hmag("HistMag", "Mag", 19, 0, 100); 854 for (int i=0; i<mag.GetSize(); i++) 855 hmag.Fill(mag[i]); 856 */ 857 858 // 859 // Search for matching Magnitudes 860 // 861 for (int i=0; i<mag.GetSize(); i++) 862 { 863 if (mag[i]>48-15 && mag[i]<48+15) 864 h.Fill(x[i], y[i]); 865 } 866 867 // 868 // Serach for an excess in the histogram 869 // 870 Int_t mx, my, dummy; 871 h.GetMaximumBin(mx, my, dummy); 872 873 const double xmax = h.GetXaxis()->GetBinCenter(mx); 874 const double dx = h.GetXaxis()->GetBinWidth(mx); 875 876 const double ymax = h.GetYaxis()->GetBinCenter(my); 877 const double dy = h.GetYaxis()->GetBinWidth(my); 878 879 cout << setprecision(3); 880 cout << "Cut-XY: " << xmax << " +- " << dx << " / " << ymax << " +- " << dy << endl; 881 882 TGraph g; 883 for (int i=0; i<mag.GetSize(); i++) 884 { 885 if (!(x[i]>xmax-dx && x[i]<xmax+dx && 886 y[i]>ymax-dy && y[i]<ymax+dy && 887 mag[i]>48-15 && mag[i]<48+15)) 888 continue; 889 890 g.SetPoint(g.GetN(), x[i], y[i]); 891 } 892 893 cout << "Offset-XY: " << g.GetMean(1) << " +- " << g.GetRMS(1) << " / "; 894 cout << g.GetMean(2) << " +- " << g.GetRMS(2) << endl; 895 896 AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg; 897 AltAz pos1 = fSao->CalcAltAzFromPix(768/2+g.GetMean(1), 576/2+g.GetMean(2))*kRad2Deg; 898 899 pos1 -= pos0; 900 901 ofstream fout("tracking_error.txt"); 902 fout << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl; 903 fout.close(); 904 905 return ZdAz(-pos1.Alt(), pos1.Az()); 906 } 907 908 void MGPngReader::CalcTrackingError(Leds &leds, MStarList &stars) 909 { 910 const Int_t max = leds.GetEntries(); 911 815 912 if (stars.GetRealEntries() < 3) 816 913 { … … 819 916 } 820 917 821 if ( spots.GetRealEntries()< 1)918 if (max < 1) 822 919 { 823 920 cout << "Sorry, less than 1 detected spot in FOV!" << endl; … … 825 922 } 826 923 827 Int_t idx = 0; 828 829 MStarList sortedspots; 924 stars.Sort(); // Sort by magnitude 925 926 TString str = "data/tracking_"; 927 str += fSao->GetMjd()-52000; 928 str += ".txt"; 929 930 ofstream fout(str); 931 932 TArrayF x, y, mag; 933 934 Int_t num = 0; 935 936 // FIXME: Is predifined value 3 a good idea? 830 937 831 938 MStar *star; 832 MStar *spot;833 939 MStarListIter NextStar(&stars); 834 MStarListIter NextSpot(&spots); 835 836 while ((spot=NextSpot())) 837 { 838 AltAz aa = fSao->CalcAltAzFromPix(spot->GetX(), spot->GetY()); 839 spot->Set(aa.Az(), aa.Alt()); 840 } 841 842 while ((star=NextStar())) 843 { 844 AltAz aa = fSao->CalcAltAzFromPix(star->GetX(), star->GetY()); 845 star->Set(aa.Az(), aa.Alt()); 846 847 const double aaz = star->GetX(); 848 const double dphi2 = aaz/2.; 849 const double cos2 = cos(dphi2)*cos(dphi2); 850 const double sin2 = sin(dphi2)*sin(dphi2); 851 852 Double_t min = 800; 853 854 NextSpot.Reset(); 855 while ((spot=NextSpot())) 940 while ((star=NextStar()) && num++<max+3) 941 { 942 TIter NextSp(&leds); 943 Led *spot=NULL; 944 while ((spot=(Led*)NextSp())) 856 945 { 857 const double pzd = TMath::Pi()/2-spot->GetY(); 858 const double azd = TMath::Pi()/2-star->GetY(); 859 860 const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2; 861 862 const Double_t dist = acos(d); 863 864 if (dist>=min) 865 continue; 866 867 min = dist; 868 sortedspots.AddAt(idx, spot->GetX(), spot->GetY(), spot->GetMag()); 946 const XY dpos(spot->GetX()-star->GetX(), spot->GetY()-star->GetY()); 947 948 const Int_t idx = x.GetSize(); 949 950 x.Set(idx+1); 951 y.Set(idx+1); 952 mag.Set(idx+1); 953 954 x.AddAt(dpos.X(), idx); 955 y.AddAt(dpos.Y(), idx); 956 mag.AddAt(spot->GetMag()/star->GetMag(), idx); 957 958 if (fout) 959 fout << x[idx] << " " << y[idx] << " " << mag[idx] << endl; 869 960 } 870 if (min>768) 871 { 872 cout << "ERROR!!!!!!!!" << endl; 873 return; 874 } 875 idx++; 876 } 877 878 // 879 // Now we have in sortedspots the entries with the shortest distances 880 // to the corresponding ones in stars. 881 // Now calculate the tracking error. 882 // 883 NextStar.Reset(); 884 MStarListIter NextSpot2(&sortedspots); 885 886 Double_t meanx=0; 887 Double_t meany=0; 888 889 while ((star=NextStar())) 890 { 891 spot = NextSpot2(); 892 893 meanx += star->GetX() - spot->GetX(); 894 meany += star->GetY() - spot->GetY(); 895 } 896 897 meanx /= idx; 898 meany /= idx; 899 900 cout << "Tracking Error: dAlt=" << meany*180/TMath::Pi(); 901 cout << "° dAz=" << meanx*180/TMath::Pi() << "° (calculated"; 902 cout << " with " << idx << " stars/spots)" << endl; 903 } 904 961 } 962 963 ZdAz d = TrackingError(x, y, mag); 964 965 // 966 // Calculated offsets 967 // 968 969 // round= floor(x+.5) 970 cout << "Offset-ZdAz: " << d.Zd()*60 << "' / " << d.Az()*60 << "'" << endl; 971 cout << "Offset-ZdAz: " << d.Zd()/360*16384 << " / " << d.Az()/360*16384 << " (SE) " << endl; 972 973 // 974 // Current Pointing position 975 // 976 ZdAz cpos = fSao->GetZdAz()-d; 977 fPZdAz->SetCoordinates(cpos); 978 } 905 979 906 980 … … 945 1019 946 1020 MStarList spots; 1021 1022 /* 947 1023 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 948 1024 Filter2::Execute(spots, c); 949 1025 else 950 if (fDisplay->IsEntryChecked(IDM_kFilter)) 951 Filter::Execute(c); 1026 */ 1027 if (fDisplay->IsEntryChecked(IDM_kFilter)) 1028 Filter::Execute(c); 952 1029 953 1030 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) … … 1031 1108 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 1032 1109 { 1110 Timer time(tm); 1111 1112 GetCoordinates(); 1113 1114 MStarList stars; 1115 fSao->GetStars(stars, time.GetMjd(), *fRaDec); 1116 1117 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 1118 { 1119 Leds leds; 1120 CaosFilter::Execute(c, leds, 1); 1121 1122 cout << "Found: " << leds.GetEntries() << " leds" << endl; 1123 1124 CaosFilter::RemoveTwins(leds, 3); 1125 leds.Compress(); 1126 1127 cout << "Rest: " << leds.GetEntries() << " leds" << endl; 1128 1129 CalcTrackingError(leds, stars); 1130 } 1131 1132 byte cimg[768*576]; 1133 fSao->GetImg(c, cimg, stars); 1134 1033 1135 DrawCircle(c, 0.5); 1034 1136 DrawCircle(c, 1.0); 1035 1137 DrawCircle(c, 1.5); 1036 1138 1037 byte cimg[768*576]; 1038 1039 GetCoordinates(); 1040 1041 Timer time(tm); 1042 1043 MStarList stars; 1044 fSao->GetStars(stars, time.GetMjd(), *fRaDec); 1045 fSao->GetImg(c, cimg, stars); 1046 //fSao->GetImg(c, cimg, time.CalcMjd(), *fRaDec); 1139 fCZdAz->SetCoordinates(fSao->GetZdAz()); 1047 1140 1048 1141 fImage->DrawColImg(c, cimg); 1049 1050 fCZdAz->SetCoordinates(fSao->GetZdAz());1051 1052 if (fDisplay->IsEntryChecked(IDM_kStarguider))1053 CalcTrackingError(spots, stars);1054 1142 } 1055 1143 else … … 1067 1155 { 1068 1156 const int dy = (int)sqrt(rpix*rpix-dx*dx); 1069 img[cx+dx + (cy-dy)*768] = 0x d0;1070 img[cx+dx + (cy+dy)*768] = 0x d0;1071 img[cx-dy + (cy+dx)*768] = 0x d0;1072 img[cx+dy + (cy+dx)*768] = 0x d0;1157 img[cx+dx + (cy-dy)*768] = 0x40; 1158 img[cx+dx + (cy+dy)*768] = 0x40; 1159 img[cx-dy + (cy+dx)*768] = 0x40; 1160 img[cx+dy + (cy+dx)*768] = 0x40; 1073 1161 } 1074 1162 } -
trunk/MagicSoft/Cosy/gui/MGPngReader.h
r1802 r1810 13 13 #include "MGImage.h" 14 14 15 #include <TH1.h> 16 #include <TH2.h> 17 #include <TGraph.h> 18 #include <TCanvas.h> 15 #include "coord.h" 19 16 20 class AltAz; 21 class RaDec; 17 class TArrayF; 18 class TH1F; 19 class TH2F; 20 class TGraph; 22 21 23 22 class TTimer; … … 87 86 MGCoordinates *fCZdAz; 88 87 88 MGCoordinates *fPZdAz; 89 89 90 TGTextEntry *fPixSize; 90 91 … … 104 105 void Toggle(MGPopupMenu *p, UInt_t id); 105 106 void GetCoordinates(); 106 void CalcTrackingError(MStarList &, MStarList &); 107 void CalcTrackingError(Leds &, MStarList &); 108 ZdAz TrackingError(TArrayF &alt, TArrayF &az, TArrayF &mag) const; 107 109 108 110 void InitHists();
Note:
See TracChangeset
for help on using the changeset viewer.