Changeset 1819 for trunk/MagicSoft/Cosy/gui
- Timestamp:
- 03/12/03 14:41:29 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/GuiLinkDef.h
r1802 r1819 19 19 #pragma link C++ class MGCosy+; 20 20 #pragma link C++ class MGStarguider+; 21 #pragma link C++ class MGPngReader+;22 21 23 22 #endif -
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r1810 r1819 200 200 const double cos2 = cos(dphi2)*cos(dphi2); 201 201 const double sin2 = sin(dphi2)*sin(dphi2); 202 const double d = cos(azd)*cos2 - cos(2*el+azd)*sin2; 202 const double d = cos(azd)*cos2 - cos(2*el)*sin2; 203 204 // 205 // Original: 206 // cos(Zd1)*cos(Zd2)+sin(Zd1)*sin(Zd2)*cos(dAz) 207 // 208 // Correct: 209 // const double d = cos(azd)*cos2 - cos(el1+el2)*sin2; 210 // 211 // Estimated: 212 // const double d = cos(azd)*cos2 - cos(2*el)*sin2; 213 // 203 214 204 215 double dist = acos(d); -
trunk/MagicSoft/Cosy/gui/MGStarguider.cc
r1816 r1819 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 … … 20 22 #include "Filter.h" 21 23 #include "Filter2.h" 24 #include "CaosFilter.h" 22 25 #include "Writer.h" 23 26 #include "base/timer.h" … … 25 28 #include "MStarList.h" 26 29 30 #include <TH1.h> 31 #include <TH2.h> 32 #include <TGraph.h> 33 #include <TCanvas.h> 34 35 #include <TFile.h> 36 #include <TTree.h> 37 #include <TBranch.h> 38 39 #include "Led.h" 40 #include "Leds.h" 41 #include "Rings.h" 42 43 #include "MGMenu.h" 44 27 45 ClassImp(MGStarguider); 28 46 29 47 enum { 30 48 IDM_kFilter, 49 IDM_kCaosFilter, 31 50 IDM_kCatalog, 32 51 IDM_kStarguider, … … 60 79 IDM_kInterpol5, 61 80 IDM_kInterpol2, 62 IDM_kInterpol1 81 IDM_kInterpol1, 82 IDM_kPositions, 83 IDM_kRings, 84 IDM_kLeds, 85 IDM_kStartAnalyse, 86 IDM_kStopAnalyse, 87 IDM_kResetHistograms 63 88 }; 64 89 … … 72 97 #define kZOOM 96 73 98 74 MGStarguider::MGStarguider(MObservatory::LocationName_t key) 75 : TGMainFrame(gClient->GetRoot(), 768, 700), fObservatory(key), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2) 76 { 77 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE); 78 99 void MGStarguider::InitHists() 100 { 101 Double_t xmin = 480.1-1.0; 102 Double_t xmax = 480.1+1.0; 103 104 Double_t ymin = 217.5-1.0; 105 Double_t ymax = 217.5+1.0; 106 107 Double_t rmin = 117.4-1.0; 108 Double_t rmax = 117.4+1.0; 109 110 Int_t xbin = 60; 111 Int_t ybin = 60; 112 Int_t rbin = 60; 113 114 fHistpr = new TH1F; 115 fHistpr->SetNameTitle("pr","Radius of the ring"); 116 fHistpr->SetBins(rbin, rmin, rmax); 117 fHistpr->SetXTitle("r [mm]"); 118 fHistpr->SetYTitle("counts"); 119 120 fHistprx = new TH1F; 121 fHistprx->SetNameTitle("prx","x-coordinate of the ring-center"); 122 fHistprx->SetBins(xbin, xmin, xmax); 123 fHistprx->SetXTitle("x [mm]"); 124 fHistprx->SetYTitle("counts"); 125 126 fHistpry = new TH1F; 127 fHistpry->SetNameTitle("pry","y-coordniate of the ring-center"); 128 fHistpry->SetBins(ybin, ymin, ymax); 129 fHistpry->SetXTitle("y [mm]"); 130 fHistpry->SetYTitle("counts"); 131 132 for (int i=0; i<6; i++) 133 { 134 TString name = "Angle"; 135 TString title = "Angle of Led "; 136 137 name += i; 138 title += i; 139 140 fHistw[i] = new TH1F; 141 fHistw[i]->SetNameTitle(name, title); 142 fHistw[i]->SetBins(26, -25, 25); 143 fHistw[i]->SetXTitle("\\Phi [arcmin]"); 144 fHistw[i]->SetYTitle("counts"); 145 146 name = "Angles"; 147 title = "Angles of the Leds "; 148 149 name += i; 150 title += i; 151 152 fHistv[i] = new TH1F; 153 fHistv[i]->SetNameTitle(name, title); 154 fHistv[i]->SetBins(721, -180.5, 180.5); 155 fHistv[i]->SetXTitle("\\Phi [deg]"); 156 fHistv[i]->SetYTitle("counts"); 157 } 158 159 fHistallw = new TH1F; 160 fHistallw->SetNameTitle("allw","Rotation angel"); 161 fHistallw->SetBins(26, -25, 25); 162 fHistallw->SetXTitle("\\Phi [arcmin]"); 163 fHistallw->SetYTitle("counts"); 164 165 fHistprxpry = new TH2F; 166 fHistprxpry->SetNameTitle("prx und pry","x- and y-coordniate of the ring-center"); 167 fHistprxpry->SetBins(xbin, xmin, xmax, ybin, ymin, ymax); 168 fHistprxpry->SetXTitle("x [mm]"); 169 fHistprxpry->SetYTitle("y [mm]"); 170 fHistprxpry->SetZTitle("counts"); 171 } 172 173 void MGStarguider::InitGraphs() 174 { 175 fGraphprx = new TGraph; 176 fGraphprx->SetTitle("time-developement of the x-coordinate of the ring-center"); 177 178 fGraphpry = new TGraph; 179 fGraphpry->SetTitle("time-developement of the y-coordinate of the ring-center"); 180 181 for (int i=0; i<6; i++) 182 { 183 TString title = "Time-developement of the angle "; 184 title += i; 185 186 fGraphw[i] = new TGraph; 187 fGraphw[i]->SetTitle(title); 188 } 189 } 190 191 void MGStarguider::InitGui() 192 { 79 193 fList = new MGList; 80 194 81 fSao = new StarCatalog(fObservatory);82 fRaDec = new RaDec(180, 40);83 84 // p = pointer to MainFrame (not owner)85 86 195 const TGWindow *p=gClient->GetRoot(); 87 196 … … 89 198 // Create Menu for MGStarguider Display 90 199 // 91 fDisplay = new TGPopupMenu(p);200 fDisplay = new MGPopupMenu(p); 92 201 fDisplay->AddEntry("&Filter", IDM_kFilter); 202 fDisplay->AddEntry("C&aosFilter", IDM_kCaosFilter); 93 203 fDisplay->AddEntry("Sao &Catalog", IDM_kCatalog); 94 204 fDisplay->AddEntry("Starguider", IDM_kStarguider); 205 fDisplay->DisableEntry(IDM_kStarguider); 95 206 fDisplay->Associate(this); 96 207 fList->Add(fDisplay); 97 208 98 fFileType = new TGPopupMenu(p);209 fFileType = new MGPopupMenu(p); 99 210 fFileType->AddEntry("PP&M", IDM_kPPM); 100 211 fFileType->AddEntry("&PNG", IDM_kPNG); … … 103 214 fList->Add(fFileType); 104 215 105 fWriteType = new TGPopupMenu(p); 106 fWriteType->AddEntry("Once", IDM_kOnce); 107 fWriteType->AddEntry("Continous", IDM_kContinous); 108 fWriteType->CheckEntry(IDM_kOnce); 216 fWriteType = new MGPopupMenu(p); 217 fWriteType->AddEntry("&Once", IDM_kOnce); 218 fWriteType->AddEntry("&Continous", IDM_kContinous); 109 219 fWriteType->Associate(this); 110 220 fList->Add(fWriteType); 111 221 112 fWriteRate = new TGPopupMenu(p);222 fWriteRate = new MGPopupMenu(p); 113 223 fWriteRate->AddEntry("25/s", IDM_kRate25ps); 114 224 fWriteRate->AddEntry("5/s", IDM_kRate5ps); … … 124 234 fWrtRate = 25*60; 125 235 126 fWrite = new TGPopupMenu(p);127 fWrite ->AddEntry("&Start", IDM_kStart);128 fWrite ->AddEntry("Sto&p", IDM_kStop);129 fWrite ->AddSeparator();130 fWrite ->AddPopup("File &Type", fFileType);131 fWrite ->AddPopup("&Write Type", fWriteType);132 fWrite ->AddPopup("Write &Rate", fWriteRate);133 fWrite ->DisableEntry(IDM_kStop);134 fWrite ->Associate(this);135 fList->Add(fWrite );136 137 fLimMag = new TGPopupMenu(p);236 fWritePictures = new MGPopupMenu(p); 237 fWritePictures->AddEntry("&Start", IDM_kStart); 238 fWritePictures->AddEntry("Sto&p", IDM_kStop); 239 fWritePictures->AddSeparator(); 240 fWritePictures->AddPopup("File &Type", fFileType); 241 fWritePictures->AddPopup("&Write Type", fWriteType); 242 fWritePictures->AddPopup("Write &Rate", fWriteRate); 243 fWritePictures->DisableEntry(IDM_kStop); 244 fWritePictures->Associate(this); 245 fList->Add(fWritePictures); 246 247 fLimMag = new MGPopupMenu(p); 138 248 fLimMag->AddEntry("3", IDM_kLimMag3); 139 249 fLimMag->AddEntry("4", IDM_kLimMag4); … … 147 257 fList->Add(fLimMag); 148 258 149 fSao->SetLimitMag( 8.0);150 151 fInterpol = new TGPopupMenu(p);259 fSao->SetLimitMag(7.0); 260 261 fInterpol = new MGPopupMenu(p); 152 262 fInterpol->AddEntry("125", IDM_kInterpol125); 153 263 fInterpol->AddEntry("25", IDM_kInterpol25); … … 156 266 fInterpol->AddEntry("2", IDM_kInterpol2); 157 267 fInterpol->AddEntry("Off", IDM_kInterpol1); 158 fInterpol->CheckEntry(IDM_kInterpol 25);268 fInterpol->CheckEntry(IDM_kInterpol1); 159 269 fInterpol->Associate(this); 160 270 fList->Add(fInterpol); 161 271 162 fIntRate = 25;163 164 fSetup = new TGPopupMenu(p);272 fIntRate = 1; 273 274 fSetup = new MGPopupMenu(p); 165 275 fSetup->AddPopup("Lim. &Magnitude", fLimMag); 166 276 fSetup->AddPopup("Disp. &Interpolation", fInterpol); … … 169 279 fList->Add(fSetup); 170 280 171 fMenu = new TGMenuBar(this, 0, 0, kHorizontalFrame); 281 fWrite = new MGPopupMenu(p); 282 fWrite->AddEntry("&Positions", IDM_kPositions); 283 fWrite->AddEntry("&Leds", IDM_kLeds); 284 fWrite->AddEntry("&Rings", IDM_kRings); 285 fWrite->Associate(this); 286 fList->Add(fWrite); 287 288 fAnalyse = new MGPopupMenu(p); 289 fAnalyse->AddEntry("S&tart Analyse", IDM_kStartAnalyse); 290 fAnalyse->AddEntry("St&opp Analyse", IDM_kStopAnalyse); 291 fAnalyse->DisableEntry(IDM_kStopAnalyse); 292 fAnalyse->AddEntry("&Reset Histograms", IDM_kResetHistograms); 293 // fAnalyse->AddEntry("Reset &Graph", IDM_kResetGraph); 294 fAnalyse->Associate(this); 295 fList->Add(fAnalyse); 296 297 fMenu = new MGMenuBar(this, 0, 0, kHorizontalFrame); 172 298 fMenu->AddPopup("&Display", fDisplay, NULL); 173 fMenu->AddPopup("&Write ", fWrite, NULL);299 fMenu->AddPopup("&WritePics", fWritePictures, NULL); 174 300 fMenu->AddPopup("&Setup", fSetup, NULL); 175 301 fMenu->Resize(fMenu->GetDefaultSize()); 302 fMenu->BindKeys(this); 176 303 AddFrame(fMenu); //, new TGLayoutHints (kLHintsNormal, 0, 4, 0, 0)); 177 304 fList->Add(fMenu); 305 306 fCaOs = new MGPopupMenu(p); 307 fCaOs->AddPopup("&Write", fWrite); 308 fCaOs->AddPopup("&Analyse", fAnalyse); 309 fCaOs->Associate(this); 310 fCaOs->BindKeys(fMenu, this); 311 fList->Add(fCaOs); 178 312 179 313 fCRaDec = new MGCoordinates(this, kETypeRaDec); … … 182 316 fList->Add(fCRaDec); 183 317 184 fCZdAz = new MGCoordinates(this, kETypeZdAz );318 fCZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 185 319 fCZdAz->Move(240+12+10, fMenu->GetDefaultHeight()+584); 186 320 AddFrame(fCZdAz); 187 321 fList->Add(fCZdAz); 188 322 189 const Double_t pixsize = 23.5; 323 fPZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 324 fPZdAz->Move(240+12+10, fMenu->GetDefaultHeight()+630); 325 AddFrame(fPZdAz); 326 fList->Add(fPZdAz); 327 328 TGLabel *l = new TGLabel(this, "Arb.-Sky Pos"); 329 l->SetTextJustify(kTextLeft); 330 l->Move(480+32, fMenu->GetDefaultHeight()+590); 331 AddFrame(l); 332 fList->Add(l); 333 334 l = new TGLabel(this, "arcsec/pix"); 335 l->SetTextJustify(kTextLeft); 336 l->Move(605, fMenu->GetDefaultHeight()+619); 337 AddFrame(l); 338 fList->Add(l); 339 340 l = new TGLabel(this, "Pointing Pos"); 341 l->SetTextJustify(kTextLeft); 342 l->Move(480+32, fMenu->GetDefaultHeight()+655); 343 AddFrame(l); 344 fList->Add(l); 345 346 const Double_t pixsize = 23.4; 190 347 191 348 fSao->SetPixSize(pixsize/3600); … … 196 353 fPixSize = new TGTextEntry(this, txt, IDM_kPixSize); 197 354 fPixSize->SetAlignment(kTextCenterX); 198 fPixSize->Move( 600, fMenu->GetDefaultHeight()+584);355 fPixSize->Move(547, fMenu->GetDefaultHeight()+617); 199 356 AddFrame(fPixSize); 200 357 fList->Add(fPixSize); … … 226 383 MapWindow(); 227 384 385 //------------------------------------------------------------ 386 // XY xy(3.819444, 24.05333); 387 // fCRaDec->SetCoordinates(xy); 388 // fRaDec->Set(xy.X()*360/24, xy.Y()); 389 //------------------------------------------------------------ 390 } 391 392 MGStarguider::MGStarguider(MObservatory::LocationName_t obs) 393 : TGMainFrame(gClient->GetRoot(), 768, 740), fFile(NULL), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2) 394 { 395 fSao = new StarCatalog(obs); 396 fRaDec = new RaDec(180, 40); 397 398 InitHists(); 399 InitGraphs(); 400 401 InitGui(); 402 403 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE); 404 228 405 fTimer=new TTimer(this, 100); // 100ms 229 406 fTimer->TurnOn(); … … 232 409 MGStarguider::~MGStarguider() 233 410 { 234 gVirtualX->GrabButton( 0, kButton2, 0, 0, 0, 0, kFALSE);411 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kFALSE); 235 412 236 413 fTimer->TurnOff(); 237 414 delete fTimer; 238 415 416 delete fList; 417 239 418 delete fSao; 240 419 delete fRaDec; 241 420 242 delete fList; 421 delete fHistpr; 422 delete fHistprx; 423 delete fHistpry; 424 delete fHistprxpry; 425 delete fHistallw; 426 delete fGraphprx; 427 delete fGraphpry; 428 429 for (int i=0; i<6; i++) 430 { 431 delete fHistw[i]; 432 delete fHistv[i]; 433 delete fGraphw[i]; 434 } 435 243 436 cout << "Camera Display destroyed." << endl; 244 437 } … … 253 446 cout << "EventDisplay::CloseWindow: Exit Application Loop." << endl; 254 447 255 /*ExitLoop();*/ 256 //cout << "FIXME: ExitLoop not called!!!!!!" << endl; 257 448 //fClient.ExitLoop(); 449 // cout << "FIXME: ExitLoop not called!!!!!!" << endl; 258 450 gSystem->ExitLoop(); 259 451 } 260 452 261 void MGStarguider::Toggle( TGPopupMenu *p, UInt_t id)453 void MGStarguider::Toggle(MGPopupMenu *p, UInt_t id) 262 454 { 263 455 if (p->IsEntryChecked(id)) … … 265 457 else 266 458 p->CheckEntry(id); 267 459 } 460 461 void MGStarguider::ResetHists() 462 { 463 fHistprx->Reset(); 464 fHistpry->Reset(); 465 fHistpr->Reset(); 466 fHistprxpry->Reset(); 467 fHistallw->Reset(); 468 for (int i=0; i<6; i++) 469 { 470 fHistw[i]->Reset(); 471 fHistv[i]->Reset(); 472 } 473 } 474 475 void MGStarguider::DisplayAnalysis() 476 { 477 TCanvas *c = new TCanvas("cring", "Center of the ring", 800, 800); 478 c->Divide(2,2); 479 c->cd(1); 480 fHistprx->Fit("gaus"); 481 fHistprx->DrawCopy(); 482 c->cd(2); 483 fHistpry->Fit("gaus"); 484 fHistpry->DrawCopy(); 485 c->cd(3); 486 fHistpr->Fit("gaus"); 487 fHistpr->DrawCopy(); 488 c->cd(4); 489 fHistprxpry->DrawCopy(/*"surf2"*/); 490 c->Update(); 491 492 c = new TCanvas("c3", "Absolute angles of the leds", 800, 800); 493 c->Divide(2,3); 494 for (int i=0; i<6; i++) 495 { 496 c->cd(i+1); 497 TH1 *h = fHistv[i]->DrawCopy(); 498 h->SetLineColor(i+1); 499 cout << "Led #" << i << ": MeanPhi=" << h->GetMean() << endl; 500 } 501 c->Update(); 502 503 c = new TCanvas("c5", "timedevelopement of prx", 800, 800); 504 fGraphprx->Draw("ALP*"); 505 fGraphprx->GetHistogram()->SetXTitle("time [1/25 s]"); 506 fGraphprx->GetHistogram()->SetYTitle("x-coordinate"); 507 c->Modified(); 508 c->Update(); 509 510 c = new TCanvas("c6", "timedevelopement of pry", 800, 800); 511 fGraphpry->Draw("ALP*"); 512 fGraphpry->GetHistogram()->SetXTitle("time [1/25 s]"); 513 fGraphpry->GetHistogram()->SetYTitle("y-coordinate"); 514 c->Modified(); 515 c->Update(); 516 517 c = new TCanvas("c2", "Relative angles of the Leds", 800, 800); 518 c->Divide(2,3); 519 for (int i=0; i<6; i++) 520 { 521 c->cd(i+1); 522 fHistw[i]->DrawCopy(); 523 } 524 c->Update(); 525 526 c = new TCanvas("c7", "timedevelopement of the relative angles of the Leds", 800, 800); 527 c->Divide(2,3); 528 for (int i=0; i<6; i++) 529 { 530 c->cd(i+1); 531 fGraphw[i]->Draw("ALP*"); 532 fGraphw[i]->GetHistogram()->SetXTitle("t [1/25s]"); 533 fGraphw[i]->GetHistogram()->SetYTitle("[deg]"); 534 } 535 c->Modified(); 536 c->Update(); 537 538 c = new TCanvas("c4", "rotation angle ", 800, 800); 539 fHistallw->Fit("gaus"); 540 fHistallw->DrawCopy(); 541 } 542 543 void MGStarguider::OpenFile() 544 { 545 int i=0; 546 char name[100]; 547 while (1) 548 { 549 sprintf(name, "data/data%03d.root", i++); 550 if (gSystem->AccessPathName(name, kFileExists)) 551 break; 552 } 553 554 fFile = new TFile(name, "RECREATE"); 555 556 if (!fFile->IsOpen()) 557 { 558 delete fFile; 559 fFile = NULL; 560 561 cout << "Error: Cannot open file '" << name << "'" << endl; 562 563 } 564 565 fTree = new TTree("Data", "Real CaOs Data"); 566 567 fLeds = NULL; 568 fRings = NULL; 569 fTime = 0; 570 571 fBranchL = fTree->Branch("Leds.", "Leds", &fLeds); 572 fBranchR = fTree->Branch("Rings.", "Rings", &fRings); 573 fBranchT = fTree->Branch("Time.", &fTime, "fTime/D");//, &fTime); 574 575 cout << "Root file '" << name << "' open." << endl; 268 576 } 269 577 … … 282 590 283 591 case kC_COMMAND: 592 //cout << "kC_COMMAND" << endl; 284 593 switch (GET_SUBMSG(msg)) 285 594 { 286 595 case kCM_MENU: 596 //cout << "kCM_MENU #" << mp1 << endl; 287 597 switch (mp1) 288 598 { … … 313 623 return kTRUE; 314 624 625 case IDM_kCaosFilter: 626 if (!fDisplay->IsEntryChecked(IDM_kCaosFilter)) 627 OpenFile(); 628 Toggle(fDisplay, IDM_kCaosFilter); 629 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 630 fMenu->AddPopup("&CaOs", fCaOs, NULL); 631 else 632 { 633 fFile->Write(); 634 delete fFile; 635 fFile = NULL; 636 637 cout << "Root file closed." << endl; 638 639 if(fWrite->IsEntryChecked(IDM_kPositions)) 640 fWrite->UnCheckEntry(IDM_kPositions); 641 if(fWrite->IsEntryChecked(IDM_kLeds)) 642 fWrite->UnCheckEntry(IDM_kLeds); 643 if(fWrite->IsEntryChecked(IDM_kRings)) 644 fWrite->UnCheckEntry(IDM_kRings); 645 if(fAnalyse->IsEntryEnabled(IDM_kStopAnalyse)) 646 { 647 fAnalyse->DisableEntry(IDM_kStopAnalyse); 648 fAnalyse->EnableEntry(IDM_kStartAnalyse); 649 ResetHists(); 650 // Graphs are not reset !!! 651 } 652 fMenu->RemovePopup("CaOs"); 653 } 654 fMenu->Resize(fMenu->GetDefaultSize()); 655 MapSubwindows(); 656 MapWindow(); 657 return kTRUE; 658 659 case IDM_kPositions: 660 Toggle(fWrite, IDM_kPositions); 661 return kTRUE; 662 663 case IDM_kLeds: 664 Toggle(fWrite, IDM_kLeds); 665 return kTRUE; 666 667 case IDM_kRings: 668 Toggle(fWrite, IDM_kRings); 669 return kTRUE; 670 671 case IDM_kStartAnalyse: 672 fAnalyse->DisableEntry(IDM_kStartAnalyse); 673 fAnalyse->EnableEntry(IDM_kStopAnalyse); 674 return kTRUE; 675 676 case IDM_kStopAnalyse: 677 { 678 fAnalyse->DisableEntry(IDM_kStopAnalyse); 679 fAnalyse->EnableEntry(IDM_kStartAnalyse); 680 681 DisplayAnalysis(); 682 683 return kTRUE; 684 } 685 686 case IDM_kResetHistograms: 687 ResetHists(); 688 return kTRUE; 689 690 /* case IDM_kResetGraph: 691 { 692 fGraphx->GetHistogram()->Reset(); 693 694 } 695 */ 696 315 697 case IDM_kUseFileRaDec: 316 698 Toggle(fSetup, IDM_kUseFileRaDec); … … 318 700 319 701 case IDM_kStart: 320 fWrite ->DisableEntry(IDM_kStart);321 fWrite ->EnableEntry(IDM_kStop);702 fWritePictures->DisableEntry(IDM_kStart); 703 fWritePictures->EnableEntry(IDM_kStop); 322 704 return kTRUE; 323 705 324 706 case IDM_kStop: 325 fWrite ->DisableEntry(IDM_kStop);326 fWrite ->EnableEntry(IDM_kStart);707 fWritePictures->DisableEntry(IDM_kStop); 708 fWritePictures->EnableEntry(IDM_kStart); 327 709 return kTRUE; 328 710 … … 460 842 } 461 843 462 void MGStarguider::CalcTrackingError(MStarList &spots, MStarList &stars) 463 { 844 ZdAz MGStarguider::TrackingError(TArrayF &x, TArrayF &y, TArrayF &mag) const 845 { 846 // 847 // Viewable area (FIXME: AZ) 848 // 849 TH2F h("Hist", "dX/dY", 77, -768/2-.5, 768/2+.5, 58, -576/2-.5, 576/2+.5); // 3 850 851 /* 852 TH1F hmag("HistMag", "Mag", 19, 0, 100); 853 for (int i=0; i<mag.GetSize(); i++) 854 hmag.Fill(mag[i]); 855 */ 856 857 // 858 // Search for matching Magnitudes 859 // 860 for (int i=0; i<mag.GetSize(); i++) 861 { 862 if (mag[i]>48-15 && mag[i]<48+15) 863 h.Fill(x[i], y[i]); 864 } 865 866 // 867 // Serach for an excess in the histogram 868 // 869 Int_t mx, my, dummy; 870 h.GetMaximumBin(mx, my, dummy); 871 872 const double xmax = h.GetXaxis()->GetBinCenter(mx); 873 const double dx = h.GetXaxis()->GetBinWidth(mx); 874 875 const double ymax = h.GetYaxis()->GetBinCenter(my); 876 const double dy = h.GetYaxis()->GetBinWidth(my); 877 878 cout << setprecision(3); 879 cout << "Cut-XY: " << xmax << " +- " << dx << " / " << ymax << " +- " << dy << endl; 880 881 TGraph g; 882 for (int i=0; i<mag.GetSize(); i++) 883 { 884 if (!(x[i]>xmax-dx && x[i]<xmax+dx && 885 y[i]>ymax-dy && y[i]<ymax+dy && 886 mag[i]>48-15 && mag[i]<48+15)) 887 continue; 888 889 g.SetPoint(g.GetN(), x[i], y[i]); 890 } 891 892 cout << "Offset-XY: " << g.GetMean(1) << " +- " << g.GetRMS(1) << " / "; 893 cout << g.GetMean(2) << " +- " << g.GetRMS(2) << endl; 894 895 AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg; 896 AltAz pos1 = fSao->CalcAltAzFromPix(768/2+g.GetMean(1), 576/2+g.GetMean(2))*kRad2Deg; 897 898 pos1 -= pos0; 899 900 ofstream fout("tracking_error.txt"); 901 fout << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl; 902 fout.close(); 903 904 return ZdAz(-pos1.Alt(), pos1.Az()); 905 } 906 907 void MGStarguider::CalcTrackingError(Leds &leds, MStarList &stars) 908 { 909 const Int_t max = leds.GetEntries(); 910 464 911 if (stars.GetRealEntries() < 3) 465 912 { … … 468 915 } 469 916 470 if ( spots.GetRealEntries()< 1)917 if (max < 1) 471 918 { 472 919 cout << "Sorry, less than 1 detected spot in FOV!" << endl; … … 474 921 } 475 922 476 Int_t idx = 0; 477 478 MStarList sortedspots; 923 stars.Sort(); // Sort by magnitude 924 925 TString str = "data/tracking_"; 926 str += fSao->GetMjd()-52000; 927 str += ".txt"; 928 929 ofstream fout(str); 930 931 TArrayF x, y, mag; 932 933 Int_t num = 0; 934 935 // FIXME: Is predifined value 3 a good idea? 479 936 480 937 MStar *star; 481 MStar *spot;482 938 MStarListIter NextStar(&stars); 483 MStarListIter NextSpot(&spots); 484 485 while ((spot=NextSpot())) 486 { 487 AltAz aa = fSao->CalcAltAzFromPix(spot->GetX(), spot->GetY()); 488 spot->Set(aa.Az(), aa.Alt()); 489 } 490 491 while ((star=NextStar())) 492 { 493 AltAz aa = fSao->CalcAltAzFromPix(star->GetX(), star->GetY()); 494 star->Set(aa.Az(), aa.Alt()); 495 496 const double aaz = star->GetX(); 497 const double dphi2 = aaz/2.; 498 const double cos2 = cos(dphi2)*cos(dphi2); 499 const double sin2 = sin(dphi2)*sin(dphi2); 500 501 Double_t min = 800; 502 503 NextSpot.Reset(); 504 while ((spot=NextSpot())) 939 while ((star=NextStar()) && num++<max+3) 940 { 941 TIter NextSp(&leds); 942 Led *spot=NULL; 943 while ((spot=(Led*)NextSp())) 505 944 { 506 const double pzd = TMath::Pi()/2-spot->GetY(); 507 const double azd = TMath::Pi()/2-star->GetY(); 508 509 const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2; 510 511 const Double_t dist = acos(d); 512 513 if (dist>=min) 514 continue; 515 516 min = dist; 517 sortedspots.AddAt(idx, spot->GetX(), spot->GetY(), spot->GetMag()); 945 const XY dpos(spot->GetX()-star->GetX(), spot->GetY()-star->GetY()); 946 947 const Int_t idx = x.GetSize(); 948 949 x.Set(idx+1); 950 y.Set(idx+1); 951 mag.Set(idx+1); 952 953 x.AddAt(dpos.X(), idx); 954 y.AddAt(dpos.Y(), idx); 955 mag.AddAt(spot->GetMag()/star->GetMag(), idx); 956 957 if (fout) 958 fout << x[idx] << " " << y[idx] << " " << mag[idx] << endl; 518 959 } 519 if (min>768) 520 { 521 cout << "ERROR!!!!!!!!" << endl; 522 return; 523 } 524 idx++; 525 } 526 527 // 528 // Now we have in sortedspots the entries with the shortest distances 529 // to the corresponding ones in stars. 530 // Now calculate the tracking error. 531 // 532 NextStar.Reset(); 533 MStarListIter NextSpot2(&sortedspots); 534 535 Double_t meanx=0; 536 Double_t meany=0; 537 538 while ((star=NextStar())) 539 { 540 spot = NextSpot2(); 541 542 meanx += star->GetX() - spot->GetX(); 543 meany += star->GetY() - spot->GetY(); 544 } 545 546 meanx /= idx; 547 meany /= idx; 548 549 cout << "Tracking Error: dAlt=" << meany*180/TMath::Pi(); 550 cout << "° dAz=" << meanx*180/TMath::Pi() << "° (calculated"; 551 cout << " with " << idx << " stars/spots)" << endl; 552 } 960 } 961 962 ZdAz d = TrackingError(x, y, mag); 963 964 // 965 // Calculated offsets 966 // 967 968 // round= floor(x+.5) 969 cout << "Offset-ZdAz: " << d.Zd()*60 << "' / " << d.Az()*60 << "'" << endl; 970 cout << "Offset-ZdAz: " << d.Zd()/360*16384 << " / " << d.Az()/360*16384 << " (SE) " << endl; 971 972 // 973 // Current Pointing position 974 // 975 ZdAz cpos = fSao->GetZdAz()-d; 976 fPZdAz->SetCoordinates(cpos); 977 } 978 553 979 554 980 void MGStarguider::ProcessFrame(const unsigned long n, byte *img, struct timeval *tm) … … 568 994 c[i] = (byte)(myimg[i]/fIntRate+.5); 569 995 570 if (!fWrite ->IsEntryEnabled(IDM_kStart) &&996 if (!fWritePictures->IsEntryEnabled(IDM_kStart) && 571 997 (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce))) 572 998 { … … 581 1007 } 582 1008 583 584 1009 MStarList spots; 1010 1011 /* 585 1012 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 586 1013 Filter2::Execute(spots, c); 587 1014 else 588 if (fDisplay->IsEntryChecked(IDM_kFilter)) 589 Filter::Execute(c); 1015 */ 1016 if (fDisplay->IsEntryChecked(IDM_kFilter)) 1017 Filter::Execute(c); 1018 1019 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 1020 { 1021 // Double_t kConv = 0.502; // [pix/mm] 1022 1023 static Timer t0(tm); 1024 Timer t(tm); 1025 1026 fTime = (t.GetMjd()-t0.GetMjd())*24*60*60; 1027 1028 Leds leds; 1029 CaosFilter::Execute(c, leds, 1); 1030 1031 if (fWrite->IsEntryChecked(IDM_kPositions)) 1032 leds.Print(); 1033 1034 CaosFilter::FilterLeds(leds); 1035 leds.Compress(); 1036 1037 if (fWrite->IsEntryChecked(IDM_kLeds)) 1038 leds.Print(); 1039 1040 Rings rings; 1041 rings.CalcRings(leds); 1042 1043 leds.Sort(); 1044 1045 fLeds = &leds; 1046 fRings = &rings; 1047 1048 if (fFile) 1049 fTree->Fill(); 1050 1051 if (fWrite->IsEntryChecked(IDM_kRings)) 1052 rings.Print(); 1053 1054 if (fAnalyse->IsEntryEnabled(IDM_kStopAnalyse)) 1055 { 1056 const Ring ¢er = rings.GetCenter(); 1057 1058 Double_t phi[6] = 1059 { 1060 -124.727, 1061 -61.0495, 1062 -16.7907, 1063 49.3119, 1064 139.086 1065 }; 1066 1067 fHistpr->Fill(center.GetR()); 1068 fHistprx->Fill(center.GetX()); 1069 fHistpry->Fill(center.GetY()); 1070 fHistprxpry->Fill(center.GetX(), center.GetY()); 1071 1072 Double_t sum = 0; 1073 for (int i=0; i<6 && leds.At(i); i++) 1074 { 1075 const Double_t w = (leds(i).GetPhi()-phi[i])*60; 1076 1077 sum += w; 1078 1079 fHistw[i]->Fill(w); 1080 fHistv[i]->Fill(leds(i).GetPhi()); 1081 fGraphw[i]->SetPoint(fGraphw[i]->GetN(), fTime, w); 1082 } 1083 fHistallw->Fill(sum/5); 1084 1085 fGraphprx->SetPoint(fGraphprx->GetN(), fTime, center.GetX()); 1086 fGraphpry->SetPoint(fGraphpry->GetN(), fTime, center.GetY()); 1087 } 1088 } 590 1089 591 1090 byte zimg[kZOOM*kZOOM]; … … 598 1097 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 599 1098 { 600 byte cimg[768*576];1099 Timer time(tm); 601 1100 602 1101 GetCoordinates(); 603 604 Timer time(tm);605 1102 606 1103 MStarList stars; 607 1104 fSao->GetStars(stars, time.GetMjd(), *fRaDec); 1105 1106 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 1107 { 1108 Leds leds; 1109 CaosFilter::Execute(c, leds, 1); 1110 1111 cout << "Found: " << leds.GetEntries() << " leds" << endl; 1112 1113 CaosFilter::RemoveTwins(leds, 3); 1114 leds.Compress(); 1115 1116 cout << "Rest: " << leds.GetEntries() << " leds" << endl; 1117 1118 CalcTrackingError(leds, stars); 1119 } 1120 1121 byte cimg[768*576]; 608 1122 fSao->GetImg(c, cimg, stars); 609 //fSao->GetImg(c, cimg, time.CalcMjd(), *fRaDec); 1123 1124 DrawCircle(c, 0.5); 1125 DrawCircle(c, 1.0); 1126 DrawCircle(c, 1.5); 1127 1128 fCZdAz->SetCoordinates(fSao->GetZdAz()); 610 1129 611 1130 fImage->DrawColImg(c, cimg); 612 613 fCZdAz->SetCoordinates(fSao->GetZdAz());614 615 if (fDisplay->IsEntryChecked(IDM_kStarguider))616 CalcTrackingError(spots, stars);617 1131 } 618 1132 else … … 620 1134 621 1135 memset(myimg, 0, 768*576*sizeof(float)); 1136 } 1137 1138 void MGStarguider::DrawCircle(byte *img, double r) 1139 { 1140 const double rpix = r*60*60/fSao->GetPixSize()+1; 1141 const int cx = 768/2; 1142 const int cy = 576/2; 1143 for (int dx=-(int)(rpix*0.7); dx<(int)(rpix*0.7); dx++) 1144 { 1145 const int dy = (int)sqrt(rpix*rpix-dx*dx); 1146 img[cx+dx + (cy-dy)*768] = 0x40; 1147 img[cx+dx + (cy+dy)*768] = 0x40; 1148 img[cx-dy + (cy+dx)*768] = 0x40; 1149 img[cx+dy + (cy+dx)*768] = 0x40; 1150 } 622 1151 } 623 1152 -
trunk/MagicSoft/Cosy/gui/MGStarguider.h
r1802 r1819 1 #ifndef MGSTARGUIDER_H2 #define MGSTARGUIDER_H1 #ifndef COSY_MGStarguider 2 #define COSY_MGStarguider 3 3 4 4 #ifndef ROOT_TGFrame … … 6 6 #endif 7 7 #include "PixClient.h" 8 #ifndef MARS_MObservatory 9 #include "MObservatory.h" 10 #endif 8 11 9 12 #include "MGList.h" 10 13 #include "MGImage.h" 11 14 12 #ifndef MARS_MObservatory 13 #include "MObservatory.h" 14 #endif 15 #include "coord.h" 15 16 16 class AltAz; 17 class RaDec; 17 class TArrayF; 18 class TH1F; 19 class TH2F; 20 class TGraph; 18 21 19 22 class TTimer; 20 23 21 class TGMenuBar;22 class TGPopupMenu;24 class MGMenuBar; 25 class MGPopupMenu; 23 26 class TGTextEntry; 24 27 … … 29 32 class MStarList; 30 33 34 class TFile; 35 class TTree; 36 class TBranch; 37 38 class Leds; 39 class Rings; 40 31 41 class MGStarguider : public PixClient, public TGMainFrame 32 42 { … … 34 44 MGList *fList; 35 45 36 TGMenuBar *fMenu;46 MGMenuBar *fMenu; 37 47 MGImage *fImage; 38 48 MGImage *fZoomImage; 39 49 40 TGPopupMenu *fDisplay; 41 TGPopupMenu *fWrite; 42 TGPopupMenu *fFileType; 43 TGPopupMenu *fWriteType; 44 TGPopupMenu *fWriteRate; 45 TGPopupMenu *fInterpol; 46 TGPopupMenu *fSetup; 47 TGPopupMenu *fLimMag; 50 MGPopupMenu *fDisplay; 51 MGPopupMenu *fWrite; 52 MGPopupMenu *fWritePictures; 53 MGPopupMenu *fFileType; 54 MGPopupMenu *fWriteType; 55 MGPopupMenu *fAnalyse; 56 MGPopupMenu *fCaOs; 57 MGPopupMenu *fWriteRate; 58 MGPopupMenu *fInterpol; 59 MGPopupMenu *fSetup; 60 MGPopupMenu *fLimMag; 61 62 TFile *fFile; 63 TTree *fTree; 64 TBranch *fBranchL; 65 TBranch *fBranchT; 66 TBranch *fBranchR; 67 68 Leds *fLeds; 69 Rings *fRings; 70 Double_t fTime; 71 72 TH1F *fHistpr; 73 TH1F *fHistprx; 74 TH1F *fHistpry; 75 TH1F *fHistw[6]; 76 TH1F *fHistallw; 77 TH1F *fHistv[6]; 78 79 TH2F *fHistprxpry; 80 81 TGraph *fGraphprx; 82 TGraph *fGraphpry; 83 TGraph *fGraphw[6]; 48 84 49 85 MGCoordinates *fCRaDec; 50 86 MGCoordinates *fCZdAz; 87 88 MGCoordinates *fPZdAz; 51 89 52 90 TGTextEntry *fPixSize; … … 58 96 TTimer *fTimer; 59 97 60 const MObservatory::LocationName_t fObservatory;61 62 98 Int_t fDx; 63 99 Int_t fDy; … … 67 103 68 104 void SetPixSize(const double pixsize); 69 void Toggle( TGPopupMenu *p, UInt_t id);105 void Toggle(MGPopupMenu *p, UInt_t id); 70 106 void GetCoordinates(); 71 void CalcTrackingError(MStarList &, MStarList &); 107 void CalcTrackingError(Leds &, MStarList &); 108 ZdAz TrackingError(TArrayF &alt, TArrayF &az, TArrayF &mag) const; 109 110 void InitHists(); 111 void InitGraphs(); 112 void InitGui(); 113 114 void OpenFile(); 115 116 void ResetHists(); 117 void DisplayAnalysis(); 72 118 73 119 Bool_t HandleTimer(TTimer *t); 120 //Bool_t HandleKey(Event_t* event); 121 122 void DrawCircle(byte *img, double r); 74 123 75 124 public: 76 MGStarguider(MObservatory::LocationName_t key);125 MGStarguider(MObservatory::LocationName_t obs); 77 126 virtual ~MGStarguider(); 78 127 -
trunk/MagicSoft/Cosy/gui/Makefile
r1802 r1819 40 40 MGVelocity.cc \ 41 41 MGStarguider.cc \ 42 MGPngReader.cc \43 42 MGSkyPosition.cc \ 44 43 MGMenu.cc
Note:
See TracChangeset
for help on using the changeset viewer.