10
10
from .LegacyMeta import LutFile , ProjectMeta , ScanMeta
11
11
from .tools import parse_csv
12
12
13
-
14
13
SEP_ENDING = "_sep.gif"
15
14
MEASURE_ENDING = "_meas.txt"
16
15
@@ -254,6 +253,21 @@ def read(self):
254
253
date_entry ["raw_background_1" ] = a_file
255
254
if a_file .name .endswith ("_back_large_raw_2.tif" ):
256
255
date_entry ["raw_background_2" ] = a_file
256
+ # Remove incomplete entries, as seen e.g. in:
257
+ # 20240911_0908_background_large_manual.tif
258
+ # 20240911_0908_back_large_1.tif
259
+ # 20240911_0908_back_large_2.tif
260
+ # 20240911_0908_back_large_manual_log.txt
261
+ # 20240911_0908_back_large_raw_1.tif
262
+ # 20240911_0908_back_large_raw_2.tif
263
+ # 20240911_1037_back_large_raw_1.tif <- This one is a mistake
264
+ for a_date in list (self .content .keys ()):
265
+ file_set = self .content [a_date ]
266
+ if (
267
+ file_set ["raw_background_1" ] is None
268
+ or file_set ["raw_background_2" ] is None
269
+ ):
270
+ del self .content [a_date ]
257
271
258
272
def read_groups (self ) -> Dict [str , List [DirEntry ]]:
259
273
"""
@@ -290,7 +304,7 @@ def get_dates(self) -> List[str]:
290
304
"""
291
305
return list (self .content .keys ())
292
306
293
- def _last_date_before (self , max_date : datetime ) -> List [str ]:
307
+ def _last_dates_before (self , max_date : datetime ) -> List [Tuple [ datetime , str ] ]:
294
308
sorted_dates = sorted (
295
309
[
296
310
(datetime .strptime (a_date , "%Y%m%d_%H%M" ), a_date )
@@ -301,21 +315,22 @@ def _last_date_before(self, max_date: datetime) -> List[str]:
301
315
return not_after
302
316
303
317
def get_last_background_before (self , max_date : datetime ) -> Optional [Path ]:
304
- not_after = self ._last_date_before (max_date )
318
+ not_after = self ._last_dates_before (max_date )
305
319
if len (not_after ) == 0 :
306
320
return None
307
321
last_date , last_date_str = not_after [- 1 ]
308
322
return self .content [last_date_str ]["final_background" ]
309
323
310
324
def get_last_raw_backgrounds_before (self , max_date : datetime ) -> List [Path ]:
311
- not_after = self ._last_date_before (max_date )
325
+ not_after = self ._last_dates_before (max_date )
312
326
if len (not_after ) == 0 :
313
327
return []
314
328
last_date , last_date_str = not_after [- 1 ]
315
- return [
329
+ bg1 , bg2 = (
316
330
self .content [last_date_str ]["raw_background_1" ],
317
331
self .content [last_date_str ]["raw_background_2" ],
318
- ]
332
+ )
333
+ return [bg1 , bg2 ]
319
334
320
335
def get_raw_background_file (self , scan_date : str , index : Union [int , str ]) -> Path :
321
336
"""Return a conventional file path for a scanned background image"""
0 commit comments