@@ -110,12 +110,8 @@ def __iter__(self) -> Union[xr.DataArray, xr.Dataset]:
110
110
init_time_indexer = xr .DataArray (selected_init_times , coords = coords )
111
111
step_indexer = xr .DataArray (steps , coords = coords )
112
112
113
- # Slice out the data which does not need to be diffed
114
- xr_non_accum = xr_data .sel ({self .channel_dim_name : non_accum_channels })
115
- xr_sel_non_accum = xr_non_accum .sel (step = step_indexer , init_time_utc = init_time_indexer )
116
-
117
113
if len (accum_channels ) == 0 :
118
- xr_sel = xr_sel_non_accum
114
+ xr_sel = xr_data . sel ( step = step_indexer , init_time_utc = init_time_indexer )
119
115
120
116
else :
121
117
# First minimise the size of the dataset we are diffing
@@ -125,13 +121,21 @@ def __iter__(self) -> Union[xr.DataArray, xr.Dataset]:
125
121
min_step = min (steps )
126
122
max_step = max (steps ) + (xr_data .step [1 ] - xr_data .step [0 ])
127
123
128
- xr_accum = xr_data .sel (
124
+ xr_min = xr_data .sel (
129
125
{
130
- self .channel_dim_name : accum_channels ,
131
126
"init_time_utc" : unique_init_times ,
132
127
"step" : slice (min_step , max_step ),
133
128
}
134
- ).compute ()
129
+ )
130
+
131
+ # Slice out the data which does not need to be diffed
132
+ xr_non_accum = xr_min .sel ({self .channel_dim_name : non_accum_channels })
133
+ xr_sel_non_accum = xr_non_accum .sel (
134
+ step = step_indexer , init_time_utc = init_time_indexer
135
+ )
136
+
137
+ # Slice out the channels which need to be diffed
138
+ xr_accum = xr_min .sel ({self .channel_dim_name : accum_channels })
135
139
136
140
# Take the diff and slice requested data
137
141
xr_accum = xr_accum .diff (dim = "step" , label = "lower" )
0 commit comments