forked from mayurisrao/GMOSS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefraction.c
More file actions
48 lines (44 loc) · 1.58 KB
/
refraction.c
File metadata and controls
48 lines (44 loc) · 1.58 KB
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
/* Program to calculate the apparent altitude given the observed altitude and vice versa
Author - Mayuri SRao
Date - 15 Feb 2013
*/
/* #include<stdio.h> */
/* #include<math.h> */
/* # define alpha 0.0065 //temp lapse rate [deg C per meter] */
/* # define PI 3.14159265 */
/* double refraction (double rad_elevation, double m_altitude); */
/* int main() */
/* { */
/* double elevation, new_elevation, altitude; */
/* printf("Enter the true elevation in radians to be corrected for refraction\n"); */
/* scanf("%lf",&elevation); */
/* printf("Enter the altitude of the observing location in meters.. 0 being sea level\n"); */
/* scanf("%lf",&altitude); */
/* new_elevation = refraction(elevation, altitude); */
/* printf("true_elevation = %g, \tobserved_elevation = %g\n",elevation,new_elevation); */
/* return 0; */
/* } */
#include<stdio.h>
#include<math.h>
# define alpha 0.0065 //temp lapse rate [deg C per meter]
# define PI 3.14159265
double refraction (double rad_elevation, double m_altitude)
{
double d2r = PI/180.0;
double deg_elevation;
double tpcor,R,new_ele,pres,temp;
pres = 1010.*pow((1-6.5/288000*m_altitude),5.255);
if (m_altitude > 11000)
{temp = 211.5;}
else
{temp = 283.0 - alpha*m_altitude;}
deg_elevation = rad_elevation/d2r;
// printf("elevation in deg = %lf \n",deg_elevation);
R = 1.02/tan((deg_elevation + (10.3/(deg_elevation + 5.11)))*d2r);//refraction correction in arcminutes
if (deg_elevation == 90.0)
{ R += 0.0019279;}
tpcor = pres/1010. * 283/temp;
R = tpcor*(R/60);
new_ele = deg_elevation + R;
return new_ele*d2r;
}