/[PAMELA software]/quicklook/OrbitalRate/src/OrbitalRate.cpp
ViewVC logotype

Diff of /quicklook/OrbitalRate/src/OrbitalRate.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by pam-rm2, Mon Apr 2 19:44:38 2007 UTC revision 1.8 by pam-rm2, Sat Nov 3 22:11:18 2007 UTC
# Line 324  void Rate(TString *filename, TString out Line 324  void Rate(TString *filename, TString out
324      exit(EXIT_FAILURE);      exit(EXIT_FAILURE);
325    }    }
326    
327    //Get the Julian date of the Resours offset    // Here I do: resurs offset + timesync
328    TDatime offRes = TDatime(offDate, offTime);    TDatime offRes = TDatime(offDate, offTime);
329    // Add to the Resours Offset the timesync.  This is now the date at    TTimeStamp offResTS = TTimeStamp(offRes.GetYear(), offRes.GetMonth(), offRes.GetDay(), offRes.GetHour(), offRes.GetMinute(), offRes.GetSecond(), 0, kTRUE, timesync);
   // the moment of the timesync.  
   offRes.Set(offRes.Convert() + (UInt_t) timesync);  
330    
331    // Now I need a pointer to a cTle object.  The class misses a    // Now I need a pointer to a cTle object.  The class misses a
332    // constructor without arguments, so we have to give it a dummy TLE.    // constructor without arguments, so we have to give it a dummy TLE.
# Line 339  void Rate(TString *filename, TString out Line 337  void Rate(TString *filename, TString out
337    
338    // If we have to use a TLE file, call getTle().    // If we have to use a TLE file, call getTle().
339    if (tleFile != "")    if (tleFile != "")
340      tle1 = getTle(tleFile, offRes);      tle1 = getTle(tleFile, offResTS); // modify getTle() to use offResTS!
341      else
342        cout<<"OrbitalRate: Warning!!! No tle file supplied.\n";
343    
344      // Here I do: resurs offset + timesync - obt of the timesync
345      offResTS.Set(offResTS.GetSec() - obt_timesync, kTRUE, 0, kFALSE);
346    
347    cOrbit       orbit(*tle1);    cOrbit       orbit(*tle1);
348    cEci         eci;    cEci         eci;
349    cCoordGeo    coo;    cCoordGeo    coo;
350    
351    // offRes is now "offset date" + timesync.  Now I subtract the obt    // Here I do: resurs offset + timesync - obt of the timesync - tle time
352    // of the timesync.  Remember that the time of the event from the    TTimeStamp tledate = getTleDatetime(tle1);
   // tle date is:  
   // tle date - (offset date + timesync - obt timesync + obt event).  
   offRes.Set(offRes.Convert() - (UInt_t) obt_timesync);  
   
   // Get the Julian date of the TLE epoch  
   string datetime = getTleDatetime(tle1);  
   TDatime tledate = TDatime(datetime.c_str());  
   
353    cJulian jdatetime = cJulian((int) (tle1->getField(cTle::FLD_EPOCHYEAR)+2e3), tle1->getField(cTle::FLD_EPOCHDAY));    cJulian jdatetime = cJulian((int) (tle1->getField(cTle::FLD_EPOCHYEAR)+2e3), tle1->getField(cTle::FLD_EPOCHDAY));
354    int pYear, pMon; double pDOM;    int pYear, pMon; double pDOM;
355    jdatetime.getComponent(&pYear, &pMon, &pDOM);    jdatetime.getComponent(&pYear, &pMon, &pDOM);
356      offsetTime = ((Long64_t) offResTS.GetSec() - (Long64_t) tledate.GetSec());
   offsetTime = ((Long64_t) offRes.Convert() - (Long64_t) tledate.Convert());  
