Coverage for src/ufig/plugins/cleanup_catalogs.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-12 19:08 +0000

1# Copyright (C) 2024 ETH Zurich 

2# Institute for Particle Physics and Astrophysics 

3# Author: Silvan Fischbacher 

4# created: Fri Sep 06 2024 

5 

6 

7from cosmic_toolbox import arraytools as at 

8from cosmic_toolbox import file_utils, logger 

9from ivy.plugin.base_plugin import BasePlugin 

10 

11LOGGER = logger.get_logger(__file__) 

12 

13 

14class Plugin(BasePlugin): 

15 """ 

16 Cleanup the catalogs: 

17 - delete det_clf catalogs 

18 - load the sextractor catalogs and restructure them such that they can be loaded 

19 with at.load_hdf like the ucat catalog 

20 """ 

21 

22 def __call__(self): 

23 par = self.ctx.parameters 

24 

25 for f in par.det_clf_catalog_name_dict: 

26 file_utils.robust_remove(par.det_clf_catalog_name_dict[f]) 

27 

28 try: 

29 for f in par.sextractor_forced_photo_catalog_name_dict: 

30 cat = at.load_hdf_cols(par.sextractor_forced_photo_catalog_name_dict[f]) 

31 file_utils.robust_remove( 

32 par.sextractor_forced_photo_catalog_name_dict[f] 

33 ) 

34 at.save_hdf(par.sextractor_forced_photo_catalog_name_dict[f], cat) 

35 except FileNotFoundError: 

36 pass 

37 

38 def __str__(self): 

39 return "cleanup catalogs"