def test_list_and_describe_data_ids(self):
     store = CDSDataStore(cds_api_url=_CDS_API_URL,
                          cds_api_key=_CDS_API_KEY)
     data_ids = store.get_data_ids()
     self.assertIsInstance(data_ids, Iterator)
     for data_id in data_ids:
         self.assertIsInstance(data_id, tuple)
         self.assertTrue(1 <= len(data_id) <= 2)
         for element in data_id:
             self.assertIsInstance(element, str)
         descriptor = store.describe_data(data_id[0])
         self.assertIsInstance(descriptor, DataDescriptor)
Beispiel #2
0
 def test_soil_moisture_volumetric_minimal_params(self):
     store = CDSDataStore(client_class=CDSClientMock,
                          endpoint_url=_CDS_API_URL,
                          cds_api_key=_CDS_API_KEY)
     data_id = 'satellite-soil-moisture:volumetric:monthly'
     dataset = store.open_data(
         data_id,
         time_range=['2015-01-01', '2015-02-28'],
     )
     self.assertTrue('sm' in dataset.variables)
     self.assertEqual(2, len(dataset.variables['time']))
     self.assertEqual('2014-12-31T12:00:00Z',
                      dataset.attrs['time_coverage_start'])
     self.assertEqual('2015-02-28T12:00:00Z',
                      dataset.attrs['time_coverage_end'])
     description = store.describe_data(data_id)
     self.assertCountEqual(description.data_vars.keys(),
                           map(str, dataset.data_vars))
 def test_soil_moisture_without_optional_parameters(self):
     store = CDSDataStore(client_class=CDSClientMock,
                          cds_api_url=_CDS_API_URL,
                          cds_api_key=_CDS_API_KEY)
     data_id = 'satellite-soil-moisture:volumetric:monthly'
     dataset = store.open_data(
         data_id,
         variable_names=['volumetric_surface_soil_moisture'],
         time_range=['2015-01-01', '2015-02-28'],
     )
     self.assertTrue('sm' in dataset.variables)
     self.assertEqual(2, len(dataset.variables['time']))
     self.assertEqual('2014-12-31T12:00:00Z',
                      dataset.attrs['time_coverage_start'])
     self.assertEqual('2015-02-28T12:00:00Z',
                      dataset.attrs['time_coverage_end'])
     description = store.describe_data(data_id)
     self.assertEqual(sorted([dv.name for dv in description.data_vars]),
                      sorted(map(str, dataset.data_vars)))
Beispiel #4
0
    def test_soil_moisture_saturation_10_day(self):
        store = CDSDataStore(client_class=CDSClientMock,
                             endpoint_url=_CDS_API_URL,
                             cds_api_key=_CDS_API_KEY)

        data_id = 'satellite-soil-moisture:saturation:10-day'
        dataset = store.open_data(
            data_id,
            time_range=['2015-04-01', '2015-04-11'],
        )
        self.assertTrue('sm' in dataset.variables)
        self.assertEqual(2, len(dataset.variables['time']))
        self.assertEqual('2015-03-31T12:00:00Z',
                         dataset.attrs['time_coverage_start'])
        self.assertEqual('2015-04-20T12:00:00Z',
                         dataset.attrs['time_coverage_end'])
        description = store.describe_data(data_id)
        self.assertCountEqual(description.data_vars.keys(),
                              map(str, dataset.data_vars))
Beispiel #5
0
 def test_era5_describe_data(self):
     store = CDSDataStore(endpoint_url=_CDS_API_URL,
                          cds_api_key=_CDS_API_KEY)
     descriptor = store.describe_data(
         'reanalysis-era5-single-levels:reanalysis')
     self.assertEqual(265, len(descriptor.data_vars))
     self.assertEqual('WGS84', descriptor.crs)
     self.assertTupleEqual((-180, -90, 180, 90), descriptor.bbox)
     # We don't exhaustively check all 260 variables, but we check one
     # fully and make sure that the rest have correct type and dimensions.
     expected_vd = VariableDescriptor(
         name='u100',
         dtype='float32',
         dims=('time', 'latitude', 'longitude'),
         attrs=dict(units='m s**-1', long_name='100 metre U wind component'))
     self.assertDictEqual(expected_vd.__dict__,
                          descriptor.data_vars['u100'].__dict__)
     for vd in descriptor.data_vars.values():
         self.assertEqual('float32', vd.dtype)
         self.assertTupleEqual(('time', 'latitude', 'longitude'),
                               vd.dims)