@@ -127,6 +127,23 @@ def _load_data(self, file_path: str, data_out: np.ndarray):
127127 else :
128128 data_out [t , :] = data
129129
130+ def _load_times (self ) -> np .ndarray :
131+ # Read in (only) the times for which SLCF data is available
132+ n = self .dimension .size (cell_centered = False )
133+ dtype_data = fdtype .combine (fdtype .FLOAT , fdtype .new ((('f' , n ),)))
134+
135+ file_path = os .path .join (self ._parent_slice ._root_path , self .filename )
136+
137+ n_t = (os .stat (file_path ).st_size - self ._offset ) // dtype_data .itemsize
138+ times = np .empty (n_t )
139+
140+ with open (file_path , 'rb' ) as infile :
141+ infile .seek (self ._offset )
142+ for t , data in enumerate (fdtype .read (infile , dtype_data , n_t )):
143+ times [t ] = data [0 ][0 ]
144+
145+ return times
146+
130147 @property
131148 def data (self ) -> np .ndarray :
132149 """Method to lazy load the slice's data.
@@ -189,18 +206,11 @@ class Slice(np.lib.mixins.NDArrayOperatorsMixin):
189206 :ivar extent: :class:`Extent` object containing 3-dimensional extent information.
190207 """
191208
192- def __init__ (self , root_path : str , slice_id : str , cell_centered : bool , times : np . ndarray ,
209+ def __init__ (self , root_path : str , slice_id : str , cell_centered : bool ,
193210 multimesh_data : Collection [Dict ]):
194211 self ._root_path = root_path
195212 self .cell_centered = cell_centered
196213
197- self .times = times
198-
199- if times is not None :
200- self .n_t = times .size
201- else :
202- self .n_t = - 1
203-
204214 self .id = slice_id
205215
206216 # List of all subslices this slice consists of (one per mesh).
@@ -262,6 +272,10 @@ def __init__(self, root_path: str, slice_id: str, cell_centered: bool, times: np
262272 y_start , y_start if self .orientation == 2 else y_end ,
263273 z_start , z_start if self .orientation == 3 else z_end )
264274
275+ # Read in the available time steps, using arbitrary the first sub-slice
276+ self .times = self .subslices [0 ]._load_times ()
277+ self .n_t = len (self .times )
278+
265279 # If lazy loading has been disabled by the user, load the data instantaneously instead
266280 if not settings .LAZY_LOAD :
267281 for _ , subslice in self ._subslices .items ():
0 commit comments