@@ -223,14 +223,22 @@ def __grids(self):
223223 useful_chunk = ndimage .find_objects (np .where (self .data .mask , 0 , 1 ))
224224 assert (len (useful_chunk ) == 1 )
225225 x_dim , y_dim = self .data [useful_chunk [0 ]].shape
226+ # Use 'back-size-x' and 'back-size-y' if available, fall back to 'grid'.
227+ back_size_x = self .conf .image .back_size_x or self .conf .image .grid
228+ if back_size_x is None :
229+ raise ValueError ("Expected either back-size-x or grid to be set in the config object" )
230+ back_size_y = self .conf .image .back_size_y or self .conf .image .grid
231+ if back_size_y is None :
232+ raise ValueError ("Expected either back-size-y or grid to be set in the config object" )
226233 # We should divide up the image into subimages such that each grid
227234 # node is centered on a subimage. This is only possible if
228235 # self.back_size_x and self.back_size_y are divisors of xdim and ydim,
229236 # respectively. If not, we need to select a frame within useful_chunk
230237 # that does have the appropriate dimensions. At the same time, it should
231238 # be as large as possible and centered within useful_chunk.
232- rem_row = np .mod (x_dim , self .conf .image .back_size_x )
233- rem_col = np .mod (y_dim , self .conf .image .back_size_y )
239+ rem_row = np .mod (x_dim , back_size_x )
240+ rem_col = np .mod (y_dim , back_size_y )
241+
234242 start_offset_row , rem_rem_row = divmod (rem_row , 2 )
235243 start_offset_col , rem_rem_col = divmod (rem_col , 2 )
236244 end_offset_row = start_offset_row + rem_rem_row
@@ -245,8 +253,8 @@ def __grids(self):
245253
246254 # Before proceeding, check that our data has the size of at least
247255 # one subimage, for both dimensions.
248- if (centred_inds [1 ] - centred_inds [0 ] > self . conf . image . back_size_x and
249- centred_inds [3 ] - centred_inds [2 ] > self . conf . image . back_size_y ):
256+ if (centred_inds [1 ] - centred_inds [0 ] > back_size_x and
257+ centred_inds [3 ] - centred_inds [2 ] > back_size_y ):
250258
251259 subimages , number_of_elements_for_each_subimage = \
252260 utils .make_subimages (self .data .data [centred_inds [0 ]:
@@ -257,7 +265,7 @@ def __grids(self):
257265 centred_inds [1 ],
258266 centred_inds [2 ]:
259267 centred_inds [3 ]],
260- self . conf . image . back_size_x , self . conf . image . back_size_y )
268+ back_size_x , back_size_y )
261269
262270 mean_grid = np .zeros (number_of_elements_for_each_subimage .shape ,
263271 dtype = np .float32 )
0 commit comments