source: trunk/MagicSoft/Mars/mtemp/mpisa/classes/mispointing/MVPTime.cc@ 5138

Last change on this file since 5138 was 5120, checked in by stamerra, 20 years ago
*** empty log message ***
File size: 3.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Robert Wagner 11/2002 <mailto:magicsoft@rwagner.de>
19!
20! Copyright: MAGIC Software Development, 2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MVPTime //
28// //
29// Time Container used by the visibility plotter storing times in MJD //
30// //
31// This is a simple time container for the Visibility Plotter. It takes //
32// "normal" or MJD-formatted time, converts it to MJD and can return MJD. //
33// //
34// The astronomical algorithms used are taken from SLALIB 2.4-8. //
35// //
36/////////////////////////////////////////////////////////////////////////////
37#include "MVPTime.h"
38
39#include <slalib.h>
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44ClassImp(MVPTime);
45
46MVPTime::MVPTime(const char *name, const char *title)
47{
48 fName = name ? name : "MVPTime";
49 fTitle = title ? title : "Storage container for time";
50}
51
52MVPTime::~MVPTime()
53{
54 // do nothing special.
55}
56
57void MVPTime::SetTime(UInt_t yr, UInt_t mo, UInt_t dy, UInt_t hr, UInt_t mi, UInt_t se)
58{
59 fUT1 = CalendarToUT1(yr, mo, dy, hr, mi, se);
60 fYear = yr;
61 fMonth = mo;
62 fDay = dy;
63}
64
65void MVPTime::SetMJD(Double_t mjd, Double_t fracMjd)
66{
67 fUT1 = mjd + fracMjd;
68 Double_t fd;
69 Int_t status;
70 slaDjcl (mjd, &fYear, &fMonth, &fDay, &fd, &status);
71}
72
73// --------------------------------------------------------------------------
74//
75//
76Double_t MVPTime::CalendarToUT1(UInt_t yr, UInt_t mo, UInt_t dy, UInt_t hr, UInt_t mi, UInt_t se)
77{
78 int status;
79 Double_t mjd;
80 slaCldj(yr, mo, dy, &mjd, &status);
81 switch (status)
82 {
83 case 1:
84 *fLog << "CalendarToMJD Warn: bad year" << endl;
85 break;
86 case 2:
87 *fLog << "CalendarToMJD Warn: bad month" << endl;
88 break;
89 case 3:
90 *fLog << "CalendarToMJD Warn: bad day" << endl;
91 break;
92 }
93
94 mjd += ((Double_t)hr/24) + ((Double_t)mi/(24*60)) + ((Double_t)se/(24*60*60));
95 return mjd;
96}
97
98// --------------------------------------------------------------------------
99//
100//
101Double_t MVPTime::MJDStartOfYear(UInt_t year)
102{
103 int status;
104 Double_t mjd;
105 slaCldj(year, 1, 1, &mjd, &status);
106 switch (status)
107 {
108 case 1:
109 *fLog << "CalendarToMJD Warn: bad year" << endl;
110 break;
111 case 2:
112 *fLog << "CalendarToMJD Warn: bad month" << endl;
113 break;
114 case 3:
115 *fLog << "CalendarToMJD Warn: bad day" << endl;
116 break;
117 }
118 return mjd;
119}
120
121void MVPTime::Print(Option_t *) const
122{
123 *fLog << all;
124 *fLog << "Time (MJD) is: " << fUT1 << endl;
125}
Note: See TracBrowser for help on using the repository browser.