How to use the cdflib.epochs.CDFepoch.compute_epoch 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
return None
        if starttime is None:
            stime = 0.0
        else:
            if isinstance(starttime, float) or isinstance(starttime, int) or isinstance(starttime, np.float64):
                stime = starttime
            elif isinstance(starttime, list) or isinstance(starttime, tuple):
                stime = CDFepoch.compute_epoch(starttime)
            else:
                print('Bad start time')
                return None
        if endtime is not None:
            if isinstance(endtime, float) or isinstance(endtime, int) or isinstance(endtime, np.float64):
                etime = endtime
            elif isinstance(endtime, list) or isinstance(endtime, tuple):
                etime = CDFepoch.compute_epoch(endtime)
            else:
                print('Bad end time')
                return None
        else:
            etime = 1.0E31
        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 len(value) == 23:
                # CDF_EPOCH
                if value.lower() == '9999-12-31t23:59:59.999' or value.lower() == '9999-12-31 23:59:59.999':
                    return -1.0E31
                else:
                    date = re.findall('(\d+)\-(\d+)\-(\d+)T(\d+)\:(\d+)\:(\d+)\.(\d+)', value)
                    if not date:
                        date = re.findall('(\d+)\-(\d+)\-(\d+) (\d+)\:(\d+)\:(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\d+)', value)
                    yy = int(date[0][0])
                    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])
                    ms = int(date[0][6])
                return CDFepoch.compute_epoch([yy, mm, dd, hh, mn, ss, ms])
            elif len(value) == 35 or (len(value) == 32):
                # CDF_EPOCH16
                if value.lower() == '9999-12-31 23:59:59.999.999.999.999' or value.lower() == \
                        '9999-12-31t23:59:59.999999999999':
                    return -1.0E31 - 1.0E31j
                else:
                    date = re.findall('(\d+)\-(\d+)\-(\d+)T(\d+)\:(\d+)\:(\d+)\.(\d+)', value)
                    if not date:
                        date = re.findall('(\d+)\-(\d+)\-(\d+) (\d+)\:(\d+)\:(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\d+)', value)
                    yy = int(date[0][0])
                    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:
github MAVENSDC / cdflib / cdflib / epochs.py View on Github external
if (isinstance(epochs[0], float) or
                    isinstance(epochs[0], np.float64)):
                new_epochs = epochs
            else:
                print('Bad data')
                return None
        else:
            print('Bad data')
            return None
        if starttime is None:
            stime = 0.0
        else:
            if isinstance(starttime, float) or isinstance(starttime, int) or isinstance(starttime, np.float64):
                stime = starttime
            elif isinstance(starttime, list) or isinstance(starttime, tuple):
                stime = CDFepoch.compute_epoch(starttime)
            else:
                print('Bad start time')
                return None
        if endtime is not None:
            if isinstance(endtime, float) or isinstance(endtime, int) or isinstance(endtime, np.float64):
                etime = endtime
            elif isinstance(endtime, list) or isinstance(endtime, tuple):
                etime = CDFepoch.compute_epoch(endtime)
            else:
                print('Bad end time')
                return None
        else:
            etime = 1.0E31
        if stime > etime:
            print('Invalid start/end time')
            return None