59 |
|
{"", 0} |
60 |
|
}; |
61 |
|
/* required values */ |
62 |
+ |
int year = 0; /* year (optional) */ |
63 |
|
int month, day; /* date */ |
64 |
|
double hour; /* time */ |
65 |
|
int tsolar; /* 0=standard, 1=solar */ |
126 |
|
skytype = S_CLEAR; |
127 |
|
dosun = argv[i][0] == '+'; |
128 |
|
break; |
129 |
+ |
case 'y': |
130 |
+ |
year = atoi(argv[++i]); |
131 |
+ |
break; |
132 |
|
case 'r': |
133 |
|
case 'R': |
134 |
|
u_solar = argv[i][1]=='R' ? -1 : 1; |
175 |
|
else |
176 |
|
userror("bad option"); |
177 |
|
|
178 |
+ |
if (year && (year < 1950) | (year > 2050)) |
179 |
+ |
fprintf(stderr, |
180 |
+ |
"%s: warning - year should be in range 1950-2050\n", |
181 |
+ |
progname); |
182 |
|
if (month && !tsolar && fabs(s_meridian-s_longitude) > 45*PI/180) |
183 |
|
fprintf(stderr, |
184 |
|
"%s: warning - %.1f hours btwn. standard meridian and longitude\n", |
199 |
|
double normfactor; |
200 |
|
/* compute solar direction */ |
201 |
|
if (month) { /* from date and time */ |
202 |
< |
int jd; |
195 |
< |
double sd, st; |
202 |
> |
double sd, st = hour; |
203 |
|
|
204 |
< |
jd = jdate(month, day); /* Julian date */ |
205 |
< |
sd = sdec(jd); /* solar declination */ |
206 |
< |
if (tsolar) /* solar time */ |
207 |
< |
st = hour; |
208 |
< |
else |
209 |
< |
st = hour + stadj(jd); |
204 |
> |
if (year) { /* Michalsky algorithm? */ |
205 |
> |
double mjd = mjdate(year, month, day, hour); |
206 |
> |
if (tsolar) |
207 |
> |
sd = msdec(mjd, NULL); |
208 |
> |
else |
209 |
> |
sd = msdec(mjd, &st); |
210 |
> |
} else { |
211 |
> |
int jd = jdate(month, day); /* Julian date */ |
212 |
> |
sd = sdec(jd); /* solar declination */ |
213 |
> |
if (!tsolar) /* get solar time? */ |
214 |
> |
st = hour + stadj(jd); |
215 |
> |
} |
216 |
|
altitude = salt(sd, st); |
217 |
|
azimuth = sazi(sd, st); |
218 |
|
printf("# Local solar time: %.2f\n", st); |