1 |
greg |
1.2 |
/* Copyright (c) 1989 Regents of the University of California */ |
2 |
greg |
1.1 |
|
3 |
|
|
#ifndef lint |
4 |
|
|
static char SCCSid[] = "$SunId$ LBL"; |
5 |
|
|
#endif |
6 |
greg |
1.2 |
|
7 |
|
|
/* |
8 |
greg |
1.1 |
* SOLAR CALCULATIONS |
9 |
|
|
* |
10 |
|
|
* 3/31/87 |
11 |
|
|
* |
12 |
|
|
*/ |
13 |
|
|
|
14 |
|
|
#define PI 3.141592654 |
15 |
|
|
|
16 |
|
|
double s_latitude = 0.66; /* site latitude (radians) */ |
17 |
|
|
double s_longitude = 2.13; /* site longitude (radians) */ |
18 |
|
|
double s_meridian = 2.0944; /* standard meridian (radians) */ |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
int |
22 |
|
|
jdate(month, day) /* Julian date (days into year) */ |
23 |
|
|
int month, day; |
24 |
|
|
{ |
25 |
|
|
static short mo_da[12] = {0,31,59,90,120,151,181,212,243,273,304,334}; |
26 |
|
|
|
27 |
|
|
return(mo_da[month-1] + day); |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
double |
32 |
|
|
stadj(jd) /* solar time adjustment from Julian date */ |
33 |
|
|
int jd; |
34 |
|
|
{ |
35 |
|
|
double sin(); |
36 |
|
|
|
37 |
|
|
return( 0.170 * sin( (4*PI/373) * (jd - 80) ) - |
38 |
|
|
0.129 * sin( (2*PI/355) * (jd - 8) ) + |
39 |
|
|
12 * (s_meridian - s_longitude) / PI ); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
|
43 |
|
|
double |
44 |
|
|
sdec(jd) /* solar declination angle from Julian date */ |
45 |
|
|
int jd; |
46 |
|
|
{ |
47 |
|
|
double sin(); |
48 |
|
|
|
49 |
|
|
return( 0.4093 * sin( (2*PI/368) * (jd - 81) ) ); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
double |
54 |
|
|
salt(sd, st) /* solar altitude from solar declination and solar time */ |
55 |
|
|
double sd, st; |
56 |
|
|
{ |
57 |
|
|
double sin(), cos(), asin(); |
58 |
|
|
|
59 |
|
|
return( asin( sin(s_latitude) * sin(sd) - |
60 |
|
|
cos(s_latitude) * cos(sd) * cos(st*(PI/12)) ) ); |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
|
64 |
|
|
double |
65 |
|
|
sazi(sd, st) /* solar azimuth from solar declination and solar time */ |
66 |
|
|
double sd, st; |
67 |
|
|
{ |
68 |
|
|
double sin(), cos(), atan2(); |
69 |
|
|
|
70 |
|
|
return( -atan2( cos(sd)*sin(st*(PI/12)), |
71 |
|
|
-cos(s_latitude)*sin(sd) - |
72 |
|
|
sin(s_latitude)*cos(sd)*cos(st*(PI/12)) ) ); |
73 |
|
|
} |