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

Re: [Orekit Users] pyhelpers.py error in absolutedate_to_datetime



Hi,

Many thanks for spotting this, this is now updated in the repository!

Best Regards
/Petrus


On Tue, Nov 1, 2016 at 4:34 PM, Glenn Ehrlich <glenn.ehrlich@gmail.com> wrote:
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



--
_____________________________________________
Petrus Hyvönen, Uppsala, Sweden
Mobile Phone/SMS:+46 73 803 19 00