Coverage for src/ufig/config/common.py: 100%

196 statements  

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

1# Copyright (C) 2018 ETH Zurich, Institute for Particle Physics and Astrophysics 

2 

3""" 

4Created on Mar 6, 2018 

5author: Joerg Herbel 

6""" 

7 

8import numpy as np 

9 

10# ================================================================== 

11# G E N E R A L 

12# ================================================================== 

13 

14# Filters 

15 

16# Filter bands (multi-band only): 

17filters = ["g", "r", "i", "z", "Y"] 

18 

19# Reference filter band for cutting eg. apparent star magnitudes: 

20reference_band = "r" 

21 

22# Output 

23 

24# Tile name (multi-band only): 

25tile_name = "ufig" 

26 

27# Format of image names (multi-band only): 

28image_name_format = "{}_{}.fits" 

29 

30# Format of galaxy catalog names (multi-band only) 

31galaxy_catalog_name_format = "{}_{}.gal.cat" 

32 

33# Format of star catalog names (multi-band only) 

34star_catalog_name_format = "{}_{}.star.cat" 

35 

36# Format of detection clf catalog names (multi-band only) 

37det_clf_catalog_name_format = "{}_{}.det_clf.cat" 

38 

39# Dictionary of image names (multi-band only): 

40image_name_dict = {} 

41 

42# Dictionary of galaxy catalog names (multi-band only): 

43galaxy_catalog_name_dict = {} 

44 

45# Dictionary of star catalog names (multi-band only): 

46star_catalog_name_dict = {} 

47 

48# Dictionary of detection clf catalog names (multi-band: 

49det_clf_catalog_name_dict = {} 

50# only) 

51 

52# output image name: 

53image_name = "ufig.fits" 

54 

55# output catalog of galaxies used: 

56galaxy_catalog_name = "ufig.gal.cat" 

57 

58# output catalog of stars used: 

59star_catalog_name = "ufig.star.cat" 

60 

61 

62# True if file should be overwritten: 

63overwrite = True 

64 

65# Maps path 

66 

67# Remote dir containing shear and PSF maps: 

68maps_remote_dir = "ufig_res/maps/" 

69 

70# Directory for writing SExtractor weight maps to fits: 

71tempdir_weight_fits = "" 

72 

73# Filepath containing overlap information: 

74filepath_overlapblock = None 

75 

76 

77# Seed and RNGs 

78 

79# General seed set when initializing UFig: 

80seed = 102301239 

81 

82# Seed offset set before converting mags to number of phot for gals 

83gal_nphot_seed_offset = 500 

84 

85# Seed offset set before sampling the number of stars: 

86star_num_seed_offset = 600 

87 

88# Seed offset set before sampling star positions: 

89star_dist_seed_offset = 700 

90 

91# Seed offset set before converting mags to number of phot for stars 

92star_nphot_seed_offset = 800 

93 

94# Seed offset set before rendering the gals (different phot noise) 

95gal_render_seed_offset = 900 

96 

97# Seed offset set before rendering the stars (different phot noise) 

98star_render_seed_offset = 1000 

99 

100# Seed offset set before drawing the background values in each pixel 

101background_seed_offset = 1100 

102coeffs_seed_offset = 1300 # Seed offset set before drawing template coefficients 

103 

104# Seed offset set before adding compression noise to image 

105compression_noise_seed_offset = 123234 

106 

107# galsbi seeds that are needed in ufig 

108seed_ngal = 500 

109gal_dist_seed_offset = 200 

110gal_sersic_seed_offset = 300 

111gal_ellipticities_seed_offset = 400 

112 

113# Value in ADU out to which stellar profiles are rendered (should be 

114render_stars_accuracy = 0.3 

115# sub-dominant to noise rms) 

116 

117 

118# Number of threads used when rendering photon-based: 

119n_threads_photon_rendering = 1 

120 

121# Stars below this magnitude will be rendered: 

122mag_pixel_rendering_stars = 17 

123# using pixel fft, ignoring higher order PSF moments 

124 

125# ================================================================== 

126# C A M E R A 

127# ================================================================== 

128 

129# pixel scale (arcsec/pixel): 

130pixscale = 0.263 

131 

132# Dictionary of saturation levels (multi-band only): 

