j2000test.c 3.79 KB
Newer Older
Jeroen Vreeken's avatar
Jeroen Vreeken committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
	Command generator for J2000.0 positions

	Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008
	Copyright Stichting C.A. Muller Radioastronomiestation, 2008

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <fcntl.h>
#include <termios.h>
#include <signal.h>
#include <ctype.h>
#include <inttypes.h>
#include <arpa/inet.h>
#include <sys/select.h>
#include <sys/ioctl.h>
#include <errno.h>

#include <libnova/transform.h>
#include <libnova/julian_day.h>
#include <libnova/utility.h>


struct lnh_lnlat_posn dwingeloo;
struct ln_lnlat_posn dwingeloo_pos;
struct ln_equ_posn object;
struct ln_hms track_hms;
struct ln_dms track_dms;


int main(int argc, char **argv)
{
	struct setpoint_command *sp_command_az = NULL;
	struct setpoint_command *sp_command_el = NULL;
	int i;
	time_t lastt = 0;
	int fd_stat, fd_cmd;
	time_t t;

	printf("libnova version: %s\n", ln_get_version());

/* hekje: 52.812067 6.3963333 
   paul: 52.812024 6.39670 */

	/* 6.3961694 */
	dwingeloo.lng.neg = 0;
	dwingeloo.lng.degrees = 6;
	dwingeloo.lng.minutes = 23;
	dwingeloo.lng.seconds = 46.21;
	/* 52.812019 */
	dwingeloo.lat.neg = 0;
	dwingeloo.lat.degrees = 52;
	dwingeloo.lat.minutes = 48;
	dwingeloo.lat.seconds = 43.27;
	ln_hlnlat_to_lnlat(&dwingeloo, &dwingeloo_pos);

	/* casa */
//	track_hms.hours = 23;
//	track_hms.minutes = 23;
//	track_hms.seconds = 26;
//	track_dms.neg = 0;
//	track_dms.degrees = 58;
//	track_dms.minutes = 48;
//	track_dms.seconds = 0.0;

	/* cyga */
//	track_hms.hours = 19;
//	track_hms.minutes = 59;
//	track_hms.seconds = 28.3566;
//	track_dms.neg = 0;
//	track_dms.degrees = 40;
//	track_dms.minutes = 44;
//	track_dms.seconds = 2.096;

	/* virgoa */
	track_hms.hours = 12;
	track_hms.minutes = 30;
	track_hms.seconds = 49.4;
	track_dms.neg = 0;
	track_dms.degrees = 12;
	track_dms.minutes = 23;
	track_dms.seconds = 28;

	/* taua */
//	track_hms.hours = 05;
//	track_hms.minutes = 34;
//	track_hms.seconds = 31.97;
//	track_dms.neg = 0;
//	track_dms.degrees = 22;
//	track_dms.minutes = 00;
//	track_dms.seconds = 52.1;

	object.ra = ln_hms_to_deg(&track_hms);
	object.dec = ln_dms_to_deg(&track_dms);

	ln_deg_to_hms(object.ra, &track_hms);
	ln_deg_to_dms(object.dec, &track_dms);

	t = 1241136000 -60 + 3600*24*0;
	for (i = 0; i < 60 * 24; i++)
	{
		struct ln_date date;
		double JD;
		struct ln_hrz_posn hrz;
		int high = 0;
		fd_set fdset_rx;
		struct timeval tv;
		
		{
			t += 60;
		
			ln_get_date_from_timet(&t, &date);
			JD = ln_get_julian_day(&date);
			ln_get_hrz_from_equ(&object, &dwingeloo_pos, JD, &hrz);

			/* libnova has an az range from 0 to 360 with 0 being South.
			   Dwingeloo has an az range from -270 to 270 with 0 being South
			   
			   Stars that stay north of dwingeloo (incl circumpolar)
			   can be tracked in either positive of negative north.
			   So we take the nearest.
			   Other stars pass through south.
			 */

			printf("%02dh%02dm%04.1f %s%03dd%02dm%04.1f %d %f %f %s",
			    track_hms.hours, track_hms.minutes, track_hms.seconds,
			    track_dms.neg ? "-" : " ",
			    track_dms.degrees, track_dms.minutes, track_dms.seconds,
			    (unsigned int)t, hrz.az, hrz.alt, ctime(&t));

		}

	}

}