astronomy-bundle-js icon indicating copy to clipboard operation
astronomy-bundle-js copied to clipboard

UT and DT are mixed up

Open hjy1210 opened this issue 4 years ago • 1 comments

Issue: UT and DT are mixed

Problem 1

Someone browsed to timeanddate, got 2021 Vernal Equinox at 2021/3/20 9:37.

He want use astronomy-bundle to check above data。

He perform first experiment,

async function testEquinox(){
    let toi1 = createTimeOfInterest.fromTime(2021, 3, 20, 9, 36, 0)
    let toi2 = createTimeOfInterest.fromTime(2021, 3, 20, 9, 37, 0)
    let toi3 = createTimeOfInterest.fromTime(2021, 3, 20, 9, 38, 0)
    let sun1 = createSun(toi1)
    let sun2 = createSun(toi2)
    let sun3 = createSun(toi3)
    let position1 = await sun1.getApparentGeocentricEclipticSphericalCoordinates();
    let position2 = await sun2.getApparentGeocentricEclipticSphericalCoordinates();
    let position3 = await sun3.getApparentGeocentricEclipticSphericalCoordinates();
    console.log(position1.lon, position2.lon, position3.lon) // -0.0017761217740727689 -0.0010860381094624687 -0.00039595474322699515
}
testEquinox() // -0.0017761217740727689 -0.0010860381094624687 -0.00039595474322699515

He was not satisfied with the result, according to computation, 2021 Vernal Equinox should be after 2021/3/20 9:38 UT!

He suspect astronomy-bundle misused DT with UT.

After implement two utility functions

function Ut2Dt(toi){
    return createTimeOfInterest.fromJulianDay(toi.jd + toi.getDeltaT()/86400)
}
function Dt2Ut(toi){
    return createTimeOfInterest.fromJulianDay(toi.jd - toi.getDeltaT()/86400)
}

He perform second experiment,

async function testEquinox2(){
    let toi1 = createTimeOfInterest.fromTime(2021, 3, 20, 9, 36, 0)
    let toi2 = createTimeOfInterest.fromTime(2021, 3, 20, 9, 37, 0)
    let toi3 = createTimeOfInterest.fromTime(2021, 3, 20, 9, 38, 0)
    let sun1 = createSun(Ut2Dt(toi1))
    let sun2 = createSun(Ut2Dt(toi2))
    let sun3 = createSun(Ut2Dt(toi3))
    let position1 = await sun1.getApparentGeocentricEclipticSphericalCoordinates();
    let position2 = await sun2.getApparentGeocentricEclipticSphericalCoordinates();
    let position3 = await sun3.getApparentGeocentricEclipticSphericalCoordinates();
    console.log(position1.lon, position2.lon, position3.lon)
}
testEquinox2() // -0.0009480212285894601 -0.00025793791893701564 0.0004321450841539218

He IS satisfied with the result, 2021 Vernal Equinox should be between 2021/3/20 9:37 and 9:38 and more close to 9:37 UT!

Problem 2

He browsed to eclipse.gsfc.nasa.gov, get moon phase result

2021/1/13 05:00	New Moon
2021/1/20 21:02	First Quarter
2021/1/28 19:16	Full Moon
2021/2/04 17:37	Last Quarter

Use following snippet to check

function testMoonPhase(year, month, day, hour, min, sec) {
    let toi = createTimeOfInterest.fromTime(year, month, day, hour, min, sec)
    console.log("now", toi.time)
    let moon = createMoon(toi)
    let moon2 = createMoon(Ut2Dt(toi))
    console.log("upcoming new moon", moon.getUpcomingNewMoon().time)
    console.log("adjusted upcoming new moon", Dt2Ut(moon2.getUpcomingNewMoon()).time)
    console.log("upcoming first quarter", moon.getUpcomingFirstQuarter().time)
    console.log("adjust upcoming first quarter", Dt2Ut(moon2.getUpcomingFirstQuarter()).time)
    console.log("upcoming full moon", moon.getUpcomingFullMoon().time)
    console.log("adjusted upcoming full moon", Dt2Ut(moon2.getUpcomingFullMoon()).time)
    console.log("upcoming last quarter", moon.getUpcomingLastQuarter().time)
    console.log("adjusted upcoming last quarter", Dt2Ut(moon2.getUpcomingLastQuarter()).time)
}
testMoonPhase(2021,1,20,3,10,0)
// now { year: 2021, month: 1, day: 20, hour: 3, min: 10, sec: 0 }
// upcoming new moon { year: 2021, month: 1, day: 13, hour: 5, min: 1, sec: 33 }
// adjusted upcoming new moon { year: 2021, month: 1, day: 13, hour: 5, min: 0, sec: 20 }
// upcoming first quarter { year: 2021, month: 1, day: 20, hour: 21, min: 3, sec: 15 }
// adjust upcoming first quarter { year: 2021, month: 1, day: 20, hour: 21, min: 2, sec: 2 }
// upcoming full moon { year: 2021, month: 1, day: 28, hour: 19, min: 17, sec: 33 }
// adjusted upcoming full moon { year: 2021, month: 1, day: 28, hour: 19, min: 16, sec: 20 }
// upcoming last quarter { year: 2021, month: 2, day: 4, hour: 17, min: 38, sec: 17 }
// adjusted upcoming last quarter { year: 2021, month: 2, day: 4, hour: 17, min: 37, sec: 4 }

He concluded astronomy-bundle mixed UT with DT(dynamical time).

Conclusion

I think

  • all(most) of computations in Meeus is using time in dynamical time scale.
  • User use functions such as getUpcomingNewMoon, getApparentGeocentricEclipticSphericalCoordinates for daily use, ordinarily use universal time as time scale.

Suggestions for astronomy-bundle:

  • input/output time in universal time scale.
  • during internal computation, use dynamical time scale.
  • may be add property jde(in addition to original jd) in ITime is an option.

hjy1210 avatar Jan 20 '21 14:01 hjy1210

typo error: may be add property jde(in addition to original jd) in TimeOfInterest is an option.

hjy1210 avatar Jan 20 '21 22:01 hjy1210