コード例 #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')
コード例 #2
0
ファイル: test_io.py プロジェクト: CCI-Tools/ect-core
    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')
コード例 #3
0
ファイル: test_io.py プロジェクト: stratosgear/cate
    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'))
コード例 #4
0
ファイル: test_io.py プロジェクト: CCI-Tools/ect-core
    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'))
コード例 #5
0
ファイル: openall.py プロジェクト: CCI-Tools/ect-core
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()
コード例 #6
0
ファイル: openall.py プロジェクト: whigg/cate
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()