133saturation_level_dict = {} 

134 

135# Dictionary of gain_dict (multi-band only): 

136gain_dict = {} 

137 

138# saturation (ADU): 

139saturation_level = 35256.77280358 

140 

141# gain (e/ADU): 

142gain = 4.321430284118572 

143 

144# ================================================================== 

145# I M A G E P R O P E R T I E S 

146# ================================================================== 

147 

148# number of pixels on image x-axis: 

149size_x = 10000 

150 

151# number of pixels on image y-axis: 

152size_y = 10000 

153 

154# center of field: 

155ra0 = 70.459787 

156 

157# center of field: 

158dec0 = -44.244444 

159 

160# Dictionary of magnitude zeropoints (multi-band only): 

161magzero_dict = {} 

162 

163# magnitude zeropoint: 

164magzero = 30.0 

165 

166# Dictionary of exposure times (multi-band only): 

167exposure_time_dict = {} 

168 

169# exposure time (s) of a single exposure: 

170exposure_time = 90.0 

171 

172# precision of the image: 

173image_precision = np.float64 

174 

175# ================================================================== 

176# I N P U T C A T A L O G S 

177# ================================================================== 

178 

179nside_sampling = 512 

180apparent_magnitude_offset = 0.0 

181 

182# Stars 

183# ---------------------------------- 

184# magnitude distribution (empricial) 

185# ----------------------------------: 

186 

187 

188# coefficient for CDF of stars: 

189stars_mag_0 = 17 

190 

191# coefficients for CDF of stars: 

192stars_mag_cdf_a = 0.000214734 

193 

194# magnitude distribution (a0,: 

195stars_mag_cdf_b = -0.00978518 

196 

197# a1, a2, a3 for (A.7) in Berge: 

198stars_mag_cdf_c = 0.189962 

199 

200# et al. 2012): 

201stars_mag_cdf_d = 2.80165 

202 

203# maximum star magnitude cutoff: 

204stars_mag_max = 27.0 

205 

206# minimum star magnitude cutoff: 

207stars_mag_min = 14.0 

208 

209# increase or decrease the number of stars: 

210# (they will be resampled from the Besancon model) 

211stars_counts_scale = 1 

212 

213# catalog precision 

214catalog_precision = np.float64 

215 

216# --------------------------------- 

217# magnitude distribution (Besancon) 

218# --------------------------------- 

219 

220# type of Besancon to use, options available:: 

221# besancon_map - use spatially varying Besancon model 

222# besancon_gaia_splice - splice GAIA and Besancon 

223star_catalogue_type = "besancon_map" 

224 

225# Format of besancon catalog file name (multi-band only) 

226besancon_cat_name_format = "{}_besancon.fits" 

227 

228# Catalog containing sample of stars: 

229besancon_cat_name = "ufig_besancon.fits" 

230 

231# -------------------------------- 

232# GAIA stars 

233# -------------------------------- 

234filepath_gaia = "DES0441-4414_gaia.h5" 

235gaia_mag_g_limit = 19 

236 

237# Maximum distanace in pixels to match detected objects with GAIA input 

238max_dist_pix_match_gaia = 1 

239 

240# --------------------------------------------------- 

241# spatially varying magnitude distribution (Besancon) 

242# --------------------------------------------------- 

243 

244# Path to pickle file containing list of available Besancon catalogs: 

245besancon_map_path = "cats/besancon_map_y1a1_nside8.pkl" 

246 

247# Galaxies 

248# ------------------------------------ 

249# magnitude distribution (single-band) 

250# ------------------------------------ 

251 

252# coefficient for CDF of galaxies: 

253gals_mag_0 = 23 

254 

255# coefficients for CDF of galaxies: 

256gals_mag_cdf_a = 0 

257 

258# magnitude distribution (a0,a1, a2, a3 for (A.7) in Berge et al. 2012): 

259gals_mag_cdf_b = -0.0076 

260gals_mag_cdf_c = 0.356 

261gals_mag_cdf_d = 4.52 

262 

263# maximum galaxy magnitude cutoff: 

264gals_mag_max = 27 

265 

266# minimum galaxy magnitude cutoff: 

267gals_mag_min = 16 

268 

