How to use the cdflib.epochs.CDFepoch._JulianDay 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
def _LeapSecondsfromYMD(year, month, day):  # @NoSelf
        j = -1
        m = 12 * year + month
        for i, _ in reversed(list(enumerate(CDFepoch.LTS))):
            n = 12 * CDFepoch.LTS[i][0] + CDFepoch.LTS[i][1]
            if m >= n:
                j = i
                break
        if j == -1:
            return 0.0
        da = CDFepoch.LTS[j][3]
        # pre-1972
        if j < CDFepoch.NERA1:
            jda = CDFepoch._JulianDay(year, month, day)
            da = da + ((jda - CDFepoch.MJDbase) - CDFepoch.LTS[j][4]) * CDFepoch.LTS[j][5]
        return da
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
elif ((year > 9999) or (month < 0 or month > 12) or (hour < 0 or hour > 23) or (
                    minute < 0 or minute > 59)
                  or (second < 0 or second > 59) or (msec < 0 or msec > 999) or (usec < 0 or usec > 999) or
                  (nsec < 0 or nsec > 999) or (psec < 0 or psec > 999)):
                epoch = CDFepoch._computeEpoch16(year, month, day, hour,
                                        minute, second, msec,
                                        usec, nsec, psec)
            else:
                if month == 0:
                    if day < 1 or day > 366:
                        epoch = CDFepoch._computeEpoch16(year, month, day, hour, minute, second, msec, usec, nsec, psec)
                else:
                    if day < 1 or day > 31:
                        epoch = CDFepoch._computeEpoch16(year, month, day, hour, minute, second, msec, usec, nsec, psec)
                if month == 0:
                    daysSince0AD = CDFepoch._JulianDay(year, 1, 1) + (day - 1) - 1721060
                else:
                    daysSince0AD = CDFepoch._JulianDay(year, month, day) - 1721060
                secInDay = (3600 * hour) + (60 * minute) + second
                epoch16_0 = float(86400.0 * daysSince0AD) + float(secInDay)
                epoch16_1 = float(psec) + float(1000.0 * nsec) + float(1000000.0 * usec) + float(
                    1000000000.0 * msec)
                epoch.append(epoch16_0)
                epoch.append(epoch16_1)
            cepoch = complex(epoch[0], epoch[1])
            if count == 1:
                if to_np is None:
                    return cepoch
                else:
                    return np.array(cepoch)
            else:
                epochs.append(cepoch)
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
or (second < 0 or second > 59) or (msec < 0 or msec > 999) or (usec < 0 or usec > 999) or
                  (nsec < 0 or nsec > 999) or (psec < 0 or psec > 999)):
                epoch = CDFepoch._computeEpoch16(year, month, day, hour,
                                        minute, second, msec,
                                        usec, nsec, psec)
            else:
                if month == 0:
                    if day < 1 or day > 366:
                        epoch = CDFepoch._computeEpoch16(year, month, day, hour, minute, second, msec, usec, nsec, psec)
                else:
                    if day < 1 or day > 31:
                        epoch = CDFepoch._computeEpoch16(year, month, day, hour, minute, second, msec, usec, nsec, psec)
                if month == 0:
                    daysSince0AD = CDFepoch._JulianDay(year, 1, 1) + (day - 1) - 1721060
                else:
                    daysSince0AD = CDFepoch._JulianDay(year, month, day) - 1721060
                secInDay = (3600 * hour) + (60 * minute) + second
                epoch16_0 = float(86400.0 * daysSince0AD) + float(secInDay)
                epoch16_1 = float(psec) + float(1000.0 * nsec) + float(1000000.0 * usec) + float(
                    1000000000.0 * msec)
                epoch.append(epoch16_0)
                epoch.append(epoch16_1)
            cepoch = complex(epoch[0], epoch[1])
            if count == 1:
                if to_np is None:
                    return cepoch
                else:
                    return np.array(cepoch)
            else:
                epochs.append(cepoch)
        if to_np is None:
            return epochs
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
def _computeEpoch16(y, m, d, h, mn, s, ms, msu, msn, msp):  # @NoSelf
        if m == 0:
            daysSince0AD = CDFepoch._JulianDay(y, 1, 1) + (d - 1) - 1721060
        else:
            if m < 0:
                y -= 1
                m = 13 + m
            daysSince0AD = CDFepoch._JulianDay(y, m, d) - 1721060
        if daysSince0AD < 0:
            print('Illegal epoch')
            return None
        epoch = list()
        epoch.append(float(86400.0 * daysSince0AD + 3600.0 * h + 60.0 * mn) + float(s))
        epoch.append(float(msp) + float(1000.0 * msn) + float(1000000.0 * msu) + math.pow(10.0, 9) * ms)
        if epoch[1] < 0.0 or epoch[1] >= math.pow(10.0, 12):
            if epoch[1] < 0.0:
                sec = int(epoch[1] / math.pow(10.0, 12))
                tmp = epoch[1] - sec * math.pow(10.0, 12)
                if tmp != 0.0 and tmp != -0.0:
                    epoch[0] = epoch[0] + sec - 1
                    epoch[1] = math.pow(10.0, 12.0) + tmp
                else:
                    epoch[0] = epoch[0] + sec
                    epoch[1] = 0.0
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
print('Invalid tt2000 components')
                return None
            if month == 0:
                month = 1
            if year == 9999 and month == 12 and day == 31 and hour == 23 and minute == 59 and second == 59 and \
                    msec == 999 and usec == 999 and nsec == 999:
                nanoSecSinceJ2000 = CDFepoch.FILLED_TT2000_VALUE
            elif year == 0 and month == 1 and day == 1 and hour == 0 and minute == 0 and second == 0 and msec == 0 and \
                    usec == 0 and nsec == 0:
                nanoSecSinceJ2000 = CDFepoch.DEFAULT_TT2000_PADVALUE
            else:
                iy = 10000000 * month + 10000 * day + year
                if iy != CDFepoch.currentDay:
                    CDFepoch.currentDay = iy
                    CDFepoch.currentLeapSeconds = CDFepoch._LeapSecondsfromYMD(year, month, day)
                    CDFepoch.currentJDay = CDFepoch._JulianDay(year, month, day)
                jd = CDFepoch.currentJDay
                jd = jd - CDFepoch.JulianDateJ2000_12h
                subDayinNanoSecs = int(hour * CDFepoch.HOURinNanoSecs +
                                       minute * CDFepoch.MINUTEinNanoSecs +
                                       second * CDFepoch.SECinNanoSecs + msec * 1000000 +
                                       usec * 1000 + nsec)
                nanoSecSinceJ2000 = int(jd * CDFepoch.DAYinNanoSecs +
                                        subDayinNanoSecs)
                t2 = int(CDFepoch.currentLeapSeconds * CDFepoch.SECinNanoSecs)
                if nanoSecSinceJ2000 < 0:
                    nanoSecSinceJ2000 = int(nanoSecSinceJ2000 + t2)
                    nanoSecSinceJ2000 = int(nanoSecSinceJ2000 +
                                            CDFepoch.dTinNanoSecs)
                    nanoSecSinceJ2000 = int(nanoSecSinceJ2000 -
                                            CDFepoch.T12hinNanoSecs)
                else: