Beispiel #1
0
 def __init__(self, cube_config, name='water_mask', dir=None):
     super(WaterMaskProvider, self).__init__(cube_config, name)
     if dir is None:
         raise ValueError('dir_path expected')
     if not os.path.isabs(dir):
         self._dir_path = Config.instance().get_cube_source_path(dir)
     else:
         self._dir_path = dir
     self.cube_config.static_data = True
Beispiel #2
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.gleam import GleamProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('GLEAM/v3a_BETA/')


class GleamProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = GleamProvider(
            CubeConfig(end_time=datetime(2001, 12, 31, 23, 0)),
            dir=SOURCE_DIR,
            var="E")
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(365, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[3], datetime(2001, 1, 4, 0, 0),
            datetime(2001, 1, 5, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) +
            ['2001', 'E_2001_GLEAM_v3a_BETA.nc'], 3)
        self.assert_source_time_ranges(
            source_time_ranges[364], datetime(2001, 12, 31, 0, 0),
            datetime(2002, 1, 1, 0, 0),
Beispiel #3
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.albedo import AlbedoProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path(
    'globalbedo_CF_compliant/05deg/8daily')


class AlbedoProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = AlbedoProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(461, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(2001, 1, 1, 0),
            datetime(2001, 1, 9, 0),
            self.get_source_dir_list(SOURCE_DIR) +
            ['GlobAlbedo.merge.albedo.05.2001001.nc'], 0)
        self.assert_source_time_ranges(
            source_time_ranges[1], datetime(2001, 1, 9, 0),
            datetime(2001, 1, 17, 0),
            self.get_source_dir_list(SOURCE_DIR) +
            ['GlobAlbedo.merge.albedo.05.2001009.nc'], 0)
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.snow_area_extent import SnowAreaExtentProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('SnowAreaExtent')


class SnowAreaExtentProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR), 'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = SnowAreaExtentProvider(CubeConfig(), dir=SOURCE_DIR, resampling_order="space_first")
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(120, len(source_time_ranges))
        self.assert_source_time_ranges(source_time_ranges[0],
                                       datetime(2003, 1, 1, 0, 0, 0, 33),
                                       datetime(2003, 2, 1, 0, 0, 0, 33),
                                       self.get_source_dir_list(SOURCE_DIR) + ['MFSC.36000.18000.2003.nc'],
                                       0)
        self.assert_source_time_ranges(source_time_ranges[1],
                                       datetime(2003, 2, 1, 0, 0, 0, 33),
                                       datetime(2003, 3, 1, 0, 0, 0, 33),
                                       self.get_source_dir_list(SOURCE_DIR) + ['MFSC.36000.18000.2003.nc'],
                                       1)
        self.assert_source_time_ranges(source_time_ranges[6],
                                       datetime(2003, 7, 1, 0, 0, 0, 33),
Beispiel #5
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.burnt_area import BurntAreaProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('BurntArea')


class BurntAreaProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR), 'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = BurntAreaProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(225, len(source_time_ranges))
        self.assert_source_time_ranges(source_time_ranges[0],
                                       datetime(1995, 1, 6, 0, 0),
                                       datetime(1995, 2, 6, 0, 0),
                                       self.get_source_dir_list(SOURCE_DIR) + ['BurntArea.GFED4.1995.nc.gz'],
                                       0)
        self.assert_source_time_ranges(source_time_ranges[1],
                                       datetime(1995, 2, 6, 0, 0),
                                       datetime(1995, 3, 6, 0, 0),
                                       self.get_source_dir_list(SOURCE_DIR) + ['BurntArea.GFED4.1995.nc.gz'],
                                       1)
        self.assert_source_time_ranges(source_time_ranges[6],
                                       datetime(1995, 7, 6, 0, 0),
Beispiel #6
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.globvapour import GlobVapourProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path(
    'globvapour/GOME_SCIA_GOME2/monthly')


class GlobVapourProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = GlobVapourProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(156, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(1996, 1, 1, 0, 0),
            datetime(1996, 2, 1, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) +
            ['1996', 'GV_GOMExxxxxxx_MM_19960101_E_3.nc'], 0)
        self.assert_source_time_ranges(
            source_time_ranges[125], datetime(2006, 6, 1, 0, 0),
            datetime(2006, 7, 1, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) + [
                '2006',
Beispiel #7
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.precip import PrecipProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('CPC_precip')


class PrecipProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = PrecipProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(13149, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(1979, 1, 1, 0, 0, 0, 33),
            datetime(1979, 1, 2, 0, 0, 0, 33),
            self.get_source_dir_list(SOURCE_DIR) +
            ['Precip.V1.720.360.1979.nc.gz'], 0)
        self.assert_source_time_ranges(
            source_time_ranges[6], datetime(1979, 1, 7, 0, 0, 0, 33),
            datetime(1979, 1, 8, 0, 0, 0, 33),
            self.get_source_dir_list(SOURCE_DIR) +
            ['Precip.V1.720.360.1979.nc.gz'], 6)
        self.assert_source_time_ranges(
Beispiel #8
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.air_temperature import AirTemperatureProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path("T2m-ECMWF/low/")


class AirTemperatureProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR), 'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = AirTemperatureProvider(CubeConfig(end_time=datetime(2001, 12, 31, 23, 0)), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(730, len(source_time_ranges))
        self.assert_source_time_ranges(source_time_ranges[0],
                                       datetime(2001, 1, 1, 0, 0),
                                       datetime(2001, 1, 1, 12, 0),
                                       self.get_source_dir_list(SOURCE_DIR) + ['t2m_2001_01.nc'],
                                       0)
        self.assert_source_time_ranges(source_time_ranges[6],
                                       datetime(2001, 1, 4, 0, 0),
                                       datetime(2001, 1, 4, 12, 0),
                                       self.get_source_dir_list(SOURCE_DIR) + ['t2m_2001_01.nc'],
                                       6)
        self.assert_source_time_ranges(source_time_ranges[729],
                                       datetime(2001, 12, 31, 12, 0),
Beispiel #9
0
import os
import unittest
from datetime import datetime
from esdl import CubeConfig
from esdl.providers.aerosols import AerosolsProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path(
    'CCI-Aerosols/AATSR_SU_v4.1/L3_DAILY')


class AerosolsProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = AerosolsProvider(CubeConfig(end_time=datetime(2003, 1, 1)),
                                    dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(97, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(2002, 7, 24, 0, 0),
            datetime(2002, 7, 25, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) + [
                '2002',
                '20020724-ESACCI-L3C_AEROSOL-AOD-AATSR_ENVISAT-SU_DAILY-fv4.1.nc'
            ], 0)
        self.assert_source_time_ranges(
            source_time_ranges[6], datetime(2002, 8, 6, 0, 0),
            datetime(2002, 8, 7, 0, 0),
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.soil_moisture import SoilMoistureProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('ECV_sm')


class SoilMoistureProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = SoilMoistureProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(12784, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(1979, 1, 1, 0, 0, 0, 33),
            datetime(1979, 1, 2, 0, 0, 0, 33),
            self.get_source_dir_list(SOURCE_DIR) +
            ['SoilMoisture.ESACCI-L3S.1979.v2_1.nc.gz'], 0)
        self.assert_source_time_ranges(
            source_time_ranges[6], datetime(1979, 1, 7, 0, 0, 0, 33),
            datetime(1979, 1, 8, 0, 0, 0, 33),
            self.get_source_dir_list(SOURCE_DIR) +
            ['SoilMoisture.ESACCI-L3S.1979.v2_1.nc.gz'], 6)
        self.assert_source_time_ranges(
Beispiel #11
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.ozone import OzoneProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path(
    'Ozone-CCI/Total_Columns\\L3\\MERGED')


class OzoneProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = OzoneProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(185, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(1996, 3, 10, 0, 0),
            datetime(1996, 3, 31, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) +
            ['ESACCI-OZONE-L3S-TC-MERGED-DLR_1M-19960310-fv0100.nc'], None)
        self.assert_source_time_ranges(
            source_time_ranges[6], datetime(1996, 9, 1, 0, 0),
            datetime(1996, 9, 30, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) +
            ['ESACCI-OZONE-L3S-TC-MERGED-DLR_1M-19960901-fv0100.nc'], None)
Beispiel #12
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.mpi_bgc import MPIBGCProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('MPI_BGC')


class MPIBGCTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = MPIBGCProvider(
            CubeConfig(end_time=datetime(2001, 12, 31, 23, 0)),
            dir=SOURCE_DIR + "/LE",
            var="LE")
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(46, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[1], datetime(2001, 1, 9, 0, 0),
            datetime(2001, 1, 17, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) + ['LE', 'LE_2001.nc'], 1)
        self.assert_source_time_ranges(
            source_time_ranges[45], datetime(2001, 12, 27, 0, 0),
            datetime(2002, 1, 4, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) + ['LE', 'LE_2001.nc'], 45)
Beispiel #13
0
import os
import unittest
from datetime import datetime

import numpy as np

from esdl import CubeConfig
from esdl.providers.snow_water_equivalent import SnowWaterEquivalentProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('SWE')


class SnowWaterEquivalentProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = SnowWaterEquivalentProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(12054, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(1980, 1, 1, 0, 0),
            datetime(1980, 1, 2, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) + ['SWE.1440.720.1980.nc'], 0)
        self.assert_source_time_ranges(
            source_time_ranges[1000], datetime(1982, 9, 27, 0, 0),
            datetime(1982, 9, 28, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) + ['SWE.1440.720.1982.nc'],
            269)
Beispiel #14
0
import os
import unittest
from datetime import datetime
from esdl import CubeConfig
from esdl.providers.country_mask import CountryMaskProvider
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('CountryCodes')


class CountryMaskProviderTest(unittest.TestCase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_temporal_coverage(self):
        provider = CountryMaskProvider(
            CubeConfig(end_time=datetime(2003, 1, 1)), dir=SOURCE_DIR)
        provider.prepare()
        self.assertEqual(
            (datetime(2001, 1, 1, 0, 0), datetime(2003, 1, 1, 0, 0)),
            provider.temporal_coverage)

    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_get_images(self):
        provider = CountryMaskProvider(
            CubeConfig(end_time=datetime(2003, 1, 1)), dir=SOURCE_DIR)
        provider.prepare()
        images = provider.compute_variable_images(datetime(2002, 7, 27),
                                                  datetime(2002, 8, 4))

        self.assertIsNotNone(images)
Beispiel #15
0
import os
import unittest
from datetime import datetime
from esdl import CubeConfig
from esdl.providers.water_mask import WaterMaskProvider
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('WaterBodies4.0')


class WaterMaskProviderTest(unittest.TestCase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_temporal_coverage(self):
        provider = WaterMaskProvider(CubeConfig(end_time=datetime(2003, 1, 1)),
                                     dir=SOURCE_DIR)
        provider.prepare()
        self.assertEqual(
            (datetime(2001, 1, 1, 0, 0), datetime(2003, 1, 1, 0, 0)),
            provider.temporal_coverage)

    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_get_images(self):
        provider = WaterMaskProvider(CubeConfig(end_time=datetime(2003, 1, 1)),
                                     dir=SOURCE_DIR)
        provider.prepare()
        images = provider.compute_variable_images(datetime(2002, 7, 27),
                                                  datetime(2002, 8, 4))

        self.assertIsNotNone(images)
Beispiel #16
0
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.c_emissions import CEmissionsProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path('Fire_C_Emissions')


class CEmissionsProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR), 'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = CEmissionsProvider(CubeConfig(), dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(120, len(source_time_ranges))
        self.assert_source_time_ranges(source_time_ranges[0],
                                       datetime(2001, 1, 1, 0, 0),
                                       datetime(2001, 2, 1, 0, 0),
                                       self.get_source_dir_list(SOURCE_DIR) + ['fire_C_Emissions.nc'],
                                       0)
        self.assert_source_time_ranges(source_time_ranges[11],
                                       datetime(2001, 12, 1, 0, 0),
                                       datetime(2002, 1, 1, 0, 0),
                                       self.get_source_dir_list(SOURCE_DIR) + ['fire_C_Emissions.nc'],
                                       11)
        self.assert_source_time_ranges(source_time_ranges[119],
                                       datetime(2010, 12, 1, 0, 0),
import os
import unittest
from datetime import datetime

from esdl import CubeConfig
from esdl.providers.land_surface_temperature import LandSurfTemperatureProvider
from test.providers.provider_test_utils import ProviderTestBase
from esdl.util import Config

SOURCE_DIR = Config.instance().get_cube_source_path(
    "globtemperature/ftp2.globtemperature.info/AATSR/L3/")


class LandSurfTemperatureProviderTest(ProviderTestBase):
    @unittest.skipIf(not os.path.exists(SOURCE_DIR),
                     'test data not found: ' + SOURCE_DIR)
    def test_source_time_ranges(self):
        provider = LandSurfTemperatureProvider(CubeConfig(
            start_time=datetime(2003, 1, 1, 0, 0),
            end_time=datetime(2003, 12, 31, 23, 0)),
                                               dir=SOURCE_DIR)
        provider.prepare()
        source_time_ranges = provider.source_time_ranges
        self.assertEqual(320, len(source_time_ranges))
        self.assert_source_time_ranges(
            source_time_ranges[0], datetime(2003, 1, 2, 0, 0),
            datetime(2003, 1, 3, 0, 0),
            self.get_source_dir_list(SOURCE_DIR) + [
                'GT_SSD-L3-AATSR_LST_3-20030102_H1.0V1.0-H36.0V18.0-CUOL-0.05X0.05-V1.0.nc'
            ], 0)
        self.assert_source_time_ranges(