Exemple #1
0
 def setUp(self):
     """Set up cube """
     data = np.array(
         [0, 1, 5, 11, 20, 5, 9, 10, 4, 2, 0, 1, 29, 30, 1, 5, 6, 6],
         dtype=np.int32).reshape((2, 3, 3))
     cube = set_up_variable_cube(
         data,
         "weather_code",
         "1",
     )
     date_times = [
         datetime.datetime(2017, 11, 19, 0, 30),
         datetime.datetime(2017, 11, 19, 1, 30),
     ]
     self.cube = add_coordinate(
         cube,
         date_times,
         "time",
         is_datetime=True,
         order=[1, 0, 2, 3],
     )
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())
     self.data_directory = mkdtemp()
     self.nc_file = self.data_directory + "/wxcode.nc"
     pathlib.Path(self.nc_file).touch(exist_ok=True)
 def setUp(self):
     """Set up cube """
     data = np.array([
         0.1, 0.3, 0.4, 0.2, 0.6, 0.7, 0.4, 0.2, 0.1, 0.2, 0.2, 0.5, 0.1,
         0.3, 0.9, 0.8, 0.5, 0.3, 0.6, 0.3, 0.5, 0.6, 0.8, 0.2, 0.8, 0.1,
         0.2
     ]).reshape(3, 1, 3, 3)
     self.cube = set_up_probability_threshold_cube(
         data, 'air_temperature', 'K', spp__relative_to_threshold='above')
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())
 def setUp(self):
     """ Set up wxcubes for testing. """
     super().setUp()
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())
     self.expected_wxcode = np.array([[1, 29, 5], [6, 7, 8], [10, 11, 12]])
     self.expected_wxcode_night = np.array([[0, 28, 5], [6, 7, 8],
                                            [9, 11, 12]])
     self.expected_wxcode_no_lightning = np.array([[1, 3, 5], [6, 7, 8],
                                                   [10, 11, 12]])
     self.expected_wxcode_alternate = np.array([[14, 15, 17], [18, 23, 24],
                                                [26, 27, 27]])
Exemple #4
0
 def setUp(self):
     """Set up cube """
     data = np.array([
         0.1, 0.3, 0.4, 0.2, 0.6, 0.7, 0.4, 0.2, 0.1, 0.2, 0.2, 0.5, 0.1,
         0.3, 0.9, 0.8, 0.5, 0.3, 0.6, 0.3, 0.5, 0.6, 0.8, 0.2, 0.8, 0.1,
         0.2
     ],
                     dtype=np.float32).reshape((3, 3, 3))
     self.cube = set_up_probability_cube(
         data, np.array([288, 290, 292], dtype=np.float32))
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())
Exemple #5
0
 def setUp(self):
     """Set up cube """
     data = np.array(
         [0, 1, 5, 11, 20, 5, 9, 10, 4, 2, 0, 1, 29, 30, 1, 5, 6, 6],
         dtype=np.int32
     ).reshape(2, 1, 3, 3)
     self.cube = set_up_cube(data, 'air_temperature', 'K',
                             realizations=np.array([0, 1], dtype=np.int32))
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())
     self.data_directory = mkdtemp()
     self.nc_file = self.data_directory + '/wxcode.nc'
     pathlib.Path(self.nc_file).touch(exist_ok=True)
 def setUp(self):
     """Set up cube """
     data = np.array(
         [
             [[0.1, 0.3, 0.4], [0.2, 0.6, 0.7], [0.4, 0.2, 0.1]],
             [[0.2, 0.2, 0.5], [0.1, 0.3, 0.9], [0.8, 0.5, 0.3]],
             [[0.6, 0.3, 0.5], [0.6, 0.8, 0.2], [0.8, 0.1, 0.2]],
         ],
         dtype=np.float32,
     )
     self.cube = set_up_probability_cube(
         data, np.array([288, 290, 292], dtype=np.float32))
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())
Exemple #7
0
def test_node_points_to_valid_value(tree_name):
    """Test that succeed and fail point to valid values or nodes."""
    valid_codes = list(WX_DICT.keys())
    tree = TREES[tree_name]
    for node in tree:
        for value in tree[node]["succeed"], tree[node]["fail"]:
            if isinstance(value, str):
                assert value in tree.keys()
            else:
                assert value in valid_codes
Exemple #8
0
 def setUp(self):
     """Set up for update_daynight class"""
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())
     self.cube_data = np.array([[
         [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
         [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
         [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
         [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
         [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
         [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],
         [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
         [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14],
         [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],
         [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17],
         [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18],
         [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],
         [23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23],
         [26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26],
         [27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27],
         [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]]])
 def setUp(self):
     """ Set up wxcubes for testing. """
     self.cubes, self.cubes_no_lightning = set_up_wxcubes()
     self.wxcode = np.array(list(WX_DICT.keys()))
     self.wxmeaning = " ".join(WX_DICT.values())