@@ -86,7 +86,7 @@ def test_extract_volume(self):
86
86
def test_volume_statistics (self ):
87
87
"""Test to take the volume weighted average of a (2,3,2,2) cube."""
88
88
result = volume_statistics (self .grid_4d , 'mean' )
89
- expected = np .array ([1. , 1. ])
89
+ expected = np .ma . array ([1. , 1. ], mask = False )
90
90
self .assert_array_equal (result .data , expected )
91
91
92
92
def test_volume_statistics_long (self ):
@@ -97,7 +97,27 @@ def test_volume_statistics_long(self):
97
97
different methods for small and large cubes.
98
98
"""
99
99
result = volume_statistics (self .grid_4d_2 , 'mean' )
100
- expected = np .array ([1. , 1. , 1. , 1. ])
100
+ expected = np .ma .array ([1. , 1. , 1. , 1. ], mask = False )
101
+ self .assert_array_equal (result .data , expected )
102
+
103
+ def test_volume_statistics_masked_level (self ):
104
+ """
105
+ Test to take the volume weighted average of a (2,3,2,2) cube
106
+ where the last depth level is fully masked.
107
+ """
108
+ self .grid_4d .data [:, - 1 , :, :] = np .ma .masked_all ((2 , 2 , 2 ))
109
+ result = volume_statistics (self .grid_4d , 'mean' )
110
+ expected = np .ma .array ([1. , 1. ], mask = False )
111
+ self .assert_array_equal (result .data , expected )
112
+
113
+ def test_volume_statistics_masked_timestep (self ):
114
+ """
115
+ Test to take the volume weighted average of a (2,3,2,2) cube
116
+ where the first timestep is fully masked.
117
+ """
118
+ self .grid_4d .data [0 , :, :, :] = np .ma .masked_all ((3 , 2 , 2 ))
119
+ result = volume_statistics (self .grid_4d , 'mean' )
120
+ expected = np .ma .array ([1. , 1 ], mask = [True , False ])
101
121
self .assert_array_equal (result .data , expected )
102
122
103
123
def test_depth_integration_1d (self ):
0 commit comments