357    
358    /********** Magnetic Field **************/    /********** Magnetic Field **************/
359    // Check that all this is correct!    // Check that all this is correct!
# Line 368  void Rate(TString *filename, TString out Line 362  void Rate(TString *filename, TString out
362    // I can now compute the magnetic dipole moment at the actual date,    // I can now compute the magnetic dipole moment at the actual date,
363    // using the cJulian date.  I don't to recompute it for every event    // using the cJulian date.  I don't to recompute it for every event
364    // beacause changes are not relevant at all.    // beacause changes are not relevant at all.
365    Int_t y = tledate.GetYear();  //   Int_t y = tledate.GetYear();
366    Int_t m = tledate.GetMonth();  //   Int_t m = tledate.GetMonth();
367    Int_t d = tledate.GetDay();  //   Int_t d = tledate.GetDay();
368      UInt_t y, m, d;
369      tledate.GetDate(kTRUE, 0, &y, &m, &d);
370    float year = (float) y + (m*31+d)/365;    float year = (float) y + (m*31+d)/365;
371    
372    // Initialize common data for geopack    // Initialize common data for geopack
# Line 730  void Rate(TString *filename, TString out Line 726  void Rate(TString *filename, TString out
726  // Scale() and Merge()).  // Scale() and Merge()).
727  //  //
728  // This function depends on InitStyle();  // This function depends on InitStyle();
729  int printHist(TH2F *h, TString mapFile, TString outDirectory, TString outputFilename, char *title, int width, int height, bool use_log, bool bool_shift)  int printHist(TH2F *h, TString mapFile, TString outDirectory, TString outputFilename, const char *title, int width, int height, bool use_log, bool bool_shift)
730  {  {
731    InitStyle();    InitStyle();
732    
# Line 828  void saveHist(TH1 *h, TString savetoroot Line 824  void saveHist(TH1 *h, TString savetoroot
824  // querying the database with the RESURS DK-1 id number 29228,  // querying the database with the RESURS DK-1 id number 29228,
825  // selecting the widest timespan, including the satellite name in the  // selecting the widest timespan, including the satellite name in the
826  // results.  // results.
827  cTle *getTle(TString tleFile, TDatime offRes)  cTle *getTle(TString tleFile, TTimeStamp offResTS)
828  {  {
829    Float_t tledatefromfile, tledatefromroot;    Float_t tledatefromfile, tledatefromroot;
830    fstream tlefile(tleFile.Data(), ios::in);    fstream tlefile(tleFile.Data(), ios::in);
# Line 858  cTle *getTle(TString tleFile, TDatime of Line 854  cTle *getTle(TString tleFile, TDatime of
854    // Sort by date    // Sort by date
855    sort(ctles.begin(), ctles.end(), compTLE);    sort(ctles.begin(), ctles.end(), compTLE);
856    
857    tledatefromroot = (offRes.GetYear()-2000)*1e3 + (offRes.Convert() - (TDatime(offRes.GetYear(), 1, 1, 0, 0, 0)).Convert())/ (24.*3600.);    UInt_t year, month, day;
858      offResTS.GetDate(kTRUE, 0, &year, &month, &day);
859      TTimeStamp firstofjan = TTimeStamp(year, 1, 1, 0, 0, 0);
860      tledatefromroot = (year-2000)*1e3 + (offResTS.GetSec() - firstofjan.GetSec())/(24.*3600.);
861    
862    for(iter = ctles.begin(); iter != ctles.end(); iter++) {    for(iter = ctles.begin(); iter != ctles.end(); iter++) {
863      cTle *tle = *iter;      cTle *tle = *iter;
# Line 973  TH2F* shiftHist(TH2F* h, Float_t shift) Line 972  TH2F* shiftHist(TH2F* h, Float_t shift)
972  }  }
973    
974    
975  // Return a string like YYYY-MM-DD hh:mm:ss, a datetime format.  //
976  string getTleDatetime(cTle *tle)  // Returns the tle date as a TTimeStamp object.
977    //
978    TTimeStamp getTleDatetime(cTle *tle)
979  {  {
980    int year, mon, day, hh, mm, ss;    int year, mon, day, hh, mm, ss;
981    double dom; // day of month (is double!)    double dom; // day of month (is double!)
# Line 994  string getTleDatetime(cTle *tle) Line 995  string getTleDatetime(cTle *tle)
995    ss = (int) floor( ((((dom - day) * 24 - hh) * 60 - mm) * 60));    ss = (int) floor( ((((dom - day) * 24 - hh) * 60 - mm) * 60));
996    //  ms = (int) floor( (((((dom - day) * 24 - hh) * 60 - mm) * 60) - ss) * 1000);    //  ms = (int) floor( (((((dom - day) * 24 - hh) * 60 - mm) * 60) - ss) * 1000);
997    
998    date << year << "-" << mon << "-" << day << " " << hh << ":" << mm << ":" << ss;    TTimeStamp t = TTimeStamp(year, mon, day, hh, mm, ss, 0, true);
999    
1000    return date.str();    return t;
1001  }  }
1002    
1003  //  //

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.23