コード例 #1
0
 def test_reproject_input_data_odd_downsample(self):
     """test function reproject_input_data with odd downsampling"""
     data_in, meta_list = data_arrays_resampling_demo()
     #
     data_out, meta_out = \
         lp.reproject_input_data(data_in, meta_list,
                                i_align=0, # high res data as reference
                                target_res_arcsec=6120, # 1.7 degree
                                global_origins=(-180, 90),
                                )
     self.assertEqual(1.7, meta_out['transform'][0])  # check resolution
     reference_array = np.array([[0.425, 1.7631578], [3.425, 4.763158]],
                                dtype='float32')
     np.testing.assert_array_equal(reference_array, data_out[0])
コード例 #2
0
 def test_reproject_input_data_downsample_conserve_sum(self):
     """test function reproject_input_data downsampling with conservation of sum"""
     data_in, meta_list = data_arrays_resampling_demo()
     #
     data_out, meta_out = lp.reproject_input_data(data_in,
                                                  meta_list,
                                                  i_align=0,
                                                  target_res_arcsec=None,
                                                  global_origins=(-180, 90),
                                                  conserve='sum')
     # test reference data unchanged:
     np.testing.assert_array_equal(data_in[0], data_out[0])
     # test conserve sum:
     for i, _ in enumerate(data_in):
         self.assertAlmostEqual(data_in[i].sum(), data_out[i].sum())
コード例 #3
0
 def test_reproject_input_data_downsample(self):
     """test function reproject_input_data downsampling lit to pop grid
     (default resampling for LitPop)"""
     data_in, meta_list = data_arrays_resampling_demo()
     #
     data_out, meta_out = lp.reproject_input_data(data_in,
                                                  meta_list,
                                                  i_align=0,
                                                  target_res_arcsec=None,
                                                  global_origins=(-180, 90))
     # test reference data unchanged:
     np.testing.assert_array_equal(data_in[0], data_out[0])
     # test northward shift:
     np.testing.assert_array_equal(data_in[1][1, :], data_out[1][0, :])
     # test reprojected nl data:
     reference_array = np.array([[5.020408, 2.267857, 0.12244898],
                                 [1.1224489, 0.6785714, 0.7346939]],
                                dtype='float32')
     np.testing.assert_array_almost_equal_nulp(reference_array, data_out[2])
コード例 #4
0
 def test_reproject_input_data_upsample(self):
     """test function reproject_input_data with upsampling
     (usually not required for LitPop)"""
     data_in, meta_list = data_arrays_resampling_demo()
     #
     data_out, meta_out = lp.reproject_input_data(
         data_in,
         meta_list,
         i_align=2,  # high res data as reference
         target_res_arcsec=None,
         global_origins=(-180, 90))
     # test reference data unchanged:
     np.testing.assert_array_equal(data_in[2], data_out[2])
     # test northward shift:
     np.testing.assert_array_equal(data_out[0][2, :], data_out[1][0, :])
     np.testing.assert_array_equal(data_out[0][3, :], data_out[1][1, :])
     # test reprojected nl data:
     reference_array = np.array(
         [[0., 0.25, 0.75, 1.25, 1.75, 2.], [0.75, 1., 1.5, 2., 2.5, 2.75],
          [2.25, 2.5, 3., 3.5, 4., 4.25], [3., 3.25, 3.75, 4.25, 4.75, 5.]],
         dtype='float32')
     np.testing.assert_array_equal(reference_array, data_out[0])