Converting rectangular to polar coordinates I'm following the steps in this paper on how to calculate geocentric longitude. In section 3.4.2 it says the
Geocentric rectangular co-ordinates of Mercury then are:
Xg = Xh−X0 = 0.990 A.U.
Yg = Yh−Y0 = −0.259 A.U.

Converting these into polar form, we get the geocentric distance and longitude as:
rg = √(X2g+Y2g) = 1.024 A.U.
λg = tan−1(Yg/Xg) = 345.3◦.

For the life of me I cannot get the inverse tan of (Yg/Xg) to give me 345.3. This is what I'm doing in python:
Xg= 0.990 
Yg= -0.259 
math.degrees(math.atan(Yg/Xg)) = -14.66091789971255

Any help greatly appreciated.
You miss the simple fact that a circle is 360° periodic. Your result is correct:
360°-14.66° = 345.34°.
Thus you miss that the arctan usually returns -180...+180° and you don't correct for the fact that the longitude is positive defined in the range of 0 ... 360°. Thus add +360° when your result is negative.