How to use the cdflib.epochs.CDFepoch.compute_tt2000 function in cdflib

To help you get started, we’ve selected a few cdflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
tmpNanosecs = CDFepoch.compute_tt2000(xdate1)
                if tmpNanosecs != t3:
                    dat0 = CDFepoch._LeapSecondsfromYMD(xdate1[0],
                                               xdate1[1], xdate1[2])
                    tmpx = t2 - int(dat0 * CDFepoch.SECinNanoSecs)
                    tmpy = int((1.0 * tmpx) / CDFepoch.SECinNanoSecsD)
                    nansec = int(tmpx - tmpy * CDFepoch.SECinNanoSecs)
                    if nansec < 0:
                        nansec = CDFepoch.SECinNanoSecs + nansec
                        tmpy = tmpy - 1
                    epoch = tmpy + CDFepoch.J2000Since0AD12hSec
                    xdate1 = CDFepoch._EPOCHbreakdownTT2000(epoch)
                    xdate1.append(0)
                    xdate1.append(0)
                    xdate1.append(nansec)
                    tmpNanosecs = CDFepoch.compute_tt2000(xdate1)
                    if tmpNanosecs != t3:
                        dat0 = CDFepoch._LeapSecondsfromYMD(xdate1[0],
                                                   xdate1[1],
                                                   xdate1[2])
                        tmpx = t2 - int(dat0 * CDFepoch.SECinNanoSecs)
                        tmpy = int((1.0 * tmpx) / CDFepoch.SECinNanoSecsD)
                        nansec = int(tmpx - tmpy * CDFepoch.SECinNanoSecs)
                        if nansec < 0:
                            nansec = CDFepoch.SECinNanoSecs + nansec
                            tmpy = tmpy - 1
                        epoch = tmpy + CDFepoch.J2000Since0AD12hSec
                        # One more determination
                        xdate1 = CDFepoch._EPOCHbreakdownTT2000(epoch)
                ye1 = int(xdate1[0])
                mo1 = int(xdate1[1])
                da1 = int(xdate1[2])
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
return None
        if starttime is None:
            stime = int(-9223372036854775807)
        else:
            if isinstance(starttime, int) or isinstance(starttime, np.int64):
                stime = starttime
            elif isinstance(starttime, list):
                stime = CDFepoch.compute_tt2000(starttime)
            else:
                print('Bad start time')
                return None
        if endtime is not None:
            if isinstance(endtime, int) or isinstance(endtime, np.int64):
                etime = endtime
            elif isinstance(endtime, list) or isinstance(endtime, tuple):
                etime = CDFepoch.compute_tt2000(endtime)
            else:
                print('Bad end time')
                return None
        else:
            etime = int(9223372036854775807)
        if stime > etime:
            print('Invalid start/end time')
            return None
        if isinstance(new_epochs, list) or isinstance(new_epochs, tuple):
            new_epochs2 = np.array(new_epochs)
        else:
            new_epochs2 = new_epochs
        return np.where(np.logical_and(new_epochs2 >= stime, new_epochs2 <= etime))[0]
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
if not isinstance(datetimes, (list, tuple, np.ndarray)):
            raise TypeError('datetime must be in list form')
        if isinstance(datetimes[0], numbers.Number):
            items = len(datetimes)
        elif isinstance(datetimes[0], (list, tuple, np.ndarray)):
            items = len(datetimes[0])
        else:
            print('Unknown input')
            return
        if items == 7:
            return CDFepoch.compute_epoch(datetimes, to_np)
        elif items == 10:
            return CDFepoch.compute_epoch16(datetimes, to_np)
        elif items == 9:
            return CDFepoch.compute_tt2000(datetimes, to_np)
        else:
            print('Unknown input')
            return
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
def _LoadLeapNanoSecondsTable():  # @NoSelf
        NST = list()
        for ix in range(0, CDFepoch.NERA1):
            NST.append(CDFepoch.FILLED_TT2000_VALUE)
        for ix in range(CDFepoch.NERA1, CDFepoch.NDAT):
            NST.append(CDFepoch.compute_tt2000(
                [int(CDFepoch.LTS[ix][0]), int(CDFepoch.LTS[ix][1]), int(CDFepoch.LTS[ix][2]), 0, 0, 0, 0, 0, 0]))
        return NST
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
mm = int(date[0][1])
                    dd = int(date[0][2])
                    hh = int(date[0][3])
                    mn = int(date[0][4])
                    ss = int(date[0][5])
                    if len(date[0]) == 7:
                        subs = int(date[0][6])
                        ms = int(subs / 1000000)
                        subms = int(subs % 1000000)
                        us = int(subms / 1000)
                        ns = int(subms % 1000)
                    else:
                        ms = int(date[0][6])
                        us = int(date[0][7])
                        ns = int(date[0][8])
                return CDFepoch.compute_tt2000([yy, mm, dd, hh, mn, ss, ms, us, ns])
            else:
                print('Invalid cdf epoch type...')
                return None
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
elif isinstance(epochs, list) or isinstance(epochs, tuple) or isinstance(epochs, np.ndarray):
            if isinstance(epochs[0], int) or isinstance(epochs[0], np.int64):
                new_epochs = epochs
            else:
                print('Bad data')
                return None
        else:
            print('Bad data')
            return None
        if starttime is None:
            stime = int(-9223372036854775807)
        else:
            if isinstance(starttime, int) or isinstance(starttime, np.int64):
                stime = starttime
            elif isinstance(starttime, list):
                stime = CDFepoch.compute_tt2000(starttime)
            else:
                print('Bad start time')
                return None
        if endtime is not None:
            if isinstance(endtime, int) or isinstance(endtime, np.int64):
                etime = endtime
            elif isinstance(endtime, list) or isinstance(endtime, tuple):
                etime = CDFepoch.compute_tt2000(endtime)
            else:
                print('Bad end time')
                return None
        else:
            etime = int(9223372036854775807)
        if stime > etime:
            print('Invalid start/end time')
            return None