source: trunk/MagicSoft/slalib/refv.c

Last change on this file was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.6 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaRefv ( double vu[3], double refa, double refb, double vr[3] )
4/*
5** - - - - - - - -
6** s l a R e f v
7** - - - - - - - -
8**
9** Adjust an unrefracted Cartesian vector to include the effect of
10** atmospheric refraction, using the simple A tan z + B tan^3 z
11** model.
12**
13** Given:
14** vu double unrefracted position of the source (az/el 3-vector)
15** refa double A: tan z coefficient (radian)
16** refb double B: tan^3 z coefficient (radian)
17**
18** Returned:
19** *vr double refracted position of the source (az/el 3-vector)
20**
21** Notes:
22**
23** 1 This routine applies the adjustment for refraction in the
24** opposite sense to the usual one - it takes an unrefracted
25** (in vacuo) position and produces an observed (refracted)
26** position, whereas the A tan Z + B tan^3 Z model strictly
27** applies to the case where an observed position is to have the
28** refraction removed. The unrefracted to refracted case is
29** harder, and requires an inverted form of the text-book
30** refraction models; the algorithm used here is equivalent to
31** one iteration of the Newton-Raphson method applied to the above
32** formula.
33**
34** 2 Though optimized for speed rather than precision, the present
35** routine achieves consistency with the refracted-to-unrefracted
36** A tan Z + B tan^3 Z model at better than 1 microarcsecond within
37** 30 degrees of the zenith and remains within 1 milliarcsecond to
38** beyond ZD 70 degrees. The inherent accuracy of the model is, of
39** course, far worse than this - see the documentation for slaRefco
40** for more information.
41**
42** 3 At low elevations (below about 3 degrees) the refraction
43** correction is held back to prevent arithmetic problems and
44** wildly wrong results. Over a wide range of observer heights
45** and corresponding temperatures and pressures, the following
46** levels of accuracy (arcsec) are achieved, relative to numerical
47** integration through a model atmosphere:
48**
49** ZD error
50**
51** 80 0.4
52** 81 0.8
53** 82 1.6
54** 83 3
55** 84 7
56** 85 17
57** 86 45
58** 87 150
59** 88 340
60** 89 620
61** 90 1100
62** 91 1900 } relevant only to
63** 92 3200 } high-elevation sites
64**
65** 4 See also the routine slaRefz, which performs the adjustment to
66** the zenith distance rather than in Cartesian Az/El coordinates.
67** The present routine is faster than slaRefz and, except very low down,
68** is equally accurate for all practical purposes. However, beyond
69** about ZD 84 degrees slaRefz should be used, and for the utmost
70** accuracy iterative use of slaRefro should be considered.
71**
72** Last revision: 4 June 1997
73**
74** Copyright P.T.Wallace. All rights reserved.
75*/
76{
77 double x, y, z1, z, zsq, rsq, r, wb, wt, d, cd, f;
78
79/* Initial estimate = unrefracted vector */
80 x = vu[0];
81 y = vu[1];
82 z1 = vu[2];
83
84/* Keep correction approximately constant below about 3 deg elevation */
85 z = gmax ( z1, 0.05 );
86
87/* One Newton-Raphson iteration */
88 zsq = z * z;
89 rsq = x * x + y * y;
90 r = sqrt ( rsq );
91 wb = refb * rsq / zsq;
92 wt = ( refa + wb ) / ( 1.0 + ( refa + 3.0 * wb ) * ( zsq + rsq ) / zsq );
93 d = wt * r / z;
94 cd = 1.0 - d * d / 2.0;
95 f = cd * ( 1.0 - wt );
96
97/* Post-refraction x,y,z */
98 vr[0] = x * f;
99 vr[1] = y * f;
100 vr[2] = cd * ( z + d * r ) + ( z1 - z );
101}
Note: See TracBrowser for help on using the repository browser.