269# ----------------------------------- 

270# size-mag distribution (single-band) 

271# ----------------------------------- 

272 

273# rms r50 size distribution (arcsec): 

274size_sigma = 0.35638773798050416 

275 

276# corr angle for r50 size-mag theta in (A.11) Berge et al. 2012 

277size_theta = 0.10000007376338751 

278 

279# mean magnitude; mag_p in (A.11): 

280size_mag_mean = 25.309 

281 

282# mean log(r50); log(r50,p) in (A.11): 

283size_log_mean = -0.796 

284 

285 

286# -------------------------- 

287# Limit on number of photons 

288# -------------------------- 

289 

290 

291# Upper limit on the sum of the number of photons for all galaxies. This parameter has 

292# the function to limit runtime for ABC runs. A reasonable value depends, among others, 

293# on the size of the image and the apparent magnitude limits: 

294n_phot_sum_gal_max = np.inf 

295 

296 

297# ================================================================== 

298# S H E A R 

299# ================================================================== 

300 

301# Type of the shear field (constant or variable): 

302shear_type = "constant" 

303 

304# --------------- 

305# constant shear 

306# --------------- 

307 

308# 1-Component of constant shear added to ellipticity: 

309g1_constant = 0.0 

310 

311# 2-Component of constant shear added to ellipticity: 

312g2_constant = 0.0 

313 

314# -------------- 

315# variable shear 

316# -------------- 

317 

318# Shear maps; must be stored in res/maps/ or in remote_dir 

319shear_maps = "shear_maps.fits" 

320 

321# Prefactor to account for a potential flipping of the shear g1-map: 

322g1_prefactor = -1 

323 

324# ================================================================== 

325# P S F 

326# ================================================================== 

327 

328# Type of the PSF field to add, options 

329# constant_moffat: 

330# maps_moffat: 

331# coadd_moffat_cnn 

332# coadd_moffat_cnn_read: 

333psf_type = "constant_moffat" 

334 

335 

336# beta parameter of the Moffat PSF: 

337# Relative flux in the first component of the PSF (set to one if PSF 

338# consists of a single component) 

339psf_beta = [3.5] 

340psf_flux_ratio = 1.0 

341psf_flux_ratio_variable = False 

342 

343# ------------ 

344# constant psf 

345# ------------ 

346 

347# FWHM of total PSF (arcsec): 

348seeing = 0.9 

349 

350# mean PSF e1: 

351psf_e1 = 0.015 

352 

353# mean PSF e2: 

354psf_e2 = 0.01 

355 

356# ------------ 

357# variable psf 

358# ------------ 

359 

360# Format of file names of PSF maps (multi-band only) 

361psf_maps_file_name_format = "psf_{}.fits" 

362 

363# Dictionary of file names of PSF maps (multi-band only): 

364psf_maps_dict = {} 

365 

366# Healpy maps with PSF fields (0: r50, 1: e1, 2: e2): 

367psf_maps = "sva1_2048_psf.fits" 

368filepath_psfmodel_input = "DES0441-4414_r_psfmodel.h5" 

369filepath_psfmodel_input_format = "DES0441-4414_{}_psfmodel.h5" 

370filepath_psfmodel_input_dict = {} 

371 

372 

373# Fudge factor calibrating input psf_r50: 

374psf_r50_factor = 1.0 

375 

376# Additive shift calibrating input psf_r50: 

377psf_r50_shift = 0.0 

378 

379# Fudge factor calibrating input psf_e1: 

380psf_e1_factor = 1.0 

381 

382# Additive shift calibrating input psf_e1: 

383psf_e1_shift = 0.0 

384 

385# Prefactor to account for a potential flipping of the PSF e1-map: 

386psf_e1_prefactor = -1 

387 

388# Fudge factor calibrating input psf_e2: 

389psf_e2_factor = 1.0 

390 

391# factors to modify the PSF cnn parameters: 

392psf_cnn_factors = { 

393 "psf_fwhm_cnn": [0.0, 1.0], 

394 "psf_e1_cnn": [0.0, 1.0], 

395 "psf_e2_cnn": [0.0, 1.0], 

396 "psf_f1_cnn": [0.0, 1.0], 

397 "psf_f2_cnn": [0.0, 1.0], 

398 "psf_g1_cnn": [0.0, 1.0], 

399 "psf_g2_cnn": [0.0, 1.0], 

400 "psf_kurtosis_cnn": [0.0, 1.0], 

401 "psf_flux_ratio_cnn": [0, 1.0], 

402} 

