File: pal1Atmt.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 (119 lines) | stat: -rw-r--r-- 3,651 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
*+
*  Name:
*     pal1Atmt

*  Purpose:
*     Calculate troposphere parameters

*  Language:
*     Starlink ANSI C

*  Type of Module:
*     Library routine

*  Invocation:
*     void pal1Atmt ( double r0, double t0, double alpha, double gamm2,
*                     double delm2, double c1, double c2, double c3,
*                     double c4, double c5, double c6, double r,
*                     double *t, double *dn, double *rdndr );

*  Arguments:
*     r0 = double (Given)
*         Height of observer from centre of the Earth (metre)
*     t0 = double (Given)
*         Temperature of the observer (K)
*     alpha = double (Given)
*         Alpha (see HMNAO paper)
*     gamm2 = double (Given)
*         Gamma minus 2 (see HMNAO paper)
*     delm2 = double (Given)
*         Delta minus 2 (see HMNAO paper)
*     c1 = double (Given)
*         Useful term (see palRefro source)
*     c2 = double (Given)
*         Useful term (see palRefro source)
*     c3 = double (Given)
*         Useful term (see palRefro source)
*     c4 = double (Given)
*         Useful term (see palRefro source)
*     c5 = double (Given)
*         Useful term (see palRefro source)
*     c6 = double (Given)
*         Useful term (see palRefro source)
*     r = double (Given)
*         Current distance from the centre of the Earth (metre)
*     t = double * (Returned)
*         Temperature at r (K)
*     dn = double * (Returned)
*         Refractive index at r.
*     rdndr = double * (Returned)
*         r * rate the refractive index is changing at r.

*  Description:
*     Refractive index and derivative with respect to height for
*     the troposphere.

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

*  Notes:
*     - Internal routine used by palRefro
*     - Note that in the optical case c5 and c6 are zero.

*  History:
*     2012-08-24 (TIMJ):
*        Initial version, copied from Fortran SLA source.
*        Adapted with permission from the Fortran SLALIB library.
*     {enter_further_changes_here}

*  Copyright:
*     Copyright (C) 2004 Patrick T. Wallace
*     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 <math.h>

#include "palmac.h"
#include "pal1.h"

void pal1Atmt ( double r0, double t0, double alpha, double gamm2,
                double delm2, double c1, double c2, double c3, double c4,
                double c5, double c6, double r,
                double *t, double *dn, double *rdndr ) {

  double tt0;
  double tt0gm2;
  double tt0dm2;

  *t = DMAX( DMIN( t0 - alpha*(r-r0), 320.0), 100.0 );
  tt0 = *t / t0;
  tt0gm2 = pow( tt0, gamm2 );
  tt0dm2 = pow( tt0, delm2 );
  *dn = 1.0 + ( c1 * tt0gm2 - ( c2 - c5 / *t ) * tt0dm2 ) * tt0;
  *rdndr = r * ( -c3 * tt0gm2 + ( c4 - c6 / tt0 ) * tt0dm2 );

}