diff --git a/btk/draw_blends.py b/btk/draw_blends.py index 42ddca6e8..5da0cb0fd 100644 --- a/btk/draw_blends.py +++ b/btk/draw_blends.py @@ -616,9 +616,10 @@ def render_single(self, entry, filt, psf, survey, extra_data): # get galaxy flux try: mag_name = f"{survey.name}_{filt.name}" - gal_flux = mag2counts(entry[mag_name], survey, filt).to_value("electron") + gal_mag = entry[mag_name] except KeyError: - gal_flux = mag2counts(entry["ref_mag"], survey, filt).to_value("electron") + gal_mag = entry["ref_mag"] + gal_flux = mag2counts(gal_mag, survey, filt).to_value("electron") gal = galsim_catalog.makeGalaxy( entry["btk_index"], gal_type=self.gal_type, noise_pad_size=0