@@ -1361,6 +1361,34 @@ def test_Field_indices(self):
13611361 x = g .dimension_coordinate ("X" ).array
13621362 self .assertTrue ((x == [- 200 , - 160 , - 120 , - 80 , - 40 , 0 , 40 ]).all ())
13631363
1364+ indices = f .indices (grid_longitude = cf .wo (1 , 5 ))
1365+ g = f [indices ]
1366+ self .assertEqual (g .shape , (1 , 10 , 9 ))
1367+ x = g .dimension_coordinate ("X" ).array
1368+ self .assertTrue (
1369+ (x == [- 320 , - 280 , - 240 , - 200 , - 160 , - 120 , - 80 , - 40 , 0 ]).all ()
1370+ )
1371+
1372+ indices = f .indices (grid_longitude = cf .wo (41 , 45 ))
1373+ g = f [indices ]
1374+ self .assertEqual (g .shape , (1 , 10 , 9 ))
1375+ x = g .dimension_coordinate ("X" ).array
1376+ self .assertTrue (
1377+ (x == [- 280 , - 240 , - 200 , - 160 , - 120 , - 80 , - 40 , 0 , 40 ]).all ()
1378+ )
1379+
1380+ indices = f .indices (grid_longitude = cf .wo (- 5 , - 1 ))
1381+ g = f [indices ]
1382+ self .assertEqual (g .shape , (1 , 10 , 9 ))
1383+ x = g .dimension_coordinate ("X" ).array
1384+ self .assertTrue ((x == [0 , 40 , 80 , 120 , 160 , 200 , 240 , 280 , 320 ]).all ())
1385+
1386+ indices = f .indices (grid_longitude = cf .wo (- 45 , - 41 ))
1387+ g = f [indices ]
1388+ self .assertEqual (g .shape , (1 , 10 , 9 ))
1389+ x = g .dimension_coordinate ("X" ).array
1390+ self .assertTrue ((x == [- 40 , 0 , 40 , 80 , 120 , 160 , 200 , 240 , 280 ]).all ())
1391+
13641392 with self .assertRaises (ValueError ):
13651393 # No X coordinate values lie outside the range [-90, 370]
13661394 f .indices (grid_longitude = cf .wo (- 90 , 370 ))
0 commit comments