Converting Julian Date to Barycentric Julian Date

Is there a process or script in PI that will convert an image's Julian Date (JD) to a Barycentric Julian Date (BJD) and put it into the image header?
 
The BJD depends on the distance to the object observed, and the relative direction to the sun (actually to the solar system barycentre), so you would have to enter this additional data (Pixinsight could not derive it from the usual header content). Since you are only likely to need to use BJD if you are doing accurate astrometry, you will usually have a good enough approximation to the object distance. I'm not aware of any PI script to support this.
 
The following JavaScript function should give you a good approximation to the BJD:

JavaScript:
/*
 * Compute an approximation to the Barycentric Julian Date (BJD) for the
 * specified time point and position vector.
 *
 * time        The required time point. Can be either a Date object, a string
 *             in ISO 8601 format, or a Julian Date (JD).
 *
 * pos         A Vector object whose components are the geocentric equatorial
 *             coordinates of the observed object.
 *
 * distance    Distance to the object in au. If not specified or a value <= 0
 *             is specified, the object is assumed to be at infinite distance.
 *
 * timescale   The timescale. Can be one of "TT", "TDB", "Teph", "UTC", "TAI"
 *             and "UT". If not specified, UTC is assumed.
 *
 * Returns the approximate BJD in the specified timescale, neglecting
 * relativistic corrections and assuming a geocentric observer.
 */
function BJD( time, pos, distance, timescale )
{
   // Time point as a JD
   if ( typeof( time ) === "string" )
      time = new Date( time );
   if ( time instanceof Date )
   {
      let year = t.getUTCFullYear();
      let month = t.getUTCMonth() + 1;
      let day = t.getUTCDate() + 1;
      let dayf = (t.getUTCHours() + (t.getUTCMinutes() + (t.getUTCSeconds() + t.getUTCMilliseconds()/1000)/60)/60)/24;
      time = Math.complexTimeToJD( year, month, day, dayf );
   }

   // Object at infinite distance by default
   if ( distance === undefined )
      distance = 0;     
   // UTC timescale by default
   if ( timescale === undefined )
      timescale = "UTC";

   // Compute positions for the specified time and timescale
   var P = new Position( time, timescale );
   // Barycentric position vector of the geocenter
   var r = P.barycentricPositionOfEarth;
   // Unit vector in the direction of the observed object
   var u = pos.unit();
   // BJD correction
   var d;
   if ( distance > 0 )
   {
      // Known distance to object
      u.mul( distance );
      r.add( u );
      d = r.l2norm() - distance;
   }
   else
   {
      // Infinite distance
      d = r.dot( u );
   }

   const au_km    = 149597870.7;          // astronomical unit (km)
   const c_km_s   = 299792.458;           // speed of light (km/s)
   const c_au_day = (c_km_s/au_km)*86400; // speed of light (au/day)

   return time + d/c_au_day;
}

I have no time right now to verify the results of this function (or even if it works correctly), but this is the idea. As you probably know, PixInsight integrates state-of-the-art solar system ephemerides and reduction of positions since version 1.8.6. I'll check the function with actual data as soon as I can.
 
As a really nerdy academic point, the line:
Code:
d = r.l2norm() - distance;
risks a loss of precision problem if distance > 10,000AU (assuming double precision calculations).
There is an alternative formula for this, but I doubt if any PI users are doing astrometry on Oort cloud objects;)! (just use infinite distance).
 
Hi Fred,

Not nerdy at all; you've pointed out an important flaw here. Indeed, if the distance to the observed object is much larger than the distance Earth-Sun, the computed correction can be meaningless. For serious work with very distant objects the above implementation is not valid. For serious astrometry relativistic effects should also be taken into account. Definitely, we have everything necessary to implement calculation of the BJD rigorously in PixInsight; the code above is just a rough proof of concept.
 
The usual fix for this problem is to use the first couple of terms of an asymptotic approximation (i.e. the Taylor series as a function of 1/distance). I believe this is accurate to ~1ms at stellar distances.
 
"As you probably know ... ". Actually, I don't know. This script fragment reveals a collection of types and methods I've never seen before. I'd love to find out more about the functionality available in PI scripts, but, as I've said before, there is no documentation (and I really don't have time to mine the information by reverse engineering hundreds of random scripts - which may or may not be usefully commented).
 
Back
Top