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
|
/*****************************************************************************
* Johns Hopkins University
* Center For Astrophysical Sciences
* FUSE
*****************************************************************************
*
*
*
* Usage:
* mjd2hjd [-h] [-v level] mjd ra_h ra_m ra_s dec_d dec_m dec_s
*
*
* Arguments:
* mjd : Modified Julian Day
* ra_h ra_m ra_s dec_d dec_m dec_s : RA and DEC of target : hh mm ss.s dd mm ss.s
*
*
* Options:
* -h: this help message
* -v: verbosity level (=1; 0 is silent)
*
*
*
*
*
* History: 10/06/04 bjg v1.0
* 10/26/04 bjg v1.1 Cosmetic change
*
****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#include "calfuse.h"
#define SECONDS_PER_DAY (24.0*3600.0)
static char CF_PRGM_ID[]= "mjd2hjd";
static char CF_VER_NUM[]= "1.1";
double gethmjd(double, int, int, float, int, int, float);
int main(int argc,char *argv[]){
int optc;
double lighttime;
double jd, mjd, hjd, hmjd;
int rah,ram,decd,decm;
float ras,decs;
char opts[] = "hv:";
char usage[] =
"Usage:\n"
" mjd2hjd [-h] [-v level] mjd ra_h ra_m ra_s dec_d dec_m dec_s\n";
char argument[] =
"Arguments:\n"
" mjd : Modified Julian Day.\n"
" ra_h ra_m ra_s dec_d dec_m dec_s : RA and DEC of target.\n";
char option[] =
"Options:\n"
" -h: this help message\n"
" -v: verbosity level (=1; 0 is silent)\n";
verbose_level = 1;
/* Check number of options and arguments */
while ((optc = getopt(argc, argv, opts)) != -1) {
switch(optc) {
case 'h':
printf("%s\n%s\n%s", usage, argument, option);
return EXIT_SUCCESS;
case 'v':
verbose_level = atoi(optarg);
break;
}
}
/* Initialize error checking. */
cf_error_init(CF_PRGM_ID, CF_VER_NUM, stderr);
if (argc != optind+7)
cf_if_error("%s\nIncorrect number of program arguments", usage);
cf_timestamp(CF_PRGM_ID, CF_VER_NUM, "Started execution.");
sscanf(argv[optind],"%lf",&mjd);
sscanf(argv[optind+1],"%d",&rah);
sscanf(argv[optind+2],"%d",&ram);
sscanf(argv[optind+3],"%f",&ras);
sscanf(argv[optind+4],"%d",&decd);
sscanf(argv[optind+5],"%d",&decm);
sscanf(argv[optind+6],"%f",&decs);
hmjd=gethmjd(mjd,rah,ram,ras,decd,decs,decm);
jd = mjd + 2400000.5;
hjd = hmjd + 2400000.5;
lighttime=(hmjd-mjd)*SECONDS_PER_DAY;
cf_verbose(1,"Right Ascension of target: %d h %d m %f s",rah,ram,ras);
cf_verbose(1,"Declination of target: %d deg %d m %f s",decd,decm,decs);
cf_verbose(1,"jd= %lf",jd);
cf_verbose(1,"mjd= %lf",mjd);
cf_verbose(1,"hjd= %lf",hjd);
cf_verbose(1,"hmjd= %lf",hmjd);
cf_verbose(1,"heliocentric light time correction = %lf s",lighttime);
cf_verbose(1,"---positive when Earth is closer to target than Sun");
return EXIT_SUCCESS;
}
|