1717 */
1818package org .aavso .tools .vstar .util .date ;
1919
20- import junit .framework .TestCase ;
21-
20+ import org .aavso .tools .vstar .util .Tolerance ;
2221import org .aavso .tools .vstar .util .coords .DecInfo ;
2322import org .aavso .tools .vstar .util .coords .EpochType ;
2423import org .aavso .tools .vstar .util .coords .RAInfo ;
2524
25+ import junit .framework .TestCase ;
26+
2627/**
2728 * J2000HJDConverter unit tests.
2829 */
@@ -154,8 +155,9 @@ public void testJulianCenturiesEx24a() {
154155
155156 public void testEccentricityEx24a () {
156157 double T = julianCenturiesEx24a ();
157- double eDegs = Math .toDegrees (converter .eccentricity (T ));
158- assertEquals ("0.016711651" , getNumToPrecision (eDegs , 9 ));
158+ // Eccentricity is dimensionless (Meeus 24.4).
159+ double e = converter .eccentricity (T );
160+ assertEquals ("0.016711651" , getNumToPrecision (e , 9 ));
159161 }
160162
161163 public void testSolarCoordsEx24a () {
@@ -174,25 +176,27 @@ public void testSolarCoordsEx24a() {
174176 double CDegs = Math .toDegrees (coords .getEquationOfCenter ());
175177 assertEquals ("-1.89732" , getNumToPrecision (CDegs , 5 ));
176178
177- // Meeus gives 198.38082, so we differ by 0.00001
178- assertEquals ("198.38083" , getNumToPrecision (coords .getApparentRA (), 5 ));
179-
180- // Meeus gives -7.78507, so we differ by 0.00003
181- assertEquals ("-7.78504" , getNumToPrecision (coords .getApparentDec (), 5 ));
179+ // Meeus gives 198.38082, and when previously using true solar longitude
180+ // instead of J2000-corrected true solar longitude, we differed from Meeus
181+ // by 0.00001 (198.38083). With J2000 correction, the apparent RA is
182+ // 198.48529 instead. Example 24.a in Meeus does not show the result with
183+ // J2000 correction. These values are consistent with subsequent improved
184+ // HJD conversion accuracy.
185+ assertEquals ("198.48529" , getNumToPrecision (coords .getApparentRA (), 5 ));
186+
187+ // Meeus gives -7.78507, and when previously using true solar longitude
188+ // instead of J2000-corrected true solar longitude, we differed from Meeus
189+ // by by 0.00003 (-7.78504). With J2000 correction, the apparent Dec is
190+ // -7.82721 instead. Example 24.a in Meeus does not show the result with
191+ // J2000 correction. These values are consistent with subsequent improved
192+ // HJD conversion accuracy.
193+ assertEquals ("-7.82721" , getNumToPrecision (coords .getApparentDec (), 5 ));
182194
183- // Not provided in Meeus, but not wildly at odds with apparent RA.
184195 double ra = coords .getRA ();
185- assertEquals ("198.38167" , getNumToPrecision (ra , 5 ));
186- // When Sun's longitude is referred to standard equinox of J2000.0
187- // (trueSolarLong2000).
188- // assertEquals("198.48617", getNumToPrecision(ra, 5));
196+ assertEquals ("198.48613" , getNumToPrecision (ra , 5 ));
189197
190- // Not provided in Meeus, but not wildly at odds with apparent Dec.
191198 double dec = coords .getDec ();
192- assertEquals ("-7.78546" , getNumToPrecision (dec , 5 ));
193- // When Sun's longitude is referred to standard equinox of J2000.0
194- // (trueSolarLong2000).
195- // assertEquals("-7.82756", getNumToPrecision(dec, 5));
199+ assertEquals ("-7.82764" , getNumToPrecision (dec , 5 ));
196200 }
197201
198202 public void testRadiusVectorEx24a () {
@@ -204,9 +208,8 @@ public void testRadiusVectorEx24a() {
204208
205209 double R = converter .radiusVector (T , coords .getTrueAnomaly (),
206210 coords .getEquationOfCenter ());
207- // Meeus Ex 24.a gives R = 0.99766, whereas we have R = 0.99996.
208- // Is this an error in Meeus or in our computation?
209- assertEquals ("0.99996" , getNumToPrecision (R , 5 ));
211+ // Meeus Ex 24.a, p 153: R = 0.99766 AU (requires eccentricity as dimensionless).
212+ assertEquals ("0.99766" , getNumToPrecision (R , 5 ));
210213 }
211214
212215 private double julianCenturiesEx24a () {
@@ -233,7 +236,7 @@ public void testHJDRCar1() {
233236 // to 2448908.49782, whereas the convert() method gives
234237 // 2448908.497815484, the same to 5 decimal places (~1/100th of a
235238 // second).
236- assertEquals ( " 2448908.49782" , getNumToPrecision ( hjd , 5 ));
239+ assertTrue ( Tolerance . areClose ( 2448908.4978207937 , hjd , 1e-5 , true ));
237240 }
238241
239242 // R Car with JD2
@@ -251,7 +254,8 @@ public void testHJDRCar2() {
251254 // to 2457501.86943, whereas the convert() method gives
252255 // 2457501.8694125116, the same to 4 decimal places (~1/10th of a
253256 // second).
254- assertEquals ("2457501.86941" , getNumToPrecision (hjd , 5 ));
257+ // Corrected radius vector (eccentricity dimensionless) matches BAA to ~0.01 day.
258+ assertTrue (Tolerance .areClose (2457501.869426729 , hjd , 1e-5 , true ));
255259 }
256260
257261 // X Sgr with Meeus's Ex24.a JD
@@ -268,7 +272,8 @@ public void testHJDXSgr1() {
268272 // entry for R Car. That gave the result 2448908.4977766555, shortened
269273 // to 2448908.49778, whereas the convert() method gives
270274 // 2448908.497780874.
271- assertEquals ("2448908.49778" , getNumToPrecision (hjd , 5 ));
275+ // Corrected radius vector; result within ~1 s of BAA.
276+ assertTrue (Tolerance .areClose (2448908.4977766555 , hjd , 1e-5 , true ));
272277 }
273278
274279 // X Sgr with JD2
@@ -285,7 +290,8 @@ public void testHJDXSgr2() {
285290 // entry for R Car. That gave the result 2457501.8707473096, shortened
286291 // to 2457501.87075, whereas the convert() method gives
287292 // 2457501.870747149.
288- assertEquals ("2457501.87075" , getNumToPrecision (hjd , 5 ));
293+ // Corrected radius vector; result within ~1 s of BAA.
294+ Tolerance .areClose (2457501.8707473096 , hjd , 1e-5 , true );
289295 }
290296
291297 // Sig Oct with Meeus's Ex24.a JD
@@ -302,7 +308,7 @@ public void testHJDSigOct1() {
302308 // entry for R Car. That gave the result 2448908.4992657346, shortened
303309 // to 2448908.49927, whereas the convert() method gives
304310 // 2448908.499268005.
305- assertEquals ( " 2448908.49927" , getNumToPrecision ( hjd , 5 ));
311+ assertTrue ( Tolerance . areClose ( 2448908.4992657346 , hjd , 1e-5 , true ));
306312 }
307313
308314 // Sig Oct with JD2
@@ -319,7 +325,8 @@ public void testHJDSigOct2() {
319325 // entry for R Car. That gave the result 2457501.8685732614, shortened
320326 // to 2457501.86857, whereas the convert() method gives
321327 // 2457501.868574388.
322- assertEquals ("2457501.86857" , getNumToPrecision (hjd , 5 ));
328+ // Corrected radius vector; result within ~1 s of BAA.
329+ assertTrue (Tolerance .areClose (2457501.8685732614 , hjd , 1e-5 , true ));
323330 }
324331
325332 // Helpers
0 commit comments