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. |
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! |
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 |
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 |
|
|
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); |
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; |
901 |
|
|
902 |
// Look for a timesync in the TFile rootFile. Set timesync and |
// Look for a timesync in the TFile rootFile. Set timesync and |
903 |
// obt_timesync. Returns 1 if timesync is found, 0 otherwise. |
// obt_timesync. Returns 1 if timesync is found, 0 otherwise. |
904 |
int lookforTimesync(TFile *rootFile, Float_t *timesync, Float_t *obt_timesync) { |
UInt_t lookforTimesync(TFile *rootFile, Float_t *timesync, Float_t *obt_timesync) { |
905 |
*timesync = -1; // will be != -1 if found |
*timesync = -1; // will be != -1 if found |
906 |
|
|
907 |
ULong64_t nevents = 0; |
ULong64_t nevents = 0; |
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!) |
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 |
// |
// |