Skip to content

Commit 0daad62

Browse files
committed
Add bulge_flux_fraction column to source injection
1 parent 0537c5b commit 0daad62

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

python/lsst/pipe/tasks/insertFakes.py

+27-12
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,6 @@ class InsertFakesConfig(PipelineTaskConfig,
371371
default="disk_n",
372372
)
373373

374-
bulge_disk_flux_ratio_col = pexConfig.Field(
375-
doc="Source catalog column name for the bulge/disk flux ratio.",
376-
dtype=str,
377-
default="bulge_disk_flux_ratio",
378-
)
379-
380374
mag_col = pexConfig.Field(
381375
doc="Source catalog column name template for magnitudes, in the format "
382376
"``filter name``_mag_col. E.g., if this config variable is set to "
@@ -386,6 +380,13 @@ class InsertFakesConfig(PipelineTaskConfig,
386380
default="%s_mag"
387381
)
388382

383+
bulge_flux_fraction_col = pexConfig.Field(
384+
doc="Source catalog column name for fraction of flux in bulge "
385+
"component.",
386+
dtype=str,
387+
default="%s_bulge_flux_fraction"
388+
)
389+
389390
select_col = pexConfig.Field(
390391
doc="Source catalog column name to be used to select which sources to "
391392
"add.",
@@ -407,6 +408,13 @@ class InsertFakesConfig(PipelineTaskConfig,
407408

408409
# Deprecated config variables
409410

411+
bulge_disk_flux_ratio_col = pexConfig.Field(
412+
doc="Source catalog column name for the bulge/disk flux ratio.",
413+
dtype=str,
414+
default="bulge_disk_flux_ratio",
415+
deprecated="Use `bulge_flux_fraction_col` instead."
416+
)
417+
410418
raColName = pexConfig.Field(
411419
doc="RA column name used in the fake source catalog.",
412420
dtype=str,
@@ -789,16 +797,23 @@ def add_to_replace_dict(new_name, depr_name, std_name):
789797
"axis ratio."
790798
)
791799

792-
# Process the bulge/disk flux ratio if possible.
793-
if cfg.bulge_disk_flux_ratio_col in fakeCat.columns:
800+
# Populate bulge_flux_fraction using either new-style with string interpolation,
801+
# or old-style from b/d flux ratio. If neither are available, fall back to
802+
# deprecated behavior of bd flux ratio = 1.0, or equivalently,
803+
# bulge_flux_fraction=0.5
804+
if cfg.bulge_flux_fraction_col%band in fakeCat.columns:
794805
fakeCat = fakeCat.rename(
795806
columns={
796-
cfg.bulge_disk_flux_ratio_col: 'bulge_disk_flux_ratio'
807+
cfg.bulge_flux_fraction_col%band: 'bulge_flux_fraction'
797808
},
798809
copy=False
799810
)
811+
elif cfg.bulge_disk_flux_ratio_col in fakeCat.columns:
812+
fakeCat['bulge_flux_fraction'] = (
813+
fakeCat['bulge_disk_flux_ratio'] / (1 + fakeCat['bulge_disk_flux_ratio'])
814+
)
800815
else:
801-
fakeCat['bulge_disk_flux_ratio'] = 1.0
816+
fakeCat['bulge_flux_fraction'] = 0.5
802817

803818
return fakeCat
804819

@@ -850,7 +865,7 @@ def _generateGSObjectsFromCatalog(self, exposure, fakeCat, galCheckVal, starChec
850865
disk = galsim.Sersic(n=row['disk_n'], half_light_radius=disk_gs_HLR)
851866
disk = disk.shear(q=row['disk_axis_ratio'], beta=((90 - row['disk_pa'])*galsim.degrees))
852867

853-
gal = bulge*row['bulge_disk_flux_ratio'] + disk
868+
gal = bulge*row['bulge_flux_fraction'] + disk*(1-row['bulge_flux_fraction'])
854869
gal = gal.withFlux(flux)
855870

856871
yield skyCoord, gal
@@ -1159,7 +1174,7 @@ def mkFakeGalsimGalaxies(self, fakeCat, band, photoCalib, pixelScale, psf, image
11591174
disk = galsim.Sersic(n=row['disk_n'], half_light_radius=disk_gs_HLR)
11601175
disk = disk.shear(q=row['disk_axis_ratio'], beta=((90 - row['disk_pa'])*galsim.degrees))
11611176

1162-
gal = bulge*row['bulge_disk_flux_ratio'] + disk
1177+
gal = bulge*row['bulge_flux_fraction'] + disk*(1-row['bulge_flux_fraction'])
11631178
gal = gal.withFlux(flux)
11641179

11651180
psfIm = galsim.InterpolatedImage(galsim.Image(psfKernel), scale=pixelScale)

0 commit comments

Comments
 (0)