How can I calculate the elliptical shape of the sun at sunset. Is their a formula?
This shape is called the “omega shape”, at least as the lower limb of the sun disappears beneath the apparent horizon (the sun has already set quite a bit farther beneath the horizon and one is only seeing so much of the sun because of refraction effects). It is called an omega because it is not strictly an oval or ellipse at that point, and actually has a pair of “feet” at the bottom like an omega. The actual shape will vary, depending on refraction effects, and those depend on the temperature profile of the atmospheric layers. The shape is typically computed in a simulation by ray-tracing, although one might be able to do some sort of approximation by an ellipse. See the attached link for more details.