tudat-team / tudat

A C++ platform to perform astrodynamics and space research.
BSD 3-Clause "New" or "Revised" License
17 stars 27 forks source link

Date conversion to JD not working before 1970 #161

Open FDahmani opened 1 year ago

FDahmani commented 1 year ago

Hi all, I've noticed some strange behavior with the 'time_conversion.calendar_date_to_julian_day()' function. Specifically, when trying a date before 1970, it simply stops the script without providing any output or error.

Thanks, Fabien

DominicDirkx commented 1 year ago

Hi Fabien, do you have a minimal script that yields this issue? For me the following:

import datetime
from tudatpy.kernel.astro import time_conversion

calendar_date = datetime.datetime(1920, 5, 21, 13, 52, 41)
print(calendar_date)
julian_date = time_conversion.calendar_date_to_julian_day(calendar_date)
print(julian_date)

runs perfectly fine. Does this script run for you?

FDahmani commented 1 year ago

For me, this exact script does not work. It only prints the calendar date and only when choosing a date after 1970 it prints the Julian date as well. I am using VSC and I am running Tudatpy=0.7.3.dev4. Even when running from the shell, the program stops without any output.

DominicDirkx commented 1 year ago

That's very odd... which OS are you using? If I understand you correctly, it prints nothing for a date before 1970, and only the calendar date for a date after 1970?

FDahmani commented 1 year ago

I'm using windows, and no it always prints a calendar date (correct, i.e. the datetime function works well), but only prints a JD after 1970.

DominicDirkx commented 1 year ago

Hi Fabien, if you build a manual kernel with the latest develop branch, and use this for your code, does the issue persist?

FDahmani commented 11 months ago
date = datetime.datetime(1960,1,1,13,7,23,891234)
date_check = time_conversion.calendar_date_to_julian_day(date)
print(date_check,date)

gives

RuntimeError: Error when creating Tudat DateTime, input seconds was -0.108766

date = datetime.datetime(1960,1,1,13,7,23)
date_check = time_conversion.calendar_date_to_julian_day(date)
print(date_check,date)

gives no output

This only happens on Windows for me, in my Linux environment it goes smoothly