Coverage for src/ufig/plugins/estimate_psf.py: 86%

17 statements  

« prev     ^ index     » next       coverage.py v7.10.2, created at 2025-08-07 15:17 +0000

1# Copyright (C) 2025 ETH Zurich 

2# Institute for Particle Physics and Astrophysics 

3# Author: Silvan Fischbacher 

4# created: Wed Jul 23 2025 

5 

6import os 

7 

8from cosmic_toolbox import logger 

9from ivy.plugin.base_plugin import BasePlugin 

10 

11from ufig.psf_estimation import PSFEstimationPipeline 

12 

13LOGGER = logger.get_logger(__file__) 

14 

15 

16class Plugin(BasePlugin): 

17 def __call__(self): 

18 par = self.ctx.parameters 

19 

20 psf_est = PSFEstimationPipeline( 

21 astrometry_errors=par.psfmodel_astrometry_errors, 

22 max_dist_gaia_arcsec=par.psfmodel_max_dist_gaia_arcsec, 

23 cnn_variance_type=par.psfmodel_cnn_variance_type, 

24 filepath_cnn_info=getattr(par, "filepath_cnn_info", None), 

25 poly_order=par.psfmodel_poly_order, 

26 polynomial_type=par.psfmodel_polynomial_type, 

27 star_mag_range=par.psfmodel_star_mag_range, 

28 min_n_exposures=par.psfmodel_min_n_exposures, 

29 n_sigma_clip=par.psfmodel_n_sigma_clip, 

30 fraction_validation_stars=par.psfmodel_fraction_validation_stars, 

31 save_star_cube=par.psfmodel_save_star_cube, 

32 psfmodel_raise_underdetermined_error=par.psfmodel_raise_underdetermined_error, 

33 star_stamp_shape=par.psfmodel_star_stamp_shape, 

34 sextractor_flags=par.psfmodel_sextractor_flags, 

35 flag_coadd_boundaries=par.psfmodel_flag_coadd_boundaries, 

36 moments_lim=par.psfmodel_moments_lim, 

37 beta_lim=par.psfmodel_beta_lim, 

38 fwhm_lim=par.psfmodel_fwhm_lim, 

39 ellipticity_lim=par.psfmodel_ellipticity_lim, 

40 flexion_lim=par.psfmodel_flexion_lim, 

41 kurtosis_lim=par.psfmodel_kurtosis_lim, 

42 n_max_refit=par.psfmodel_n_max_refit, 

43 psf_measurement_adjustment=par.psf_measurement_adjustment, 

44 psfmodel_corr_brighter_fatter=par.psfmodel_corr_brighter_fatter, 

45 psfmodel_ridge_alpha=par.psfmodel_ridge_alpha, 

46 image_shape=(par.size_y, par.size_x), 

47 precision=par.catalog_precision, 

48 ) 

49 

50 sexcat_name = None 

51 if os.path.exists(par.sextractor_catalog_name): 51 ↛ 52line 51 didn't jump to line 52 because the condition on line 51 was never true

52 sexcat_name = par.sextractor_catalog_name 

53 elif os.path.exists(par.sextractor_forced_photo_catalog_name): 53 ↛ 56line 53 didn't jump to line 56 because the condition on line 53 was always true

54 sexcat_name = par.sextractor_forced_photo_catalog_name 

55 

56 psf_est.create_psf_model( 

57 filepath_image=par.image_name, 

58 filepath_sexcat=sexcat_name, 

59 filepath_sysmaps=par.filepath_sysmaps, 

60 filepath_gaia=par.filepath_gaia, 

61 filepath_cnn=par.filepath_cnn, 

62 filepath_out_model=par.filepath_psfmodel_output, 

63 filepath_out_cat=par.filepath_psfmodel_output_catalog, 

64 ) 

65 

66 def __str__(self): 

67 return "estimate PSF"