403 

404 

405# exponential suppression factor for the PSF flexions: 

406psf_flexion_suppression = -5.0 

407 

408 

409# ============== 

410# PSF estimation 

411# ============== 

412 

413# Output PSF model: 

414filepath_psfmodel_output = "ufig_psfmodel.h5" 

415 

416# Format of SExtractor output catalog filenames (multi-band only) 

417filepath_psfmodel_output_format = "{}.psfmodel.h5" 

418 

419# Dictionary of file names of output catalogs: 

420filepath_psfmodel_output_dict = {} 

421# (multi-band only) 

422 

423# Whether to store the filepath_psfmodel_output file (False will remove it) 

424psfmodel_output_store = False 

425 

426# Polynomial order for fitting PSF: 

427psfmodel_poly_order = 5 

428 

429# Regression regularisation parameter: 

430psfmodel_ridge_alpha = 1e-6 

431 

432# Type of polynomial to fit, options: [standard, chebyshev]: 

433psfmodel_polynomial_type = "standard" 

434 

435# magnitude of stars used in PSF fitting: 

436psfmodel_star_mag_range = [17, 22] 

437 

438# clip star outliers in PSF measurement: 

439psfmodel_n_sigma_clip = 3 

440 

441# fraction of stars to exclude from PSF fitting, use later for validation 

442psfmodel_fraction_validation_stars = 0 

443 

444# parameters for correcting brighter fatter, None or dict, example: {'c1r': 0.22, 

445# 'c1e1': -0.02, 'c1e2': 0.00, 'mag_ref':22}: 

446psfmodel_corr_brighter_fatter = None 

447 

448# columns use to find star outliers 

449psfmodel_outlier_removal_columns = [ 

450 "psf_fwhm", 

451 "psf_e1", 

452 "psf_e2", 

453] 

454 

455# ================ 

456# Shear estimation 

457# ================ 

458 

459# which method to use for shape estimation [moments_source_extractor, hsm]: 

460shear_estimation_method = "moments_source_extractor" 

461shear_estimation_stamp_shape = 29 

462shear_estimation_moments_window = "FLUX_RADIUS" 

463shear_estimation_hsm_round_moments = True 

464shear_estimation_hsm_params = {"max_mom2_iter": 1000} 

465 

466# =============== 

467# remove overlap with multiple tiles 

468# =============== 

469filename_overlapblock = "DES0441-4414_overlapblock.h5" 

470 

471# ================================================================== 

472# R A D I A L G A L A X Y P R O F I L E S T A B L E 

473# ================================================================== 

474 

475# Whether table with values of the inverse is computed on-the-fly 

476compute_gamma_table_onthefly = False 

477 

478# size of the interpolation for the: 

479sersicprecision = 9 

480 

481# interpolation of the intrinsic galaxy function: 

482gammaprecision = 13 

483 

484# boundary between different interpolation regimes of the radial cdf 

485gammaprecisionhigh = 4 

486# Wheter to copy the gamma table to the current working directory to avoid too many jobs 

487# accessing the same file 

488copy_gamma_table_to_cwd = False 

489 

490# ================================================================== 

491# B A C K G R O U N D A N D E X P O S U R E T I M E 

492# ================================================================== 

493 

494# Format of sysmaps: 

495# 'sysmaps_hdf' 

496# 'sysmaps_hdf_combined' 

497sysmaps_type = "sysmaps_hdf" 

498 

499 

500# Background 

501 

502# Type of the background model: 

503background_type = "gaussian" 

504 

505# -------------- 

506# constant noise 

507# -------------- 

508 

509# rms Gaussian noise (ADU) in coadd: 

510background_sigma = 5.8819049462619528 

511 

512# ----------------------------------------------- 

513# single-file systematic maps with exposure info 

514# #----------------------------------------------- 

515filepath_sysmaps = "tile_sys/DES0441-4414_r_sysmaps.h5" 

516 

517# Format of file names of background images (multi-band only) 

518filepath_sysmaps_format = "tile_sys/DES0441-4414_{}_sysmaps.h5" 

519 

520# Dictionary of file names of background images (multi-band only) 

521filepath_sysmaps_dict = {} 

522 

523 

524# -------------- 

525# variable noise 

526# -------------- 

527 

528# Format of file names of background images (multi-band only): 

529bkg_rms_file_name_format = "ufig_{}_bgrms.fits" 

530# Dictionary of file names of background images (multi-band only): 

531bkg_rms_file_name_dict = {} 

532 

533# Map containing the RMS of the background across the image: 

534bkg_rms_file_name = "background_rms.fits" 

535# Scaling the background_rms-map 

536bkg_noise_scale = 1.00 

537# Amplitude of the bkg_rms-map and mean of const gaussian bkg: 

538bkg_noise_amp = 0.0 

539 

540# Use if background_noise is called before convert_photons_to_adu: 

541bkg_noise_multiply_gain = False 

542 

543# ------------------ 

544# compression noise 

545# ----------------- 

546# Uniform noise in range [-compression_noise_level, compression_noise_level] 

547compression_noise_level = 0.6 

548# to emulate compression noise 

549 

550# ----------- 

551# chunked map 

552# ----------- 

553chunksize = 2500 # Size of the quadratic chunks background map is split up in 

554 

555# Exposure Time 

556exp_time_type = "constant" # Whether the exposure time varies across the image 

557 

558# ---------------------- 

559# constant exposure time 

560# ---------------------- 

561n_exp_dict = {} # Dictionary of exposure time (multi-band only) 

562n_exp = 7 # effective number of exposures in coadd 

563 

564# ---------------------- 

565# variable exposure time 

566# ---------------------- 

567 

568# Format of file names of exposure time images (multi-band only) 

569exp_time_file_name_format = "ufig_{}_texp.fits" 

570 

571# Dictionary of file names of exposure time images (multi-band only) 

572exp_time_file_name_dict = {} 

573 

574# Image of the exposure time in every pixel 

575exp_time_file_name = "" 

576 

577# Background subtraction 

578 

579# number of iterations for sigma clipping 

580bgsubract_n_iter = 10 

581 

582# spacing of pixels in img bkg estimation is done for (downsampling) 

583bgsubract_n_downsample = 50 

584 

585# size in pixels for local sky subtraction 

586back_size = 128 

587 

588# Resampling 

589 

590# lanczos_integral or read_from_file 

591lanczos_kernel_type = "lanczos_integral" 

592 

593# ------- 

594# lanczos 

595# ------- 

596 

597# kernel to simulate correlated noise (only for lanczos_integral) 

598lanczos_n = 2 

599 

600# ------------------------ 

601# empirical lanczos kernel 

602# ------------------------ 

603# Filepath containing empirical resampling kernel 

604 

605filename_resampling_kernel = "lanczos_resampling_kernel_n3.txt" 

606 

607# ================================================================== 

608# S O U R C E E X T R A C T O R 

609# ================================================================== 

610 

611# SExtractor executable 

612sextractor_binary = "sex" 

613 

614# SExtractor configuration file 

615sextractor_config = "default.sex" 

616 

617# SExtractor S/G separation neural network 

618sextractor_nnw = "default.nnw" 

619 

620# SExtractor filter 

621sextractor_filter = "gauss_3.0_5x5.conv" 

622 

623# SExtractor parameter file 

624sextractor_params = "default.param" 

625# Format of SExtractor output catalog filenames (multi-band only) 

626sextractor_catalog_name_format = "{}_{}.sexcat" 

627 

628# Dictionary of file names of output catalogs (multi-band only) 

629sextractor_catalog_name_dict = {} 

630 

631# SExtractor output catalog 

632sextractor_catalog_name = "ufig.sexcat" 

633 

634# SExtractor check-images; ["SEGMENTATION","BACKGROUND","APERTURES"] 

635sextractor_checkimages = [] 

636 

637# SExtractor check-images suffixes; ["_seg.fits","_bkg.fits","_ap.fits"] 

638sextractor_checkimages_suffixes = [] 

639sextractor_use_temp = False 

640sextractor_use_forced_photo = False 

641 

642# ----------------------------- 

643# variable source extractor run 

644# ----------------------------- 

645 

646# SExtractor weighting scheme (usually NONE or MAP_WEIGHT) 

647weight_type = "NONE" 

648 

649# SExtractor boolean whether weight maps are gain maps (Y) or not (N) 

650weight_gain = "N" 

651# Format of file names of weight images (multi-band only) 

652weight_image_format = "{}_{}_invvar.fits" 

653 

654# Dictionary of file names of weight images (multi-band only) 

655weight_image_dict = {} 

656# Name of weight image stored in maps_remote_dir 

657weight_image = "DES0441-4414_r_invvar.fits" 

658flag_gain_times_nexp = True 

659 

660# --------------------------------------- 

661# Forced-photometry run (multi-band only) 

662# --------------------------------------- 

663# Dictionary of file names of output catalogs for forced-photometry mode (multi-band 

664# only) 

665sextractor_forced_photo_catalog_name_dict = {} 

666 

667# Format of SExtractor output catalog filenames for forced-photomery mode (multi-band 

668# only) 

669sextractor_forced_photo_catalog_name_format = "{}_{}_forced_photo.sexcat" 

670 

671# Filter band used as detection image for forced-photometry mode (multi-band only) 

672sextractor_forced_photo_detection_bands = ["r"] 

673# Dictionary of file names of mask files for forced-photometry mode (multi-band only) 

674sextractor_mask_name_dict = {} 

675 

676 

677# ================================================================== 

678# M A T C H I N G 

679# ================================================================== 

680 

681# Number of cells in which obj are matched each axis is divided 

682matching_cells = 20 

683 

684# Percentage of overlap of matching cells 

685cells_overlap = 0.05 

686 

687# Max radius in x- and y-direction for obj to be matched (pixels) 

688max_radius = 2.5 

689 

690# Max mag difference for obj between input and output 

691mag_diff = 4 

692 

693# Extension the SExtractor catalog resides in 

694sextractor_ext = 2 

695 

696# Column containing x-coordinates used to match obj 

697matching_x = "XWIN_IMAGE" 

698 

699# Column containing y-coordinates used to match obj 

700matching_y = "YWIN_IMAGE" 

701 

702# Column containing magnitude used to match obj 

703matching_mag = "MAG_AUTO" 

704 

705# ================================================================== 

706# E M U L A T O R 

707# ================================================================== 

708 

709# how to estimate the flux when running the emulator, options available: 

710# - none: no flux estimation 

711# - full_image: estimate flux from a simplified rendering of the full image 

712# - points: equivalent to full_image but only evaluated at the positions of the objects 

713# (and therefore sometimes faster) 

714# - integrated: average galaxy density weighted by magnitudes and size 

715# - binned_integrated: average galaxy density weighted by magnitudes and size in bins 

716# - ngal: number of galaxies for different magnitude cuts 

717flux_estimation_type = "none" 

718 

719# magnitude value that is used for scaling 

720mag_for_scaling = [22, 23, 24] 

721 

722# r50 value that is used for scaling 

723r50_for_scaling = 0.5 

724 

725# number of bins used for flux estimation 

726n_bins_for_flux_estimation = 1 

727 

728# if to use the minimal emulator that does not require local information (e.g. bkg or 

729# psf) 

730emu_mini = False 

731 

732 

733# ================================================================== 

734# V A R I A B L E S Y S T E M A T I C S 

735# ================================================================== 

736 

737# These parameters are used to add some noise on estimated systematics such 

738# as background and PSF. This is useful to test the robustness of the pipeline 

739# to small errors in the systematics. 

740 

741# Background 

742# ---------------- 

743# standard deviation of the scatter added to the background amplitude 

744bkg_amp_variation_sigma = 0.0 

745bkg_amp_variation_sigma_dict = {} 

746# standard deviation of the scatter added to the background noise 

747bkg_noise_variation_sigma = 0.0 

748bkg_noise_variation_sigma_dict = {} 

749 

750# PSF 

751# ---------------- 

752# standard deviation of the scatter added to the PSF fwhm 

753psf_fwhm_variation_sigma = 0.0 

754psf_fwhm_variation_sigma_dict = {}