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).





Wednesday, May 14, 2025

A Python script for downloading TESS light curves as text files

[Revised 2025-07-06] 

Generally, TESS light curves are accessible via the MAST portal, which provides references to FITS files containing light curves in the standard TESS-SPOC format, the QLP format, and other variations (such as TASOC). FITS files in the TESS-SPOC and QLP formats can be read using VStar software. However, some other useful software packages (e.g., MCV by I. L. Andronov) do not support FITS files. 

To streamline the use of TESS data in programs that cannot directly read FITS files, an interactive Python script, TESSdata.py, was developed. It is a part of the 'Light Curve Viewer' project, and can be used completely independently.

The script requires the Lightkurve package, which can be installed using pip

>pip install lightkurve

 Upon launching TESSdata.py, the user is presented with the following text menu:



To select a star of interest, the user must press '1' and then ENTER. After that, they must enter either the star's name or its coordinates (RA and Dec):

After pressing ENTER, the program attempts to load a list of available light curves for the TESS mission. This process may take some time. If a network error occurs at this step, simply retry. Once loading is successful, the following extended menu appears:

 

Press '2' and then ENTER to view the list of available light curves:

 


To load one or more light curves, use menu options '3' or '4'. Option '3' loads observations as fluxes without any transformation. Please note that the units in which the fluxes are measured may vary depending on the data 'flavor' (see the 'author' column). Option '4' additionally transforms fluxes into TESS magnitudes, assuming that the median star magnitude corresponds to the TESSMAG parameter of the light curve. Note: Sometimes, the data contains negative fluxes (this is common in TASOC data). In this case, the conversion to magnitudes causes an error.

Let's load QLP light curves for sectors 58 and 59 as TESS magnitudes. To do this, press '4' and enter the numbers of the required light curves (found in the leftmost column of the table):


If a network error occurs, simply repeat the step.

After successfully loading the data, additional information appears at the top: the numbers of the light curves, the magnitude of the star, and other relevant details:

Now, the user can preview the data by selecting menu option '6'. An interactive plot will then be displayed:


To continue, close the plot window.

Now, the data can be saved to a text file. To do this, select menu option '5'. The user can either enter a file name directly or press '?' to open the file chooser:


The file is saved in text format, with an additional header that follows the Flexible Text Format used in VStar:

  

This format is recognized by MCV software:


 Also, data in this format can be read by VStar (via the Flexible Text plug-in):

 

and LCV:

 


Note: The current version of TESSdata.py attempts to extract flux errors, which are converted to magnitude errors during the transformation to magnitudes. Lightkurve version 2.4.2 does not provide error values, whereas version 2.5.0 does.