-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptg_sub.c
170 lines (135 loc) · 3.51 KB
/
ptg_sub.c
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*******************************************************************/
/* ptg_sub.c ->void PTG_SUB(in,out,choice,max,inc) */
/* Jing M. Chen, [email protected] */
/* Sylvain G. Leblanc [email protected] */
/*******************************************************************/
/* Subroutine that calculates the hotspot kernels */
/* Latest update September 25, 1998 */
/*******************************************************************/
# include <stdio.h>
# include <math.h>
# include <string.h>
# include "data.h"
void PTG_SUB(in_p,out_p,CHOICE,MAX,INC)
struct PARAMETER in_p;
struct RESULT *out_p;
char *CHOICE;
double INC; /* increment of the numerical integration */
int MAX; /* maximum number of integration steps */
{
double IN1 = 0; /* numerator value of integral */
double IN2 = 0; /* denominator value of integral */
double FLAG_IN1=0,FLAG_IN2=0;
register int i=0;
double exp();
double F_theta=0;
double Lt=0;
double Cold=0,Hot=0;
double W=0,PTG=0,F=0,H=0;
double XI =0;
double lambda_m=0;
out_p->Error[10] =0;
/**************calculation of F() ************************************/
if(!strcmp("CANOPY",CHOICE))
{
W = in_p.Ws;
Lt=out_p->Ls;
Cold=out_p->PT_Cold;
Hot = 1-out_p->Pig;
XI = out_p->xi;
H = out_p->H;
lambda_m = out_p->lambda_m;
} else
if(!strcmp("GROUND",CHOICE))
{
W = out_p->Wt;
Lt=out_p->Lt;
Cold=out_p->PS;
Hot = out_p->Pig;
XI = out_p->xi;
H = out_p->H;
lambda_m = out_p->lambda_m;
} else
if(!strcmp("NADIR",CHOICE))
{
W = sqrt(PI*in_p.R*in_p.R);
Lt = out_p->OmegaT*PI*in_p.R*in_p.R*in_p.D/in_p.B;
Cold = out_p->Pvg*(1-out_p->Pig);
Hot = out_p->Viewed_shadow;
out_p->Medium = Hot - Cold;
if(Hot - Cold < 0 )
{
Hot = Cold;
}
XI = out_p->vza;
H=out_p->Hc/3. + in_p.Hb + in_p.Ha;
lambda_m =H*tan(XI);
}
if (XI < PI/2.)
{
for(i=0;i<MAX ;i++)
{
IN1 = IN1 + exp(-Lt*(1+(lambda_m + INC*i)/W))/atan((lambda_m +INC*i )/H) ;
IN2 =IN2 + exp(-Lt*(1+(lambda_m + INC*i)/W));
if (FLAG_IN1 == IN1 &&FLAG_IN2 == IN2 ) i = MAX;
FLAG_IN1 = IN1;
FLAG_IN2 = IN2;
}
if (IN1 > 10000 || IN1 < -10000)
{
IN1 =0;
if(XI>0.00001)
{
/* printf("\n (IN1) Possible problem with ");
printf("Hotspot kernel at xi= %5.3f",
XI*180./PI); */
out_p->Error[10] =1;
}
}
if (IN2 > 10000 || IN2 < -10000)
{
IN2 =0;
if(XI>0.00001)
{
/* printf("\n (IN2) Possible problem with ");
printf("Hotspot kernel at xi= %5.3f",XI*180/PI);*/
out_p->Error[10] =1;
}
}
F_theta =0;
if(IN2 !=0) F_theta = 1-IN1/IN2*XI;
F=F_theta;
PTG= (Hot-Cold)*F_theta + Cold;
}
else
{
PTG = Cold;
F =0;
}
if (F_theta <0) PTG = Cold;
if (F_theta >1) PTG = Cold;
/***********************************************************************/
if(!strcmp("CANOPY",CHOICE))
{
out_p->PT=PTG;
out_p->Fs=F;
} else
if(!strcmp("GROUND",CHOICE))
{
out_p->PG=PTG;
out_p->Ft=F;
} else
if(!strcmp("NADIR",CHOICE))
{
out_p->Error[12] =0;
/* if((out_p->Pvg> PTG) && (out_p->Viewed_shadow > out_p->Pvg-out_p->PS)) out_p->PS = (out_p->Pvg- PTG); */
out_p->ZG = PTG;
if(out_p->PS > out_p->Pvg - out_p->ZG) out_p->PS = out_p->Pvg - out_p->ZG;
if(out_p->Pvg - out_p->ZG < 0)
{
out_p->PS = 0;
out_p->Error[12] = 1;
}
out_p->Fn = F*out_p->Fd;
}
}