Пример #1
0
def preproc_file():
    return PreprocessorFile(
        attributes={'filename': '/output/preproc/file.nc'},
        settings={
            'extract_levels': {
                'scheme': 'linear',
                'levels': [95000]
            },
        },
    )
Пример #2
0
 def test_mask_fillvalues(self, tmp_path):
     """Test the fillvalues mask: func mask_fillvalues."""
     data_1 = data_2 = self.mock_data
     data_2.mask = np.ones((4, 3, 3), bool)
     coords_spec = [(self.times, 0), (self.lats, 1), (self.lons, 2)]
     cube_1 = iris.cube.Cube(data_1, dim_coords_and_dims=coords_spec)
     cube_2 = iris.cube.Cube(data_2, dim_coords_and_dims=coords_spec)
     filename_1 = str(tmp_path / 'file1.nc')
     filename_2 = str(tmp_path / 'file2.nc')
     product_1 = PreprocessorFile(attributes={'filename': filename_1},
                                  settings={})
     product_1.cubes = [cube_1]
     product_2 = PreprocessorFile(attributes={'filename': filename_2},
                                  settings={})
     product_2.cubes = [cube_2]
     results = mask_fillvalues({product_1, product_2},
                               0.95,
                               min_value=-1.e10,
                               time_window=1)
     result_1, result_2 = None, None
     for product in results:
         if product.filename == filename_1:
             result_1 = product.cubes[0]
         if product.filename == filename_2:
             result_2 = product.cubes[0]
     assert_array_equal(result_2.data.mask, data_2.mask)
     assert_array_equal(result_1.data, data_1)
Пример #3
0
 def test_mask_fillvalues_zero_threshold(self, tmp_path):
     """Test the fillvalues mask: func mask_fillvalues for 0-threshold"""
     data_1 = self.mock_data
     data_2 = self.mock_data[0:3]
     data_1.mask = np.ones((4, 3, 3), bool)
     data_1.mask[0] = False
     data_1.mask[2] = False
     data_2.mask = np.ones((3, 3, 3), bool)
     data_2.mask[0] = False
     data_2.mask[1] = False
     coords_spec = [(self.times, 0), (self.lats, 1), (self.lons, 2)]
     coords_spec2 = [(self.time2, 0), (self.lats, 1), (self.lons, 2)]
     cube_1 = iris.cube.Cube(data_1, dim_coords_and_dims=coords_spec)
     cube_2 = iris.cube.Cube(data_2, dim_coords_and_dims=coords_spec2)
     filename_1 = str(tmp_path / 'file1.nc')
     filename_2 = str(tmp_path / 'file2.nc')
     product_1 = PreprocessorFile(attributes={'filename': filename_1},
                                  settings={})
     product_1.cubes = [cube_1]
     product_2 = PreprocessorFile(attributes={'filename': filename_2},
                                  settings={})
     product_2.cubes = [cube_2]
     results = mask_fillvalues({product_1, product_2}, 0., min_value=-1.e20)
     result_1, result_2 = None, None
     for product in results:
         if product.filename == filename_1:
             result_1 = product.cubes[0]
         if product.filename == filename_2:
             result_2 = product.cubes[0]
     # identical masks
     assert_array_equal(
         result_2.data[0, ...].mask,
         result_1.data[0, ...].mask,
     )
     # identical masks with cumluative
     cumulative_mask = cube_1[1:2].data.mask | cube_2[1:2].data.mask
     assert_array_equal(result_1[1:2].data.mask, cumulative_mask)
     assert_array_equal(result_2[2:3].data.mask, cumulative_mask)