I'm trying to make an application that calculates ISS flyovers.
I figured out how to actually get the flyover, but I am struggling with figuring out how to calculate the apparent magnitude of the space station during those flyovers. I've looked at Is there any way to calculate the visual magnitude of a satellite (ISS)? and Calculating the Phase Angle between the Sun / ISS and an observer on the earth.
I figured out how to calculate the solar phase angle, but I cannot figure out how to get the formula provided by Is there any way to calculate the visual magnitude of a satellite (ISS)? working. I have the phase angle in degrees and the distance to the satellite in km. This is the formula:
Mag = Std. Mag - 15 + 5*LOG(Range) - 2.5*LOG(SIN(B) + (pi-B)*COS(B))
For the ISS I use -1.8 as the std.mag. https://stackoverflow.com/users/2949204/liam-kennedy provided this formula and seems to know how to get it working, but I can't for my life.
Note: I am doing this in C# and know my phase angle is correct, but even doing it with Python and pyephem I wasn't getting anything close to Heavens-Above's results. Setting B to 113, std.mag to -1.8, and range to 485 is giving me 11.25, yet on Heavens-Above with the exact same data they get -3.0.
Here is the code I am using
var B = phaseAngle;
var magnitude = intrinsicMagnitude - 15 + 5 * Math.Log(distanceToSatellite) - 2.5 * Math.Log(Math.Sin(B) + (Math.PI - B) * Math.Cos(B));
EDIT: I solved this problem here: https://astronomy.stackexchange.com/questions/28744/calculating-the-apparent-magnitude-of-a-satellite/28765#28765
Moderator please mark this solved.