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); |
330 |
// the moment of the timesync. |
// cout<<"timesync="<<timesync<<" obt_timesync="<<obt_timesync<<endl; |
331 |
offRes.Set(offRes.Convert() + (UInt_t) timesync); |
// cout<<"offResTS.GetSec()="<<offResTS.GetSec()<<endl; |
332 |
|
// cout<<"offResTS.AsString()="<<offResTS.AsString()<<endl<<endl; |
333 |
|
|
334 |
// 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 |
335 |
// constructor without arguments, so we have to give it a dummy TLE. |
// constructor without arguments, so we have to give it a dummy TLE. |
340 |
|
|
341 |
// If we have to use a TLE file, call getTle(). |
// If we have to use a TLE file, call getTle(). |
342 |
if (tleFile != "") |
if (tleFile != "") |
343 |
tle1 = getTle(tleFile, offRes); |
tle1 = getTle(tleFile, offResTS); // modify getTle() to use offResTS! |
344 |
|
else |
345 |
|
cout<<"OrbitalRate: Warning!!! No tle file supplied.\n"; |
346 |
|
|
347 |
|
// Here I do: resurs offset + timesync - obt of the timesync |
348 |
|
// cout<<"here0 "<<offResTS.GetSec()<<endl; |
349 |
|
// offResTS.Set(offResTS.GetSec() - obt_timesync, kTRUE, 0, kFALSE); |
350 |
|
offResTS.Set(offResTS.GetSec() - obt_timesync, kFALSE, 0, kFALSE); |
351 |
|
// cout<<"here1 "<<offResTS.GetSec()<<endl; |
352 |
|
|
353 |
cOrbit orbit(*tle1); |
cOrbit orbit(*tle1); |
354 |
cEci eci; |
cEci eci; |
355 |
cCoordGeo coo; |
cCoordGeo coo; |
356 |
|
|
357 |
// offRes is now "offset date" + timesync. Now I subtract the obt |
// Here I do: resurs offset + timesync - obt of the timesync - tle time |
358 |
// 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()); |
|
|
|
|
359 |
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)); |
360 |
int pYear, pMon; double pDOM; |
int pYear, pMon; double pDOM; |
361 |
jdatetime.getComponent(&pYear, &pMon, &pDOM); |
jdatetime.getComponent(&pYear, &pMon, &pDOM); |
362 |
|
offsetTime = ((Long64_t) offResTS.GetSec() - (Long64_t) tledate.GetSec()); |
363 |
offsetTime = ((Long64_t) offRes.Convert() - (Long64_t) tledate.Convert()); |
// cerr<<"offsetTime="<<offsetTime<<endl |
364 |
|
// <<"offResTS.GetSec()="<<offResTS.GetSec()<<endl |
365 |
|
// <<"tledate.GetSec()="<<tledate.GetSec()<<endl<<endl; |
366 |
|
|
367 |
/********** Magnetic Field **************/ |
/********** Magnetic Field **************/ |
368 |
// Check that all this is correct! |
// Check that all this is correct! |
371 |
// I can now compute the magnetic dipole moment at the actual date, |
// I can now compute the magnetic dipole moment at the actual date, |
372 |
// 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 |
373 |
// beacause changes are not relevant at all. |
// beacause changes are not relevant at all. |
374 |
Int_t y = tledate.GetYear(); |
UInt_t y, m, d; |
375 |
Int_t m = tledate.GetMonth(); |
tledate.GetDate(kTRUE, 0, &y, &m, &d); |
|
Int_t d = tledate.GetDay(); |
|
376 |
float year = (float) y + (m*31+d)/365; |
float year = (float) y + (m*31+d)/365; |
377 |
|
|
378 |
// Initialize common data for geopack |
// Initialize common data for geopack |
430 |
// event and the tle date. I use seconds and not milliseconds |
// event and the tle date. I use seconds and not milliseconds |
431 |
// because the indetermination on the timesync is about 1s. |
// because the indetermination on the timesync is about 1s. |
432 |
timeElapsedFromTLE = offsetTime + obt/1000; |
timeElapsedFromTLE = offsetTime + obt/1000; |
433 |
|
if(!i) cerr<<"1st event: timeElapsedFromTLE="<<timeElapsedFromTLE<<endl; |
434 |
|
|
435 |
// I also need the abstime in seconds rounded to the lower |
// I also need the abstime in seconds rounded to the lower |
436 |
// value. Every second, we set a_second_is_over to true. Only |
// value. Every second, we set a_second_is_over to true. Only |
733 |
// Scale() and Merge()). |
// Scale() and Merge()). |
734 |
// |
// |
735 |
// This function depends on InitStyle(); |
// This function depends on InitStyle(); |
736 |
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) |
737 |
{ |
{ |
738 |
InitStyle(); |
InitStyle(); |
739 |
|
|
831 |
// querying the database with the RESURS DK-1 id number 29228, |
// querying the database with the RESURS DK-1 id number 29228, |
832 |
// selecting the widest timespan, including the satellite name in the |
// selecting the widest timespan, including the satellite name in the |
833 |
// results. |
// results. |
834 |
cTle *getTle(TString tleFile, TDatime offRes) |
cTle *getTle(TString tleFile, TTimeStamp offResTS) |
835 |
{ |
{ |
836 |
Float_t tledatefromfile, tledatefromroot; |
Float_t tledatefromfile, tledatefromroot; |
837 |
fstream tlefile(tleFile.Data(), ios::in); |
fstream tlefile(tleFile.Data(), ios::in); |
861 |
// Sort by date |
// Sort by date |
862 |
sort(ctles.begin(), ctles.end(), compTLE); |
sort(ctles.begin(), ctles.end(), compTLE); |
863 |
|
|
864 |
tledatefromroot = (offRes.GetYear()-2000)*1e3 + (offRes.Convert() - (TDatime(offRes.GetYear(), 1, 1, 0, 0, 0)).Convert())/ (24.*3600.); |
UInt_t year, month, day; |
865 |
|
offResTS.GetDate(kTRUE, 0, &year, &month, &day); |
866 |
|
TTimeStamp firstofjan = TTimeStamp(year, 1, 1, 0, 0, 0); |
867 |
|
tledatefromroot = (year-2000)*1e3 + (offResTS.GetSec() - firstofjan.GetSec())/(24.*3600.); |
868 |
|
|
869 |
for(iter = ctles.begin(); iter != ctles.end(); iter++) { |
for(iter = ctles.begin(); iter != ctles.end(); iter++) { |
870 |
cTle *tle = *iter; |
cTle *tle = *iter; |
908 |
|
|
909 |
// Look for a timesync in the TFile rootFile. Set timesync and |
// Look for a timesync in the TFile rootFile. Set timesync and |
910 |
// obt_timesync. Returns 1 if timesync is found, 0 otherwise. |
// obt_timesync. Returns 1 if timesync is found, 0 otherwise. |
911 |
int lookforTimesync(TFile *rootFile, Float_t *timesync, Float_t *obt_timesync) { |
UInt_t lookforTimesync(TFile *rootFile, Float_t *timesync, Float_t *obt_timesync) { |
912 |
*timesync = -1; // will be != -1 if found |
*timesync = -1; // will be != -1 if found |
913 |
|
|
914 |
ULong64_t nevents = 0; |
ULong64_t nevents = 0; |
979 |
} |
} |
980 |
|
|
981 |
|
|
982 |
// Return a string like YYYY-MM-DD hh:mm:ss, a datetime format. |
// |
983 |
string getTleDatetime(cTle *tle) |
// Returns the tle date as a TTimeStamp object. |
984 |
|
// |
985 |
|
TTimeStamp getTleDatetime(cTle *tle) |
986 |
{ |
{ |
987 |
int year, mon, day, hh, mm, ss; |
int year, mon, day, hh, mm, ss; |
988 |
double dom; // day of month (is double!) |
double dom; // day of month (is double!) |
1002 |
ss = (int) floor( ((((dom - day) * 24 - hh) * 60 - mm) * 60)); |
ss = (int) floor( ((((dom - day) * 24 - hh) * 60 - mm) * 60)); |
1003 |
// ms = (int) floor( (((((dom - day) * 24 - hh) * 60 - mm) * 60) - ss) * 1000); |
// ms = (int) floor( (((((dom - day) * 24 - hh) * 60 - mm) * 60) - ss) * 1000); |
1004 |
|
|
1005 |
date << year << "-" << mon << "-" << day << " " << hh << ":" << mm << ":" << ss; |
TTimeStamp t = TTimeStamp(year, mon, day, hh, mm, ss, 0, true); |
1006 |
|
|
1007 |
return date.str(); |
return t; |
1008 |
} |
} |
1009 |
|
|
1010 |
// |
// |