@@ -54,6 +54,7 @@ def __init__(
5454 self .grid_type = None # one of _GridType members
5555 self .cell_widths : list = None
5656 self .global_dims : list = None
57+ self .time_index_number : int = None
5758 self ._process_selection (xr_ds )
5859
5960 self .yt_coord_names = _convert_to_yt_internal_coords (self .selected_coords )
@@ -130,7 +131,8 @@ def _process_selection(self, xr_ds):
130131 reverse_axis = [] # axes must be positive-monitonic for yt
131132 reverse_axis_names = []
132133 global_dims = [] # the global shape
133- for c in full_coords :
134+ time_index_number = None
135+ for icoord , c in enumerate (full_coords ):
134136 coord_da = getattr (xr_ds , c ) # the full coordinate data array
135137
136138 # check if coordinate values are increasing
@@ -156,6 +158,8 @@ def _process_selection(self, xr_ds):
156158 sel_or_isel = getattr (coord_da , self .sel_dict_type )
157159 coord_vals = sel_or_isel (coord_select ).values .astype (np .float64 )
158160 is_time_dim = _check_for_time (c , coord_vals )
161+ if is_time_dim :
162+ time_index_number = icoord
159163
160164 if coord_vals .size > 1 :
161165 # not positive-monotonic? reverse it for cell width calculations
@@ -193,6 +197,8 @@ def _process_selection(self, xr_ds):
193197 self .ndims = len (n_edges )
194198 self .selected_shape = tuple (n_edges )
195199 self .select_shape_cells = tuple (n_cells )
200+ if time_index_number is not None :
201+ _ = full_dimranges .pop (time_index_number )
196202 self .full_bbox = np .array (full_dimranges ).astype (np .float64 )
197203 self .selected_bbox = np .array (dimranges ).astype (np .float64 )
198204 self .full_coords = tuple (full_coords )
@@ -201,9 +207,15 @@ def _process_selection(self, xr_ds):
201207 self .selected_time = time
202208 self .grid_type = grid_type
203209 self .cell_widths = cell_widths
204- self .reverse_axis = reverse_axis
205210 self .reverse_axis_names = reverse_axis_names
206211 self .global_dims = np .array (global_dims )
212+ if time_index_number is not None :
213+ _ = global_dims .pop (time_index_number )
214+ _ = reverse_axis .pop (time_index_number )
215+ self .reverse_axis = reverse_axis
216+ self .time_index_number = time_index_number
217+ self .global_dims_no_time = np .array (global_dims )
218+
207219 # self.coord_selected_arrays = coord_selected_arrays
208220
209221 # set the yt grid dictionary
0 commit comments