@@ -25,7 +25,7 @@ def setUp(self):
25
25
fx_data = np .empty ((3 , 3 ))
26
26
fx_data [:] = 60.
27
27
fx_data [1 , 2 ] = 30.
28
- self .new_cube_data = np .empty ((3 , 3 ))
28
+ self .new_cube_data = np .empty ((2 , 3 , 3 ))
29
29
self .new_cube_data [:] = 200.
30
30
crd_sys = iris .coord_systems .GeogCS (iris .fileformats .pp .EARTH_RADIUS )
31
31
self .lons = iris .coords .DimCoord ([0 , 1.5 , 3 ],
@@ -38,6 +38,11 @@ def setUp(self):
38
38
bounds = [[0 , 1 ], [1 , 2 ], [2 , 3 ]],
39
39
units = 'degrees_north' ,
40
40
coord_system = crd_sys )
41
+ self .zcoord = iris .coords .DimCoord ([0.5 , 5. ],
42
+ long_name = 'zcoord' ,
43
+ bounds = [[0. , 2.5 ], [2.5 , 25. ]],
44
+ units = 'm' ,
45
+ attributes = {'positive' : 'down' })
41
46
self .times = iris .coords .DimCoord ([0 , 1.5 , 2.5 , 3.5 ],
42
47
standard_name = 'time' ,
43
48
bounds = [[0 , 1 ], [1 , 2 ], [2 , 3 ],
@@ -47,9 +52,11 @@ def setUp(self):
47
52
standard_name = 'time' ,
48
53
bounds = [[0 , 1 ], [1 , 2 ], [2 , 3 ]],
49
54
units = 'hours' )
50
- self .coords_spec = [(self .lats , 0 ), (self .lons , 1 )]
55
+ self .fx_coords_spec = [(self .lats , 0 ), (self .lons , 1 )]
56
+ self .cube_coords_spec = [(self .zcoord , 0 ),
57
+ (self .lats , 1 ), (self .lons , 2 )]
51
58
self .fx_mask = iris .cube .Cube (fx_data ,
52
- dim_coords_and_dims = self .coords_spec ,
59
+ dim_coords_and_dims = self .fx_coords_spec ,
53
60
units = '%' )
54
61
self .mock_data = np .ma .empty ((4 , 3 , 3 ))
55
62
self .mock_data [:] = 10.
@@ -69,8 +76,10 @@ def test_components_fx_var(self, tmp_path):
69
76
'frequency' : 'fx' ,
70
77
'filename' : sftlf_file }
71
78
}
72
- new_cube_land = iris .cube .Cube (self .new_cube_data ,
73
- dim_coords_and_dims = self .coords_spec )
79
+ new_cube_land = iris .cube .Cube (
80
+ self .new_cube_data ,
81
+ dim_coords_and_dims = self .cube_coords_spec
82
+ )
74
83
new_cube_land = add_fx_variables (new_cube_land , fx_vars ,
75
84
CheckLevels .IGNORE )
76
85
result_land = mask_landsea (
@@ -92,8 +101,10 @@ def test_components_fx_var(self, tmp_path):
92
101
'frequency' : 'fx' ,
93
102
'filename' : sftlf_file }
94
103
}
95
- new_cube_ice = iris .cube .Cube (self .new_cube_data ,
96
- dim_coords_and_dims = self .coords_spec )
104
+ new_cube_ice = iris .cube .Cube (
105
+ self .new_cube_data ,
106
+ dim_coords_and_dims = self .cube_coords_spec
107
+ )
97
108
new_cube_ice = add_fx_variables (new_cube_ice , fx_vars ,
98
109
CheckLevels .IGNORE )
99
110
result_ice = mask_landseaice (
@@ -117,12 +128,16 @@ def test_mask_landsea(self, tmp_path):
117
128
'frequency' : 'fx' ,
118
129
'filename' : sftlf_file }
119
130
}
120
- new_cube_land = iris .cube .Cube (self .new_cube_data ,
121
- dim_coords_and_dims = self .coords_spec )
131
+ new_cube_land = iris .cube .Cube (
132
+ self .new_cube_data ,
133
+ dim_coords_and_dims = self .cube_coords_spec
134
+ )
122
135
new_cube_land = add_fx_variables (new_cube_land , fx_vars ,
123
136
CheckLevels .IGNORE )
124
- new_cube_sea = iris .cube .Cube (self .new_cube_data ,
125
- dim_coords_and_dims = self .coords_spec )
137
+ new_cube_sea = iris .cube .Cube (
138
+ self .new_cube_data ,
139
+ dim_coords_and_dims = self .cube_coords_spec
140
+ )
126
141
new_cube_sea = add_fx_variables (new_cube_sea , fx_vars ,
127
142
CheckLevels .IGNORE )
128
143
@@ -135,26 +150,30 @@ def test_mask_landsea(self, tmp_path):
135
150
new_cube_sea ,
136
151
'sea' ,
137
152
)
138
- expected = np .ma .empty ((3 , 3 ))
153
+ expected = np .ma .empty ((2 , 3 , 3 ))
139
154
expected .data [:] = 200.
140
- expected .mask = np .ones ((3 , 3 ), bool )
141
- expected .mask [1 , 2 ] = False
155
+ expected .mask = np .ones ((2 , 3 , 3 ), bool )
156
+ expected .mask [:, 1 , 2 ] = False
142
157
# set fillvalues so we are sure they are equal
143
158
np .ma .set_fill_value (result_land .data , 1e+20 )
144
159
np .ma .set_fill_value (result_sea .data , 1e+20 )
145
160
np .ma .set_fill_value (expected , 1e+20 )
146
161
assert_array_equal (result_land .data , expected )
147
- expected .mask = np .zeros ((3 , 3 ), bool )
148
- expected .mask [1 , 2 ] = True
162
+ expected .mask = np .zeros ((2 , 3 , 3 ), bool )
163
+ expected .mask [:, 1 , 2 ] = True
149
164
assert_array_equal (result_sea .data , expected )
150
165
151
166
# Mask with shp files although sftlf is available
152
- new_cube_land = iris .cube .Cube (self .new_cube_data ,
153
- dim_coords_and_dims = self .coords_spec )
167
+ new_cube_land = iris .cube .Cube (
168
+ self .new_cube_data ,
169
+ dim_coords_and_dims = self .cube_coords_spec
170
+ )
154
171
new_cube_land = add_fx_variables (new_cube_land , fx_vars ,
155
172
CheckLevels .IGNORE )
156
- new_cube_sea = iris .cube .Cube (self .new_cube_data ,
157
- dim_coords_and_dims = self .coords_spec )
173
+ new_cube_sea = iris .cube .Cube (
174
+ self .new_cube_data ,
175
+ dim_coords_and_dims = self .cube_coords_spec
176
+ )
158
177
new_cube_sea = add_fx_variables (new_cube_sea , fx_vars ,
159
178
CheckLevels .IGNORE )
160
179
result_land = mask_landsea (
@@ -177,10 +196,14 @@ def test_mask_landsea(self, tmp_path):
177
196
assert_array_equal (result_sea .data , expected )
178
197
179
198
# mask with shp files
180
- new_cube_land = iris .cube .Cube (self .new_cube_data ,
181
- dim_coords_and_dims = self .coords_spec )
182
- new_cube_sea = iris .cube .Cube (self .new_cube_data ,
183
- dim_coords_and_dims = self .coords_spec )
199
+ new_cube_land = iris .cube .Cube (
200
+ self .new_cube_data ,
201
+ dim_coords_and_dims = self .cube_coords_spec
202
+ )
203
+ new_cube_sea = iris .cube .Cube (
204
+ self .new_cube_data ,
205
+ dim_coords_and_dims = self .cube_coords_spec
206
+ )
184
207
result_land = mask_landsea (new_cube_land , 'land' )
185
208
result_sea = mask_landsea (new_cube_sea , 'sea' )
186
209
@@ -207,15 +230,17 @@ def test_mask_landseaice(self, tmp_path):
207
230
'frequency' : 'fx' ,
208
231
'filename' : sftgif_file }
209
232
}
210
- new_cube_ice = iris .cube .Cube (self .new_cube_data ,
211
- dim_coords_and_dims = self .coords_spec )
233
+ new_cube_ice = iris .cube .Cube (
234
+ self .new_cube_data ,
235
+ dim_coords_and_dims = self .cube_coords_spec
236
+ )
212
237
new_cube_ice = add_fx_variables (new_cube_ice , fx_vars ,
213
238
CheckLevels .IGNORE )
214
239
result_ice = mask_landseaice (new_cube_ice , 'ice' )
215
- expected = np .ma .empty ((3 , 3 ))
240
+ expected = np .ma .empty ((2 , 3 , 3 ))
216
241
expected .data [:] = 200.
217
- expected .mask = np .ones ((3 , 3 ), bool )
218
- expected .mask [1 , 2 ] = False
242
+ expected .mask = np .ones ((2 , 3 , 3 ), bool )
243
+ expected .mask [:, 1 , 2 ] = False
219
244
np .ma .set_fill_value (result_ice .data , 1e+20 )
220
245
np .ma .set_fill_value (expected , 1e+20 )
221
246
assert_array_equal (result_ice .data , expected )
0 commit comments