The Question
I am familiar with the standard hydrostatic equation connecting pressure, density, and height/depth - $P = \rho gh$. However, it is well known that density ($\rho$) varies with temperature. Therefore, how should this equation be altered to account for a liquid$^1$ with a temperature gradient?
That is to say, what is the pressure at the bottom of a liquid where the temperature at the top is different to that at the point of pressure measurement?
Or am I incorrect in thinking it makes any difference?
(Although this post seems to indicate that I am right.)
The Context
I work for a company that provides control and monitoring systems for medium and large ships. A system recently provided for measuring the quantity of oil in the ship's tanks relies heavily on this equation, using pressure sensors installed in the tanks to calculate the depth of liquid. However, the client insists that our system is insufficiently accurate.
In the interests of customer satisfaction, and the potential for further system sales, I have been tasked with investigating ways of improving our mathematics, this being the main one. We already take account of the oil's Specific Gravity (as measured at 15ºC) and temperature at the pressure sensor (used to calculate the Volume Correction Factor, and therefore density), and are considering an extra temperature sensor at the top of the tank. My question is intended to find out if this will provide a notable benefit.
$^1$As you can see from the context, I am only interested in liquids. If your response takes gases into account too, that's fine by me.