Calculation of TOA radiance from Sentinel-2 1C product reflectance

I was trying to convert the Sentinel-2 1C product to radiance and came across two links first once says

radiance = ((pixelValueBandX * cos(incidenceAngle) * solarIrradianceBandX) / (pi * d2)) / 10000

        where d2 is 1.0/U

Where as second one says

rad = rho * cos(radians(sza)) * Es * sc / (pi * d2)
where: d2 = 1.0 / U
scale: 1 / (0.001 * 1000) = 1 (default)

So, I have few questions amongst the two which one is correct. I don’t see any scaling factor in the first one. Moreover, does the incidence angle here denotes the value of Mean_Sun_Angle.ZENITH_ANGLE from file MTD_TL.xml ?

Also, Let’s say i do atmospheric correction using SEN2COR or DOS. I would get the BOA reflectance, right? So, then how do i convert it to a BOA radiance?

If you want to work with atmospherically corrected data, you need to select the appropriate data source (Sentinel-2 L2A). THe parameters SENCOR and DOS are just approximation of this correction and will not make it possible to get results that you are looking for.

I suggest you check the following documentation as well:

ok, from Sentinel-2 L2A i would get the surface reflectance (BOA). Then how do i convert it to a BOA radiance?

Can’t you use the same algorithm as you have described above?

Yes, but there were two links which i found. Which one is correct as i asked in the original question.

Ah, I see. The formulas look more or less the same to me, but I might be missing something.

This goes beyond my knowledge. Perhaps someone else can help.