jluastro / PopSyCLE

Population Synthesis for Compact-object Lensing Events
https://popsycle.readthedocs.io/en/latest/
16 stars 3 forks source link

black hole neighbors cause unphysical blend fractions #34

Open MichaelMedford opened 3 years ago

MichaelMedford commented 3 years ago

I found a microlensing event where there is a black hole in the neighbors. The bug is that the negative magnitude of the black hole is a mask indicating no brightness. However that "negative" magnitude is being propagated into the f_blend to create unphysical results.

Here is an example:

from astropy.io import fits
refined_events = fits.open('/g2/scratch/microlens/galaxia/gridruns/l6_b3/l6_b3_refined_events_r_Schlafly11.fits')[1].data
idx = 1484

mag_source = refined_events[idx]['ubv_r_app_S']
mag_neighbor = refined_events[idx]['ubv_r_app_N']
mag_lens = refined_events[idx]['ubv_r_app_L']
print('-- Magnitudes -- ')
print('Source mag: %.2f' % mag_source)
print('Neighbor mag: %.2f' % mag_neighbor)
print('Lens mag: %.2f' % mag_lens)

f_blend = refined_events[idx]['f_blend_r']
mag_to_flux = lambda x: 10 ** (x / -2.5)
b_sff = mag_to_flux(mag_source) / (mag_to_flux(mag_source) + mag_to_flux(mag_lens) + mag_to_flux(mag_neighbor))
print('-- Blending -- ')
print('f_blend: %.2e' % f_blend)
print('b_sff: %.2e' % b_sff)

This produces:

-- Magnitudes -- 
Source mag: 18.29
Neighbor mag: -300.76
Lens mag: 26.92
-- Blending -- 
f_blend: 2.39e-128
b_sff: 2.39e-128

The f_blend_r field is simply treating the neighbor magnitude as if it were a physical quantity. This results in a very small blend fraction that does represent what you would expect for an 18th magnitude star behind a 27th magnitude lens.