Changeset 8728 for trunk/MagicSoft/Mars
- Timestamp:
- 09/03/07 13:07:35 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mpointing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc
r8641 r8728 18 18 ! Author(s): Thomas Bretz, 07/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 520 ! Copyright: MAGIC Software Development, 2000-2007 21 21 ! 22 22 ! … … 31 31 // There are some quality parameters to steer which are the valid 32 32 // starguider data points: 33 // 33 34 // * MPointingDevCalc.NumMinStars: 8 34 35 // Minimum number of identified stars required to accep the data 36 // 35 37 // * MPointingDevCalc.NsbLevel: 3.0 36 // Minimum deviation (in rms) from the the mean allowed for the measured 37 // NSB (noise in the ccd camera) 38 // Minimum deviation (in rms) from the the mean allowed for the 39 // measured NSB (noise in the ccd camera) 40 // 38 41 // * MPointingDevCalc.NsbMin: 30 39 42 // - minimum NSB to be used in mean/rms calculation 43 // 40 44 // * MPointingDevCalc.NsbMax: 60 41 45 // - maximum NSB to be used in mean/rms calculation 46 // 42 47 // * MPointingDevCalc.MaxAbsDev: 15 43 48 // - Maximum absolute deviation which is consideres as valid (arcmin) … … 49 54 // The calculation of NSB mean and rms is reset for each file (ReInit) 50 55 // 56 // If your starguider data doesn't fullfill this requirement the latest 57 // value which could be correctly calculated is used instead. If the time 58 // for which no valid value can be calculated exceeds one minute 59 // the return value is reset to 0/0. The maximum time allowed without 60 // a valid value can be setup using: 61 // 62 // * MPointingDevCalc.MaxAge: 1 63 // Maximum time before the starguider is reset to 0/0 in minutes 64 // 65 // Note, that the starguider itself is not well calibrated. Therefore 66 // it is necessary to do a starguider calibration in our software. 67 // 68 // There are two options: 69 // 70 // * Simple starguider calibration using offsets in the camera plane 71 // 72 // The starguider is calibrated by taking its values (dZd/dAz) 73 // adding them to the source position, calculating the source position 74 // in the camera plane and adding the offsets. To switch off the 75 // full starguider calibration do: 76 // 77 // * MPointingDevCalc.PointingModels: 78 // 79 // To set the offsets (in units of degree) use 80 // 81 // * MPointingDevCalc.Dx: -0.001 82 // * MPointingDevCalc.Dy: -0.004 83 // 84 // * A starguider calibration using a pointing model calculated 85 // from calibration data, so called TPoints 86 // 87 // Because the pointing model can change from time to time 88 // you can give the run-number from which on a new pointing 89 // model is valid. The run itself is included, e.g.: 90 // 91 // * MPointingDevCalc.PointingModels: 85240 89180 92 // * MPointingDevCalc.FilePrefix: resources/starguider 93 // 94 // mean that for all runs<85240 the simple offset correction is used. 95 // For runs >=85240 and <89180 the file resources/starguider0085240.txt 96 // and for runs >=89180 the file resources/starguider0089180.txt is 97 // used. To setup a default file for all runs before 85240 setup 98 // a low number (eg. 0 or 1) 99 // 100 // In the case a pointing model is used additional offsets in 101 // the x/y-camera plane (in units of deg) can be set using the DX 102 // and DY parameters of the pointing model. The fDx and fDy data 103 // members of this class are ignored. To overwrite the starguider 104 // calibrated offset in either Az or Zd with a constant, you 105 // can use the PX/PY directive in the pointing model. (To enable 106 // the overwrite set the third column, the error, to a value 107 // greater than zero) 108 // 109 // 110 // At the PostProcessing step a table with statistics is print if the 111 // debug level is greater or equal 3 (in most applications it is switched 112 // on by -v3) 113 // 114 // 115 // Pointing Models: 116 // ---------------- 117 // 118 // What we know so far about (maybe) important changes in cosy: 119 // 120 // 18.03.2006: The camera holding has been repaired and the camera got 121 // shifted a little bit. 122 // 123 // 16.04.2006: Around this date a roque lamp focussing hass been done 124 // 125 // 25.04.2006: A missalignment intrduced with the roque adjust has been 126 // corrected 127 // 128 // The starguider pointing model for the time before 18.3.2006 and after 129 // April 2006 (in fact there are no TPoints until 07/2006 to check it) 130 // and for the period 07/2006 to (at least) 06/2007 are very similar. 131 // 132 // The pointing model for the time between 18.3.2006 and 04/2006 is 133 // clearly different, mainly giving different Azimuth values between 134 // Zenith and roughly ~25deg, and a slight offset on both axes. 135 // 136 // 10.5.2006: pos1 -= pos0 commented (What was the mentioned fix?) 137 // 29.6.2006: repaired 138 // 139 // 23.3.2006: new starguider algorithm 140 // 141 // 17.3.2005: Fixed units of "nompos" in MDriveCom 142 // 143 // 144 // New pointing models have been installed (if the pointing model 145 // is different, than the previous one it might mean, that also 146 // the starguider calibration is different.) 147 // 148 // 29. Apr. 2004 ~25800 149 // 5. Aug. 2004 ~32000 150 // 19. Aug. 2004 ~33530 151 // 7. Jun. 2005 ~57650 152 // 8. Jun. 2005 153 // 9. Jun. 2005 ~57860 154 // 12. Sep. 2005 ~68338 155 // 24. Nov. 2005 ~75562 156 // 17. Oct. 2006 ~103130 157 // 17. Jun. 2007 ~248193 158 // 159 // 160 // ToDo: 161 // ----- 162 // 163 // * Is 0/0 the best assumption if the starguider partly fails? 164 // 51 165 // 52 166 // Input Container: 167 // MRawRunHeader 53 168 // MReportStarguider 54 169 // … … 74 189 using namespace std; 75 190 76 const TString MPointingDevCalc::fgFileName="resources/starguider.txt"; 191 const TString MPointingDevCalc::fgFilePrefix="resources/starguider"; 192 193 // -------------------------------------------------------------------------- 194 // 195 // Destructor. Call Clear() and delete fPointingModels if any. 196 // 197 MPointingDevCalc::~MPointingDevCalc() 198 { 199 Clear(); 200 } 77 201 78 202 // -------------------------------------------------------------------------- … … 90 214 // -------------------------------------------------------------------------- 91 215 // 216 // Sort the entries in fPoinitngModels 217 // 218 void MPointingDevCalc::SortPointingModels() 219 { 220 const int n = fPointingModels.GetSize(); 221 222 TArrayI idx(n); 223 224 TMath::Sort(n, fPointingModels.GetArray(), idx.GetArray(), kFALSE); 225 226 const TArrayI arr(fPointingModels); 227 228 for (int i=0; i<n; i++) 229 fPointingModels[i] = arr[idx[i]]; 230 } 231 232 // -------------------------------------------------------------------------- 233 // 234 // Set new pointing models 235 // 236 void MPointingDevCalc::SetPointingModels(const TString &models) 237 { 238 fPointingModels.Set(0); 239 240 if (models.IsNull()) 241 return; 242 243 TObjArray *arr = models.Tokenize(" "); 244 245 const int n = arr->GetEntries(); 246 fPointingModels.Set(n); 247 248 for (int i=0; i<n; i++) 249 fPointingModels[i] = atoi((*arr)[i]->GetName()); 250 251 delete arr; 252 253 SortPointingModels(); 254 } 255 256 // -------------------------------------------------------------------------- 257 // 258 // Return a string with the pointing models, seperated by a space. 259 // 260 TString MPointingDevCalc::GetPointingModels() const 261 { 262 TString rc; 263 for (int i=0; i<fPointingModels.GetSize(); i++) 264 rc += Form ("%d ", fPointingModels[i]); 265 266 return rc; 267 } 268 269 // -------------------------------------------------------------------------- 270 // 271 // Add a number to the pointing models 272 // 273 void MPointingDevCalc::AddPointingModel(UInt_t runnum) 274 { 275 const int n = fPointingModels.GetSize(); 276 for (int i=0; i<n; i++) 277 if ((UInt_t)fPointingModels[i]==runnum) 278 { 279 *fLog << warn << "WARNING - Pointing model " << runnum << " already in list... ignored." << endl; 280 return; 281 } 282 283 fPointingModels.Set(n+1); 284 fPointingModels[n] = runnum; 285 286 SortPointingModels(); 287 } 288 289 // -------------------------------------------------------------------------- 290 // 291 // Find the highest number in the array which is lower or equal num. 292 // 293 UInt_t MPointingDevCalc::FindPointingModel(UInt_t num) 294 { 295 const int n = fPointingModels.GetSize(); 296 if (n==0) 297 return (UInt_t)-1; 298 299 // Loop over all pointing models 300 for (int i=0; i<n; i++) 301 { 302 // The number stored in the array did not yet overtake the runnumber 303 if ((UInt_t)fPointingModels[i]<num) 304 continue; 305 306 // The first pointing model is later than this run: use a default 307 if (i==0) 308 return (UInt_t)-1; 309 310 // The last entry in the array is the right one. 311 return fPointingModels[i-1]; 312 } 313 314 // Runnumber is after last entry of pointing models. Use the last one. 315 return fPointingModels[n-1]; 316 } 317 318 // -------------------------------------------------------------------------- 319 // 92 320 // Clear the pointing model. If run-number >= 87751 read the new 93 // pointing model with fFile Name321 // pointing model with fFilePrefix 94 322 // 95 323 Bool_t MPointingDevCalc::ReadPointingModel(const MRawRunHeader &run) 96 324 { 97 if (run.GetRunNumber()<85240) 325 const UInt_t num = FindPointingModel(run.GetRunNumber()); 326 327 // No poinitng models are defined. Use simple dx/dy-calibration 328 if (num==(UInt_t)-1) 98 329 { 99 330 Clear(); … … 101 332 } 102 333 334 // compile the name for the starguider files 335 // The file with the number 00000000 is the default file 336 TString fname = Form("%s%08d.txt", fFilePrefix.Data(), num); 337 103 338 if (!fPointing) 104 339 fPointing = new MPointing; 105 340 106 if (f FileName==fPointing->GetName())107 { 108 *fLog << inf << f FileName << " already loaded." << endl;341 if (fname==fPointing->GetName()) 342 { 343 *fLog << inf << fname << " already loaded." << endl; 109 344 return kTRUE; 110 345 } 111 346 112 return fPointing->Load(f FileName);347 return fPointing->Load(fname); 113 348 } 114 349 … … 210 445 // For calibration add MDriveReport::GetErrorZd/Az ! 211 446 fDeviation->SetDevXY(fDx, fDy); // 1arcmin ~ 5mm 212 //devzd -= 2.686/60;213 //devaz -= 2.840/60;214 447 215 448 return; 216 449 } 217 218 // def?: 20.105, 773219 // 0/0 : 20.119, 763220 // -/- : 19.417 726221 // +mis: 19.80, 756222 450 223 451 // Get the nominal position the star is at the sky … … 229 457 // calculate as follows: 230 458 // 231 // Position at which the starguider camera is pointing in real: 232 // pointing position = nominal position - mis 233 ZdAz mis(devzd, devaz); 234 mis *= TMath::DegToRad(); 235 236 // The pointing mode is the conversion from the real pointing 459 // The mispointing measured by the starguider: 460 // ZdAz mis(devzd, devaz); 461 // mis *= TMath::DegToRad(); 462 463 // The pointing model is the conversion from the real pointing 237 464 // position of the telescope into the pointing position measured 238 465 // by the starguider. 239 466 // 240 // --> To get the real poiting position of the telescope we have 241 // to convert the measured position back; 242 // 467 // To keep as close to the fitted model we use the forward correction. 243 468 244 469 // Position at which the starguider camera is pointing in real: … … 247 472 // The position measured as the starguider's pointing position 248 473 ZdAz pos(nom); // cpos = sao - dev 249 pos -= mis;474 pos -= ZdAz(devzd, devaz)*TMath::DegToRad(); 250 475 251 476 // Now we convert the starguider's pointing position into the … … 253 478 // the telescope pointing position into the starguider pointing 254 479 // position) 255 ZdAz point = fPointing->CorrectBack(pos); 480 ZdAz point = fPointing->CorrectBack(pos); //FWD!!! 256 481 257 482 // MSrcPosCalc uses the following condition to calculate the 258 483 // source position in the camera: 259 484 // real pointing pos = nominal pointing pos - dev 260 // 485 // --> dev = nominal - real 261 486 // Therefor we calculate dev as follows: 262 487 ZdAz dev(nom); … … 264 489 dev *= TMath::RadToDeg(); 265 490 266 // Set Measured mispointing and additional offset 267 fDeviation->SetDevZdAz(dev.Zd(), dev.Az()); 268 fDeviation->SetDevXY(0, 0); 491 /* 492 // We chose the other way. It is less accurate because is is the 493 // other was than the poinitng model was fittet, but it is more 494 // accurate because the nominal (i.e. real) pointing position 495 // is less accurately known than the position returned by the 496 // starguider. 497 // 498 // Calculate the deviation which would be measured by the starguider 499 // if applied to a perfectly pointing telescope. 500 ZdAz dev = fPointing->Correct(nom); 501 dev -= nom; 502 503 // Now add these offsets and the starguider measured offsets to 504 // the real pointing deviation of the telescope (note, that 505 // signs here are just conventions) 506 dev += ZdAz(devzd, devaz)*TMath::DegToRad(); // --> nom-mis 507 dev *= TMath::RadToDeg(); 508 */ 509 510 // Check if the starguider pointing model requests overwriting 511 // of the values with constants (e.g. 0) 512 devaz = fPointing->IsPxValid() ? fPointing->GetPx() : dev.Az(); 513 devzd = fPointing->IsPyValid() ? fPointing->GetPy() : dev.Zd(); 514 515 fDeviation->SetDevZdAz(devzd, devaz); 516 fDeviation->SetDevXY(fPointing->GetDxy()); 269 517 } 270 518 271 519 Int_t MPointingDevCalc::ProcessStarguiderReport() 272 520 { 273 /************* CHECK STATUS!!! ******************/274 275 521 Double_t devzd = fReport->GetDevZd(); // [arcmin] 276 522 Double_t devaz = fReport->GetDevAz(); // [arcmin] … … 393 639 // MPointingDevCalc.MaxAbsDev: 15 394 640 // MPointingDevCalc.MaxAge: 1.0 641 // MPointingDevCalc.Dx: -0.001 642 // MPointingDevCalc.Dy: -0.004 643 // 644 // For a detailed description see the class reference. 395 645 // 396 646 Int_t MPointingDevCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print) … … 437 687 rc = kTRUE; 438 688 } 689 if (IsEnvDefined(env, prefix, "FilePrefix", print)) 690 { 691 fFilePrefix = GetEnvValue(env, prefix, "FilePrefix", fFilePrefix); 692 rc = kTRUE; 693 } 694 if (IsEnvDefined(env, prefix, "PointingModels", print)) 695 { 696 SetPointingModels(GetEnvValue(env, prefix, "PointingModels", GetPointingModels())); 697 rc = kTRUE; 698 } 439 699 440 700 return rc; -
trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.h
r8601 r8728 18 18 { 19 19 private: 20 static const TString fgFile Name; //! default file name of pointing model20 static const TString fgFilePrefix; //! default file name of pointing model 21 21 22 22 MReportStarguider *fReport; //! MReportStarguider to get mispointing … … 33 33 Double_t fLastMjd; //! Time of last processed report 34 34 35 TString fFileName; // File name of pointing model 35 TString fFilePrefix; // File name of pointing model 36 TArrayI fPointingModels; // List with pointing models 36 37 37 UInt_t fNumMinStars; // Minimum number of identified stars38 UInt_t fNumMinStars; // [num] Minimum number of identified stars 38 39 Float_t fNsbLevel; // Minimum deviation from mean in sigma 39 Float_t fNsbMin; // Minimum NSB to calc mean and rms40 Float_t fNsbMax; // Maximum NSB to calc mean and rms40 Float_t fNsbMin; // [au] Minimum NSB to calc mean and rms 41 Float_t fNsbMax; // [au] Maximum NSB to calc mean and rms 41 42 Float_t fMaxAbsDev; // [arcmin] Maximum considered absolute deviation 42 43 Float_t fMaxAge; // [min] Maximum age of reports to be used without an update 43 44 44 Float_t fDx; // Starguider calibration dx45 Float_t fDy; // Starguider calibration dy45 Float_t fDx; // [deg] Starguider calibration dx 46 Float_t fDy; // [deg] Starguider calibration dy 46 47 47 48 // MPointingDevCalc … … 49 50 50 51 Bool_t ReadPointingModel(const MRawRunHeader &run); 52 UInt_t FindPointingModel(UInt_t num); 53 void SortPointingModels(); 51 54 52 55 Int_t ProcessStarguiderReport(); … … 64 67 public: 65 68 MPointingDevCalc() : fReport(0), fDeviation(0), fPointing(0), 66 fSkip(7), fFile Name(fgFileName), fNumMinStars(8),69 fSkip(7), fFilePrefix(fgFilePrefix), fNumMinStars(8), 67 70 fNsbLevel(3), fNsbMin(30), fNsbMax(60), fMaxAbsDev(15), 68 fMaxAge(1), fDx(- 7), fDy(16)71 fMaxAge(1), fDx(-0.001), fDy(-0.004) 69 72 { 70 73 fName = "MPointingDevCalc"; 71 fTitle = "Task calculating the pointing deviation";74 fTitle = "Task calculating the starguider correction"; 72 75 73 76 AddToBranchList("MReportStarguider.*"); 74 77 } 75 ~MPointingDevCalc() 76 { 77 Clear(); 78 } 78 ~MPointingDevCalc(); 79 79 80 // Tobject 80 81 void Clear(Option_t *o=""); 81 82 83 // Setter 82 84 void SetNumMinStars(UInt_t n) { fNumMinStars=n; } 83 85 void SetNsbLevel(Float_t lvl) { fNsbLevel=lvl; } … … 89 91 void SetMaxAge(Float_t age) { fMaxAge=age; } 90 92 91 ClassDef(MPointingDevCalc, 0) //Task calculating the pointing deviation 93 void SetFilePrefix(const char *n) { fFilePrefix=n; } 94 95 // Handle pointing models 96 void SetPointingModels(const TString &models); 97 void AddPointingModel(UInt_t runnum); 98 TString GetPointingModels() const; 99 100 ClassDef(MPointingDevCalc, 0) //Task calculating the starguider correction 92 101 }; 93 102
Note:
See TracChangeset
for help on using the changeset viewer.