How to use cdflib - 10 common examples

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_cdfwrite.py View on Github external
def cdf_create(fn: Path, spec: dict):
    # str(fn) is a Python==3.5 workaround
    return cdfwrite.CDF(str(fn), cdf_spec=spec)
github MAVENSDC / cdflib / tests / test_cdfwrite.py View on Github external
def cdf_read(fn: Path, validate: bool = False):
    # str(fn) is a Python==3.5 workaround
    return cdfread.CDF(str(fn), validate=validate)
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
def test_findepochrange_cdfepoch(self):
        start_time = "2013-12-01T12:24:22.000"
        end_time = "2014-12-01T12:24:22.000"
        x = cdflib.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 = cdflib.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
        self.assertGreaterEqual(time_array[index[0]], cdflib.cdfepoch.compute(test_start))
        self.assertLessEqual(time_array[index[0]-1], cdflib.cdfepoch.compute(test_start))

        self.assertLessEqual(time_array[index[-1]], cdflib.cdfepoch.compute(test_end))
        return
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
def test_compute_cdftt2000(self):
        random_time = list()
        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
        x = cdflib.cdfepoch.breakdown(cdflib.cdfepoch.compute(random_time))
        i = 0
        for t in x:
            self.assertEqual(t, random_time[i], 'Time '+str(random_time) + ' was not equal to ' + str(x))
            i += 1
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
x = cdflib.cdfepoch.parse([start_time, end_time])
        first_int_step = int((x[1].real - x[0].real) / 1000)
        second_int_step = int((x[1].imag - x[0].imag) / 1000)
        time_array = []
        for i in range(0, 1000):
            time_array.append(x[0] + complex(first_int_step * i, second_int_step * i))

        test_start = [1978, 6, 10, 3, 24, 22, 351, 793, 238, 462]
        test_end = [1978, 6, 12, 23, 11, 1, 338, 341, 416, 466]
        index = cdflib.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
        self.assertGreaterEqual(time_array[index[0]].real, cdflib.cdfepoch.compute(test_start).real)
        self.assertLessEqual(time_array[index[0] - 1].real, cdflib.cdfepoch.compute(test_start).real)
        self.assertLessEqual(time_array[index[-1]].real, cdflib.cdfepoch.compute(test_end).real)
        self.assertGreaterEqual(time_array[index[-1] + 1].real, cdflib.cdfepoch.compute(test_end).real)
        return
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
def test_findepochrange_cdftt2000(self):
        start_time = "2004-03-01T12:24:22.351793238"
        end_time = "2004-03-01T12:28:22.351793238"
        x = cdflib.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 = cdflib.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
        self.assertGreaterEqual(time_array[index[0]], cdflib.cdfepoch.compute(test_start))
        self.assertLessEqual(time_array[index[0]-1], cdflib.cdfepoch.compute(test_start))

        self.assertLessEqual(time_array[index[-1]], cdflib.cdfepoch.compute(test_end))
        self.assertGreaterEqual(time_array[index[-1]+1], cdflib.cdfepoch.compute(test_end))
        return
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
def test_findepochrange_cdftt2000(self):
        start_time = "2004-03-01T12:24:22.351793238"
        end_time = "2004-03-01T12:28:22.351793238"
        x = cdflib.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 = cdflib.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
        self.assertGreaterEqual(time_array[index[0]], cdflib.cdfepoch.compute(test_start))
        self.assertLessEqual(time_array[index[0]-1], cdflib.cdfepoch.compute(test_start))

        self.assertLessEqual(time_array[index[-1]], cdflib.cdfepoch.compute(test_end))
        self.assertGreaterEqual(time_array[index[-1]+1], cdflib.cdfepoch.compute(test_end))
        return
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
def test_findepochrange_cdfepoch(self):
        start_time = "2013-12-01T12:24:22.000"
        end_time = "2014-12-01T12:24:22.000"
        x = cdflib.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 = cdflib.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
        self.assertGreaterEqual(time_array[index[0]], cdflib.cdfepoch.compute(test_start))
        self.assertLessEqual(time_array[index[0]-1], cdflib.cdfepoch.compute(test_start))

        self.assertLessEqual(time_array[index[-1]], cdflib.cdfepoch.compute(test_end))
        return
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
def test_findepochrange_cdftt2000(self):
        start_time = "2004-03-01T12:24:22.351793238"
        end_time = "2004-03-01T12:28:22.351793238"
        x = cdflib.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 = cdflib.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
        self.assertGreaterEqual(time_array[index[0]], cdflib.cdfepoch.compute(test_start))
        self.assertLessEqual(time_array[index[0]-1], cdflib.cdfepoch.compute(test_start))

        self.assertLessEqual(time_array[index[-1]], cdflib.cdfepoch.compute(test_end))
        self.assertGreaterEqual(time_array[index[-1]+1], cdflib.cdfepoch.compute(test_end))
        return
github MAVENSDC / cdflib / tests / test_epochs.py View on Github external
def test_compute_cdfepoch(self):
        """
        Using random numbers for the compute tests
        """
        random_time = list()
        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 = cdflib.cdfepoch.breakdown(cdflib.cdfepoch.compute(random_time))
        i = 0
        for t in x:
            self.assertEqual(t, random_time[i], 'Time '+str(random_time) + ' was not equal to ' + str(x))
            i += 1