File: palAirmas.c

package info (click to toggle)
starlink-pal 0.9.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,808 kB
  • sloc: ansic: 6,689; makefile: 128; sh: 81
file content (99 lines) | stat: -rw-r--r-- 3,101 bytes parent folder | download | duplicates (3)
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
/*
*+
*  Name:
*     palAirmas

*  Purpose:
*     Air mass at given zenith distance

*  Language:
*     Starlink ANSI C

*  Type of Module:
*     Library routine

*  Invocation:
*     double palAirmas( double zd );

*  Arguments:
*     zd = double (Given)
*        Observed zenith distance (radians)

*  Description:
*     Calculates the airmass at the observed zenith distance.

*  Authors:
*     PTW: Patrick Wallace (STFC)
*     TIMJ: Tim Jenness (JAC, Hawaii)
*     {enter_new_authors_here}

*  Notes:
*     - The "observed" zenith distance referred to above means "as
*       affected by refraction".
*     - Uses Hardie's (1962) polynomial fit to Bemporad's data for
*       the relative air mass, X, in units of thickness at the zenith
*       as tabulated by Schoenberg (1929). This is adequate for all
*       normal needs as it is accurate to better than 0.1% up to X =
*       6.8 and better than 1% up to X = 10. Bemporad's tabulated
*       values are unlikely to be trustworthy to such accuracy
*       because of variations in density, pressure and other
*       conditions in the atmosphere from those assumed in his work.
*     - The sign of the ZD is ignored.
*     - At zenith distances greater than about ZD = 87 degrees the
*       air mass is held constant to avoid arithmetic overflows.

*  See Also:
*     - Hardie, R.H., 1962, in "Astronomical Techniques"
*         ed. W.A. Hiltner, University of Chicago Press, p180.
*     - Schoenberg, E., 1929, Hdb. d. Ap.,
*         Berlin, Julius Springer, 2, 268.

*  History:
*     2012-03-02 (TIMJ):
*        Initial version from the SLA/F version including documentation.
*        Adapted with permission from the Fortran SLALIB library.
*     {enter_further_changes_here}

*  Copyright:
*     Copyright (C) 1999 Rutherford Appleton Laboratory.
*     Copyright (C) 2012 Science and Technology Facilities Council.
*     All Rights Reserved.

*  Licence:
*     This program is free software; you can redistribute it and/or
*     modify it under the terms of the GNU General Public License as
*     published by the Free Software Foundation; either version 3 of
*     the License, or (at your option) any later version.
*
*     This program is distributed in the hope that it will be
*     useful, but WITHOUT ANY WARRANTY; without even the implied
*     warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
*     PURPOSE. See the GNU General Public License for more details.
*
*     You should have received a copy of the GNU General Public License
*     along with this program; if not, write to the Free Software
*     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
*     MA 02110-1301, USA.

*  Bugs:
*     {note_any_bugs_here}
*-
*/

#include "pal.h"
#include "palmac.h"

double palAirmas ( double zd ) {
  double seczm1;
  double airmass;

  /* Have maximum zenith distance of 87 deg */
  const double MAXZD = 87.0 * PAL__DD2R;

  zd = fabs(zd);
  zd = ( zd > MAXZD ? MAXZD : zd );

  seczm1 = (1.0 / cos(zd)) - 1.0;
  airmass = 1.0 + seczm1*(0.9981833 - seczm1*(0.002875 + 0.0008083*seczm1));
  return airmass;
}