[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orekit Users] pyhelpers.py error in absolutedate_to_datetime



Folks,

There’s a minor error in the python wrapper pyhelpers.py function absolutedate_to_datetime. The 7th argument to the python datetime constructor is microseconds not milliseconds. See https://docs.python.org/2/library/datetime.html#.

The fix is to change multiplying by 1000.0 to 1000000.0

The code from pyhelpers.py:

def absolutedate_to_datetime(orekit_absolutedate):
    ''' Converts between orekit.AbsoluteDate objects
    and python datetime objects (utc)'''

    utc = TimeScalesFactory.getUTC()
    or_comp = orekit_absolutedate.getComponents(utc)
    or_date = or_comp.getDate()
    or_time = or_comp.getTime()
    seconds = or_time.getSecond()
    return datetime(or_date.getYear(),
                    or_date.getMonth(),
                    or_date.getDay(),
                    or_time.getHour(),
                    or_time.getMinute(),
                    int(math.floor(seconds)),
                    int(1000.0 * (seconds - math.floor(seconds)))) # glenn: change 1000.0 to 1000000.0

Glenn