Skip to content

Commit 6818d4a

Browse files
Merge pull request #14 from JuliaSpaceMissionDesign/dev
Update to v.1.1.2
2 parents af24be6 + 13cbada commit 6818d4a

File tree

12 files changed

+152
-88
lines changed

12 files changed

+152
-88
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "IERSConventions"
22
uuid = "4e86e20e-879b-40dc-9e12-cee74f4cd199"
33
authors = ["JSMD Team"]
4-
version = "1.2.0"
4+
version = "1.1.2"
55

66
[deps]
77
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"

src/delaunay.jl

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,24 @@ centuries since J2000.
4949
"""
5050
function delaunay_anomaly_moon(::IERSAModels, tdb_c::Number)
5151
# This expression is valid for both IERS2003 and IERS2010
52-
mod2pi(
53-
arcsec2rad(
54-
@evalpoly(tdb_c, 485868.249036, 1717915923.2178, 31.8792, 0.051635, -0.00024470)
52+
arcsec2rad(
53+
jrem(
54+
@evalpoly(tdb_c, 485868.249036, 1717915923.2178, 31.8792, 0.051635, -0.00024470),
55+
1296000
5556
)
5657
)
5758
end
5859

5960
function delaunay_anomaly_moon(::IERSModel, tdb_c::Number)
60-
arcsec2rad(mod(485868.249036 + 1717915923.2178tdb_c, 1296000))
61+
arcsec2rad(jrem(485868.249036 + 1717915923.2178tdb_c, 1296000))
6162
end
6263

6364
function delaunay_anomaly_moon(::IERS1996, tdb_c::Number)
64-
r = mod(1325tdb_c, 1)
65-
mod2pi(arcsec2rad(@evalpoly(tdb_c, 485866.733, 715922.633, 31.310, 0.064)) + 2π*r)
65+
r = jrem(1325tdb_c, 1)
66+
rem2pi(
67+
arcsec2rad(@evalpoly(tdb_c, 485866.733, 715922.633, 31.310, 0.064)) + 2π*r,
68+
RoundNearest
69+
)
6670
end
6771

6872

@@ -73,20 +77,24 @@ Compute the mean anomaly of the Sun, in radians, given time `tdb_c` expressed in
7377
centuries since J2000.
7478
"""
7579
function delaunay_anomaly_sun(::IERSAModels, tdb_c::Number)
76-
mod2pi(
77-
arcsec2rad(
78-
@evalpoly(tdb_c, 1287104.793048, 129596581.0481, -0.5532, 0.000136, -0.00001149)
80+
arcsec2rad(
81+
jrem(
82+
@evalpoly(tdb_c, 1287104.793048, 129596581.0481, -0.5532, 0.000136, -0.00001149),
83+
1296000
7984
)
8085
)
8186
end
8287

8388
function delaunay_anomaly_sun(::IERSModel, tdb_c::Number)
84-
arcsec2rad(mod(1287104.79305 + 129596581.0481tdb_c, 1296000))
89+
arcsec2rad(jrem(1287104.79305 + 129596581.0481tdb_c, 1296000))
8590
end
8691

8792
function delaunay_anomaly_sun(::IERS1996, tdb_c::Number)
88-
r = mod(99tdb_c, 1)
89-
mod2pi(arcsec2rad(@evalpoly(tdb_c, 1287099.804, 1292581.224, -0.577, -0.012)) + 2π*r)
93+
r = jrem(99tdb_c, 1)
94+
rem2pi(
95+
arcsec2rad(@evalpoly(tdb_c, 1287099.804, 1292581.224, -0.577, -0.012)) + 2π*r,
96+
RoundNearest
97+
)
9098
end
9199

92100

@@ -97,20 +105,24 @@ Compute the difference between the longitude of the Moon and the longitude of th
97105
node, in radians, given time `tdb_c` expressed in TDB Julian centuries since J2000.
98106
"""
99107
function delaunay_longitude_diff(::IERSAModels, tdb_c::Number)
100-
mod2pi(
101-
arcsec2rad(
102-
@evalpoly(tdb_c, 335779.526232, 1739527262.8478, -12.7512, -0.001037, +0.00000417)
108+
arcsec2rad(
109+
jrem(
110+
@evalpoly(tdb_c, 335779.526232, 1739527262.8478, -12.7512, -0.001037, 0.00000417),
111+
1296000
103112
)
104113
)
105114
end
106115

107116
function delaunay_longitude_diff(::IERSModel, tdb_c::Number)
108-
arcsec2rad(mod(335779.526232 + 1739527262.8478tdb_c, 1296000))
117+
arcsec2rad(jrem(335779.526232 + 1739527262.8478tdb_c, 1296000))
109118
end
110119

111120
function delaunay_longitude_diff(::IERS1996, tdb_c::Number)
112-
r = mod(1342tdb_c, 1)
113-
mod2pi(arcsec2rad(@evalpoly(tdb_c, 335778.877, 295263.137, -13.257, 0.011)) + 2π*r)
121+
r = jrem(1342tdb_c, 1)
122+
rem2pi(
123+
arcsec2rad(@evalpoly(tdb_c, 335778.877, 295263.137, -13.257, 0.011)) + 2π*r,
124+
RoundNearest
125+
)
114126
end
115127

116128
"""
@@ -120,20 +132,24 @@ Compute the mean elongation of the Moon from the Sun, in radians, given time `td
120132
TDB Julian centuries since J2000.
121133
"""
122134
function delaunay_elongation_moon(::IERSAModels, tdb_c::Number)
123-
mod2pi(
124-
arcsec2rad(
125-
@evalpoly(tdb_c, 1072260.703692, 1602961601.2090, -6.3706, 0.006593, -0.00003169)
135+
arcsec2rad(
136+
jrem(
137+
@evalpoly(tdb_c, 1072260.703692, 1602961601.2090, -6.3706, 0.006593, -0.00003169),
138+
1296000
126139
)
127140
)
128141
end
129142

130143
function delaunay_elongation_moon(::IERSModel, tdb_c::Number)
131-
arcsec2rad(mod(1072260.70369 + 1602961601.2090tdb_c, 1296000))
144+
arcsec2rad(jrem(1072260.70369 + 1602961601.2090tdb_c, 1296000))
132145
end
133146

134147
function delaunay_elongation_moon(::IERS1996, tdb_c::Number)
135-
r = mod(1236tdb_c, 1)
136-
mod2pi(arcsec2rad(@evalpoly(tdb_c, 1072261.307, 1105601.328, -6.891, 0.019)) + 2π*r)
148+
r = jrem(1236tdb_c, 1)
149+
rem2pi(
150+
arcsec2rad(@evalpoly(tdb_c, 1072261.307, 1105601.328, -6.891, 0.019)) + 2π*r,
151+
RoundNearest
152+
)
137153
end
138154

139155
"""
@@ -144,18 +160,26 @@ measured from the mean equinox of date, in radians, given time `tdb_c` expressed
144160
centuries since J2000.
145161
"""
146162
function delaunay_longitude_node(::IERSAModels, tdb_c::Number)
147-
mod2pi(
148-
arcsec2rad(
149-
@evalpoly(tdb_c, 450160.398036, -6962890.5431, 7.4722, 0.007702, -0.00005939)
163+
arcsec2rad(
164+
jrem(
165+
@evalpoly(tdb_c, 450160.398036, -6962890.5431, 7.4722, 0.007702, -0.00005939),
166+
1296000
150167
)
151168
)
152169
end
153170

154171
function delaunay_longitude_node(::IERSModel, tdb_c::Number)
155-
arcsec2rad(mod(450160.398036 - 6962890.5431tdb_c, 1296000))
172+
arcsec2rad(jrem(450160.398036 - 6962890.5431tdb_c, 1296000))
156173
end
157174

158175
function delaunay_longitude_node(::IERS1996, tdb_c::Number)
159-
r = mod(-5tdb_c, 1)
160-
mod2pi(arcsec2rad(@evalpoly(tdb_c, 450160.280, -482890.539, 7.455, 0.008)) + 2π*r)
161-
end
176+
r = jrem(-5tdb_c, 1)
177+
rem2pi(
178+
arcsec2rad(@evalpoly(tdb_c, 450160.280, -482890.539, 7.455, 0.008)) + 2π*r,
179+
RoundNearest
180+
)
181+
end
182+
183+
184+
jrem(x, y) = x - y*(x ÷ y)
185+
jrem2pi(x) = jrem(x, 2π)

src/era.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ since `J2000`, according to the IERS convention `m`.
1818
See also [`iers_era_rotm`](@ref).
1919
"""
2020
function iers_era(::IERSModel, ut1_d::Number)
21-
2221
# The function uses the fractional UT1 date to gain additional precision
2322
# in the computations
24-
return mod2pi(2π * (mod(ut1_d, 1) + 0.7790572732640 + 0.00273781191135448ut1_d))
23+
24+
# Uses integer divsion because the `mod` and `rem` functions don't work with ForwardDiff
25+
f = ut1_d - (ut1_d ÷ 1)
26+
return rem2pi(2π * (f + 0.7790572732640 + 0.00273781191135448ut1_d), RoundDown)
2527

2628
end
2729

src/planetary.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Julian centuries since `J2000`.
6868
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/fame03.c) software library
6969
"""
7070
function pa_mercury(::IERSModel, tdb_c::Number)
71-
return mod2pi(@evalpoly(tdb_c, 4.402608842, 2608.7903141574))
71+
return rem2pi(@evalpoly(tdb_c, 4.402608842, 2608.7903141574), RoundNearest)
7272
end
7373

7474
function pa_mercury(::IERS1996, ::Number)
@@ -93,11 +93,11 @@ Julian centuries since `J2000`.
9393
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/fave03.c) software library
9494
"""
9595
function pa_venus(::IERSModel, tdb_c::Number)
96-
return mod2pi(@evalpoly(tdb_c, 3.176146697, 1021.3285546211))
96+
return rem2pi(@evalpoly(tdb_c, 3.176146697, 1021.3285546211), RoundNearest)
9797
end
9898

9999
function pa_venus(::IERS1996, tdb_c::Number)
100-
return mod2pi(deg2rad(@evalpoly(tdb_c, 181.979800853, 58517.8156748)))
100+
return rem2pi(deg2rad(@evalpoly(tdb_c, 181.979800853, 58517.8156748)), RoundNearest)
101101
end
102102

103103

@@ -113,11 +113,11 @@ Julian centuries since `J2000`.
113113
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/fae03.c) software library
114114
"""
115115
function pa_earth(::IERSModel, tdb_c::Number)
116-
return mod2pi(@evalpoly(tdb_c, 1.753470314, 628.3075849991))
116+
return rem2pi(@evalpoly(tdb_c, 1.753470314, 628.3075849991), RoundNearest)
117117
end
118118

119119
function pa_earth(::IERS1996, tdb_c::Number)
120-
return mod2pi(deg2rad(@evalpoly(tdb_c, 100.466448494, 35999.3728521)))
120+
return rem2pi(deg2rad(@evalpoly(tdb_c, 100.466448494, 35999.3728521)), RoundNearest)
121121
end
122122

123123

@@ -133,11 +133,11 @@ Julian centuries since `J2000`.
133133
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/fama03.c) software library
134134
"""
135135
function pa_mars(::IERSModel, tdb_c::Number)
136-
return mod2pi(@evalpoly(tdb_c, 6.203480913, 334.0612426700))
136+
return rem2pi(@evalpoly(tdb_c, 6.203480913, 334.0612426700), RoundNearest)
137137
end
138138

139139
function pa_mars(::IERS1996, tdb_c::Number)
140-
return mod2pi(deg2rad(@evalpoly(tdb_c, 355.433274605, 19140.299314)))
140+
return rem2pi(deg2rad(@evalpoly(tdb_c, 355.433274605, 19140.299314)), RoundNearest)
141141
end
142142

143143

@@ -153,11 +153,11 @@ Julian centuries since `J2000`.
153153
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/faju03.c) software library
154154
"""
155155
function pa_jupiter(::IERSModel, tdb_c::Number)
156-
return mod2pi(@evalpoly(tdb_c, 0.599546497, 52.9690962641))
156+
return rem2pi(@evalpoly(tdb_c, 0.599546497, 52.9690962641), RoundNearest)
157157
end
158158

159159
function pa_jupiter(::IERS1996, tdb_c::Number)
160-
return mod2pi(deg2rad(@evalpoly(tdb_c, 34.3514839, 3034.90567464)))
160+
return rem2pi(deg2rad(@evalpoly(tdb_c, 34.3514839, 3034.90567464)), RoundNearest)
161161
end
162162

163163

@@ -173,11 +173,11 @@ Julian centuries since `J2000`.
173173
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/fasa03.c) software library
174174
"""
175175
function pa_saturn(::IERSModel, tdb_c::Number)
176-
return mod2pi(@evalpoly(tdb_c, 0.874016757, 21.3299104960))
176+
return rem2pi(@evalpoly(tdb_c, 0.874016757, 21.3299104960), RoundNearest)
177177
end
178178

179179
function pa_saturn(::IERS1996, tdb_c::Number)
180-
return mod2pi(deg2rad(@evalpoly(tdb_c, 50.0774713998, 1222.11379404)))
180+
return rem2pi(deg2rad(@evalpoly(tdb_c, 50.0774713998, 1222.11379404)), RoundNearest)
181181
end
182182

183183

@@ -196,7 +196,7 @@ Julian centuries since `J2000`.
196196
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/faur03.c) software library
197197
"""
198198
function pa_uranus(::IERSModel, tdb_c::Number)
199-
return mod2pi(@evalpoly(tdb_c, 5.481293872, 7.4781598567))
199+
return rem2pi(@evalpoly(tdb_c, 5.481293872, 7.4781598567), RoundNearest)
200200
end
201201

202202
function pa_uranus(::IERS1996, ::Number)
@@ -224,7 +224,7 @@ Julian centuries since `J2000`.
224224
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/fane03.c) software library
225225
"""
226226
function pa_neptune(::IERSModel, tdb_c::Number)
227-
return mod2pi(@evalpoly(tdb_c, 5.311886287, 3.8133035638))
227+
return rem2pi(@evalpoly(tdb_c, 5.311886287, 3.8133035638), RoundNearest)
228228
end
229229

230230
function pa_neptune(::IERS1996, ::Number)
@@ -249,9 +249,9 @@ expressed in `TDB` Julian centuries since `J2000`.
249249
- [ERFA](https://github.com/liberfa/erfa/blob/master/src/fapa03.c) software library
250250
"""
251251
function pa_precession(::IERSModel, tdb_c::Number)
252-
return mod2pi(@evalpoly(tdb_c, 0, 0.024381750, 0.00000538691))
252+
return jrem2pi(@evalpoly(tdb_c, 0, 0.024381750, 0.00000538691))
253253
end
254254

255255
function pa_precession(::IERS1996, tdb_c::Number)
256-
return mod2pi(deg2rad(@evalpoly(tdb_c, 0, 1.39697137214, 0.0003086)))
256+
return jrem2pi(deg2rad(@evalpoly(tdb_c, 0, 1.39697137214, 0.0003086)))
257257
end

src/rate.jl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,11 @@ export iers_earth_rot_rate
44
const ωₑ = 7.292_115_146_706_979e-5
55

66
"""
7-
iers_earth_rot_rate(LOD::Number)
7+
iers_earth_rot_rate(LOD::Number=0)
88
99
Compute the true angular velocity of the Earth accounting for the Length of the Day, i.e.,
1010
the instantaneous rate of change of UT1 with respect to a uniform time scale.
1111
"""
12-
function iers_earth_rot_rate(LOD::Number)
12+
function iers_earth_rot_rate(LOD::Number=0)
1313
return ωₑ * (1 - LOD / 86400)
1414
end
15-
16-
"""
17-
iers_earth_rot_rate()
18-
19-
Compute the nominal Earth angular velocity.
20-
"""
21-
iers_earth_rot_rate() = iers_earth_rot_rate(0.0)

src/rotations.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ in TT seconds since `J2000`, following the IERS Conventions `m`.
376376
!!! note
377377
Polar motion is neglected in the [`CPNd`](@ref) model.
378378
379+
!!! note
380+
The time derivative of the nutation and precession effects is neglected.
381+
379382
### References
380383
- IERS Technical Note No. [36](https://www.iers.org/IERS/EN/Publications/TechnicalNotes/tn36.html)
381384
"""
@@ -414,6 +417,9 @@ Reference Frame (GCRF) to the International Terrestrial Reference Frame (ITRF) a
414417
!!! note
415418
Polar motion is neglected in the [`CPNd`](@ref) model.
416419
420+
!!! note
421+
The time derivative of the nutation and precession effects is neglected.
422+
417423
### References
418424
- IERS Technical Note No. [36](https://www.iers.org/IERS/EN/Publications/TechnicalNotes/tn36.html)
419425
"""
@@ -453,6 +459,9 @@ at time `tt_s`, expressed in TT seconds since `J2000`, following the IERS Conven
453459
!!! note
454460
Polar motion is neglected in the [`CPNd`](@ref) model.
455461
462+
!!! note
463+
The time derivative of the nutation and precession effects is neglected.
464+
456465
### References
457466
- IERS Technical Note No. [36](https://www.iers.org/IERS/EN/Publications/TechnicalNotes/tn36.html)
458467
"""

src/sidereal.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ end
118118
# t = TT Julian centuries since J2000
119119
function iers_gmst(::IERS1996, tt_c::Number)
120120

121-
# Transform from TT centuries to UT1 centuries
121+
# Transform from TT centuries to UT1 centuries and days
122122
ut1_c = tt_c + offset_tt2ut1(tt_c*Tempo.CENTURY2SEC)/Tempo.CENTURY2SEC
123+
ut1_d = ut1_c*Tempo.CENTURY2DAY
123124

124125
# Coefficients for the IAU 1982 GMST-UT1 model. The first component has been adjusted
125126
# of 12 hours because the input is defined with respect to noon of 01-01-2000
@@ -129,10 +130,10 @@ function iers_gmst(::IERS1996, tt_c::Number)
129130
D = -6.2e-6
130131

131132
# Fractional part of UT1, in seconds
132-
f = Tempo.DAY2SEC*mod(ut1_c*Tempo.CENTURY2DAY, 1)
133+
f = Tempo.DAY2SEC*(ut1_d - (ut1_d ÷ 1))
133134

134135
# Compute GMST
135-
return mod2pi(2π/86400*(@evalpoly(ut1_c, A, B, C, D) + f))
136+
return rem2pi(2π/86400*(@evalpoly(ut1_c, A, B, C, D) + f), RoundDown)
136137

137138
end
138139

@@ -164,7 +165,7 @@ function iers_gmst(::IERS2003, tt_c::Number, θ::Number)
164165
)
165166

166167
# Compute GMST
167-
return mod2pi+ arcsec2rad(p))
168+
return rem2pi+ arcsec2rad(p), RoundDown)
168169

169170
end
170171

@@ -190,6 +191,6 @@ function iers_gmst(::IERS2010, tt_c::Number, θ::Number)
190191
)
191192

192193
# Compute GMST
193-
return mod2pi+ arcsec2rad(p))
194+
return rem2pi+ arcsec2rad(p), RoundDown)
194195

195196
end

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[deps]
22
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
33
ERFA = "17511681-8477-586a-8d98-4cfd5a1f2ec3"
4+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
45
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
56
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
67
ReferenceFrameRotations = "74f56ac7-18b3-5285-802d-d4bd4f104033"

0 commit comments

Comments
 (0)