Air mass: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) (Added Perl) |
(Added XPL0 example.) |
||
Line 532: | Line 532: | ||
z = z + 5 |
z = z + 5 |
||
}</lang> |
}</lang> |
||
{{out}} |
|||
<pre> |
|||
Angle 0 m 13700 m |
|||
------------------------------------ |
|||
0 1.00000000 1.00000000 |
|||
5 1.00380963 1.00380965 |
|||
10 1.01538466 1.01538475 |
|||
15 1.03517744 1.03517765 |
|||
20 1.06399053 1.06399093 |
|||
25 1.10305937 1.10306005 |
|||
30 1.15418974 1.15419083 |
|||
35 1.21998076 1.21998246 |
|||
40 1.30418931 1.30419190 |
|||
45 1.41234169 1.41234567 |
|||
50 1.55280404 1.55281025 |
|||
55 1.73875921 1.73876915 |
|||
60 1.99212000 1.99213665 |
|||
65 2.35199740 2.35202722 |
|||
70 2.89531368 2.89537287 |
|||
75 3.79582352 3.79596149 |
|||
80 5.53885809 5.53928113 |
|||
85 10.07896219 10.08115981 |
|||
90 34.32981136 34.36666557 |
|||
</pre> |
|||
=={{header|XPL0}}== |
|||
{{trans|FreeBASIC}} |
|||
<lang XPL0>define DEG = 0.017453292519943295769236907684886127134; \degrees to radians |
|||
define RE = 6371000.; \Earth radius in meters |
|||
define DD = 0.001; \integrate in this fraction of the distance already covered |
|||
define FIN = 10000000.; \integrate only to a height of 10000km, effectively infinity |
|||
function real Max(A, B); |
|||
real A, B; |
|||
return (if A>B then A else B); |
|||
function real Rho(A); |
|||
real A; |
|||
[ \the density of air as a function of height above sea level |
|||
return Exp(-A/8500.0) |
|||
end; \function |
|||
function real Height( A, Z, D ); |
|||
real A, \= altitude of observer |
|||
Z, \= zenith angle (in degrees) |
|||
D; \= distance along line of sight |
|||
real AA, HH; |
|||
[ AA:= RE + A; |
|||
HH:= sqrt( AA*AA + D*D - 2.*D*AA*Cos((180.-Z)*DEG) ); |
|||
return HH - RE; |
|||
end; \function |
|||
function real Column_density( A, Z ); |
|||
real A, Z; \integrates density along the line of sight |
|||
real Sum, D, Delta; |
|||
[ Sum:= 0.0; D:= 0.0; |
|||
while D<FIN do |
|||
[Delta:= Max(DD, (DD)*D); \adaptive step size to avoid it taking forever: |
|||
Sum:= Sum + Rho(Height(A, Z, D+0.5*Delta))*Delta; |
|||
D:= D + Delta; |
|||
]; |
|||
return Sum; |
|||
end; \function |
|||
function real Airmass( A, Z ); |
|||
real A, Z; |
|||
[ return Column_density( A, Z ) / Column_density( A, 0. ); |
|||
end; \function |
|||
real Z; |
|||
[Text(0, "Angle 0 m 13700 m^M^J"); |
|||
Text(0, "------------------------------------^M^J"); |
|||
Z:= 0.; |
|||
while Z<=90. do |
|||
[Format(2, 0); RlOut(0, Z); |
|||
Format(8, 8); RlOut(0, Airmass(0., Z)); |
|||
RlOut(0, Airmass(13700., Z)); CrLf(0); |
|||
Z:= Z + 5.; |
|||
] |
|||
]</lang> |
|||
{{out}} |
{{out}} |