*compassBox.lua*for having the apparent elevation of the bodies. These equations are from Jean Meeus (

*Astronomical Algorithms*)

Code: Select all

`----------- START REFRACTION ----------------------`

local get_refraction = function(obs, refObj)

--[[ Calculate the adjustment in altitude of a body due to atmosphric

refraction. This value varies over altitude, pressure and temperature.

Note: Default values for pressure and temperature are 1010 mBar and 10C

respectively.]]--

local my_atm_press = 980; -- mBar (user define parameter)

local my_temp = 20; -- degree Celsius (user define parameter)

R = 1.0 / math.tan(math.rad(elev + (7.31 / (elev + 4.4))));

R = R - (0.06 * math.sin (math.rad (14.7 * (R / 60.0) + 13.0)));

-- take into account of atm press and temp

R = R * ((1010 / my_atm_press) * (283.15 / (273.15 + my_temp)));

-- convert from arcminutes to degrees

R = math.abs(R/60.0);

-- no refraction when the elevation is less of zero

if elev < 0 then R = 0.000 end

return R;

-- Citation and code port from LIBNOVA, C++ astronomical library (SOURCEFORGE.net)

end

----------- END REFRACTION ------------------------

The code is a function called when the longlatBox is drawn and displayed with a new textlayout label. The refraction's value will be zero for elevations less than zero. Refraction behave (based on custom location's pressure and temperature) from a maximum for low bodies' elevations to a minimum for high bodies' elevations. Such value is added to the true elevation.

If someone wish to test the code, a zip with the improved compassBox.lua is here

Notice that I've put the labels in such a position, but nonetheless it can be as is it in the default file. Just fit the refraction's text string for you needs.