Exemple #1
0
    def test_open_dataset(self):
        # Test normal functionality
        dataset = open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY',
                               time_range='2008-01-01, 2008-03-01')
        self.assertIsNotNone(dataset)

        # Test swapped dates
        with self.assertRaises(ValueError):
            open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY', time_range='2008-03-01, 2008-01-01')

        # Test required arguments
        with self.assertRaises(TypeError):
            open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY', time_range='2008-03-01')
Exemple #2
0
    def test_open_dataset(self):
        # Test normal functionality
        dataset = open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY',
                               time_range='2008-01-01, 2008-03-01')
        self.assertIsNotNone(dataset)

        # Test swapped dates
        with self.assertRaises(ValueError):
            open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY', time_range='2008-03-01, 2008-01-01')

        # Test required arguments
        with self.assertRaises(TypeError):
            open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY', time_range='2008-03-01')
Exemple #3
0
    def test_save_dataset(self):
        # Test normal functionality
        dataset = open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY',
                               time_range='2008-01-01, 2008-03-01')
        save_dataset(dataset, 'remove_me.nc')
        self.assertTrue(os.path.isfile('remove_me.nc'))
        os.remove('remove_me.nc')

        # Test required arguments
        with self.assertRaises(TypeError):
            save_dataset(dataset)

        # Test behavior when passing unexpected type
        with self.assertRaises(NotImplementedError):
            dataset = ('a', 1, 3, 5)
            save_dataset(dataset, 'remove_me.nc')

        self.assertFalse(os.path.isfile('remove_me.nc'))
Exemple #4
0
    def test_save_dataset(self):
        # Test normal functionality
        dataset = open_dataset(ds_id='AEROSOL_AATSR_SU_L3_V4.21_MONTHLY',
                               time_range='2008-01-01, 2008-03-01')
        save_dataset(dataset, 'remove_me.nc')
        self.assertTrue(os.path.isfile('remove_me.nc'))
        os.remove('remove_me.nc')

        # Test required arguments
        with self.assertRaises(TypeError):
            save_dataset(dataset)

        # Test behavior when passing unexpected type
        with self.assertRaises(NotImplementedError):
            dataset = ('a', 1, 3, 5)
            # noinspection PyTypeChecker
            save_dataset(dataset, 'remove_me.nc')

        self.assertFalse(os.path.isfile('remove_me.nc'))
Exemple #5
0
def test_data_source(data_source, out_dir, result):
    # pprint.pprint(data_source.meta_info)
    data_source_id = data_source.id

    dataset = None
    t0 = time.clock()
    try:
        dataset = open_dataset(ds_id=data_source_id,
                               force_local=True,
                               monitor=ConsoleMonitor(stay_in_line=True,
                                                      progress_bar_size=60))
        t1 = time.clock()
        result.update(dict(result='OK', time=t1 - t0))
    except Exception as e:
        t1 = time.clock()
        result.update(dict(result='Error', time=t1 - t0, details=str(e)))
        with open(os.path.join(out_dir, 'Error-%s.txt' % data_source_id), 'w') as fp:
            traceback.print_exc(file=fp)
    finally:
        if dataset:
            dataset.close()
Exemple #6
0
def test_data_source(data_source, out_dir, result):
    # pprint.pprint(data_source.meta_info)
    data_source_id = data_source.id

    dataset = None
    t0 = time.clock()
    try:
        dataset = open_dataset(ds_id=data_source_id,
                               force_local=True,
                               monitor=ConsoleMonitor(stay_in_line=True,
                                                      progress_bar_size=60))
        t1 = time.clock()
        result.update(dict(result='OK', time=t1 - t0))
    except Exception as e:
        t1 = time.clock()
        result.update(dict(result='Error', time=t1 - t0, details=str(e)))
        with open(os.path.join(out_dir, 'Error-%s.txt' % data_source_id),
                  'w') as fp:
            traceback.print_exc(file=fp)
    finally:
        if dataset:
            dataset.close()