Hi
A suggestion : maybe it is a summer/winter time (daylight savings time)
effect ?
Damir
Le 9 juil. 04, à 16:45, Stephanie Escoffier a écrit :
> Dear Root team,
>
> I don't understand behaviour of TDatime::Convert() function, and more
> precisely why there is one hour extra.
> In practice, if I plot data with starting date of July 9, 2004 at
> 00:00 every 15 mns, TGraph have axis starting one hour before.
> I put an example below.
> If I request GMT time, so there is a shift of 3 hours.
> Maybe it is a problem of time zone effect, but TDatime::Convert()
> function should be transparent to this, like a black box.
> Moreover, if starting date is Jan 1, 2004, so there is no shift.
>
> And now if I look at result of Convert() function for the date of Jan
> 1, 1995, which is the number of seconds since Jan 1, 1970, it should
> be an integer in days. And there is one hour of shift again.
>
> root [0] TDatime *da = new TDatime(1995,1,1,0,0,0);
> root [1] UInt_t a = da->Convert();
> root [2] a
> (unsigned int)788914800
> root [3] Double_t b = (Double_t)a;
> root [4] Double_t days = b/3600/24;
> root [5] days
> (Double_t)9.13095833333333394e+03
> root [6] (days-int(days))*24.
> (double)2.30000000000145519e+01
>
>
> I found in Roottalk digest a mail dealing with the same problem
> (http://root.cern.ch/root/roottalk/roottalk03/2746.html), and it was
> said that this problem was fixed. So my question is: Does this problem
> come from the time zone effect? In this case, how can I draw data with
> correct date, knowing that add one hour to my data doesn't resolve the
> problem since GMT conversion is either 1 hour or 0 hour according to
> summer or winter?
>
> I am using ROOT 3.10/02 on Red Hat 7.2
>
> Thank you,
> regards,
>
> Stephanie
>
>
> *******************
> example:
> #include <termios.h>
> #include <iostream>
> #include <fstream>
> #include <stdlib.h>
> #include <string.h>
> #include <strstream>
> #include "TH1.h"
> #include "TH2.h"
> #include "TCanvas.h"
> #include "TStyle.h"
> #include "TGraph.h"
> #include "TRint.h"
> #include "TRint.h"
>
>
>
> TApplication* the_app;
>
> int main(int argc, char* argv[])
> {
> const int Max=20;
> Double_t Time[Max];
> Double_t Data[Max];
>
> Int_t ngraph=0;
> //one point every 15 mns
> for (int i=0; i< Max; i++)
> { Time[ngraph] = float(i)*15.*60.; // conversion in seconds
> Data[ngraph] = float(i+1);
> ngraph++;
> }
>
> TGraph* graph = new TGraph(ngraph, Time, Data);
>
> TDatime da(2004,07,09,00,00,00); // t0
> //Plot data
> TCanvas* c = new TCanvas("c","Data",600,500);
> c->cd();
> // define axes range and axes titles
> TH2F* hiscom = new TH2F("hiscom","",1000,0.,24.*15.*60.,30,0.,30.);
> hiscom->SetStats(kFALSE);
> hiscom->SetTitle("Data");
> gStyle->SetTimeOffset(da.Convert());
> // hiscom->GetXaxis()->SetTimeOffset(da.Convert());
> hiscom->GetXaxis()->SetTimeDisplay(1);
> gPad->SetGrid(1);
> hiscom->Draw("AXIS");
> graph->SetMarkerStyle(21);
> graph->SetMarkerSize(0.4); graph->SetMarkerColor(2);
> graph->Draw("P"); }
>
>
>
> #include <termios.h>
> #include <iostream>
> #include <fstream>
> #include <stdlib.h>
> #include <string.h>
> #include <strstream>
> #include "TH1.h"
> #include "TH2.h"
> #include "TCanvas.h"
> #include "TStyle.h"
> #include "TGraph.h"
> #include "TRint.h"
> #include "TRint.h"
>
>
>
> TApplication* the_app;
>
> int main(int argc, char* argv[])
> {
>
> const int Max=20;
> Double_t Time[Max];
> Double_t Data[Max];
>
> Int_t ngraph=0;
> for (int i=0; i< Max; i++)
> {
> Time[ngraph] = float(i)*15.*60.; // conversion in seconds
> Data[ngraph] = float(i+1);
> ngraph++;
> }
>
> TGraph* graph = new TGraph(ngraph, Time, Data);
>
> TDatime da(2004,01,01,00,00,00); // t0
>
> //Plot data
> TCanvas* c = new TCanvas("c","Data",600,500);
> c->cd();
>
> // define axes range and axes titles
> TH2F* hiscom = new TH2F("hiscom","",1000,0.,24.*15.*60.,30,0.,30.);
> hiscom->SetStats(kFALSE);
> hiscom->SetTitle("Data");
> gStyle->SetTimeOffset(da.Convert());
> // hiscom->GetXaxis()->SetTimeOffset(da.Convert());
> hiscom->GetXaxis()->SetTimeDisplay(1);
> gPad->SetGrid(1);
> hiscom->Draw("AXIS");
>
> graph->SetMarkerStyle(21);
> graph->SetMarkerSize(0.4);
> graph->SetMarkerColor(2);
> graph->Draw("P");
>
>
> }
>
>
> <data.eps>
====================================
Damir Buskulic, Universite de Savoie/LAPP
Chemin de Bellevue, B.P. 110, F-74941 Annecy-le-Vieux Cedex, FRANCE
Tel : +33 (0)450091600
e-mail: buskulic@lapp.in2p3.fr
====================================
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET