Coverage for src/ufig/config/common.py: 100%
215 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 15:17 +0000
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 15:17 +0000
1# Copyright (C) 2018 ETH Zurich, Institute for Particle Physics and Astrophysics
3"""
4Created on Mar 6, 2018
5author: Joerg Herbel
6"""
8import numpy as np
10# ==================================================================
11# G E N E R A L
12# ==================================================================
14# Filters
16# Filter bands (multi-band only):
17filters = ["g", "r", "i", "z", "Y"]
19# Reference filter band for cutting eg. apparent star magnitudes:
20reference_band = "r"
22# Output
24# Tile name (multi-band only):
25tile_name = "ufig"
27# Format of image names (multi-band only):
28image_name_format = "{}_{}.fits"
30# Format of galaxy catalog names (multi-band only)
31galaxy_catalog_name_format = "{}_{}.gal.cat"
33# Format of star catalog names (multi-band only)
34star_catalog_name_format = "{}_{}.star.cat"
36# Format of detection clf catalog names (multi-band only)
37det_clf_catalog_name_format = "{}_{}.det_clf.cat"
39# Dictionary of image names (multi-band only):
40image_name_dict = {}
42# Dictionary of galaxy catalog names (multi-band only):
43galaxy_catalog_name_dict = {}
45# Dictionary of star catalog names (multi-band only):
46star_catalog_name_dict = {}
48# Dictionary of detection clf catalog names (multi-band:
49det_clf_catalog_name_dict = {}
50# only)
52# output image name:
53image_name = "ufig.fits"
55# output catalog of galaxies used:
56galaxy_catalog_name = "ufig.gal.cat"
58# output catalog of stars used:
59star_catalog_name = "ufig.star.cat"
62# True if file should be overwritten:
63overwrite = True
65# Maps path
67# Remote dir containing shear and PSF maps:
68maps_remote_dir = "ufig_res/maps/"
70# Directory for writing SExtractor weight maps to fits:
71tempdir_weight_fits = ""
73# Filepath containing overlap information:
74filepath_overlapblock = None
77# Seed and RNGs
79# General seed set when initializing UFig:
80seed = 102301239
82# Seed offset set before converting mags to number of phot for gals
83gal_nphot_seed_offset = 500
85# Seed offset set before sampling the number of stars:
86star_num_seed_offset = 600
88# Seed offset set before sampling star positions:
89star_dist_seed_offset = 700
91# Seed offset set before converting mags to number of phot for stars
92star_nphot_seed_offset = 800
94# Seed offset set before rendering the gals (different phot noise)
95gal_render_seed_offset = 900
97# Seed offset set before rendering the stars (different phot noise)
98star_render_seed_offset = 1000
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
104# Seed offset set before adding compression noise to image
105compression_noise_seed_offset = 123234
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
113# Value in ADU out to which stellar profiles are rendered (should be
114render_stars_accuracy = 0.3
115# sub-dominant to noise rms)
118# Number of threads used when rendering photon-based:
119n_threads_photon_rendering = 1
121# Stars below this magnitude will be rendered:
122mag_pixel_rendering_stars = 17
123# using pixel fft, ignoring higher order PSF moments
125# ==================================================================
126# C A M E R A
127# ==================================================================
129# pixel scale (arcsec/pixel):
130pixscale = 0.263
132# Dictionary of saturation levels (multi-band only):
133saturation_level_dict = {}
135# Dictionary of gain_dict (multi-band only):
136gain_dict = {}
138# saturation (ADU):
139saturation_level = 35256.77280358
141# gain (e/ADU):
142gain = 4.321430284118572
144# ==================================================================
145# I M A G E P R O P E R T I E S
146# ==================================================================
148# number of pixels on image x-axis:
149size_x = 10000
151# number of pixels on image y-axis:
152size_y = 10000
154# center of field:
155ra0 = 70.459787
157# center of field:
158dec0 = -44.244444
160# Dictionary of magnitude zeropoints (multi-band only):
161magzero_dict = {}
163# magnitude zeropoint:
164magzero = 30.0
166# Dictionary of exposure times (multi-band only):
167exposure_time_dict = {}
169# exposure time (s) of a single exposure:
170exposure_time = 90.0
172# precision of the image:
173image_precision = np.float64
175# ==================================================================
176# I N P U T C A T A L O G S
177# ==================================================================
179nside_sampling = 512
180apparent_magnitude_offset = 0.0
182# Stars
183# ----------------------------------
184# magnitude distribution (empricial)
185# ----------------------------------:
188# coefficient for CDF of stars:
189stars_mag_0 = 17
191# coefficients for CDF of stars:
192stars_mag_cdf_a = 0.000214734
194# magnitude distribution (a0,:
195stars_mag_cdf_b = -0.00978518
197# a1, a2, a3 for (A.7) in Berge:
198stars_mag_cdf_c = 0.189962
200# et al. 2012):
201stars_mag_cdf_d = 2.80165
203# maximum star magnitude cutoff:
204stars_mag_max = 27.0
206# minimum star magnitude cutoff:
207stars_mag_min = 14.0
209# increase or decrease the number of stars:
210# (they will be resampled from the Besancon model)
211stars_counts_scale = 1
213# catalog precision
214catalog_precision = np.float64
216# ---------------------------------
217# magnitude distribution (Besancon)
218# ---------------------------------
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"
225# Format of besancon catalog file name (multi-band only)
226besancon_cat_name_format = "{}_besancon.fits"
228# Catalog containing sample of stars:
229besancon_cat_name = "ufig_besancon.fits"
231# --------------------------------
232# GAIA stars
233# --------------------------------
234filepath_gaia = "DES0441-4414_gaia.h5"
235gaia_mag_g_limit = 19
237# Maximum distanace in pixels to match detected objects with GAIA input
238max_dist_pix_match_gaia = 1
240# ---------------------------------------------------
241# spatially varying magnitude distribution (Besancon)
242# ---------------------------------------------------
244# Path to pickle file containing list of available Besancon catalogs:
245besancon_map_path = "cats/besancon_map_y1a1_nside8.pkl"
247# Galaxies
248# ------------------------------------
249# magnitude distribution (single-band)
250# ------------------------------------
252# coefficient for CDF of galaxies:
253gals_mag_0 = 23
255# coefficients for CDF of galaxies:
256gals_mag_cdf_a = 0
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
263# maximum galaxy magnitude cutoff:
264gals_mag_max = 27
266# minimum galaxy magnitude cutoff:
267gals_mag_min = 16
269# -----------------------------------
270# size-mag distribution (single-band)
271# -----------------------------------
273# rms r50 size distribution (arcsec):
274size_sigma = 0.35638773798050416
276# corr angle for r50 size-mag theta in (A.11) Berge et al. 2012
277size_theta = 0.10000007376338751
279# mean magnitude; mag_p in (A.11):
280size_mag_mean = 25.309
282# mean log(r50); log(r50,p) in (A.11):
283size_log_mean = -0.796
286# --------------------------
287# Limit on number of photons
288# --------------------------
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
297# ==================================================================
298# S H E A R
299# ==================================================================
301# Type of the shear field (constant or variable):
302shear_type = "constant"
304# ---------------
305# constant shear
306# ---------------
308# 1-Component of constant shear added to ellipticity:
309g1_constant = 0.0
311# 2-Component of constant shear added to ellipticity:
312g2_constant = 0.0
314# --------------
315# variable shear
316# --------------
318# Shear maps; must be stored in res/maps/ or in remote_dir
319shear_maps = "shear_maps.fits"
321# Prefactor to account for a potential flipping of the shear g1-map:
322g1_prefactor = -1
324# ==================================================================
325# P S F
326# ==================================================================
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"
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
343# ------------
344# constant psf
345# ------------
347# FWHM of total PSF (arcsec):
348seeing = 0.9
350# mean PSF e1:
351psf_e1 = 0.015
353# mean PSF e2:
354psf_e2 = 0.01
356# ------------
357# variable psf
358# ------------
360# Format of file names of PSF maps (multi-band only)
361psf_maps_file_name_format = "psf_{}.fits"
363# Dictionary of file names of PSF maps (multi-band only):
364psf_maps_dict = {}
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 = {}
373# Fudge factor calibrating input psf_r50:
374psf_r50_factor = 1.0
376# Additive shift calibrating input psf_r50:
377psf_r50_shift = 0.0
379# Fudge factor calibrating input psf_e1:
380psf_e1_factor = 1.0
382# Additive shift calibrating input psf_e1:
383psf_e1_shift = 0.0
385# Prefactor to account for a potential flipping of the PSF e1-map:
386psf_e1_prefactor = -1
388# Fudge factor calibrating input psf_e2:
389psf_e2_factor = 1.0
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}
405# exponential suppression factor for the PSF flexions:
406psf_flexion_suppression = -5.0
409# ==============
410# PSF estimation
411# ==============
413# Output PSF model:
414filepath_psfmodel_output = "ufig_psfmodel.h5"
416# Format of SExtractor output catalog filenames (multi-band only)
417filepath_psfmodel_output_format = "{}.psfmodel.h5"
419# Dictionary of file names of output catalogs:
420filepath_psfmodel_output_dict = {}
421# (multi-band only)
423# Catalog of PSF model parameters
424filepath_psfmodel_output_catalog = "ufig_psfmodel.cat"
426# Whether to store the filepath_psfmodel_output file (False will remove it)
427psfmodel_output_store = False
429# Polynomial order for fitting PSF:
430psfmodel_poly_order = 5
432# Regression regularisation parameter dictionary:
433psfmodel_ridge_alpha = dict(
434 psf_flux_ratio_cnn=2.10634454232412,
435 psf_fwhm_cnn=0.12252798573828638,
436 psf_e1_cnn=0.5080218046913018,
437 psf_e2_cnn=0.5080218046913018,
438 psf_f1_cnn=2.10634454232412,
439 psf_f2_cnn=2.10634454232412,
440 psf_g1_cnn=1.311133937421563,
441 psf_g2_cnn=1.311133937421563,
442 se_mom_fwhm=0.12,
443 se_mom_win=0.12,
444 se_mom_e1=0.51,
445 se_mom_e2=0.51,
446 astrometry_diff_x=0.5,
447 astrometry_diff_y=0.5,
448)
450# Type of polynomial to fit, options: [standard, chebyshev]:
451psfmodel_polynomial_type = "standard"
453# magnitude of stars used in PSF fitting:
454psfmodel_star_mag_range = [17, 22]
456# clip star outliers in PSF measurement:
457psfmodel_n_sigma_clip = 3
459# fraction of stars to exclude from PSF fitting, use later for validation
460psfmodel_fraction_validation_stars = 0
462# parameters for correcting brighter fatter
463psfmodel_corr_brighter_fatter = {
464 "c1r": 0.0,
465 "c1e1": 0.0,
466 "c1e2": 0.0,
467 "mag_ref": 22,
468 "apply_to_galaxies": False,
469}
471# columns use to find star outliers
472psfmodel_outlier_removal_columns = [
473 "psf_fwhm",
474 "psf_e1",
475 "psf_e2",
476]
478# maximum number of refits for outlier removal
479psfmodel_n_max_refit = 10
481# astrometry errors flag
482psfmodel_astrometry_errors = False
484# star stamp shape
485psfmodel_star_stamp_shape = (19, 19)
487# sextractor flags for star selection
488psfmodel_sextractor_flags = [0, 16]
490# flag coadd boundaries
491psfmodel_flag_coadd_boundaries = True
493# moments limits
494psfmodel_moments_lim = (-99, 99)
496# beta limits
497psfmodel_beta_lim = (1.5, 10)
499# fwhm limits
500psfmodel_fwhm_lim = (1, 10)
502# ellipticity limits
503psfmodel_ellipticity_lim = (-0.3, 0.3)
505# flexion limits
506psfmodel_flexion_lim = (-0.3, 0.3)
508# kurtosis limits
509psfmodel_kurtosis_lim = (-1, 1)
511# raise underdetermined error flag
512psfmodel_raise_underdetermined_error = False
514# PSF measurement adjustment (None or dict)
515psf_measurement_adjustment = None
517# minimum number of exposures
518psfmodel_min_n_exposures = 0
520# save star cube flag
521psfmodel_save_star_cube = False
523# maximum distance for GAIA matching in arcsec
524psfmodel_max_dist_gaia_arcsec = 0.1
526# CNN variance type
527psfmodel_cnn_variance_type = "constant"
529# ==================================================================
530# Shear estimation
531# ================
533# which method to use for shape estimation [moments_source_extractor, hsm]:
534shear_estimation_method = "moments_source_extractor"
535shear_estimation_stamp_shape = 29
536shear_estimation_moments_window = "FLUX_RADIUS"
537shear_estimation_hsm_round_moments = True
538shear_estimation_hsm_params = {"max_mom2_iter": 1000}
540# ===============
541# remove overlap with multiple tiles
542# ===============
543filename_overlapblock = "DES0441-4414_overlapblock.h5"
545# ==================================================================
546# 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
547# ==================================================================
549# Whether table with values of the inverse is computed on-the-fly
550compute_gamma_table_onthefly = False
552# size of the interpolation for the:
553sersicprecision = 9
555# interpolation of the intrinsic galaxy function:
556gammaprecision = 13
558# boundary between different interpolation regimes of the radial cdf
559gammaprecisionhigh = 4
560# Wheter to copy the gamma table to the current working directory to avoid too many jobs
561# accessing the same file
562copy_gamma_table_to_cwd = False
564# ==================================================================
565# 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
566# ==================================================================
568# Format of sysmaps:
569# 'sysmaps_hdf'
570# 'sysmaps_hdf_combined'
571sysmaps_type = "sysmaps_hdf"
574# Background
576# Type of the background model:
577background_type = "gaussian"
579# --------------
580# constant noise
581# --------------
583# rms Gaussian noise (ADU) in coadd:
584background_sigma = 5.8819049462619528
586# -----------------------------------------------
587# single-file systematic maps with exposure info
588# #-----------------------------------------------
589filepath_sysmaps = "tile_sys/DES0441-4414_r_sysmaps.h5"
591# Format of file names of background images (multi-band only)
592filepath_sysmaps_format = "tile_sys/DES0441-4414_{}_sysmaps.h5"
594# Dictionary of file names of background images (multi-band only)
595filepath_sysmaps_dict = {}
598# --------------
599# variable noise
600# --------------
602# Format of file names of background images (multi-band only):
603bkg_rms_file_name_format = "ufig_{}_bgrms.fits"
604# Dictionary of file names of background images (multi-band only):
605bkg_rms_file_name_dict = {}
607# Map containing the RMS of the background across the image:
608bkg_rms_file_name = "background_rms.fits"
609# Scaling the background_rms-map
610bkg_noise_scale = 1.00
611# Amplitude of the bkg_rms-map and mean of const gaussian bkg:
612bkg_noise_amp = 0.0
614# Use if background_noise is called before convert_photons_to_adu:
615bkg_noise_multiply_gain = False
617# ------------------
618# compression noise
619# -----------------
620# Uniform noise in range [-compression_noise_level, compression_noise_level]
621compression_noise_level = 0.6
622# to emulate compression noise
624# -----------
625# chunked map
626# -----------
627chunksize = 2500 # Size of the quadratic chunks background map is split up in
629# Exposure Time
630exp_time_type = "constant" # Whether the exposure time varies across the image
632# ----------------------
633# constant exposure time
634# ----------------------
635n_exp_dict = {} # Dictionary of exposure time (multi-band only)
636n_exp = 7 # effective number of exposures in coadd
638# ----------------------
639# variable exposure time
640# ----------------------
642# Format of file names of exposure time images (multi-band only)
643exp_time_file_name_format = "ufig_{}_texp.fits"
645# Dictionary of file names of exposure time images (multi-band only)
646exp_time_file_name_dict = {}
648# Image of the exposure time in every pixel
649exp_time_file_name = ""
651# Background subtraction
653# number of iterations for sigma clipping
654bgsubract_n_iter = 10
656# spacing of pixels in img bkg estimation is done for (downsampling)
657bgsubract_n_downsample = 50
659# size in pixels for local sky subtraction
660back_size = 128
662# Resampling
664# lanczos_integral or read_from_file
665lanczos_kernel_type = "lanczos_integral"
667# -------
668# lanczos
669# -------
671# kernel to simulate correlated noise (only for lanczos_integral)
672lanczos_n = 2
674# ------------------------
675# empirical lanczos kernel
676# ------------------------
677# Filepath containing empirical resampling kernel
679filename_resampling_kernel = "lanczos_resampling_kernel_n3.txt"
681# ==================================================================
682# S O U R C E E X T R A C T O R
683# ==================================================================
685# SExtractor executable
686sextractor_binary = "sex"
688# SExtractor configuration file
689sextractor_config = "default.sex"
691# SExtractor S/G separation neural network
692sextractor_nnw = "default.nnw"
694# SExtractor filter
695sextractor_filter = "gauss_3.0_5x5.conv"
697# SExtractor parameter file
698sextractor_params = "default.param"
699# Format of SExtractor output catalog filenames (multi-band only)
700sextractor_catalog_name_format = "{}_{}.sexcat"
702# Dictionary of file names of output catalogs (multi-band only)
703sextractor_catalog_name_dict = {}
705# SExtractor output catalog
706sextractor_catalog_name = "ufig.sexcat"
708# SExtractor check-images; ["SEGMENTATION","BACKGROUND","APERTURES"]
709sextractor_checkimages = []
711# SExtractor check-images suffixes; ["_seg.fits","_bkg.fits","_ap.fits"]
712sextractor_checkimages_suffixes = []
713sextractor_use_temp = False
714sextractor_use_forced_photo = False
715# radius for the adding of the flags
716sextractor_catalog_off_mask_radius = 1
718# -----------------------------
719# variable source extractor run
720# -----------------------------
722# SExtractor weighting scheme (usually NONE or MAP_WEIGHT)
723weight_type = "NONE"
725# SExtractor boolean whether weight maps are gain maps (Y) or not (N)
726weight_gain = "N"
727# Format of file names of weight images (multi-band only)
728weight_image_format = "{}_{}_invvar.fits"
730# Dictionary of file names of weight images (multi-band only)
731weight_image_dict = {}
732# Name of weight image stored in maps_remote_dir
733weight_image = "DES0441-4414_r_invvar.fits"
734flag_gain_times_nexp = True
736# ---------------------------------------
737# Forced-photometry run (multi-band only)
738# ---------------------------------------
739# Dictionary of file names of output catalogs for forced-photometry mode (multi-band
740# only)
741sextractor_forced_photo_catalog_name_dict = {}
743# Format of SExtractor output catalog filenames for forced-photomery mode (multi-band
744# only)
745sextractor_forced_photo_catalog_name_format = "{}_{}_forced_photo.sexcat"
747# Filter band used as detection image for forced-photometry mode (multi-band only)
748sextractor_forced_photo_detection_bands = ["r"]
749# Dictionary of file names of mask files for forced-photometry mode (multi-band only)
750sextractor_mask_name_dict = {}
753# ==================================================================
754# M A T C H I N G
755# ==================================================================
757# Number of cells in which obj are matched each axis is divided
758matching_cells = 20
760# Percentage of overlap of matching cells
761cells_overlap = 0.05
763# Max radius in x- and y-direction for obj to be matched (pixels)
764max_radius = 2.5
766# Max mag difference for obj between input and output
767mag_diff = 4
769# Extension the SExtractor catalog resides in
770sextractor_ext = 2
772# Column containing x-coordinates used to match obj
773matching_x = "XWIN_IMAGE"
775# Column containing y-coordinates used to match obj
776matching_y = "YWIN_IMAGE"
778# Column containing magnitude used to match obj
779matching_mag = "MAG_AUTO"
781# ==================================================================
782# E M U L A T O R
783# ==================================================================
785# how to estimate the flux when running the emulator, options available:
786# - none: no flux estimation
787# - full_image: estimate flux from a simplified rendering of the full image
788# - points: equivalent to full_image but only evaluated at the positions of the objects
789# (and therefore sometimes faster)
790# - integrated: average galaxy density weighted by magnitudes and size
791# - binned_integrated: average galaxy density weighted by magnitudes and size in bins
792# - ngal: number of galaxies for different magnitude cuts
793flux_estimation_type = "none"
795# magnitude value that is used for scaling
796mag_for_scaling = [22, 23, 24]
798# r50 value that is used for scaling
799r50_for_scaling = 0.5
801# number of bins used for flux estimation
802n_bins_for_flux_estimation = 1
804# if to use the minimal emulator that does not require local information (e.g. bkg or
805# psf)
806emu_mini = False
809# ==================================================================
810# V A R I A B L E S Y S T E M A T I C S
811# ==================================================================
813# These parameters are used to add some noise on estimated systematics such
814# as background and PSF. This is useful to test the robustness of the pipeline
815# to small errors in the systematics.
817# Background
818# ----------------
819# standard deviation of the scatter added to the background amplitude
820bkg_amp_variation_sigma = 0.0
821bkg_amp_variation_sigma_dict = {}
822# standard deviation of the scatter added to the background noise
823bkg_noise_variation_sigma = 0.0
824bkg_noise_variation_sigma_dict = {}
826# PSF
827# ----------------
828# standard deviation of the scatter added to the PSF fwhm
829psf_fwhm_variation_sigma = 0.0
830psf_fwhm_variation_sigma_dict = {}