1 | #undef EXPERT
|
---|
2 | #undef EXPERT
|
---|
3 |
|
---|
4 | #include "MStarguider.h"
|
---|
5 |
|
---|
6 | #include <fstream> // ifstream
|
---|
7 |
|
---|
8 | #include <TH2F.h>
|
---|
9 | #include <TGraph.h>
|
---|
10 | #include <TTimer.h>
|
---|
11 | #include <TSystem.h>
|
---|
12 | #include <TFile.h> // temp writeout of histos
|
---|
13 | #include <TSocket.h>
|
---|
14 |
|
---|
15 | #include <TGMenu.h>
|
---|
16 | #include <TGLabel.h>
|
---|
17 | #include <TGButton.h>
|
---|
18 | #include <TGSplitter.h> // TGHorizontal3DLine
|
---|
19 | #include <TGTextEntry.h>
|
---|
20 | #include <TGLayout.h>
|
---|
21 | #include "MString.h"
|
---|
22 |
|
---|
23 | #include "MLog.h"
|
---|
24 | #include "MLogManip.h"
|
---|
25 |
|
---|
26 | #include "MAstro.h"
|
---|
27 | #include "MString.h"
|
---|
28 |
|
---|
29 |
|
---|
30 | #include "MCosy.h"
|
---|
31 | #include "MCaos.h"
|
---|
32 | // #include "MStargLeds.h"
|
---|
33 | #include "MStargHistograms.h"
|
---|
34 | #include "MDriveCom.h"
|
---|
35 |
|
---|
36 | #include "MGStarg.h"
|
---|
37 | #include "MGNumStars.h"
|
---|
38 |
|
---|
39 | #include "MGImage.h"
|
---|
40 | #include "MGCoordinates.h"
|
---|
41 |
|
---|
42 | #include "Camera.h"
|
---|
43 | #include "PngReader.h"
|
---|
44 |
|
---|
45 | #include "Led.h"
|
---|
46 | #include "Writer.h"
|
---|
47 | #include "FilterLed.h"
|
---|
48 | #include "MStarList.h"
|
---|
49 | #include "CaosFilter.h"
|
---|
50 | #include "StarCatalog.h"
|
---|
51 | #include "MGeomCamMagic.h"
|
---|
52 | #include "MAstroCamera.h"
|
---|
53 |
|
---|
54 | #include "MGCosy.h"
|
---|
55 |
|
---|
56 | ClassImp(MStarguider);
|
---|
57 |
|
---|
58 | using namespace std;
|
---|
59 |
|
---|
60 | enum {
|
---|
61 | IDM_kFilter,
|
---|
62 | IDM_kFindStar,
|
---|
63 | IDM_kCaosFilter,
|
---|
64 | IDM_kCatalog,
|
---|
65 | IDM_kStarguider,
|
---|
66 | IDM_kStart,
|
---|
67 | IDM_kStop,
|
---|
68 | IDM_kFileType,
|
---|
69 | IDM_kPPM,
|
---|
70 | IDM_kPNG,
|
---|
71 | IDM_kOnce,
|
---|
72 | IDM_kStretch,
|
---|
73 | IDM_kInput,
|
---|
74 | IDM_kChannel1,
|
---|
75 | IDM_kChannel2,
|
---|
76 | IDM_kChannel3,
|
---|
77 | IDM_kContinous,
|
---|
78 | IDM_kRate25ps,
|
---|
79 | IDM_kRate5ps,
|
---|
80 | IDM_kRate1s,
|
---|
81 | IDM_kRate5s,
|
---|
82 | IDM_kRate30s,
|
---|
83 | IDM_kRate1m,
|
---|
84 | IDM_kRate5m,
|
---|
85 | IDM_kSetup,
|
---|
86 | IDM_kLimMag3,
|
---|
87 | IDM_kLimMag4,
|
---|
88 | IDM_kLimMag5,
|
---|
89 | IDM_kLimMag6,
|
---|
90 | IDM_kLimMag7,
|
---|
91 | IDM_kLimMag8,
|
---|
92 | IDM_kLimMag9,
|
---|
93 | IDM_kPixSize,
|
---|
94 | IDM_kAngle,
|
---|
95 | IDM_kCut,
|
---|
96 | IDM_kInterpol250,
|
---|
97 | IDM_kInterpol125,
|
---|
98 | IDM_kInterpol50,
|
---|
99 | IDM_kInterpol25,
|
---|
100 | IDM_kInterpol10,
|
---|
101 | IDM_kInterpol5,
|
---|
102 | IDM_kInterpol2,
|
---|
103 | IDM_kInterpol1,
|
---|
104 | IDM_kCaosPrintRings,
|
---|
105 | IDM_kCaosPrintLeds,
|
---|
106 | IDM_kCaosAnalStart,
|
---|
107 | IDM_kCaosAnalStop,
|
---|
108 | IDM_kCaosWriteStart,
|
---|
109 | IDM_kCaosWriteStop,
|
---|
110 | IDM_kResetHistograms,
|
---|
111 | IDM_kStargAnalysis,
|
---|
112 | IDM_kStargCaosFilter,
|
---|
113 | IDM_kStargFindStar,
|
---|
114 | IDM_kRoqueLampAna,
|
---|
115 | IDM_kStarguiderMode,
|
---|
116 | IDM_kTpointMode
|
---|
117 |
|
---|
118 | };
|
---|
119 |
|
---|
120 | Bool_t MStarguider::HandleTimer(TTimer *t)
|
---|
121 | {
|
---|
122 | if (IsMapped())
|
---|
123 | {
|
---|
124 | fImage->DoRedraw();
|
---|
125 | fZoomImage->DoRedraw();
|
---|
126 | }
|
---|
127 |
|
---|
128 | if (fCosy && fCosy->GetWin()->IsMapped())
|
---|
129 | fCosy->GetWin()->GetImage()->DoRedraw();
|
---|
130 |
|
---|
131 | fGStarg->Update(fPos, fD);
|
---|
132 | if (fDisplay->IsEntryChecked(IDM_kStarguider))
|
---|
133 | fGNumStars->Update(fNumStarsDetected, fNumStarsCorrelated);
|
---|
134 |
|
---|
135 | return kTRUE;
|
---|
136 | }
|
---|
137 |
|
---|
138 | #define kZOOM 96
|
---|
139 |
|
---|
140 | XY MStarguider::GetCoordinates() const
|
---|
141 | {
|
---|
142 | return fPZdAz->GetCoordinates();
|
---|
143 | }
|
---|
144 |
|
---|
145 | void MStarguider::InitGui(Int_t channel)
|
---|
146 | {
|
---|
147 | fList = new MGList;
|
---|
148 | fList->SetOwner();
|
---|
149 |
|
---|
150 | const TGWindow *p=gClient->GetRoot();
|
---|
151 |
|
---|
152 | fChannel = new TGPopupMenu(p);
|
---|
153 | fChannel->AddEntry("Starfield Camera", IDM_kChannel1);
|
---|
154 | fChannel->AddEntry("TPoint Camera", IDM_kChannel2);
|
---|
155 | fChannel->AddEntry("Read from File", IDM_kChannel3);
|
---|
156 | if (channel<0)
|
---|
157 | fChannel->CheckEntry(IDM_kChannel3);
|
---|
158 | else
|
---|
159 | fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2);
|
---|
160 | fChannel->Associate(this);
|
---|
161 | fList->Add(fChannel);
|
---|
162 |
|
---|
163 | fFileType = new TGPopupMenu(p);
|
---|
164 | fFileType->AddEntry("PP&M", IDM_kPPM);
|
---|
165 | fFileType->AddEntry("&PNG", IDM_kPNG);
|
---|
166 | fFileType->CheckEntry(IDM_kPNG);
|
---|
167 | fFileType->Associate(this);
|
---|
168 | fList->Add(fFileType);
|
---|
169 |
|
---|
170 | fWriteType = new TGPopupMenu(p);
|
---|
171 | fWriteType->AddEntry("&Once", IDM_kOnce);
|
---|
172 | fWriteType->AddEntry("&Continous", IDM_kContinous);
|
---|
173 | fWriteType->CheckEntry(IDM_kOnce);
|
---|
174 | fWriteType->Associate(this);
|
---|
175 | fList->Add(fWriteType);
|
---|
176 |
|
---|
177 | fWriteRate = new TGPopupMenu(p);
|
---|
178 | fWriteRate->AddEntry("25/s", IDM_kRate25ps);
|
---|
179 | fWriteRate->AddEntry("5/s", IDM_kRate5ps);
|
---|
180 | fWriteRate->AddEntry("1s", IDM_kRate1s);
|
---|
181 | fWriteRate->AddEntry("5s", IDM_kRate5s);
|
---|
182 | fWriteRate->AddEntry("30s", IDM_kRate30s);
|
---|
183 | fWriteRate->AddEntry("1min", IDM_kRate1m);
|
---|
184 | fWriteRate->AddEntry("5min", IDM_kRate5m);
|
---|
185 | fWriteRate->CheckEntry(IDM_kRate1m);
|
---|
186 | fWriteRate->Associate(this);
|
---|
187 | fList->Add(fWriteRate);
|
---|
188 |
|
---|
189 | fWrtRate = 25*60;
|
---|
190 |
|
---|
191 | fLimMag = new TGPopupMenu(p);
|
---|
192 | fLimMag->AddEntry("3", IDM_kLimMag3);
|
---|
193 | fLimMag->AddEntry("4", IDM_kLimMag4);
|
---|
194 | fLimMag->AddEntry("5", IDM_kLimMag5);
|
---|
195 | fLimMag->AddEntry("6", IDM_kLimMag6);
|
---|
196 | fLimMag->AddEntry("7", IDM_kLimMag7);
|
---|
197 | fLimMag->AddEntry("8", IDM_kLimMag8);
|
---|
198 | fLimMag->AddEntry("9", IDM_kLimMag9);
|
---|
199 | fLimMag->CheckEntry(IDM_kLimMag9);
|
---|
200 | fLimMag->Associate(this);
|
---|
201 | fList->Add(fLimMag);
|
---|
202 |
|
---|
203 | fSao->SetLimitMag(9.0);
|
---|
204 |
|
---|
205 | fInterpol = new TGPopupMenu(p);
|
---|
206 | fInterpol->AddEntry("250", IDM_kInterpol250);
|
---|
207 | fInterpol->AddEntry("125", IDM_kInterpol125);
|
---|
208 | fInterpol->AddEntry("50", IDM_kInterpol50);
|
---|
209 | fInterpol->AddEntry("25", IDM_kInterpol25);
|
---|
210 | fInterpol->AddEntry("10", IDM_kInterpol10);
|
---|
211 | fInterpol->AddEntry("5", IDM_kInterpol5);
|
---|
212 | fInterpol->AddEntry("2", IDM_kInterpol2);
|
---|
213 | fInterpol->AddEntry("Off", IDM_kInterpol1);
|
---|
214 | fInterpol->Associate(this);
|
---|
215 | fList->Add(fInterpol);
|
---|
216 |
|
---|
217 | TString disp=gVirtualX->DisplayName();
|
---|
218 | gLog << all << "Display: " << disp << endl;
|
---|
219 | if (disp.First(':')>=0)
|
---|
220 | disp=disp(0, disp.First(':'));
|
---|
221 |
|
---|
222 | if (disp.IsNull() || disp==(TString)"localhost")
|
---|
223 | {
|
---|
224 | fInterpol->CheckEntry(IDM_kInterpol5);
|
---|
225 | fIntRate = 50;
|
---|
226 | }
|
---|
227 | else
|
---|
228 | {
|
---|
229 | fInterpol->CheckEntry(IDM_kInterpol125);
|
---|
230 | fIntRate = 125;
|
---|
231 | }
|
---|
232 |
|
---|
233 | fCaosPrint = new TGPopupMenu(p);
|
---|
234 | fCaosPrint->AddEntry("&Leds", IDM_kCaosPrintLeds);
|
---|
235 | fCaosPrint->AddEntry("&Rings", IDM_kCaosPrintRings);
|
---|
236 | fCaosPrint->Associate(this);
|
---|
237 | fList->Add(fCaosPrint);
|
---|
238 |
|
---|
239 | fCaosWrite = new TGPopupMenu(p);
|
---|
240 | fCaosWrite->AddEntry("&Start", IDM_kCaosWriteStart);
|
---|
241 | fCaosWrite->AddEntry("Sto&p", IDM_kCaosWriteStop);
|
---|
242 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
243 | fCaosWrite->Associate(this);
|
---|
244 | fList->Add(fCaosWrite);
|
---|
245 |
|
---|
246 | fCaosAnalyse = new TGPopupMenu(p);
|
---|
247 | fCaosAnalyse->AddEntry("S&tart Analysis", IDM_kCaosAnalStart);
|
---|
248 | fCaosAnalyse->AddEntry("St&op Analysis", IDM_kCaosAnalStop);
|
---|
249 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
250 | fCaosAnalyse->Associate(this);
|
---|
251 | fList->Add(fCaosAnalyse);
|
---|
252 |
|
---|
253 | fMenu = new TGMenuBar(this, 0, 0, kHorizontalFrame);
|
---|
254 | fDisplay = fMenu->AddPopup("&Display");
|
---|
255 | fMode = fMenu->AddPopup("&Mode");
|
---|
256 | fWritePictures = fMenu->AddPopup("&WritePics");
|
---|
257 | fSetup = fMenu->AddPopup("&Setup");
|
---|
258 | fOperations = fMenu->AddPopup("&Operations");
|
---|
259 | fMenu->Resize(fMenu->GetDefaultSize());
|
---|
260 | AddFrame(fMenu);
|
---|
261 |
|
---|
262 | //
|
---|
263 | // Create Menu for MStarguider Display
|
---|
264 | //
|
---|
265 | //fDisplay = new MMGPopupMenu(p);
|
---|
266 | fDisplay->AddEntry("&Filter", IDM_kFilter);
|
---|
267 | fDisplay->AddEntry("Stretch", IDM_kStretch);
|
---|
268 | fDisplay->AddSeparator();
|
---|
269 | fDisplay->AddEntry("Find &Star", IDM_kFindStar);
|
---|
270 | fDisplay->AddEntry("C&aos Filter", IDM_kCaosFilter);
|
---|
271 | fDisplay->AddSeparator();
|
---|
272 | fDisplay->AddEntry("SAO &Catalog", IDM_kCatalog);
|
---|
273 | fDisplay->AddEntry("Starguider", IDM_kStarguider);
|
---|
274 | fDisplay->AddEntry("Starguider LED Filter", IDM_kStargCaosFilter);
|
---|
275 | fDisplay->AddEntry("Starguider Find Star", IDM_kStargFindStar);
|
---|
276 | fDisplay->AddSeparator();
|
---|
277 | if (channel>=0)
|
---|
278 | fDisplay->AddPopup("&Input", fChannel);
|
---|
279 | fDisplay->DisableEntry(IDM_kStargFindStar);
|
---|
280 | fDisplay->CheckEntry(IDM_kStretch);
|
---|
281 | fDisplay->Associate(this);
|
---|
282 |
|
---|
283 | fMode->AddEntry("Starguider", IDM_kStarguiderMode);
|
---|
284 | fMode->AddEntry("Tpoint", IDM_kTpointMode);
|
---|
285 | fMode->Associate(this);
|
---|
286 |
|
---|
287 | fWritePictures->AddEntry("&Start", IDM_kStart);
|
---|
288 | fWritePictures->AddEntry("Sto&p", IDM_kStop);
|
---|
289 | fWritePictures->AddSeparator();
|
---|
290 | fWritePictures->AddPopup("File &Type", fFileType);
|
---|
291 | fWritePictures->AddPopup("&Write Type", fWriteType);
|
---|
292 | fWritePictures->AddPopup("Write &Rate", fWriteRate);
|
---|
293 | fWritePictures->DisableEntry(IDM_kStop);
|
---|
294 | fWritePictures->Associate(this);
|
---|
295 |
|
---|
296 | fSetup->AddPopup("Lim. &Magnitude", fLimMag);
|
---|
297 | fSetup->AddPopup("Disp. &Interpolation", fInterpol);
|
---|
298 | fSetup->Associate(this);
|
---|
299 |
|
---|
300 | fOperations->AddEntry("Roque Lamp Analysis", IDM_kRoqueLampAna);
|
---|
301 | fOperations->AddEntry("Starguider Analysis", IDM_kStargAnalysis);
|
---|
302 | fOperations->DisableEntry(IDM_kStargAnalysis);
|
---|
303 | fOperations->Associate(this);
|
---|
304 |
|
---|
305 | fCaOs = new TGPopupMenu(p);
|
---|
306 | fCaOs->AddPopup("&Write", fCaosWrite);
|
---|
307 | fCaOs->AddPopup("&Print", fCaosPrint);
|
---|
308 | fCaOs->AddPopup("&Analyse", fCaosAnalyse);
|
---|
309 | fCaOs->Associate(this);
|
---|
310 | fList->Add(fCaOs);
|
---|
311 |
|
---|
312 | fGStarg = new MGStarg(this, 235);
|
---|
313 | fGStarg->DrawText("0.75'", "1.50'", "3.00'", "Mispointing [min]");
|
---|
314 | fGStarg->DrawHexagon();
|
---|
315 | fGStarg->Move(530,596+5);
|
---|
316 | fList->Add(fGStarg);
|
---|
317 |
|
---|
318 | //RA,Dec for catalog
|
---|
319 | fCRaDec = new MGCoordinates(this, kETypeRaDec);
|
---|
320 | fCRaDec->Move(4, fMenu->GetDefaultHeight()+584);
|
---|
321 | AddFrame(fCRaDec);
|
---|
322 |
|
---|
323 | //telescope position
|
---|
324 | fCZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
325 | fCZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+597);
|
---|
326 | AddFrame(fCZdAz);
|
---|
327 |
|
---|
328 | //starguider position
|
---|
329 | fPZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
330 | fPZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+640);
|
---|
331 | AddFrame(fPZdAz);
|
---|
332 |
|
---|
333 | //mispointing
|
---|
334 | fDZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
335 | fDZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+683);
|
---|
336 | AddFrame(fDZdAz);
|
---|
337 |
|
---|
338 | fSZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
339 | fSZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+795);
|
---|
340 | AddFrame(fSZdAz);
|
---|
341 |
|
---|
342 | fGNumStars = new MGNumStars(this, 235);
|
---|
343 | fGNumStars->DrawText("Number of stars");
|
---|
344 | fGNumStars->Move(278, fMenu->GetDefaultHeight()+713);
|
---|
345 | fList->Add(fGNumStars);
|
---|
346 |
|
---|
347 | fTPoint = new TGTextButton(this, "TPoint");
|
---|
348 | fTPoint->Move(4, fMenu->GetDefaultHeight()+785);
|
---|
349 | fTPoint->AllowStayDown(kTRUE);
|
---|
350 | AddFrame(fTPoint);
|
---|
351 |
|
---|
352 | fStargTPoint = new TGTextButton(this, "StargTPoint");
|
---|
353 | fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785);
|
---|
354 | fStargTPoint->AllowStayDown(kTRUE);
|
---|
355 | AddFrame(fStargTPoint);
|
---|
356 |
|
---|
357 | fFps = new TGLabel(this, "---fps");
|
---|
358 | fFps->SetTextJustify(kTextRight);
|
---|
359 | fFps->Move(650-495, fMenu->GetDefaultHeight()+714+23);
|
---|
360 | AddFrame(fFps);
|
---|
361 |
|
---|
362 | fPosZoom = new TGLabel(this, "(----, ----) ----.--d/----.--d");
|
---|
363 | fPosZoom->SetTextJustify(kTextLeft);
|
---|
364 | fPosZoom->Move(4, fMenu->GetDefaultHeight()+765);
|
---|
365 | AddFrame(fPosZoom);
|
---|
366 |
|
---|
367 | fSkyBright = new TGLabel(this, "Sky Brightness: --- ");
|
---|
368 | fSkyBright->SetTextJustify(kTextLeft);
|
---|
369 | fSkyBright->Move(4, fMenu->GetDefaultHeight()+785);
|
---|
370 | AddFrame(fSkyBright);
|
---|
371 |
|
---|
372 | TGLabel *l = new TGLabel(this, "deg");
|
---|
373 | l->SetTextJustify(kTextLeft);
|
---|
374 | l->Move(606-412, fMenu->GetDefaultHeight()+669);
|
---|
375 | AddFrame(l);
|
---|
376 |
|
---|
377 | l = new TGLabel(this, "arcsec/pix");
|
---|
378 | l->SetTextJustify(kTextLeft);
|
---|
379 | l->Move(606-412, fMenu->GetDefaultHeight()+692);
|
---|
380 | AddFrame(l);
|
---|
381 |
|
---|
382 | l = new TGLabel(this, "sigma");
|
---|
383 | l->SetTextJustify(kTextLeft);
|
---|
384 | l->Move(606-412, fMenu->GetDefaultHeight()+715);
|
---|
385 | AddFrame(l);
|
---|
386 |
|
---|
387 | fCZdAzText = new TGLabel(this, "Zd/Az telescope pointing at");
|
---|
388 | fCZdAzText->SetTextJustify(kTextLeft);
|
---|
389 | fCZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+584-5);
|
---|
390 | AddFrame(fCZdAzText);
|
---|
391 |
|
---|
392 | fPZdAzText = new TGLabel(this, "Zd/Az starguider pointing at");
|
---|
393 | fPZdAzText->SetTextJustify(kTextLeft);
|
---|
394 | fPZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+630+20-5-23);
|
---|
395 | AddFrame(fPZdAzText);
|
---|
396 |
|
---|
397 | fDZdAzText = new TGLabel(this, "Zd/Az mispointing");
|
---|
398 | fDZdAzText->SetTextJustify(kTextLeft);
|
---|
399 | fDZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+676+2*20-5-46);
|
---|
400 | AddFrame(fDZdAzText);
|
---|
401 |
|
---|
402 | #ifdef EXPERT
|
---|
403 | l = new TGLabel(this, "Mispointing/FindStar (Experts Only!)");
|
---|
404 | l->SetTextJustify(kTextLeft);
|
---|
405 | l->Move(240+12+20, fMenu->GetDefaultHeight()+722+3*20-5);
|
---|
406 | AddFrame(l);
|
---|
407 | #endif
|
---|
408 |
|
---|
409 | // Set input box for rotation angle
|
---|
410 | const Double_t angle = -0.2;
|
---|
411 | fSao->SetRotationAngle(angle);
|
---|
412 |
|
---|
413 | TString txt;
|
---|
414 | txt += angle;
|
---|
415 |
|
---|
416 | fAngle = new TGTextEntry(this, txt, IDM_kAngle);
|
---|
417 | fAngle->SetAlignment(kTextCenterX);
|
---|
418 | fAngle->Move(547-410, fMenu->GetDefaultHeight()+667);
|
---|
419 | AddFrame(fAngle);
|
---|
420 |
|
---|
421 | // Set input box for pixel size
|
---|
422 | const Double_t pixsize = 48.9; // used to be 23.4
|
---|
423 |
|
---|
424 | fSao->SetPixSize(pixsize);
|
---|
425 |
|
---|
426 | txt = "";
|
---|
427 | txt += pixsize;
|
---|
428 |
|
---|
429 | fPixSize = new TGTextEntry(this, txt, IDM_kPixSize);
|
---|
430 | fPixSize->SetAlignment(kTextCenterX);
|
---|
431 | fPixSize->Move(547-410, fMenu->GetDefaultHeight()+690);
|
---|
432 | AddFrame(fPixSize);
|
---|
433 |
|
---|
434 | // Set input box for cleaning cut
|
---|
435 | const Double_t cut = 3.0;
|
---|
436 |
|
---|
437 | txt = "";
|
---|
438 | txt += cut;
|
---|
439 |
|
---|
440 | fCut = new TGTextEntry(this, txt, IDM_kCut);
|
---|
441 | fCut->SetAlignment(kTextCenterX);
|
---|
442 | fCut->Move(547-410, fMenu->GetDefaultHeight()+713);
|
---|
443 | AddFrame(fCut);
|
---|
444 |
|
---|
445 | // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
|
---|
446 | // AddFrame(fLineSep, new TGLayoutHints (kLHintsNormal | kLHintsExpandX));
|
---|
447 | // fList->Add(fLineSep);
|
---|
448 |
|
---|
449 | //
|
---|
450 | // Create Image Display
|
---|
451 | //
|
---|
452 | fZoomImage = new MGImage(this, kZOOM, kZOOM);
|
---|
453 | // fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2);
|
---|
454 | fZoomImage->Move(4, 700-kZOOM-2+85);
|
---|
455 | AddFrame(fZoomImage);
|
---|
456 |
|
---|
457 | fImage = new MGImage(this, 768, 576);
|
---|
458 | fImage->Move(0, fMenu->GetDefaultHeight());
|
---|
459 | AddFrame(fImage);
|
---|
460 |
|
---|
461 | const Int_t w = 768;
|
---|
462 | const Int_t h = 840;
|
---|
463 | SetWMSizeHints(w, h, w, h, 1, 1); // set the smallest and biggest size of the Main frame
|
---|
464 |
|
---|
465 | //
|
---|
466 | // Make everything visible
|
---|
467 | //
|
---|
468 | SetWindowName("MStarguider Main Window");
|
---|
469 | SetIconName("MStarguider");
|
---|
470 |
|
---|
471 | MapSubwindows();
|
---|
472 | fTPoint->UnmapWindow();
|
---|
473 | fStargTPoint->UnmapWindow();
|
---|
474 | fGStarg->UnmapWindow();
|
---|
475 | fGNumStars->UnmapWindow();
|
---|
476 | fCRaDec->UnmapWindow();
|
---|
477 | fCZdAz->UnmapWindow();
|
---|
478 | fCZdAzText->UnmapWindow();
|
---|
479 | fPZdAz->UnmapWindow();
|
---|
480 | fPZdAzText->UnmapWindow();
|
---|
481 | fDZdAz->UnmapWindow();
|
---|
482 | fDZdAzText->UnmapWindow();
|
---|
483 | fSZdAz->UnmapWindow();
|
---|
484 | fSkyBright->UnmapWindow();
|
---|
485 | MapWindow();
|
---|
486 |
|
---|
487 |
|
---|
488 | //IconifyWindow();
|
---|
489 |
|
---|
490 | //------------------------------------------------------------
|
---|
491 | // XY xy(3.819444, 24.05333);
|
---|
492 | // fCRaDec->SetCoordinates(xy);
|
---|
493 | // fRaDec->Set(xy.X()*360/24, xy.Y());
|
---|
494 | //------------------------------------------------------------
|
---|
495 | }
|
---|
496 |
|
---|
497 | MStarguider::MStarguider(MObservatory::LocationName_t obs, Int_t channel)
|
---|
498 | : TGMainFrame(gClient->GetRoot(), 768, 840),
|
---|
499 | fNumStarsDetected(0),
|
---|
500 | fNumStarsCorrelated(0),
|
---|
501 | fCosy(NULL),
|
---|
502 | fOutTp(0),
|
---|
503 | fOutStargTp(0),
|
---|
504 | fOutRq(0),
|
---|
505 | fDx((768-kZOOM)/2),
|
---|
506 | fDy((512-kZOOM)/2),
|
---|
507 | fStatus(MDriveCom::kStandby)
|
---|
508 | {
|
---|
509 | gLog << warn << " #### FIXME: Make MCaos Thread safe!" << endl;
|
---|
510 |
|
---|
511 | // This means that all objects added with AddFrame are deleted
|
---|
512 | // automatically, including all LayoutHints.
|
---|
513 | SetCleanup();
|
---|
514 |
|
---|
515 | fAmcSocket = new TSocket("amc", 7307);
|
---|
516 |
|
---|
517 | fSao = new StarCatalog(obs);
|
---|
518 | fRaDec = new RaDec(180, 40);
|
---|
519 |
|
---|
520 | // fStargLeds = new MStargLeds;
|
---|
521 | // fStargLeds->ReadResources();
|
---|
522 |
|
---|
523 | fCaos = new MCaos;
|
---|
524 | fCaos->ReadResources();
|
---|
525 | fCaos->SetRadii(237.9, 239.9);
|
---|
526 |
|
---|
527 | fStargCaos = new MCaos;
|
---|
528 | fStargCaos->ReadResources("stargleds.txt");
|
---|
529 | fStargCaos->SetMinNumberRings(3);
|
---|
530 | fStargCaos->SetRadii(158,164);
|
---|
531 |
|
---|
532 | fStargHistograms = new MStargHistograms();
|
---|
533 |
|
---|
534 | InitGui(channel);
|
---|
535 |
|
---|
536 | fTimer=new TTimer(this, 1000/25); // 40ms
|
---|
537 | fTimer->TurnOn();
|
---|
538 |
|
---|
539 | fTime.Now();
|
---|
540 |
|
---|
541 | fTimeFromTp.Set(1970,1,1);
|
---|
542 | fAltAzOffsetFromTp = AltAz(-1000,-1000);
|
---|
543 |
|
---|
544 | gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE);
|
---|
545 |
|
---|
546 | if (channel<0)
|
---|
547 | fGetter = new PngReader(*this);
|
---|
548 | else
|
---|
549 | fGetter = new Camera(*this, channel);
|
---|
550 | }
|
---|
551 |
|
---|
552 | MStarguider::~MStarguider()
|
---|
553 | {
|
---|
554 | fGetter->ExitLoop();
|
---|
555 | delete fGetter;
|
---|
556 |
|
---|
557 | gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kFALSE);
|
---|
558 |
|
---|
559 | fTimer->TurnOff();
|
---|
560 | delete fTimer;
|
---|
561 |
|
---|
562 | delete fList;
|
---|
563 |
|
---|
564 | delete fCaos;
|
---|
565 | delete fStargCaos;
|
---|
566 | // delete fStargLeds;
|
---|
567 | delete fStargHistograms;
|
---|
568 | delete fSao;
|
---|
569 | delete fRaDec;
|
---|
570 |
|
---|
571 | if (fOutTp)
|
---|
572 | delete fOutTp;
|
---|
573 |
|
---|
574 | if (fOutStargTp)
|
---|
575 | delete fOutStargTp;
|
---|
576 |
|
---|
577 | if (fOutRq)
|
---|
578 | delete fOutRq;
|
---|
579 |
|
---|
580 | delete fAmcSocket;
|
---|
581 |
|
---|
582 | gLog << inf2 << "Camera Display destroyed." << endl;
|
---|
583 | }
|
---|
584 |
|
---|
585 | bool MStarguider::SendAmcTrigger(const char *msg)
|
---|
586 | {
|
---|
587 | if (!fAmcSocket->IsValid())
|
---|
588 | return false;
|
---|
589 |
|
---|
590 | TString txt("TRIGGER ");
|
---|
591 | txt += msg;
|
---|
592 |
|
---|
593 | const Int_t len = fAmcSocket->SendRaw(txt.Data(), txt.Length());
|
---|
594 | if (len<0)
|
---|
595 | {
|
---|
596 | gLog << err << "ERROR - Sending Trigger to Amc" << endl;
|
---|
597 | return false;
|
---|
598 | }
|
---|
599 | if (len!=txt.Length())
|
---|
600 | {
|
---|
601 | gLog << err << "Send wrong number (" << len << ") of Bytes to Amc." << endl;
|
---|
602 | return false;
|
---|
603 | }
|
---|
604 |
|
---|
605 | return true;
|
---|
606 | }
|
---|
607 |
|
---|
608 | void MStarguider::Layout()
|
---|
609 | {
|
---|
610 | // Resize(GetDefaultSize());
|
---|
611 | }
|
---|
612 |
|
---|
613 | void MStarguider::CloseWindow()
|
---|
614 | {
|
---|
615 | gLog << inf2 << "EventDisplay::CloseWindow: Exit Application Loop." << endl;
|
---|
616 |
|
---|
617 | //fClient.ExitLoop();
|
---|
618 | // cout << "FIXME: ExitLoop not called!!!!!!" << endl;
|
---|
619 | fGetter->ExitLoop();
|
---|
620 | gSystem->ExitLoop();
|
---|
621 | }
|
---|
622 |
|
---|
623 | void MStarguider::SwitchOff(TGPopupMenu *p, UInt_t id)
|
---|
624 | {
|
---|
625 | p->UnCheckEntry(id);
|
---|
626 | p->DisableEntry(id);
|
---|
627 | }
|
---|
628 |
|
---|
629 | void MStarguider::SetChannel()
|
---|
630 | {
|
---|
631 | if (fChannel->IsEntryChecked(IDM_kChannel3))
|
---|
632 | {
|
---|
633 | if (dynamic_cast<PngReader*>(fGetter)==0)
|
---|
634 | {
|
---|
635 | delete fGetter;
|
---|
636 | fGetter=new PngReader(*this);
|
---|
637 | }
|
---|
638 | }
|
---|
639 | else
|
---|
640 | {
|
---|
641 | const Int_t ch = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
|
---|
642 | if (dynamic_cast<Camera*>(fGetter)==0)
|
---|
643 | {
|
---|
644 | delete fGetter;
|
---|
645 | fGetter = new Camera(*this, ch);
|
---|
646 | }
|
---|
647 | else
|
---|
648 | fGetter->SetChannel(ch);
|
---|
649 | }
|
---|
650 | }
|
---|
651 |
|
---|
652 | void MStarguider::Toggle(TGPopupMenu *p, UInt_t id)
|
---|
653 | {
|
---|
654 | if (p->IsEntryChecked(id))
|
---|
655 | p->UnCheckEntry(id);
|
---|
656 | else
|
---|
657 | p->CheckEntry(id);
|
---|
658 | }
|
---|
659 |
|
---|
660 | void MStarguider::ToggleStargAnalysis()
|
---|
661 | {
|
---|
662 | if (fOperations->IsEntryChecked(IDM_kStargAnalysis))
|
---|
663 | fStargHistograms->OpenFile();
|
---|
664 | else
|
---|
665 | fStargHistograms->CloseFile();
|
---|
666 | }
|
---|
667 |
|
---|
668 | void MStarguider::ToggleFindStar()
|
---|
669 | {
|
---|
670 | if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy)
|
---|
671 | fTPoint->MapWindow();
|
---|
672 | else
|
---|
673 | {
|
---|
674 | fTPoint->UnmapWindow();
|
---|
675 | fTPoint->SetDown(kFALSE);
|
---|
676 | }
|
---|
677 | }
|
---|
678 |
|
---|
679 | void MStarguider::ToggleStarguider()
|
---|
680 | {
|
---|
681 | if (fDisplay->IsEntryChecked(IDM_kStarguider))
|
---|
682 | {
|
---|
683 | fLastBright = 0xff;
|
---|
684 |
|
---|
685 | fChannel->EnableEntry(IDM_kChannel1);
|
---|
686 | fDisplay->DisableEntry(IDM_kFindStar);
|
---|
687 | fDisplay->DisableEntry(IDM_kCaosFilter);
|
---|
688 | fOperations->EnableEntry(IDM_kStargAnalysis);
|
---|
689 |
|
---|
690 | fStargTPoint->MapWindow();
|
---|
691 |
|
---|
692 | fPZdAz->MapWindow();
|
---|
693 | fDZdAz->MapWindow();
|
---|
694 | fSkyBright->MapWindow();
|
---|
695 |
|
---|
696 | for (int i=IDM_kLimMag3; i<=IDM_kLimMag9; i++)
|
---|
697 | fLimMag->UnCheckEntry(i);
|
---|
698 | fLimMag->CheckEntry(IDM_kLimMag9);
|
---|
699 | fSao->SetLimitMag(9.0);
|
---|
700 |
|
---|
701 | for (int i=IDM_kInterpol250; i<=IDM_kInterpol1; i++)
|
---|
702 | fInterpol->UnCheckEntry(i);
|
---|
703 | fInterpol->CheckEntry(IDM_kInterpol125);
|
---|
704 | fIntRate = 125;
|
---|
705 |
|
---|
706 | //catalog
|
---|
707 | fDisplay->CheckEntry(IDM_kCatalog);
|
---|
708 | fCRaDec->MapWindow();
|
---|
709 | fCZdAz->MapWindow();
|
---|
710 | fCZdAzText->MapWindow();
|
---|
711 |
|
---|
712 | fPZdAz->MapWindow();
|
---|
713 | fPZdAzText->MapWindow();
|
---|
714 | fDZdAz->MapWindow();
|
---|
715 | fDZdAzText->MapWindow();
|
---|
716 |
|
---|
717 | fGStarg->MapWindow();
|
---|
718 | fGNumStars->MapWindow();
|
---|
719 |
|
---|
720 | SwitchOff(fChannel, IDM_kChannel2);
|
---|
721 | fChannel->CheckEntry(IDM_kChannel1);
|
---|
722 |
|
---|
723 | }
|
---|
724 | else
|
---|
725 | {
|
---|
726 | fStatus = MDriveCom::kStandby;
|
---|
727 |
|
---|
728 | fStargTPoint->UnmapWindow();
|
---|
729 | fStargTPoint->SetDown(kFALSE);
|
---|
730 |
|
---|
731 | fPZdAz->UnmapWindow();
|
---|
732 | fPZdAzText->UnmapWindow();
|
---|
733 | fDZdAz->UnmapWindow();
|
---|
734 | fDZdAzText->UnmapWindow();
|
---|
735 | fSkyBright->UnmapWindow();
|
---|
736 | //catalog
|
---|
737 | fCRaDec->UnmapWindow();
|
---|
738 | fCZdAz->UnmapWindow();
|
---|
739 | fCZdAzText->UnmapWindow();
|
---|
740 | fDisplay->UnCheckEntry(IDM_kCatalog);
|
---|
741 |
|
---|
742 | fGStarg->UnmapWindow();
|
---|
743 | fGNumStars->UnmapWindow();
|
---|
744 |
|
---|
745 | fChannel->EnableEntry(IDM_kChannel2);
|
---|
746 | fDisplay->EnableEntry(IDM_kFindStar);
|
---|
747 | fDisplay->EnableEntry(IDM_kCaosFilter);
|
---|
748 | fOperations->DisableEntry(IDM_kStargAnalysis);
|
---|
749 | }
|
---|
750 |
|
---|
751 | SetChannel();
|
---|
752 | //gSystem->Unlink("tracking_error.txt");
|
---|
753 | }
|
---|
754 |
|
---|
755 | void MStarguider::ToggleCaosFilter()
|
---|
756 | {
|
---|
757 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter))
|
---|
758 | {
|
---|
759 | if (!fMode->IsEntryChecked(IDM_kStarguiderMode)
|
---|
760 | && !fMode->IsEntryChecked(IDM_kTpointMode))
|
---|
761 | fMenu->AddPopup("&CaOs", fCaOs, NULL);
|
---|
762 |
|
---|
763 | SwitchOff(fDisplay, IDM_kStarguider);
|
---|
764 | SwitchOff(fDisplay, IDM_kStargCaosFilter);
|
---|
765 | fDisplay->DisableEntry(IDM_kStargFindStar);
|
---|
766 | }
|
---|
767 | else
|
---|
768 | {
|
---|
769 | fCaosWrite->UnCheckEntry(IDM_kCaosPrintLeds);
|
---|
770 | fCaosWrite->UnCheckEntry(IDM_kCaosPrintRings);
|
---|
771 |
|
---|
772 | if (fCaosAnalyse->IsEntryEnabled(IDM_kCaosAnalStop))
|
---|
773 | {
|
---|
774 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
775 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart);
|
---|
776 | fCaos->DeleteHistograms();
|
---|
777 | }
|
---|
778 | if (fCaosWrite->IsEntryEnabled(IDM_kCaosWriteStop))
|
---|
779 | {
|
---|
780 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
781 | fCaosWrite->EnableEntry(IDM_kCaosWriteStart);
|
---|
782 | fCaos->CloseFile();
|
---|
783 | }
|
---|
784 | fMenu->RemovePopup("CaOs");
|
---|
785 |
|
---|
786 | fDisplay->EnableEntry(IDM_kStargCaosFilter);
|
---|
787 | fDisplay->EnableEntry(IDM_kStarguider);
|
---|
788 | }
|
---|
789 | fMenu->Resize(fMenu->GetDefaultSize());
|
---|
790 | MapSubwindows(); // maps everything, but we don't want that
|
---|
791 | fTPoint->UnmapWindow();
|
---|
792 | fStargTPoint->UnmapWindow();
|
---|
793 | fGStarg->UnmapWindow();
|
---|
794 | fGNumStars->UnmapWindow();
|
---|
795 | fCRaDec->UnmapWindow();
|
---|
796 | fCZdAz->UnmapWindow();
|
---|
797 | fCZdAzText->UnmapWindow();
|
---|
798 | fPZdAz->UnmapWindow();
|
---|
799 | fPZdAzText->UnmapWindow();
|
---|
800 | fDZdAz->UnmapWindow();
|
---|
801 | fDZdAzText->UnmapWindow();
|
---|
802 | fSZdAz->UnmapWindow();
|
---|
803 | fSkyBright->UnmapWindow();
|
---|
804 | MapWindow();
|
---|
805 | }
|
---|
806 |
|
---|
807 | Bool_t MStarguider::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
---|
808 | {
|
---|
809 | switch (GET_MSG(msg))
|
---|
810 | {
|
---|
811 | case kC_TEXTENTRY:
|
---|
812 | if (GET_SUBMSG(msg)==kTE_ENTER)
|
---|
813 | switch (mp1)
|
---|
814 | {
|
---|
815 | case IDM_kPixSize:
|
---|
816 | {
|
---|
817 | const Float_t pixsize = atof(fPixSize->GetText());
|
---|
818 | gLog << all << "Pixel Size changed to " << pixsize << "\"/pix" << endl;
|
---|
819 | fSao->SetPixSize(pixsize);
|
---|
820 | return kTRUE;
|
---|
821 | }
|
---|
822 | case IDM_kAngle:
|
---|
823 | {
|
---|
824 | const Float_t angle = atof(fAngle->GetText());
|
---|
825 | gLog << all << "Rotation Angle changed to " << angle << "deg" << endl;
|
---|
826 | fSao->SetRotationAngle(angle);
|
---|
827 | return kTRUE;
|
---|
828 | }
|
---|
829 | case IDM_kCut:
|
---|
830 | {
|
---|
831 | const Float_t cut = atof(fCut->GetText());
|
---|
832 | gLog << all << "Starguider cleaning level changed to " << cut << " sigma." << endl;
|
---|
833 | return kTRUE;
|
---|
834 | }
|
---|
835 | }
|
---|
836 | return kTRUE;
|
---|
837 |
|
---|
838 | case kC_COMMAND:
|
---|
839 | switch (GET_SUBMSG(msg))
|
---|
840 | {
|
---|
841 | case kCM_MENU:
|
---|
842 | switch (mp1)
|
---|
843 | {
|
---|
844 | case IDM_kCatalog:
|
---|
845 | Toggle(fDisplay, IDM_kCatalog);
|
---|
846 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
847 | {
|
---|
848 | fCRaDec->MapWindow();
|
---|
849 | fCZdAz->MapWindow();
|
---|
850 | fCZdAzText->MapWindow();
|
---|
851 | }
|
---|
852 | else
|
---|
853 | {
|
---|
854 | fCRaDec->UnmapWindow();
|
---|
855 | fCZdAz->UnmapWindow();
|
---|
856 | fCZdAzText->UnmapWindow();
|
---|
857 | }
|
---|
858 | return kTRUE;
|
---|
859 |
|
---|
860 | case IDM_kRoqueLampAna:
|
---|
861 | Toggle(fOperations, IDM_kRoqueLampAna);
|
---|
862 | if (fOperations->IsEntryChecked(IDM_kRoqueLampAna))
|
---|
863 | fDisplay->CheckEntry(IDM_kStargCaosFilter);
|
---|
864 | else
|
---|
865 | fDisplay->UnCheckEntry(IDM_kStargCaosFilter);
|
---|
866 |
|
---|
867 | return kTRUE;
|
---|
868 |
|
---|
869 | case IDM_kStargFindStar:
|
---|
870 | Toggle(fDisplay, IDM_kStargFindStar);
|
---|
871 | if (fDisplay->IsEntryChecked(IDM_kStargFindStar))
|
---|
872 | fSZdAz->MapWindow();
|
---|
873 | else
|
---|
874 | fSZdAz->UnmapWindow();
|
---|
875 | return kTRUE;
|
---|
876 |
|
---|
877 | case IDM_kStarguider:
|
---|
878 | Toggle(fDisplay, IDM_kStarguider);
|
---|
879 | ToggleStarguider();
|
---|
880 | return kTRUE;
|
---|
881 |
|
---|
882 | case IDM_kStargAnalysis:
|
---|
883 | Toggle(fOperations, IDM_kStargAnalysis);
|
---|
884 | ToggleStargAnalysis();
|
---|
885 | return kTRUE;
|
---|
886 |
|
---|
887 | case IDM_kStarguiderMode:
|
---|
888 | Toggle(fMode, IDM_kStarguiderMode);
|
---|
889 |
|
---|
890 | if (fMode->IsEntryChecked(IDM_kStarguiderMode))
|
---|
891 | {
|
---|
892 | //uncheck not needed items
|
---|
893 | //general
|
---|
894 | fDisplay->UnCheckEntry(IDM_kStargFindStar);
|
---|
895 | SwitchOff(fDisplay, IDM_kFilter);
|
---|
896 | SwitchOff(fChannel, IDM_kChannel3);
|
---|
897 | SwitchOff(fOperations, IDM_kRoqueLampAna);
|
---|
898 | SwitchOff(fOperations, IDM_kStargAnalysis);
|
---|
899 |
|
---|
900 | //tpoint
|
---|
901 | SwitchOff(fDisplay, IDM_kFindStar);
|
---|
902 | ToggleFindStar();
|
---|
903 | SwitchOff(fDisplay, IDM_kCaosFilter);
|
---|
904 | ToggleCaosFilter();
|
---|
905 | fMode->UnCheckEntry(IDM_kTpointMode);
|
---|
906 |
|
---|
907 | //enable starguider items
|
---|
908 | fDisplay->EnableEntry(IDM_kStargCaosFilter);
|
---|
909 | fDisplay->EnableEntry(IDM_kStarguider);
|
---|
910 | fDisplay->EnableEntry(IDM_kCatalog);
|
---|
911 |
|
---|
912 | //check needed items
|
---|
913 | fDisplay->CheckEntry(IDM_kStretch);
|
---|
914 | fDisplay->CheckEntry(IDM_kStargCaosFilter);
|
---|
915 | fDisplay->CheckEntry(IDM_kStarguider);
|
---|
916 | ToggleStarguider();
|
---|
917 | }
|
---|
918 | else
|
---|
919 | {
|
---|
920 | //uncheck
|
---|
921 | //starguider items
|
---|
922 | fDisplay->UnCheckEntry(IDM_kStargCaosFilter);
|
---|
923 | fDisplay->UnCheckEntry(IDM_kStarguider);
|
---|
924 | ToggleStarguider();
|
---|
925 |
|
---|
926 | //general
|
---|
927 | fDisplay->UnCheckEntry(IDM_kCatalog);
|
---|
928 | fDisplay->EnableEntry(IDM_kFilter);
|
---|
929 | fDisplay->EnableEntry(IDM_kCaosFilter);
|
---|
930 | fDisplay->EnableEntry(IDM_kFindStar);
|
---|
931 | fChannel->EnableEntry(IDM_kChannel3);
|
---|
932 | fOperations->EnableEntry(IDM_kRoqueLampAna);
|
---|
933 | }
|
---|
934 | return kTRUE;
|
---|
935 |
|
---|
936 | case IDM_kTpointMode:
|
---|
937 | Toggle(fMode, IDM_kTpointMode);
|
---|
938 |
|
---|
939 | if (fMode->IsEntryChecked(IDM_kTpointMode))
|
---|
940 | {
|
---|
941 | //unchecking not needed items
|
---|
942 | //general
|
---|
943 | fDisplay->UnCheckEntry(IDM_kStargFindStar);
|
---|
944 | SwitchOff(fDisplay, IDM_kFilter);
|
---|
945 | SwitchOff(fChannel, IDM_kChannel3);
|
---|
946 | SwitchOff(fOperations, IDM_kRoqueLampAna);
|
---|
947 |
|
---|
948 | //from starguider
|
---|
949 | SwitchOff(fDisplay, IDM_kStargCaosFilter);
|
---|
950 | SwitchOff(fDisplay, IDM_kCatalog);
|
---|
951 | SwitchOff(fDisplay, IDM_kStarguider);
|
---|
952 | ToggleStarguider();
|
---|
953 | fMode->UnCheckEntry(IDM_kStarguiderMode);
|
---|
954 | SwitchOff(fOperations, IDM_kStargAnalysis);
|
---|
955 | ToggleStargAnalysis();
|
---|
956 |
|
---|
957 | //switch camera
|
---|
958 | SwitchOff(fChannel, IDM_kChannel1);
|
---|
959 | fChannel->CheckEntry(IDM_kChannel2);
|
---|
960 |
|
---|
961 | SetChannel();
|
---|
962 |
|
---|
963 | //checking needed items
|
---|
964 | fDisplay->CheckEntry(IDM_kStretch);
|
---|
965 | fDisplay->CheckEntry(IDM_kCaosFilter);
|
---|
966 | ToggleCaosFilter();
|
---|
967 | fDisplay->CheckEntry(IDM_kFindStar);
|
---|
968 | ToggleFindStar();
|
---|
969 | }
|
---|
970 | else
|
---|
971 | {
|
---|
972 | //enable
|
---|
973 | //starguider items
|
---|
974 | fDisplay->EnableEntry(IDM_kStargCaosFilter);
|
---|
975 | fDisplay->EnableEntry(IDM_kCatalog);
|
---|
976 | fDisplay->EnableEntry(IDM_kStarguider);
|
---|
977 | fOperations->EnableEntry(IDM_kStargAnalysis);
|
---|
978 |
|
---|
979 | //general
|
---|
980 | fDisplay->EnableEntry(IDM_kFilter);
|
---|
981 | fChannel->EnableEntry(IDM_kChannel1);
|
---|
982 | fChannel->EnableEntry(IDM_kChannel3);
|
---|
983 | fOperations->EnableEntry(IDM_kRoqueLampAna);
|
---|
984 |
|
---|
985 | //tpoint
|
---|
986 | fDisplay->UnCheckEntry(IDM_kCaosFilter);
|
---|
987 | ToggleCaosFilter();
|
---|
988 | fDisplay->UnCheckEntry(IDM_kFindStar);
|
---|
989 | ToggleFindStar();
|
---|
990 | }
|
---|
991 | return kTRUE;
|
---|
992 |
|
---|
993 | case IDM_kFilter:
|
---|
994 | Toggle(fDisplay, IDM_kFilter);
|
---|
995 | return kTRUE;
|
---|
996 |
|
---|
997 | case IDM_kFindStar:
|
---|
998 | Toggle(fDisplay, IDM_kFindStar);
|
---|
999 | ToggleFindStar();
|
---|
1000 | return kTRUE;
|
---|
1001 |
|
---|
1002 | case IDM_kStretch:
|
---|
1003 | Toggle(fDisplay, IDM_kStretch);
|
---|
1004 | return kTRUE;
|
---|
1005 |
|
---|
1006 | case IDM_kCaosFilter:
|
---|
1007 | Toggle(fDisplay, IDM_kCaosFilter);
|
---|
1008 | ToggleCaosFilter();
|
---|
1009 | return kTRUE;
|
---|
1010 |
|
---|
1011 | case IDM_kStargCaosFilter:
|
---|
1012 | Toggle(fDisplay, IDM_kStargCaosFilter);
|
---|
1013 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter))
|
---|
1014 | {
|
---|
1015 | fDisplay->EnableEntry(IDM_kStargFindStar);
|
---|
1016 | SwitchOff(fDisplay, IDM_kCaosFilter);
|
---|
1017 | SwitchOff(fDisplay, IDM_kFindStar);
|
---|
1018 | SwitchOff(fDisplay, IDM_kFilter);
|
---|
1019 | }
|
---|
1020 | else
|
---|
1021 | {
|
---|
1022 | fDisplay->EnableEntry(IDM_kFilter);
|
---|
1023 | fDisplay->EnableEntry(IDM_kFindStar);
|
---|
1024 | fDisplay->EnableEntry(IDM_kCaosFilter);
|
---|
1025 | fDisplay->DisableEntry(IDM_kStargFindStar);
|
---|
1026 | }
|
---|
1027 | return kTRUE;
|
---|
1028 |
|
---|
1029 | case IDM_kCaosPrintLeds:
|
---|
1030 | case IDM_kCaosPrintRings:
|
---|
1031 | Toggle(fCaosPrint, mp1);
|
---|
1032 | return kTRUE;
|
---|
1033 |
|
---|
1034 | case IDM_kCaosAnalStart:
|
---|
1035 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStart);
|
---|
1036 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStop);
|
---|
1037 | fCaos->InitHistograms();
|
---|
1038 | return kTRUE;
|
---|
1039 |
|
---|
1040 | case IDM_kCaosAnalStop:
|
---|
1041 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
1042 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart);
|
---|
1043 | fCaos->ShowHistograms();
|
---|
1044 | fCaos->DeleteHistograms();
|
---|
1045 | return kTRUE;
|
---|
1046 |
|
---|
1047 | case IDM_kCaosWriteStart:
|
---|
1048 | fCaosWrite->DisableEntry(IDM_kCaosWriteStart);
|
---|
1049 | fCaosWrite->EnableEntry(IDM_kCaosWriteStop);
|
---|
1050 | fCaos->OpenFile();
|
---|
1051 | return kTRUE;
|
---|
1052 |
|
---|
1053 | case IDM_kCaosWriteStop:
|
---|
1054 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
1055 | fCaosWrite->EnableEntry(IDM_kCaosWriteStart);
|
---|
1056 | fCaos->CloseFile();
|
---|
1057 | return kTRUE;
|
---|
1058 |
|
---|
1059 | case IDM_kStart:
|
---|
1060 | fWritePictures->DisableEntry(IDM_kStart);
|
---|
1061 | fWritePictures->EnableEntry(IDM_kStop);
|
---|
1062 | return kTRUE;
|
---|
1063 |
|
---|
1064 | case IDM_kStop:
|
---|
1065 | fWritePictures->DisableEntry(IDM_kStop);
|
---|
1066 | fWritePictures->EnableEntry(IDM_kStart);
|
---|
1067 | return kTRUE;
|
---|
1068 |
|
---|
1069 | case IDM_kPNG:
|
---|
1070 | fFileType->CheckEntry(IDM_kPNG);
|
---|
1071 | fFileType->UnCheckEntry(IDM_kPPM);
|
---|
1072 | return kTRUE;
|
---|
1073 |
|
---|
1074 | case IDM_kPPM:
|
---|
1075 | fFileType->CheckEntry(IDM_kPPM);
|
---|
1076 | fFileType->UnCheckEntry(IDM_kPNG);
|
---|
1077 | return kTRUE;
|
---|
1078 |
|
---|
1079 | case IDM_kOnce:
|
---|
1080 | fWriteType->CheckEntry(IDM_kOnce);
|
---|
1081 | fWriteType->UnCheckEntry(IDM_kContinous);
|
---|
1082 | return kTRUE;
|
---|
1083 |
|
---|
1084 | case IDM_kContinous:
|
---|
1085 | fWriteType->CheckEntry(IDM_kContinous);
|
---|
1086 | fWriteType->UnCheckEntry(IDM_kOnce);
|
---|
1087 | return kTRUE;
|
---|
1088 |
|
---|
1089 | case IDM_kRate25ps:
|
---|
1090 | case IDM_kRate5ps:
|
---|
1091 | case IDM_kRate1s:
|
---|
1092 | case IDM_kRate5s:
|
---|
1093 | case IDM_kRate30s:
|
---|
1094 | case IDM_kRate1m:
|
---|
1095 | case IDM_kRate5m:
|
---|
1096 | for (int i=IDM_kRate25ps; i<=IDM_kRate5m; i++)
|
---|
1097 | if (mp1==i)
|
---|
1098 | fWriteRate->CheckEntry(i);
|
---|
1099 | else
|
---|
1100 | fWriteRate->UnCheckEntry(i);
|
---|
1101 | switch (mp1)
|
---|
1102 | {
|
---|
1103 | case IDM_kRate25ps:
|
---|
1104 | fWrtRate = 1;
|
---|
1105 | return kTRUE;
|
---|
1106 | case IDM_kRate5ps:
|
---|
1107 | fWrtRate = 5;
|
---|
1108 | return kTRUE;
|
---|
1109 | case IDM_kRate1s:
|
---|
1110 | fWrtRate = 25;
|
---|
1111 | return kTRUE;
|
---|
1112 | case IDM_kRate5s:
|
---|
1113 | fWrtRate = 5*25;
|
---|
1114 | return kTRUE;
|
---|
1115 | case IDM_kRate30s:
|
---|
1116 | fWrtRate = 30*25;
|
---|
1117 | return kTRUE;
|
---|
1118 | case IDM_kRate1m:
|
---|
1119 | fWrtRate = 60*25;
|
---|
1120 | return kTRUE;
|
---|
1121 | case IDM_kRate5m:
|
---|
1122 | fWrtRate = 5*60*25;
|
---|
1123 | return kTRUE;
|
---|
1124 | }
|
---|
1125 | return kTRUE;
|
---|
1126 |
|
---|
1127 | case IDM_kChannel1:
|
---|
1128 | case IDM_kChannel2:
|
---|
1129 | {
|
---|
1130 | const Int_t ch0 = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
|
---|
1131 | const Int_t ch1 = mp1==IDM_kChannel1 ? 0 : 1;
|
---|
1132 |
|
---|
1133 | if (ch0==ch1)
|
---|
1134 | return kTRUE;
|
---|
1135 |
|
---|
1136 | fChannel->CheckEntry (ch1==0?IDM_kChannel1:IDM_kChannel2);
|
---|
1137 | fChannel->UnCheckEntry(ch1==1?IDM_kChannel1:IDM_kChannel2);
|
---|
1138 |
|
---|
1139 | SetChannel();
|
---|
1140 | }
|
---|
1141 | return kTRUE;
|
---|
1142 |
|
---|
1143 | case IDM_kInterpol250:
|
---|
1144 | case IDM_kInterpol125:
|
---|
1145 | case IDM_kInterpol50:
|
---|
1146 | case IDM_kInterpol25:
|
---|
1147 | case IDM_kInterpol10:
|
---|
1148 | case IDM_kInterpol5:
|
---|
1149 | case IDM_kInterpol2:
|
---|
1150 | case IDM_kInterpol1:
|
---|
1151 | for (int i=IDM_kInterpol250; i<=IDM_kInterpol1; i++)
|
---|
1152 | if (mp1==i)
|
---|
1153 | fInterpol->CheckEntry(i);
|
---|
1154 | else
|
---|
1155 | fInterpol->UnCheckEntry(i);
|
---|
1156 | switch (mp1)
|
---|
1157 | {
|
---|
1158 | case IDM_kInterpol1:
|
---|
1159 | fIntRate = 1;
|
---|
1160 | return kTRUE;
|
---|
1161 | case IDM_kInterpol2:
|
---|
1162 | fIntRate = 2;
|
---|
1163 | return kTRUE;
|
---|
1164 | case IDM_kInterpol5:
|
---|
1165 | fIntRate = 5;
|
---|
1166 | return kTRUE;
|
---|
1167 | case IDM_kInterpol10:
|
---|
1168 | fIntRate = 10;
|
---|
1169 | return kTRUE;
|
---|
1170 | case IDM_kInterpol25:
|
---|
1171 | fIntRate = 25;
|
---|
1172 | return kTRUE;
|
---|
1173 | case IDM_kInterpol50:
|
---|
1174 | fIntRate = 50;
|
---|
1175 | return kTRUE;
|
---|
1176 | case IDM_kInterpol125:
|
---|
1177 | fIntRate = 125;
|
---|
1178 | return kTRUE;
|
---|
1179 | case IDM_kInterpol250:
|
---|
1180 | fIntRate = 250;
|
---|
1181 | return kTRUE;
|
---|
1182 | }
|
---|
1183 | return kTRUE;
|
---|
1184 |
|
---|
1185 | case IDM_kLimMag3:
|
---|
1186 | case IDM_kLimMag4:
|
---|
1187 | case IDM_kLimMag5:
|
---|
1188 | case IDM_kLimMag6:
|
---|
1189 | case IDM_kLimMag7:
|
---|
1190 | case IDM_kLimMag8:
|
---|
1191 | case IDM_kLimMag9:
|
---|
1192 | for (int i=IDM_kLimMag3; i<=IDM_kLimMag9; i++)
|
---|
1193 | if (mp1==i)
|
---|
1194 | fLimMag->CheckEntry(i);
|
---|
1195 | else
|
---|
1196 | fLimMag->UnCheckEntry(i);
|
---|
1197 |
|
---|
1198 | fSao->SetLimitMag(mp1-IDM_kLimMag3+3);
|
---|
1199 | return kTRUE;
|
---|
1200 | }
|
---|
1201 | break;
|
---|
1202 | }
|
---|
1203 | break;
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 | return kTRUE;
|
---|
1207 | }
|
---|
1208 |
|
---|
1209 | void MStarguider::SetPointingPosition(RaDec rd)
|
---|
1210 | {
|
---|
1211 | rd.Ra(rd.Ra()*24/360);
|
---|
1212 | fCRaDec->SetCoordinates(rd);
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | ZdAz MStarguider::TrackingError(TArrayF &x, TArrayF &y, TArrayF &mag,
|
---|
1216 | Int_t &num) const
|
---|
1217 | {
|
---|
1218 | num = -1;
|
---|
1219 |
|
---|
1220 | // Width of the final 2D gaussian
|
---|
1221 | const Double_t width = 0.8;
|
---|
1222 |
|
---|
1223 | // The binning is made 1.7 sigma (which, in the 1D case, gives the
|
---|
1224 | // highest significance of a gaussian signal) (1bin equiv 3x3 sigma)
|
---|
1225 | const Double_t max = 50;
|
---|
1226 | const Int_t n = TMath::Nint(2*max/(1.77*1.7*width));
|
---|
1227 | //1.77=sqrt(pi) comes from pir=bin
|
---|
1228 |
|
---|
1229 | // Fill a histogram with the dx/dy values from the file
|
---|
1230 | TH2F hist("Hist", "dX/dY", n, -max, max, n, -max, max);
|
---|
1231 | // hist.SetDirectory(0);
|
---|
1232 |
|
---|
1233 | //
|
---|
1234 | // Search for matching Magnitudes
|
---|
1235 | //
|
---|
1236 | //for (int i=0; i<mag.GetSize(); i++)
|
---|
1237 | //{
|
---|
1238 | // if (mag[i]>48-15 && mag[i]<48+15)
|
---|
1239 | // h.Fill(x[i], y[i]);
|
---|
1240 | //}
|
---|
1241 |
|
---|
1242 | // fill dx and dy into histogram
|
---|
1243 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1244 | hist.Fill(x[i], y[i]);
|
---|
1245 |
|
---|
1246 | // Remove all bins which have content of only a single event
|
---|
1247 | // including under- and overflow bins
|
---|
1248 | for (int i=0; i<hist.GetSize(); i++)
|
---|
1249 | if (hist.GetBinContent(i)<1.5)
|
---|
1250 | hist.SetBinContent(i, 0);
|
---|
1251 |
|
---|
1252 | // Find the bin containing the maximum
|
---|
1253 | Int_t bx, by, bz;
|
---|
1254 | hist.GetMaximumBin(bx, by, bz);
|
---|
1255 |
|
---|
1256 | // In the worst case the events are spread through the
|
---|
1257 | // bins which are the neighbors of the maximum
|
---|
1258 | // Normally neighbors which do not belong to the signal are empty!
|
---|
1259 | hist.GetXaxis()->SetRange(bx-1, bx+1); // 3x3bins ~8x8pix ~9x9sigma
|
---|
1260 | hist.GetYaxis()->SetRange(by-1, by+1); // 3x3bins ~8x8pix ~9x9sigma
|
---|
1261 |
|
---|
1262 | // Check whether this region contains events
|
---|
1263 | num = TMath::Nint(hist.Integral());
|
---|
1264 | if (num<1)
|
---|
1265 | return ZdAz();
|
---|
1266 |
|
---|
1267 | // Get Mean for the given axis range
|
---|
1268 | Double_t mx = hist.GetMean(1);
|
---|
1269 | Double_t my = hist.GetMean(2);
|
---|
1270 |
|
---|
1271 | const Int_t max1 = TMath::Nint(hist.GetBinContent(bx, by));
|
---|
1272 |
|
---|
1273 | // Check if the maximum is unique
|
---|
1274 | Int_t bx2, by2, bz2;
|
---|
1275 | hist.GetXaxis()->SetRange(-1, 9999);
|
---|
1276 | hist.GetYaxis()->SetRange(-1, 9999);
|
---|
1277 | hist.SetBinContent(bx, by, 0);
|
---|
1278 | hist.GetMaximumBin(bx2, by2, bz2);
|
---|
1279 |
|
---|
1280 | const Int_t max2 = TMath::Nint(hist.GetBinContent(bx2, by2));
|
---|
1281 | if (max1==max2 && TMath::Abs(bx2-bx)+TMath::Abs(by2-by)>1)
|
---|
1282 | return ZdAz();
|
---|
1283 |
|
---|
1284 | // loop again over the file and fill the histogram again.
|
---|
1285 | // to get closer to the correct value
|
---|
1286 | Double_t sumx = 0;
|
---|
1287 | Double_t sumy = 0;
|
---|
1288 | num = 0;
|
---|
1289 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1290 | {
|
---|
1291 | // only fill values into the histogram which
|
---|
1292 | // are inside 2*1.7=3.4 sigma (99.7%)
|
---|
1293 | if (TMath::Hypot(x[i]-mx, y[i]-my)>width*3.4)
|
---|
1294 | continue;
|
---|
1295 |
|
---|
1296 | sumx += x[i];
|
---|
1297 | sumy += y[i];
|
---|
1298 | num++;
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | if (num<1)
|
---|
1302 | return ZdAz();
|
---|
1303 |
|
---|
1304 | // calc MeanX and MeanY
|
---|
1305 | mx = sumx/num;
|
---|
1306 | my = sumy/num;
|
---|
1307 |
|
---|
1308 | // loop again to fill the mispointing corrected histograms
|
---|
1309 | // and fill another histogram to check the quality of the calculated
|
---|
1310 | // mispointing.
|
---|
1311 | sumx = 0;
|
---|
1312 | sumy = 0;
|
---|
1313 | num = 0;
|
---|
1314 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1315 | {
|
---|
1316 | // only fill values into the histogram which
|
---|
1317 | // are inside 1.7=3.4 sigma (92%)
|
---|
1318 | // Cut at 1.7 sigma which gives the best background supression
|
---|
1319 | if (TMath::Hypot(x[i]-mx, y[i]-my)>width*1.7)
|
---|
1320 | continue;
|
---|
1321 |
|
---|
1322 | sumx += x[i];
|
---|
1323 | sumy += y[i];
|
---|
1324 | num++;
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | if (num<1)
|
---|
1328 | return ZdAz(); // FIXME!!!!!!!!!!!!
|
---|
1329 |
|
---|
1330 | // Mispointing
|
---|
1331 | mx = sumx/num;
|
---|
1332 | my = sumy/num;
|
---|
1333 |
|
---|
1334 | #ifdef EXPERT
|
---|
1335 | cout << "Offset-XY: " << mx << " +- " << my << endl;
|
---|
1336 | #endif
|
---|
1337 |
|
---|
1338 | AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg;
|
---|
1339 | AltAz pos1 = fSao->CalcAltAzFromPix(768/2+mx, 576/2+my)*kRad2Deg;
|
---|
1340 | /*
|
---|
1341 | ofstream fout1("pointingpos.txt");
|
---|
1342 | fout1 << setprecision(10) << fSao->GetMjd()-52000 << " ";
|
---|
1343 | if (fCosy)
|
---|
1344 | fout1 << fCosy->GetPointingPos() << " ";
|
---|
1345 | fout1 << -pos1.Alt() << " " << pos1.Az() << endl;
|
---|
1346 | */
|
---|
1347 | pos1 -= pos0;
|
---|
1348 | /*
|
---|
1349 | ofstream fout2("tracking_error.txt", ios::app);
|
---|
1350 | fout2 << setprecision(10) << fSao->GetMjd()-52000 << " ";
|
---|
1351 | if (fCosy)
|
---|
1352 | fout2 << fCosy->GetPointingPos() << " ";
|
---|
1353 | fout2 << -pos1.Alt() << " " << pos1.Az() << endl;
|
---|
1354 | */
|
---|
1355 | return ZdAz(-pos1.Alt(), pos1.Az());
|
---|
1356 | }
|
---|
1357 |
|
---|
1358 | Int_t MStarguider::CalcTrackingError(Leds &leds, MStarList &stars,
|
---|
1359 | ZdAz &d, MTime &t, double &bright, Int_t &num)
|
---|
1360 | {
|
---|
1361 | num = leds.GetEntries();
|
---|
1362 | //cout << "Num: " << num << endl;
|
---|
1363 | if (num < 3) //was 1
|
---|
1364 | {
|
---|
1365 | gLog << warn << "Sorry, less than 3 detected spot in FOV!" << endl;
|
---|
1366 | if (fStargTPoint->IsDown())
|
---|
1367 | fStargTPoint->SetDown(kFALSE);
|
---|
1368 | return 0;
|
---|
1369 | }
|
---|
1370 |
|
---|
1371 | //cout << "Cat: " << stars.GetRealEntries() << endl;
|
---|
1372 | if (stars.GetRealEntries() < 3)
|
---|
1373 | {
|
---|
1374 | gLog << warn << "Sorry, less than 3 stars in FOV!" << endl;
|
---|
1375 | if (fStargTPoint->IsDown())
|
---|
1376 | fStargTPoint->SetDown(kFALSE);
|
---|
1377 | return 0;
|
---|
1378 | }
|
---|
1379 |
|
---|
1380 | stars.Sort(); // Sort by magnitude
|
---|
1381 |
|
---|
1382 | #ifdef EXPERT
|
---|
1383 | TString str = "data/tracking_";
|
---|
1384 | str += fSao->GetMjd();
|
---|
1385 | str += ".txt";
|
---|
1386 |
|
---|
1387 | ofstream fout(str);
|
---|
1388 | #endif
|
---|
1389 |
|
---|
1390 | TArrayF x, y, mag;
|
---|
1391 |
|
---|
1392 | // FIXME: Is predefined value 3 a good idea?
|
---|
1393 | Int_t cnt=0;
|
---|
1394 |
|
---|
1395 | MStar *star;
|
---|
1396 | MStarListIter NextStar(&stars);
|
---|
1397 | while ((star=NextStar()) && cnt<num+5)
|
---|
1398 | {
|
---|
1399 | TIter NextSp(&leds);
|
---|
1400 | Led *spot=NULL;
|
---|
1401 | while ((spot=(Led*)NextSp()))
|
---|
1402 | {
|
---|
1403 | const XY dpos(spot->GetX()-(768-star->GetX()),
|
---|
1404 | spot->GetY()-star->GetY());
|
---|
1405 |
|
---|
1406 | const Int_t idx = x.GetSize();
|
---|
1407 |
|
---|
1408 | x.Set(idx+1);
|
---|
1409 | y.Set(idx+1);
|
---|
1410 | mag.Set(idx+1);
|
---|
1411 |
|
---|
1412 | x.AddAt(dpos.X(), idx);
|
---|
1413 | y.AddAt(dpos.Y(), idx);
|
---|
1414 | mag.AddAt(log(spot->GetMag())/star->GetMag(), idx);
|
---|
1415 |
|
---|
1416 | #ifdef EXPERT
|
---|
1417 | if (fout)
|
---|
1418 | {
|
---|
1419 | fout << spot->GetX() << " "
|
---|
1420 | << spot->GetY() << " "
|
---|
1421 | << -2.5*log(spot->GetMag()) << " "
|
---|
1422 | << star->GetX() << " "
|
---|
1423 | << star->GetY() << " "
|
---|
1424 | << star->GetMag() << " ";
|
---|
1425 | fout << x[idx] << " " << y[idx] << " " << mag[idx] << endl;
|
---|
1426 | }
|
---|
1427 | #endif
|
---|
1428 | }
|
---|
1429 | cnt++;
|
---|
1430 | }
|
---|
1431 |
|
---|
1432 | Int_t numcor = 0;
|
---|
1433 | d = TrackingError(x, y, mag, numcor);
|
---|
1434 | if (numcor<1)
|
---|
1435 | return 0;
|
---|
1436 |
|
---|
1437 | //cout << "Cor: " << numcor << endl;
|
---|
1438 |
|
---|
1439 | fDZdAz->SetCoordinates(d);
|
---|
1440 |
|
---|
1441 | //
|
---|
1442 | // Calculated offsets
|
---|
1443 | //
|
---|
1444 |
|
---|
1445 | #ifdef EXPERT
|
---|
1446 | // round= floor(x+.5)
|
---|
1447 | cout << "Offset-ZdAz: " << d.Zd()*60 << "' / " << d.Az()*60 << "'" << endl;
|
---|
1448 | cout << "Offset-ZdAz: " << d.Zd()/360*16384 << " / " << d.Az()/360*16384 << " (SE) " << endl;
|
---|
1449 | #endif
|
---|
1450 |
|
---|
1451 | //
|
---|
1452 | // Current Pointing position
|
---|
1453 | //
|
---|
1454 | ZdAz cpos = fSao->GetZdAz()-d;
|
---|
1455 | fPZdAz->SetCoordinates(cpos);
|
---|
1456 |
|
---|
1457 | // Check StargTPoint data set request
|
---|
1458 | if (!fStargTPoint->IsDown())
|
---|
1459 | return numcor;
|
---|
1460 | fStargTPoint->SetDown(kFALSE);
|
---|
1461 |
|
---|
1462 | // If no file open: open new file
|
---|
1463 | if (!fOutStargTp)
|
---|
1464 | {
|
---|
1465 | // open tpoint file
|
---|
1466 | const TString name = MCosy::GetFileName("tpoint", "starg", "txt");
|
---|
1467 | gLog << all << "TPoint-Starg File ********* " << name << " ********** " << endl;
|
---|
1468 |
|
---|
1469 | fOutStargTp = new ofstream(name);
|
---|
1470 | *fOutStargTp << "Magic Model STARGTPOINT data file" << endl;
|
---|
1471 | *fOutStargTp << ": ALTAZ" << endl;
|
---|
1472 | *fOutStargTp << "49 48 0 ";
|
---|
1473 | *fOutStargTp << t << endl;
|
---|
1474 | }
|
---|
1475 |
|
---|
1476 | // Get tracking coordinates
|
---|
1477 | const XY xy = fCRaDec->GetCoordinates();
|
---|
1478 | const RaDec rd(xy.X()*TMath::DegToRad()*15, xy.Y()*TMath::DegToRad());
|
---|
1479 |
|
---|
1480 | // From the star position in the camera we calculate the Alt/Az
|
---|
1481 | // position we are currently tracking (real pointing position)
|
---|
1482 | fSao->SetMjd(t.GetMjd());
|
---|
1483 | AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg;
|
---|
1484 |
|
---|
1485 | //correction with offset from last tpoint measurement
|
---|
1486 | za0 -= fAltAzOffsetFromTp;
|
---|
1487 | MTime t2 = fTimeFromTp;
|
---|
1488 |
|
---|
1489 | //if the difference between the tpoint and the starguider tpoint
|
---|
1490 | //is too big, the starguider tpoint is not stored
|
---|
1491 | cout << " mjd difference: " << t.GetMjd()-t2.GetMjd() << endl;
|
---|
1492 | // cout << "t: " << setprecision(11) << t.GetMjd() << endl;
|
---|
1493 | // cout << "t2: " << setprecision(11) << t2.GetMjd() << endl;
|
---|
1494 | if ((t.GetMjd()-t2.GetMjd())>0.001) //1min20sec
|
---|
1495 | {
|
---|
1496 | cout << " time difference between tpoint and starguider-tpoint > 1 min *" <<
|
---|
1497 | t.GetMjd()-t2.GetMjd() << "s) " << endl;
|
---|
1498 | cout << " => starguider tpoint hasn't been stored. " << endl;
|
---|
1499 | cout << " Please repeat whole procedure. " << endl;
|
---|
1500 | return numcor;
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 |
|
---|
1504 | // Write real pointing position
|
---|
1505 | cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
|
---|
1506 | *fOutStargTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " ";
|
---|
1507 |
|
---|
1508 | // Write system pointing position
|
---|
1509 | cout << " SE-Pos: " << 90-cpos.Zd() << "° " << cpos.Az() << "°" << endl;
|
---|
1510 | *fOutStargTp << fmod(cpos.Az()+360, 360) << " " << 90-cpos.Zd();
|
---|
1511 |
|
---|
1512 | *fOutStargTp << " " << xy.X() << " " << xy.Y();
|
---|
1513 | *fOutStargTp << " " << d.Zd() << " " << d.Az();
|
---|
1514 | *fOutStargTp << " " << setprecision(11) << t.GetMjd();
|
---|
1515 | *fOutStargTp << " " << num;
|
---|
1516 | *fOutStargTp << " " << bright;
|
---|
1517 | *fOutStargTp << endl;
|
---|
1518 |
|
---|
1519 | fTimeFromTp.Set(1970,1,1);
|
---|
1520 |
|
---|
1521 | return numcor;
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | XY MStarguider::FindRoqueLamp(FilterLed &f, FilterLed &f2, Ring &CameraCenter, MTime &t, Double_t cut, Int_t box, XY SearchCenter)
|
---|
1525 | {
|
---|
1526 | // Set search Paremeters (FIXME: Get them from user input!)
|
---|
1527 | f.SetCut(cut); // 3.5
|
---|
1528 | f.SetBox(box); // 70
|
---|
1529 |
|
---|
1530 | // Try to find Led in this area
|
---|
1531 | Leds leds;
|
---|
1532 | f.FindStar(leds, (Int_t)SearchCenter.X(), (Int_t)SearchCenter.Y(), true);
|
---|
1533 |
|
---|
1534 | // Check whether star found
|
---|
1535 | Led *star = (Led*)leds.At(0);
|
---|
1536 | if (!star || leds.GetEntries()<1)
|
---|
1537 | return XY(.0,.0);
|
---|
1538 |
|
---|
1539 | // cout << "Found Roque Lamp @ " << flush;
|
---|
1540 | star->Print();
|
---|
1541 | f.MarkPoint(star->GetX(), star->GetY(), 500);
|
---|
1542 |
|
---|
1543 | // cout << "RoquePos: " << star->GetX() << "," << star->GetY() << endl;
|
---|
1544 |
|
---|
1545 | XY roquepos(star->GetX(), star->GetY());
|
---|
1546 | XY relroquepos(roquepos.X()-CameraCenter.GetX(), roquepos.Y()-CameraCenter.GetY());
|
---|
1547 |
|
---|
1548 | // If no file open: open new Roque Lamp file
|
---|
1549 | if (!fOutRq)
|
---|
1550 | {
|
---|
1551 | const TString name = MCosy::GetFileName("tpoint", "roquelamp", "txt");
|
---|
1552 | cout << "Starg_RoqueLamp File ********* " << name << " ********** " << endl;
|
---|
1553 | fOutRq = new ofstream(name);
|
---|
1554 | *fOutRq << "# Magic Roque Lamp file " << t << endl;
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 | return relroquepos;
|
---|
1558 | }
|
---|
1559 |
|
---|
1560 | ZdAz MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t, Double_t cut, Int_t box, Double_t scalefactor = 1.0)
|
---|
1561 | {
|
---|
1562 | // Set search Paremeters (FIXME: Get them from user input!)
|
---|
1563 | f.SetCut(cut); // 3.5
|
---|
1564 | f.SetBox(box); // 70
|
---|
1565 |
|
---|
1566 | // Try to find Led in this area
|
---|
1567 | Leds leds;
|
---|
1568 | f.FindStar(leds, (Int_t)center.GetX(), (Int_t)center.GetY(), true);
|
---|
1569 |
|
---|
1570 | if (leds.GetEntries()<0)
|
---|
1571 | return ZdAz(0, 0);
|
---|
1572 |
|
---|
1573 | // Check whether star found
|
---|
1574 | Led *star = (Led*)leds.At(0);
|
---|
1575 | if (!star)
|
---|
1576 | {
|
---|
1577 | if (fTPoint->IsDown())
|
---|
1578 | {
|
---|
1579 | fTPoint->SetDown(kFALSE);
|
---|
1580 | gLog << warn << "No star found. Couldn't take a tpoint." << endl;
|
---|
1581 | }
|
---|
1582 | return ZdAz(.0,.0);
|
---|
1583 | }
|
---|
1584 | cout << "Found star @ " << flush;
|
---|
1585 | star->Print();
|
---|
1586 | f2.MarkPoint(star->GetX(), star->GetY(), 2<<2);
|
---|
1587 |
|
---|
1588 | // Initialize Star Catalog on th camera plane
|
---|
1589 | MGeomCamMagic geom;
|
---|
1590 | MAstroCamera ac;
|
---|
1591 | ac.SetGeom(geom);
|
---|
1592 | ac.SetRadiusFOV(3);
|
---|
1593 | ac.SetObservatory(*fSao);
|
---|
1594 | ac.SetTime(t);
|
---|
1595 |
|
---|
1596 | // Get tracking coordinates
|
---|
1597 | const XY xy = fCRaDec->GetCoordinates();
|
---|
1598 | const RaDec rd(xy.X()*TMath::DegToRad()*15, xy.Y()*TMath::DegToRad());
|
---|
1599 |
|
---|
1600 | ac.SetRaDec(rd.Ra(), rd.Dec());
|
---|
1601 |
|
---|
1602 | // Adapt coordinate system (GUIs and humans are counting Y in different directions)
|
---|
1603 | Double_t x = star->GetX()-center.GetX();
|
---|
1604 | Double_t y = center.GetY()-star->GetY();
|
---|
1605 |
|
---|
1606 | #ifdef EXPERT
|
---|
1607 | cout << "STAR-Offset: " << MTime(-1) << " dx=" << x << "pix dy=" << y << "pix" << endl;
|
---|
1608 | #endif
|
---|
1609 |
|
---|
1610 | // MAKE SURE THAT THIS VALUE CAN BE SETUP
|
---|
1611 | // (Scalefactor describes the difference between the tpoint (=1)
|
---|
1612 | // and the starguider (!=1) camera
|
---|
1613 | // Convert from Pixel to millimeter (1pix=2.6mm)
|
---|
1614 | x *= (2.58427 * scalefactor);
|
---|
1615 | y *= (2.58427 * scalefactor);
|
---|
1616 |
|
---|
1617 | // Correct for abberation.
|
---|
1618 | x /= 1.0713;
|
---|
1619 | y /= 1.0713;
|
---|
1620 |
|
---|
1621 | // Convert offset from camera plane into local ccordinates
|
---|
1622 | Double_t dzd, daz;
|
---|
1623 | ac.GetDiffZdAz(x, y, dzd, daz);
|
---|
1624 |
|
---|
1625 | #ifdef EXPERT
|
---|
1626 | cout << "STAR-Offset: " << MTime(-1) << " dZd=" << dzd << "d dAz=" << daz << "d" << endl;
|
---|
1627 | #endif
|
---|
1628 |
|
---|
1629 | ZdAz zdaz(dzd,daz);
|
---|
1630 |
|
---|
1631 | // Check TPoint data set request
|
---|
1632 | if (!fTPoint->IsDown())
|
---|
1633 | return zdaz;
|
---|
1634 | fTPoint->SetDown(kFALSE);
|
---|
1635 |
|
---|
1636 | // If no file open: open new file
|
---|
1637 | if (!fOutTp)
|
---|
1638 | {
|
---|
1639 | //
|
---|
1640 | // open tpoint file
|
---|
1641 | //
|
---|
1642 | const TString name = MCosy::GetFileName("tpoint", "tpoint", "txt");
|
---|
1643 | cout << "TPoint-Starg File ********* " << name << " ********** " << endl;
|
---|
1644 |
|
---|
1645 | fOutTp = new ofstream(name);
|
---|
1646 | *fOutTp << "Magic Model TPOINT data file" << endl;
|
---|
1647 | *fOutTp << ": ALTAZ" << endl;
|
---|
1648 | *fOutTp << "49 48 0 ";
|
---|
1649 | *fOutTp << t << endl;
|
---|
1650 | // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m)
|
---|
1651 | }
|
---|
1652 |
|
---|
1653 | // Output Ra/Dec the drive system thinks that it is currently tracking
|
---|
1654 | cout << "TPoint Star: " << xy.X() << "h " << xy.Y() << "°" << endl;
|
---|
1655 |
|
---|
1656 | // From the star position in the camera we calculate the Alt/Az
|
---|
1657 | // position we are currently tracking (real pointing position)
|
---|
1658 | fSao->SetMjd(t.GetMjd());
|
---|
1659 | AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg;
|
---|
1660 |
|
---|
1661 | //ZdAz za0 = fSao->GetZdAz();
|
---|
1662 | za0 -= AltAz(-dzd, daz);
|
---|
1663 | fAltAzOffsetFromTp = AltAz(-dzd, daz);
|
---|
1664 | fTimeFromTp=t;
|
---|
1665 |
|
---|
1666 |
|
---|
1667 | // From the Shaftencoders we get the current 'pointing' position
|
---|
1668 | // as it is seen by the drive system (system pointing position)
|
---|
1669 | // FIXME????
|
---|
1670 | const ZdAz za1 = fCosy->GetSePos()*TMath::TwoPi();
|
---|
1671 |
|
---|
1672 | // Write real pointing position
|
---|
1673 | cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
|
---|
1674 | *fOutTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " ";
|
---|
1675 |
|
---|
1676 | // Write system pointing position
|
---|
1677 | cout << " SE-Pos: " << 90-za1.Zd() << "° " << za1.Az() << "°" << endl;
|
---|
1678 | *fOutTp << fmod(za1.Az()+360, 360) << " " << 90-za1.Zd();
|
---|
1679 |
|
---|
1680 | *fOutTp << " " << xy.X() << " " << xy.Y();
|
---|
1681 | *fOutTp << " " << -dzd << " " << -daz;
|
---|
1682 | *fOutTp << " " << setprecision(11) << t.GetMjd();
|
---|
1683 | *fOutTp << " " << setprecision(4) << center.GetMag();
|
---|
1684 | *fOutTp << " " << star->GetMag();
|
---|
1685 | *fOutTp << endl;
|
---|
1686 |
|
---|
1687 | MLog &outrep = *fCosy->GetOutRep();
|
---|
1688 | if (outrep.Lock("MStarguider::FindStar"))
|
---|
1689 | {
|
---|
1690 | outrep << "FINDSTAR-REPORT 00 " << MTime(-1) << " " << setprecision(7);
|
---|
1691 | outrep << 90-za0.Alt() << " " << za0.Az() << " ";
|
---|
1692 | outrep << za1.Zd() << " " << za1.Az() << " ";
|
---|
1693 | outrep << xy.X() << " " << xy.Y() << " ";
|
---|
1694 | outrep << -dzd << " " << -daz << " ";
|
---|
1695 | outrep << star->GetX() << " " << star->GetY() << " ";
|
---|
1696 | outrep << center.GetX() << " " << center.GetY() << " ";
|
---|
1697 | outrep << x*1.0713/2.58427 << " " << y*1.0713/2.58427 << " " << star->GetMag();
|
---|
1698 | outrep << setprecision(11) << t.GetMjd() << endl;
|
---|
1699 | outrep.UnLock("MStarguider::FindStar");
|
---|
1700 | }
|
---|
1701 |
|
---|
1702 | return zdaz;
|
---|
1703 | }
|
---|
1704 |
|
---|
1705 | bool MStarguider::Interpolate(const unsigned long n, byte *img) const
|
---|
1706 | {
|
---|
1707 | if (fIntRate<=1)
|
---|
1708 | return true;
|
---|
1709 |
|
---|
1710 | static unsigned short myimg[768*576];
|
---|
1711 |
|
---|
1712 | unsigned short *f = myimg;
|
---|
1713 | byte *i = img;
|
---|
1714 | byte *e = img+768*576;
|
---|
1715 |
|
---|
1716 | while (i<e)
|
---|
1717 | *f++ += *i++;
|
---|
1718 |
|
---|
1719 | if (n%fIntRate)
|
---|
1720 | return false;
|
---|
1721 |
|
---|
1722 | f = myimg;
|
---|
1723 | i = img;
|
---|
1724 | e = img+768*576;
|
---|
1725 |
|
---|
1726 | while (i<e)
|
---|
1727 | *i++ = (byte)(*f++/fIntRate);
|
---|
1728 |
|
---|
1729 | memset(myimg, 0, sizeof(myimg));
|
---|
1730 |
|
---|
1731 | return true;
|
---|
1732 | }
|
---|
1733 |
|
---|
1734 | void MStarguider::ProcessFrame(const unsigned long n, byte *img,
|
---|
1735 | struct timeval *tm)
|
---|
1736 | {
|
---|
1737 | static unsigned long n0 = n;
|
---|
1738 |
|
---|
1739 | MTime t(*tm);
|
---|
1740 |
|
---|
1741 | const Double_t d = t-fTime;
|
---|
1742 | if (d>1)
|
---|
1743 | {
|
---|
1744 | const TString txt = MString::Format("%dfps", (int)((n-n0)/d+.5));
|
---|
1745 | fFps->SetText(txt);
|
---|
1746 | fTime = t;
|
---|
1747 | n0 = n;
|
---|
1748 | }
|
---|
1749 |
|
---|
1750 | if (!Interpolate(n, img))
|
---|
1751 | return;
|
---|
1752 |
|
---|
1753 | byte cimg[768*576];
|
---|
1754 | memset(cimg, 0, 768*576);
|
---|
1755 |
|
---|
1756 | FilterLed f(img, 768, 576, 2.5); // 2.5
|
---|
1757 | FilterLed f2(cimg, 768, 576); // former color 0xb0
|
---|
1758 |
|
---|
1759 | if (fDisplay->IsEntryChecked(IDM_kStretch))
|
---|
1760 | f.Stretch();
|
---|
1761 |
|
---|
1762 | if (!fWritePictures->IsEntryEnabled(IDM_kStart) &&
|
---|
1763 | (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce)))
|
---|
1764 | {
|
---|
1765 |
|
---|
1766 | if (fFileType->IsEntryChecked(IDM_kPNG))
|
---|
1767 | Writer::Png("pix/file", img, tm, fCRaDec->GetCoordinates());
|
---|
1768 |
|
---|
1769 | if (fFileType->IsEntryChecked(IDM_kPPM))
|
---|
1770 | Writer::Ppm("pix/file", img, tm, fCRaDec->GetCoordinates());
|
---|
1771 |
|
---|
1772 | if (fWriteType->IsEntryChecked(IDM_kOnce))
|
---|
1773 | ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStop, 0);
|
---|
1774 | }
|
---|
1775 |
|
---|
1776 | // Visual Filter, whole FOV
|
---|
1777 | if (fDisplay->IsEntryChecked(IDM_kFilter))
|
---|
1778 | f.Execute();
|
---|
1779 |
|
---|
1780 | // Find Center of Camera for Caos and Tpoints
|
---|
1781 | Ring center(768/2, 576/2);
|
---|
1782 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter))
|
---|
1783 | {
|
---|
1784 | const bool printl = fCaosPrint->IsEntryChecked(IDM_kCaosPrintLeds);
|
---|
1785 | const bool printr = fCaosPrint->IsEntryChecked(IDM_kCaosPrintRings);
|
---|
1786 | ZdAz pos;
|
---|
1787 | if (fCosy)
|
---|
1788 | pos = fCosy->GetPointingPos();
|
---|
1789 | center = fCaos->Run(img, printl, printr, pos, t, 19, 3.0);
|
---|
1790 | cout << "Caos Filter Camera center position: " << center.GetX() << " " << center.GetY() << " (R=" << center.GetR() << ")" << endl;
|
---|
1791 |
|
---|
1792 | }
|
---|
1793 |
|
---|
1794 | // Find Star at Center---for Tpoint Procedure
|
---|
1795 | if (fDisplay->IsEntryChecked(IDM_kFindStar) &&
|
---|
1796 | center.GetX()>0 && center.GetY()>0)
|
---|
1797 | {
|
---|
1798 | // SCALE FACTOR ASSUMED TO BE 70
|
---|
1799 | FindStar(f, f2, center, t, 3/*3.5*/, 70);
|
---|
1800 | SendAmcTrigger("TPoint");
|
---|
1801 | }
|
---|
1802 |
|
---|
1803 | byte zimg[kZOOM*kZOOM];
|
---|
1804 | for (int y=0; y<kZOOM; y++)
|
---|
1805 | for (int x=0; x<kZOOM; x++)
|
---|
1806 | zimg[x+y*kZOOM] = img[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768];
|
---|
1807 |
|
---|
1808 | fZoomImage->DrawImg(zimg);
|
---|
1809 |
|
---|
1810 | if (fCosy)
|
---|
1811 | {
|
---|
1812 | byte simg[(768/2-1)*(576/2-1)];
|
---|
1813 | for (int y=0; y<576/2-1; y++)
|
---|
1814 | for (int x=0; x<768/2-1; x++)
|
---|
1815 | simg[x+y*(768/2-1)] = ((unsigned int)img[2*x+2*y*768]+img[2*x+2*y*768+1]+img[2*x+2*(y+1)*768]+img[2*x+2*(y+1)*768+1])/4;
|
---|
1816 |
|
---|
1817 | fCosy->GetWin()->GetImage()->DrawImg(simg);
|
---|
1818 | }
|
---|
1819 |
|
---|
1820 | // Find Center of Camera in Starfield Camera picture
|
---|
1821 |
|
---|
1822 | Ring sgcenter(53.2, 293.6); // Center of camera in SG picture [px]
|
---|
1823 | //ZdAz sgcenterzdaz(0, 0); // Center of camera in SG picture [deg]
|
---|
1824 | // // (0,0)_deg is at (53.2, 293.6)_px
|
---|
1825 | ZdAz star(0, 0); // Star on curtain in [deg]
|
---|
1826 |
|
---|
1827 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter))
|
---|
1828 | {
|
---|
1829 | ZdAz pos;
|
---|
1830 | if (fCosy)
|
---|
1831 | pos = fCosy->GetPointingPos();
|
---|
1832 |
|
---|
1833 | sgcenter = fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 19, 3.0); // [px]
|
---|
1834 |
|
---|
1835 | //const Float_t pixsize = atof(fPixSize->GetText()); // [arcsec/px]
|
---|
1836 |
|
---|
1837 | // BE CAREFULL: This transformation is WRONG. It is just
|
---|
1838 | // a transformation of units, but this implies, that the
|
---|
1839 | // coordiante axis in both units look the same. This is
|
---|
1840 | // wrong exspecially near the zenith were az-lines are highly
|
---|
1841 | // curved around the zenith!
|
---|
1842 | //sgcenterzdaz.Zd((sgcenter.GetY()-293.6) * pixsize /3600 );
|
---|
1843 | //sgcenterzdaz.Az((sgcenter.GetX()-53.2) * pixsize /3600 );
|
---|
1844 | #ifdef EXPERT
|
---|
1845 | cout << "- LEDs imply offset of Zd="
|
---|
1846 | << sgcenter.GetX()-53.2 << "pix Az="
|
---|
1847 | << sgcenter.GetY()-293.6<< "pix" << endl;
|
---|
1848 | #endif
|
---|
1849 | if (fDisplay->IsEntryChecked(IDM_kStargFindStar) &&
|
---|
1850 | sgcenter.GetX()>0 && sgcenter.GetY()>0)
|
---|
1851 | {
|
---|
1852 | star = FindStar(f, f2, sgcenter, t, 4.5, 30, 267/161.9); // [deg]
|
---|
1853 | #ifdef EXPERT
|
---|
1854 | cout << "- Star is found to be off Zd=" << star.Zd()*60 << "' Az="
|
---|
1855 | << star.Az()*60 << "'" << endl;
|
---|
1856 | #endif
|
---|
1857 | fSZdAz->SetCoordinates(star); // Mispointing found from Camera
|
---|
1858 |
|
---|
1859 | SendAmcTrigger("Starguider");
|
---|
1860 | }
|
---|
1861 | }
|
---|
1862 |
|
---|
1863 | // Find Roque Lamp
|
---|
1864 |
|
---|
1865 | if (fOperations->IsEntryChecked(IDM_kRoqueLampAna))
|
---|
1866 | {
|
---|
1867 |
|
---|
1868 | Double_t imageclean = 1.5;
|
---|
1869 | Int_t boxradius = 60;
|
---|
1870 | //Double_t scalefactor = 1;
|
---|
1871 | XY searchcenter(768/2-1,576/2+25);
|
---|
1872 |
|
---|
1873 | XY roquelamp = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter);
|
---|
1874 |
|
---|
1875 | if (fOutRq)
|
---|
1876 | {
|
---|
1877 | ZdAz pos = fCosy->GetPointingPos();
|
---|
1878 |
|
---|
1879 | *fOutRq << "RoqueLampDirect: " << MTime(-1) << " "
|
---|
1880 | << pos.Zd() << " " << pos.Az() << " "
|
---|
1881 | << roquelamp.X() << " " << roquelamp.Y() << endl;
|
---|
1882 | }
|
---|
1883 |
|
---|
1884 | cout << "Starguider Camera Center: " << sgcenter.GetX() << "," << sgcenter.GetY() << endl;
|
---|
1885 | cout << ">=>=>=> Roque Lamp found at: >=>=>=> (" << roquelamp.X() << ","
|
---|
1886 | << roquelamp.Y() << ") <=<=<=<" << endl;
|
---|
1887 |
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 | // Find Spot on Camera Center in Starguider camera
|
---|
1891 | if (fOperations->IsEntryChecked(IDM_kRoqueLampAna))
|
---|
1892 | {
|
---|
1893 | XY cameraspot(0,0);
|
---|
1894 |
|
---|
1895 | Double_t imageclean = 5;
|
---|
1896 | Int_t boxradius = 60;
|
---|
1897 | //Double_t scalefactor = 1;
|
---|
1898 | // XY searchcenter(sgcenter.GetX(),sgcenter.GetY());
|
---|
1899 | XY searchcenter(60.,290.);
|
---|
1900 |
|
---|
1901 | cameraspot = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter);
|
---|
1902 |
|
---|
1903 | if (fOutRq)
|
---|
1904 | {
|
---|
1905 | ZdAz pos = fCosy->GetPointingPos();
|
---|
1906 |
|
---|
1907 | *fOutRq << "RoqueLampReflected: " << MTime(-1) << " "
|
---|
1908 | << pos.Zd() << " " << pos.Az() << " "
|
---|
1909 | << cameraspot.X() << " " << cameraspot.Y() << endl;
|
---|
1910 | }
|
---|
1911 |
|
---|
1912 | cout << ">>>>> Spot on Magic camera found at: >>>>> (" << cameraspot.X() << ","
|
---|
1913 | << cameraspot.Y() << ") <<<<<" << endl;
|
---|
1914 |
|
---|
1915 | f2.DrawCircle(sgcenter, 5.0, 0x0fa);
|
---|
1916 | f2.DrawCircle(sgcenter, 115.0, 0x0fa);
|
---|
1917 | }
|
---|
1918 | // we calculate the offset given by the three ETH Leds visible to
|
---|
1919 | // the guide camera
|
---|
1920 | // This is an (inferior, obsolete) alternative to the StarCaosFilter
|
---|
1921 | // Led offset;
|
---|
1922 | // if (fDisplay->IsEntryChecked(IDM_kStargLEDFilter))
|
---|
1923 | // fStargLeds->Run(img,offset);
|
---|
1924 |
|
---|
1925 | // Position corresponding to the camera center (53.2, 293.6)
|
---|
1926 | //Ring skycenter(392, 318);
|
---|
1927 | // MStarList spots;
|
---|
1928 |
|
---|
1929 | // we obtain a list of stars in the FOV from the SAO catalog
|
---|
1930 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
1931 | {
|
---|
1932 | MTime time(*tm);
|
---|
1933 |
|
---|
1934 | XY xy = fCRaDec->GetCoordinates(); //[h, deg]
|
---|
1935 | fRaDec->Set(xy.X()*360/24, xy.Y()); //[deg,deg]
|
---|
1936 |
|
---|
1937 | UpdatePosZoom();
|
---|
1938 |
|
---|
1939 | // Always call SetMjd first!
|
---|
1940 | fSao->SetPointing(time.GetMjd(), *fRaDec);
|
---|
1941 | fCZdAz->SetCoordinates(fSao->GetZdAz());
|
---|
1942 |
|
---|
1943 | MStarList stars;
|
---|
1944 | fSao->SetBox(230); // Region of interest around center
|
---|
1945 |
|
---|
1946 | // very careful: If center of camera cannot be determined
|
---|
1947 | // sgcenter jumps to (0,0)
|
---|
1948 |
|
---|
1949 | //Please never change this offsets!!!
|
---|
1950 | // 53.2 and 293.6 are the "preliminary" camera center
|
---|
1951 | // -9 and 28.5 are the offsets of the pointing position in the sky
|
---|
1952 |
|
---|
1953 | const Bool_t centerisvalid = sgcenter.GetX()>0 && sgcenter.GetY()>0;
|
---|
1954 | // if (centerisvalid)
|
---|
1955 | // skycenter.SetXY(sgcenter.GetX() - 53.2,
|
---|
1956 | // sgcenter.GetY() - 293.6);
|
---|
1957 |
|
---|
1958 | // we obtain stars in the effective star FOV and draw them.
|
---|
1959 | // coordinates are video frame coords.
|
---|
1960 | // We determine the ideal starfield using camera sagging info
|
---|
1961 | // from the LEDs
|
---|
1962 | const XY off(sgcenter.GetX()- 53.2-9,
|
---|
1963 | sgcenter.GetY()-293.6+28.5);
|
---|
1964 |
|
---|
1965 | fSao->CalcStars(stars, 530, 292, TMath::FloorNint(off.X()), TMath::FloorNint(off.Y()));
|
---|
1966 | fSao->DrawStars(stars, cimg);
|
---|
1967 |
|
---|
1968 | // Position around which the circles are drawn.
|
---|
1969 | const Ring skycenter(768/2-off.X(), 576/2+off.Y());
|
---|
1970 |
|
---|
1971 | // There are two corrections to the mispointing
|
---|
1972 | // - Sagging of the camera as measured with the LEDs
|
---|
1973 | // - Star not ideally centered on MAGIC Camera
|
---|
1974 |
|
---|
1975 | // Next we evaluate the offset given by the LEDs. This we obtain
|
---|
1976 | // in Zd/Az and add it to the tracking error.
|
---|
1977 | if (fDisplay->IsEntryChecked(IDM_kStarguider))
|
---|
1978 | {
|
---|
1979 | const Float_t cut = atof(fCut->GetText());
|
---|
1980 |
|
---|
1981 | Leds spots;
|
---|
1982 | f.SetBox(230);
|
---|
1983 | f.SetCut(cut);
|
---|
1984 |
|
---|
1985 | double bright;
|
---|
1986 | f.ExecuteAndMark(spots, 530, 292, bright);
|
---|
1987 |
|
---|
1988 | ULong_t color;
|
---|
1989 | gClient->GetColorByName("Green", color);
|
---|
1990 | if (bright> 60)
|
---|
1991 | gClient->GetColorByName("Yellow", color);
|
---|
1992 | if (bright> 85)
|
---|
1993 | gClient->GetColorByName("Orange", color);
|
---|
1994 | if (bright> 95)
|
---|
1995 | gClient->GetColorByName("Red", color);
|
---|
1996 | fSkyBright->SetBackgroundColor(color);
|
---|
1997 |
|
---|
1998 | const MString txt = MString::Format("Sky Brightness: %.1f", bright);
|
---|
1999 | fSkyBright->SetText(txt);
|
---|
2000 |
|
---|
2001 | const Bool_t brightnessisvalid = bright<1.75*fLastBright &&
|
---|
2002 | bright>30 && bright<110;
|
---|
2003 |
|
---|
2004 | fLastBright = bright;
|
---|
2005 |
|
---|
2006 | Int_t numstars = 0;
|
---|
2007 | const Int_t rc = CalcTrackingError(spots, stars, fD, t, bright, numstars);
|
---|
2008 |
|
---|
2009 | const Bool_t monitoring = brightnessisvalid && centerisvalid && fNumStarsCorrelated>2;
|
---|
2010 |
|
---|
2011 | fStatus = monitoring ? MDriveCom::kMonitoring : MDriveCom::kError;
|
---|
2012 |
|
---|
2013 | if (fCosy)
|
---|
2014 | fPos = fCosy->GetPointingPos();
|
---|
2015 |
|
---|
2016 | if (fOperations->IsEntryChecked(IDM_kStargAnalysis))
|
---|
2017 | fStargHistograms->Fill(spots, stars, fD,
|
---|
2018 | fSao->GetZdAz(), sgcenter, /*sgcenterzdaz,*/
|
---|
2019 | star, bright, fPos, t);
|
---|
2020 |
|
---|
2021 | fNumStarsDetected = numstars;
|
---|
2022 | fNumStarsCorrelated = rc;
|
---|
2023 |
|
---|
2024 | if (fCosy)
|
---|
2025 | {
|
---|
2026 | MDriveCom *com = fCosy->GetDriveCom();
|
---|
2027 | if (com)
|
---|
2028 | com->SendStargReport(fStatus, fD, fSao->GetZdAz(),
|
---|
2029 | sgcenter, numstars, rc, bright,
|
---|
2030 | time.GetMjd(), 0, 0); // Report
|
---|
2031 | }
|
---|
2032 |
|
---|
2033 | } //kStarguider
|
---|
2034 |
|
---|
2035 | if (centerisvalid && fNumStarsCorrelated>2)
|
---|
2036 | {
|
---|
2037 | f2.DrawCircle(skycenter, 2.0, 0x0a);
|
---|
2038 |
|
---|
2039 | const Double_t ap = fSao->GetPixSize()/3600; //[deg/pix]
|
---|
2040 |
|
---|
2041 | f2.DrawCircle(skycenter, 0.10/ap, 0x0a); //0.1deg
|
---|
2042 | f2.DrawHexagon(skycenter, 2.06/ap, 0x0a);
|
---|
2043 | f2.DrawHexagon(skycenter, 3.50/ap, 0x0a);
|
---|
2044 | }
|
---|
2045 |
|
---|
2046 | } //CalcStars
|
---|
2047 |
|
---|
2048 | // Draw Circles around center of Camera
|
---|
2049 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter) &&
|
---|
2050 | center.GetX()>0 && center.GetY()>0)
|
---|
2051 | {
|
---|
2052 | f2.DrawCircle(center, 0x0a);
|
---|
2053 | f2.DrawCircle(center, 7.0,
|
---|
2054 | fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
|
---|
2055 | f2.DrawCircle(center, 115.0, 0x0a);
|
---|
2056 | f2.DrawCircle(center, 230.0, 0x0a);
|
---|
2057 | f2.DrawCircle(center, 245.0, 0x0a);
|
---|
2058 | }
|
---|
2059 |
|
---|
2060 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter) &&
|
---|
2061 | sgcenter.GetX()>0 && sgcenter.GetY()>0)
|
---|
2062 | {
|
---|
2063 | f2.DrawCircle(sgcenter, 0x0a);
|
---|
2064 | f2.DrawCircle(sgcenter, 5.0,
|
---|
2065 | fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
|
---|
2066 | }
|
---|
2067 |
|
---|
2068 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter) ||
|
---|
2069 | fDisplay->IsEntryChecked(IDM_kCatalog) ||
|
---|
2070 | fDisplay->IsEntryChecked(IDM_kFindStar) ||
|
---|
2071 | fOperations->IsEntryChecked(IDM_kRoqueLampAna))
|
---|
2072 | fImage->DrawColImg(img, cimg);
|
---|
2073 | else
|
---|
2074 | fImage->DrawImg(img);
|
---|
2075 | }
|
---|
2076 |
|
---|
2077 | void MStarguider::UpdatePosZoom()
|
---|
2078 | {
|
---|
2079 | MString txt;
|
---|
2080 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
2081 | {
|
---|
2082 | // FIXME: Necessary?
|
---|
2083 | fSao->Now();
|
---|
2084 | AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg;
|
---|
2085 | if (aa.Az()<0)
|
---|
2086 | aa.Az(aa.Az()+360);
|
---|
2087 | txt.Form("(%d, %d) %.1fd/%.1fd", fDx, fDy, -aa.Alt(), aa.Az()-180);
|
---|
2088 | }
|
---|
2089 | else
|
---|
2090 | txt.Form("(%d, %d)", fDx, fDy);
|
---|
2091 | fPosZoom->SetText(txt);
|
---|
2092 | }
|
---|
2093 |
|
---|
2094 | Bool_t MStarguider::HandleDoubleClick(Event_t *event)
|
---|
2095 | {
|
---|
2096 | const Int_t w = fImage->GetWidth();
|
---|
2097 | const Int_t h = fImage->GetHeight();
|
---|
2098 | const Int_t x = fImage->GetX();
|
---|
2099 | const Int_t y = fImage->GetY();
|
---|
2100 |
|
---|
2101 | if (!(event->fX>x && event->fX<x+w && event->fY>y && event->fY<y+h))
|
---|
2102 | return kTRUE;
|
---|
2103 |
|
---|
2104 | Int_t dx = event->fX-x;
|
---|
2105 | Int_t dy = event->fY-y;
|
---|
2106 |
|
---|
2107 | if (dx<kZOOM/4) dx=kZOOM/4;
|
---|
2108 | if (dy<kZOOM/4) dy=kZOOM/4;
|
---|
2109 | if (dx>766-kZOOM/4) dx=766-kZOOM/4;
|
---|
2110 | if (dy>574-kZOOM/4) dy=574-kZOOM/4;
|
---|
2111 |
|
---|
2112 | fDx = dx;
|
---|
2113 | fDy = dy;
|
---|
2114 |
|
---|
2115 | UpdatePosZoom();
|
---|
2116 | return kTRUE;
|
---|
2117 | }
|
---|
2118 |
|
---|
2119 | void MStarguider::Print(TString &str, Double_t deg) const
|
---|
2120 | {
|
---|
2121 | Char_t sgn;
|
---|
2122 | UShort_t d, m, s;
|
---|
2123 |
|
---|
2124 | MAstro::Deg2Dms(deg, sgn, d, m, s);
|
---|
2125 |
|
---|
2126 | str += MString::Format("%c %03d %02d %03d ", sgn, d, m, s);
|
---|
2127 | }
|
---|