How to use the cdflib.epochs_astropy.CDFAstropy.compute 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 / tests / test_astropy_epochs.py View on Github external
def test_compute_cdfepoch():
    '''
    Using random numbers for the compute tests
    '''
    random_time = []
    random_time.append(randint(0, 2018))  # Year
    random_time.append(randint(1, 12))  # Month
    random_time.append(randint(1, 28))  # Date
    random_time.append(randint(0, 23))  # Hour
    random_time.append(randint(0, 59))  # Minute
    random_time.append(randint(0, 59))  # Second
    random_time.append(randint(0, 999))  # Millisecond
    x = cdfepoch.breakdown(cdfepoch.compute(random_time))
    i = 0
    for t in x[0]:
        assert t == random_time[i], 'Time {} was not equal to {}'.format(random_time, x)
        i += 1
github MAVENSDC / cdflib / tests / test_astropy_epochs.py View on Github external
def test_findepochrange_cdfepoch():
    start_time = "2013-12-01 12:24:22.000"
    end_time = "2014-12-01 12:24:22.000"
    x = cdfepoch.parse([start_time, end_time])
    time_array = np.arange(x[0], x[1], step=1000000)

    test_start = [2014, 8, 1, 8, 1, 54, 123]
    test_end = [2018, 1, 1, 1, 1, 1, 1]
    index = cdfepoch.findepochrange(time_array, starttime=test_start, endtime=test_end)
    # Test that the test_start is less than the first index, but more than one less
    assert time_array[index[0]] >= cdfepoch.compute(test_start)
    assert time_array[index[0]-1] <= cdfepoch.compute(test_start)

    assert time_array[index[-1]] <= cdfepoch.compute(test_end)
github MAVENSDC / cdflib / tests / test_astropy_epochs.py View on Github external
def test_findepochrange_cdftt2000():
    start_time = "2004-03-01 12:24:22.351793238"
    end_time = "2004-03-01 12:28:22.351793238"
    x = cdfepoch.parse([start_time, end_time])
    time_array = np.arange(x[0], x[1], step=1000000)

    test_start = [2004, 3, 1, 12, 25, 54, 123, 111, 98]
    test_end = [2004, 3, 1, 12, 26, 4, 123, 456, 789]
    index = cdfepoch.findepochrange(time_array, starttime=test_start, endtime=test_end)
    # Test that the test_start is less than the first index, but more than one less
    assert time_array[index[0]] >= cdfepoch.compute(test_start)
    assert time_array[index[0]-1] <= cdfepoch.compute(test_start)

    assert time_array[index[-1]] <= cdfepoch.compute(test_end)
    assert time_array[index[-1]+1] >= cdfepoch.compute(test_end)
github MAVENSDC / cdflib / tests / test_astropy_epochs.py View on Github external
def test_findepochrange_cdfepoch():
    start_time = "2013-12-01 12:24:22.000"
    end_time = "2014-12-01 12:24:22.000"
    x = cdfepoch.parse([start_time, end_time])
    time_array = np.arange(x[0], x[1], step=1000000)

    test_start = [2014, 8, 1, 8, 1, 54, 123]
    test_end = [2018, 1, 1, 1, 1, 1, 1]
    index = cdfepoch.findepochrange(time_array, starttime=test_start, endtime=test_end)
    # Test that the test_start is less than the first index, but more than one less
    assert time_array[index[0]] >= cdfepoch.compute(test_start)
    assert time_array[index[0]-1] <= cdfepoch.compute(test_start)

    assert time_array[index[-1]] <= cdfepoch.compute(test_end)
github MAVENSDC / cdflib / tests / test_astropy_epochs.py View on Github external
def test_findepochrange_cdftt2000():
    start_time = "2004-03-01 12:24:22.351793238"
    end_time = "2004-03-01 12:28:22.351793238"
    x = cdfepoch.parse([start_time, end_time])
    time_array = np.arange(x[0], x[1], step=1000000)

    test_start = [2004, 3, 1, 12, 25, 54, 123, 111, 98]
    test_end = [2004, 3, 1, 12, 26, 4, 123, 456, 789]
    index = cdfepoch.findepochrange(time_array, starttime=test_start, endtime=test_end)
    # Test that the test_start is less than the first index, but more than one less
    assert time_array[index[0]] >= cdfepoch.compute(test_start)
    assert time_array[index[0]-1] <= cdfepoch.compute(test_start)

    assert time_array[index[-1]] <= cdfepoch.compute(test_end)
    assert time_array[index[-1]+1] >= cdfepoch.compute(test_end)
github MAVENSDC / cdflib / tests / test_astropy_epochs.py View on Github external
def test_compute_cdfepoch16():
    random_time = []
    random_time.append(randint(0, 2018))  # Year
    random_time.append(randint(1, 12))  # Month
    random_time.append(randint(1, 28))  # Date
    random_time.append(randint(0, 23))  # Hour
    random_time.append(randint(0, 59))  # Minute
    random_time.append(randint(0, 59))  # Second
    random_time.append(randint(0, 999))  # Millisecond
    random_time.append(randint(0, 999))  # Microsecond
    random_time.append(randint(0, 999))  # Nanosecond
    random_time.append(randint(0, 999))  # Picosecond
    cdftime = cdfepoch.convert_to_astropy(cdfepoch.compute(random_time), format='cdf_epoch16')
    x = cdfepoch.breakdown(cdftime)
    i = 0
    for t in x[0]:
        assert t == random_time[i], 'Time {} was not equal to {}'.format(random_time, x)
        i += 1
        # Unfortunately, currently there is a pretty big loss of precision that comes with
        # the compute function.  Need to stop testing early.
        if i > 6:
            return
github MAVENSDC / cdflib / cdflib / epochs_astropy.py View on Github external
def findepochrange(epochs, starttime=None, endtime=None):  # @NoSelf
        if isinstance(starttime, list):
            start = CDFAstropy.compute(starttime)
        if isinstance(endtime, list):
            end = CDFAstropy.compute(endtime)

        epochs = CDFAstropy.convert_to_astropy(epochs)

        epochs_as_np = epochs.value
        indices = np.where((epochs_as_np >= start) & (epochs_as_np <= end))
        return min(indices[0]), max(indices[0])