CARMA C++
astrom.h
1 #ifndef astrom_h
2 #define astrom_h
3 
4 #include "carma/szaarrayutils/input.h"
5 #include "carma/szaarrayutils/output.h"
6 
7 namespace sza {
8  namespace array {
9 
10  typedef struct {
11  double longitude; /* The longitude of the site (radians, east +ve) */
12  double latitude; /* The latitude of the site (radians) */
13  double altitude; /* The height of the site above sea level (m) */
14  double sin_lat; /* sin(latitude) */
15  double cos_lat; /* cos(latitude) */
16  double rcent; /* The distance between the site and the
17  center of the Earth (AU) */
18  double raxis; /* The distance between the site and the
19  rotation axis of the Earth (AU) */
20  double velocity; /* The geocentric rotational velocity of
21  the site (m/s) */
22  } Site;
23 
24  Site *new_Site(void);
25  int set_Site(Site *site, double longitude, double latitude,
26  double altitude);
27  int read_Site(Site *site, InputStream *stream);
28  Site *del_Site(Site *site);
29 
30 
31  typedef struct {
32  int nsec; /* The number of nanoseconds after second (0-1000000000) */
33  int sec; /* The number of seconds after the minute (0-60) */
34  int min; /* The number of minutes after the hour (0-59) */
35  int hour; /* The number of hours since midnight (0-23) */
36  int day; /* The day of the month (1-31) */
37  int month; /* The month of the year (1-12) */
38  int year; /* The Gregorian year (includes the century) */
39  } Date;
40 
41  int init_Date(Date *date, int year, int month, int day, int hour, int min,
42  int sec, int nsec);
43 
44  int current_date(Date *date);
45 
46  double date_to_mjd_utc(Date *date);
47  double date_to_mjd_tt(Date *date);
48  double date_to_lst(Date *date, Site *site, double ut1utc, double eqex);
49  double date_to_time_of_day(Date *date);
50 
51  double current_mjd_utc(void);
52  double current_mjd_tt(void);
53 
54  int mjd_utc_to_date(double utc, Date *date);
55  double mjd_utc_to_mjd_tt(double utc);
56  double mjd_utc_to_lst(double utc, Site *site, double ut1utc, double eqex);
57  double mjd_utc_to_time_of_day(double utc);
58  int mjd_utc_to_ymd(long mjd, int *year, int *month, int *day);
59  int mjd_utc_to_year_day(long mjd, int *year, int *dayno);
60 
61  int day_of_year(Date *date);
62  int is_leap_year(int year);
63  int days_in_month(int is_leap, int month);
64  const char *name_of_month(int month, int upper_case, int abbreviate);
65  int dayno_to_date(int dayno, int is_leap, int *month, int *day);
66  long mjd_of_year(int year);
67 
68  /*
69  * Render a date on an output stream using a format like:
70  *
71  * dd-mmm-yyyy hh:mm:ss.s or dd-mmm-yyyy:hh:mm:ss.s
72  *
73  * Note that mmm is a 3-letter month-name abbreviation like APR.
74  * If the result takes less than width characters spaces will be
75  * prepended to make up the deficit. If the flags[] string contains
76  * a '-' character then spaces will be appended instead. The precision
77  * argument specifies the number of decimal places to show in the seconds
78  * field. If precision=0, then no decimal point will be displayed. If
79  * the flags[] string contains a ':' character then the yyyy field will
80  * be separated from the hh field by a colon instead of the normal space.
81  * The utc argument should be a UTC expressed as a Modified Julian Date.
82  */
83  int output_utc(OutputStream *stream, char *flags, int width,
84  int precision, double utc);
85 
86  int outputCarmaUtc(OutputStream *stream, char *flags, int width,
87  int precision, double utc);
88 
89  /*
90  * Read a UTC date from an ASCII input stream and return it as
91  * a Modified Julian Date. The expected format is as described for
92  * output_utc() except that the number of digits in each of the
93  * numeric fields can be less than the number shown there. Also
94  * trailing fields after the year field can be omitted.
95  */
96  int input_utc(InputStream *stream, int tell, int nospaces, double *utc);
97 
98  /*
99  * The following type is returned by dec_visibility() to report
100  * whether a specified parallalel of declination lies entirely above
101  * a given horizon, entirely below that horizon, or whether it crosses
102  * the horizon. If it crosses the horizon then dec_visibility()
103  * returns the magnitude of the hour angles at which a source at
104  * the specified declination would cross the horizon.
105  */
106  typedef enum {
107  DEC_ABOVE_HORIZON, /* The given parallel of declination is
108  entirely above the horizon */
109  DEC_BELOW_HORIZON, /* The given parallel of declination is
110  entirely below the horizon */
111  DEC_SPANS_HORIZON /* The given parallel of declination is
112  partly above and partly below the
113  horizon. The crossing points are at
114  +/- the returned hour angle */
115  } DecSpan;
116 
117  DecSpan dec_visibility(Site *site, double el, double dec, double *ha);
118 
119  }
120 }
121 
122 #endif