aboutsummaryrefslogtreecommitdiff
path: root/noao/obsutil/src/pairmass/airmass.x
blob: 8e9c585deb7a2f1f0c7f15e8eb11aa6921eb4db8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
include	<math.h>

# AIRMASS -- Compute airmass from DEC, LATITUDE and HA

# Airmass formulation from Allen "Astrophysical Quantities" 1973 p.125,133.
# and John Ball's book on Algorithms for the HP-45

double procedure airmass (ha, dec, lat)

double  ha, dec, lat, cos_zd, x

define  SCALE   750.0d0                 # Atmospheric scale height

begin
        if (IS_INDEFD (ha) || IS_INDEFD (dec) || IS_INDEFD (lat))
            call error (1, "Can't determine airmass")

        cos_zd = sin(DEGTORAD(lat)) * sin(DEGTORAD(dec)) +
                 cos(DEGTORAD(lat)) * cos(DEGTORAD(dec)) * cos(DEGTORAD(ha*15.))
        x  = SCALE * cos_zd

        return (sqrt (x**2 + 2*SCALE + 1) - x)
end