Friday, June 13, 2025

Date Conversion in VStar

Currently, VStar's "JD to BJD_TDB" and "BJD_TDB Converter" plug-ins rely on the Ohio State University time conversion service (see https://astroutils.astronomy.osu.edu/time/). like the "HJD Converter" plug-in, they do not have an intrinsic (built-in) conversion procedure. This makes the converter strictly dependent on internet services, which may sometimes be unavailable.

An obvious solution is to create a local conversion procedure. An example of this approach is the AstroImageJ software, which uses a flexible method: it can utilize both local and internet-based time conversion services, including the one mentioned above.

However, this is like reinventing the wheel. I propose an approach (perhaps not very elegant) that uses a Python microservice, allowing us to leverage the AstroPy library for the conversion.

With this approach, we do not need constantly available internet services (and even the internet connection). AstroPy loads the required ephemeris files once at startup (and probably updates them periodically). After that, an internet connection is no longer required.

In the development build (https://drive.google.com/drive/folders/1ctXp1Ddb5BK9YdFuUg1XCRW0Lm308BRi) I included the modified "JD to BJD_TDB" and "BJD_TDB Converter" plug-ins, and a Python (Flask) micro-service.

To install it under Linux:

1) Download vstar-bash.zip and vstar-plugins.zip.

2) Unpack the archives into your home directory.

3) Create the .vstar sub-directory in your home dir.

4) Copy a file vstar.properties from the vstar directory to .vstar

5) Open .vstar/vstar.properties in a text editor and set the value of the localJDconverter.active parameter to y.

Then navigate to vstar/PyMicroService/ and run "astro_time_convert.py":

>python astro_time_convert.py

Prerequisites: AstroPy and Flask packages must be installed. I installed Anaconda, which already contains these packages preinstalled.

After a successful launch, you should see something like this:

You may ignore the warning; it simply means that you are running a single-threaded internal Flask web server, which is perfectly sufficient for our needs.

To test the microservice,  run VStar, load some data (for example, V405 Dra, all times, Johnson V). Invoke the [Tools] -> [BJD_TDB Converter] command and press OK.

In a few seconds, you should see the following message (number of observations may differ):

You can try deactivating the local service (via vstar.properties), restarting VStar, and attempting the conversion again (the Ohio State University service will be used).





1 comment: