@@ -48,7 +48,22 @@ def setUp(self):
48
48
units = Unit (
49
49
'days since 1950-01-01' ,
50
50
calendar = 'gregorian' ))
51
-
51
+ yr_time = iris .coords .DimCoord ([15 , 410 ],
52
+ standard_name = 'time' ,
53
+ bounds = [[1. , 30. ], [395. , 425. ]],
54
+ units = Unit (
55
+ 'days since 1950-01-01' ,
56
+ calendar = 'gregorian' ))
57
+ yr_time2 = iris .coords .DimCoord ([1. , 367. , 733. , 1099. ],
58
+ standard_name = 'time' ,
59
+ bounds = [
60
+ [0.5 , 1.5 ],
61
+ [366 , 368 ],
62
+ [732 , 734 ],
63
+ [1098 , 1100 ], ],
64
+ units = Unit (
65
+ 'days since 1950-01-01' ,
66
+ calendar = 'gregorian' ))
52
67
zcoord = iris .coords .DimCoord ([0.5 , 5. , 50. ],
53
68
standard_name = 'air_pressure' ,
54
69
long_name = 'air_pressure' ,
@@ -75,6 +90,14 @@ def setUp(self):
75
90
coords_spec5 = [(time2 , 0 ), (zcoord , 1 ), (lats , 2 ), (lons , 3 )]
76
91
self .cube2 = iris .cube .Cube (data3 , dim_coords_and_dims = coords_spec5 )
77
92
93
+ coords_spec4_yr = [(yr_time , 0 ), (zcoord , 1 ), (lats , 2 ), (lons , 3 )]
94
+ self .cube1_yr = iris .cube .Cube (data2 ,
95
+ dim_coords_and_dims = coords_spec4_yr )
96
+
97
+ coords_spec5_yr = [(yr_time2 , 0 ), (zcoord , 1 ), (lats , 2 ), (lons , 3 )]
98
+ self .cube2_yr = iris .cube .Cube (data3 ,
99
+ dim_coords_and_dims = coords_spec5_yr )
100
+
78
101
def test_get_time_offset (self ):
79
102
"""Test time unit."""
80
103
result = _get_time_offset ("days since 1950-01-01" )
@@ -91,20 +114,34 @@ def test_compute_statistic(self):
91
114
self .assert_array_equal (stat_mean , expected_mean )
92
115
self .assert_array_equal (stat_median , expected_median )
93
116
94
- def test_compute_full_statistic_cube (self ):
117
+ def test_compute_full_statistic_mon_cube (self ):
95
118
data = [self .cube1 , self .cube2 ]
96
119
stats = multi_model_statistics (data , 'full' , ['mean' ])
97
120
expected_full_mean = np .ma .ones ((2 , 3 , 2 , 2 ))
98
121
expected_full_mean .mask = np .zeros ((2 , 3 , 2 , 2 ))
99
122
expected_full_mean .mask [1 ] = True
100
123
self .assert_array_equal (stats ['mean' ].data , expected_full_mean )
101
124
102
- def test_compute_overlap_statistic_cube (self ):
125
+ def test_compute_full_statistic_yr_cube (self ):
126
+ data = [self .cube1_yr , self .cube2_yr ]
127
+ stats = multi_model_statistics (data , 'full' , ['mean' ])
128
+ expected_full_mean = np .ma .ones ((4 , 3 , 2 , 2 ))
129
+ expected_full_mean .mask = np .zeros ((4 , 3 , 2 , 2 ))
130
+ expected_full_mean .mask [2 :4 ] = True
131
+ self .assert_array_equal (stats ['mean' ].data , expected_full_mean )
132
+
133
+ def test_compute_overlap_statistic_mon_cube (self ):
103
134
data = [self .cube1 , self .cube1 ]
104
135
stats = multi_model_statistics (data , 'overlap' , ['mean' ])
105
136
expected_ovlap_mean = np .ma .ones ((2 , 3 , 2 , 2 ))
106
137
self .assert_array_equal (stats ['mean' ].data , expected_ovlap_mean )
107
138
139
+ def test_compute_overlap_statistic_yr_cube (self ):
140
+ data = [self .cube1_yr , self .cube1_yr ]
141
+ stats = multi_model_statistics (data , 'overlap' , ['mean' ])
142
+ expected_ovlap_mean = np .ma .ones ((2 , 3 , 2 , 2 ))
143
+ self .assert_array_equal (stats ['mean' ].data , expected_ovlap_mean )
144
+
108
145
def test_compute_std (self ):
109
146
"""Test statistic."""
110
147
data = [self .cube1 .data [0 ], self .cube2 .data [0 ] * 2 ]
@@ -134,7 +171,7 @@ def test_put_in_cube(self):
134
171
stat_cube = _put_in_cube (self .cube1 , cube_data , "mean" , t_axis = None )
135
172
self .assert_array_equal (stat_cube .data , self .cube1 .data )
136
173
137
- def test_datetime_to_int_days (self ):
174
+ def test_datetime_to_int_days_no_overlap (self ):
138
175
"""Test _datetime_to_int_days."""
139
176
computed_dats = _datetime_to_int_days (self .cube1 )
140
177
expected_dats = [0 , 31 ]
0 commit comments