Coverage Report

Created: 2026-07-30 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/astro/apci13.rs
Line
Count
Source
1
use super::{IauAstrom, apci};
2
use crate::{
3
    eph::epv00,
4
    pnp::{bpn2xy, eors, pnm06a, s06},
5
};
6
7
///  Prepare for ICRS <−> CIRS, terrestrial
8
///
9
///  For a terrestrial observer, prepare star-independent astrometry
10
///  parameters for transformations between ICRS and geocentric CIRS
11
///  coordinates.  The caller supplies the date, and SOFA models are used
12
///  to predict the Earth ephemeris and CIP/CIO.
13
///
14
///  The parameters produced by this function are required in the
15
///  parallax, light deflection, aberration, and bias-precession-nutation
16
///  parts of the astrometric transformation chain.
17
///
18
///  This function is part of the International Astronomical Union's
19
///  SOFA (Standards of Fundamental Astronomy) software collection.
20
///
21
///  Status:  support function.
22
///
23
///  Given:
24
///  ```
25
///     date1  double      TDB as a 2-part...
26
///     date2  double      ...Julian Date (Note 1)
27
///  ```
28
///  Returned:
29
///  ```
30
///     astrom iauASTROM*  star-independent astrometry parameters:
31
///      pmt    double       PM time interval (SSB, Julian years)
32
///      eb     double[3]    SSB to observer (vector, au)
33
///      eh     double[3]    Sun to observer (unit vector)
34
///      em     double       distance from Sun to observer (au)
35
///      v      double[3]    barycentric observer velocity (vector, c)
36
///      bm1    double       sqrt(1-|v|^2): reciprocal of Lorenz factor
37
///      bpn    double[3][3] bias-precession-nutation matrix
38
///      along  double       unchanged
39
///      xpl    double       unchanged
40
///      ypl    double       unchanged
41
///      sphi   double       unchanged
42
///      cphi   double       unchanged
43
///      diurab double       unchanged
44
///      eral   double       unchanged
45
///      refa   double       unchanged
46
///      refb   double       unchanged
47
///     eo     double*     equation of the origins (ERA-GST, radians)
48
///  ```
49
///  Notes:
50
///
51
///  1) The TDB date date1+date2 is a Julian Date, apportioned in any
52
///     convenient way between the two arguments.  For example,
53
///     JD(TDB)=2450123.7 could be expressed in any of these ways, among
54
///     others:
55
///  ```
56
///            date1          date2
57
///
58
///         2450123.7           0.0       (JD method)
59
///         2451545.0       -1421.3       (J2000 method)
60
///         2400000.5       50123.2       (MJD method)
61
///         2450123.5           0.2       (date & time method)
62
///  ```
63
///     The JD method is the most natural and convenient to use in cases
64
///     where the loss of several decimal digits of resolution is
65
///     acceptable.  The J2000 method is best matched to the way the
66
///     argument is handled internally and will deliver the optimum
67
///     resolution.  The MJD method and the date & time methods are both
68
///     good compromises between resolution and convenience.  For most
69
///     applications of this function the choice will not be at all
70
///     critical.
71
///
72
///     TT can be used instead of TDB without any significant impact on
73
///     accuracy.
74
///
75
///  2) All the vectors are with respect to BCRS axes.
76
///
77
///  3) In cases where the caller wishes to supply his own Earth
78
///     ephemeris and CIP/CIO, the function iauApci can be used instead
79
///     of the present function.
80
///
81
///  4) This is one of several functions that inserts into the astrom
82
///     structure star-independent parameters needed for the chain of
83
///     astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed.
84
///
85
///     The various functions support different classes of observer and
86
///     portions of the transformation chain:
87
///  ```
88
///          functions         observer        transformation
89
///
90
///       iauApcg iauApcg13    geocentric      ICRS <-> GCRS
91
///       iauApci iauApci13    terrestrial     ICRS <-> CIRS
92
///       iauApco iauApco13    terrestrial     ICRS <-> observed
93
///       iauApcs iauApcs13    space           ICRS <-> GCRS
94
///       iauAper iauAper13    terrestrial     update Earth rotation
95
///       iauApio iauApio13    terrestrial     CIRS <-> observed
96
///  ```
97
///     Those with names ending in "13" use contemporary SOFA models to
98
///     compute the various ephemerides.  The others accept ephemerides
99
///     supplied by the caller.
100
///
101
///     The transformation from ICRS to GCRS covers space motion,
102
///     parallax, light deflection, and aberration.  From GCRS to CIRS
103
///     comprises frame bias and precession-nutation.  From CIRS to
104
///     observed takes account of Earth rotation, polar motion, diurnal
105
///     aberration and parallax (unless subsumed into the ICRS <-> GCRS
106
///     transformation), and atmospheric refraction.
107
///
108
///  5) The context structure astrom produced by this function is used by
109
///     iauAtciq* and iauAticq*.
110
///
111
///  Called:
112
///  ```
113
///     iauEpv00     Earth position and velocity
114
///     iauPnm06a    classical NPB matrix, IAU 2006/2000A
115
///     iauBpn2xy    extract CIP X,Y coordinates from NPB matrix
116
///     iauS06       the CIO locator s, given X,Y, IAU 2006
117
///     iauApci      astrometry parameters, ICRS-CIRS
118
///     iauEors      equation of the origins, given NPB matrix and s
119
///  ```
120
0
pub fn apci13(date1: f64, date2: f64, astrom: &mut IauAstrom, eo: &mut f64) {
121
    /* Earth barycentric & heliocentric position/velocity (au, au/d). */
122
0
    let (ehpv, ebpv) = epv00(date1, date2).unwrap();
123
124
    /* Form the equinox based BPN matrix, IAU 2006/2000A. */
125
0
    let r = pnm06a(date1, date2);
126
127
    /* Extract CIP X,Y. */
128
0
    let (x, y) = bpn2xy(&r);
129
130
    /* Obtain CIO locator s. */
131
0
    let s = s06(date1, date2, x, y);
132
133
    /* Compute the star-independent astrometry parameters. */
134
0
    apci(date1, date2, &ebpv, &ehpv[0], x, y, s, astrom);
135
136
    /* Equation of the origins. */
137
0
    *eo = eors(&r, s);
138
0
}