示例#1
0
    def test_subset(self):
        fcst = utils.create_data()

        query = {'hours': np.array([0., 2., 4., 6.]),
                 'domain': {'N': np.max(fcst['latitude'].values) - 1,
                            'S': np.min(fcst['latitude'].values) + 1,
                            'E': np.max(fcst['longitude'].values) - 1,
                            'W': np.min(fcst['longitude'].values) + 1},
                 'grid_delta': (1., 1.),
                 'variables': ['wind']}
        ss = subset.subset_dataset(fcst, query)

        np.testing.assert_array_equal(ss['longitude'].values,
                                      np.arange(query['domain']['W'],
                                                query['domain']['E'] + 1))
        np.testing.assert_array_equal(np.sort(ss['latitude'].values),
                                      np.arange(query['domain']['S'],
                                                query['domain']['N'] + 1))
示例#2
0
    def test_gfs(self):
        query = {'hours': [0., 3., 9., 24.],
                 'model': 'gfs',
                 'domain': {'N': 39.,
                            'S': 35,
                            'E': -120,
                            'W': -124},
                 'grid_delta': (1., 1.),
                 'variables': ['wind']}

        model = grads.GFS()
        gfs = model.fetch(self.temporary_fcst_path)
        expected = subset.subset_dataset(gfs, query)
        compressed = request.process_query(query, url=self.temporary_fcst_path)
        actual = compress.decompress_dataset(compressed)

        np.testing.assert_array_almost_equal(actual['x_wind'].values,
                                             expected['x_wind'].values,
                                             4)
        np.testing.assert_array_almost_equal(actual['y_wind'].values,
                                             expected['y_wind'].values,
                                             4)