The boat heading is given by the compass, that gives the Compass Heading (HDC).
The magnetic masses of the boat influence the compass, which is a magnetic device. This influence is called the compass deviation, noted d.
It depends on the boat and on its heading. Your compass has to be calibrated, the output of this calibration is a deviation curve, that gives the value of the deviation for any given heading.
The deviation is between the Compass Heading (HDC) and the Magnetic Heading (HDM).
Between the Magnetic Heading (HDM) and the True Heading (HDG) is the Magnetic Declination (noted D). It depends on your location, and on the date (it changes over time for a given location).
The Magnetic Declination is given on the charts, and sometimes returned by the RMC sentence of the GPS.
The algebraic sum of the Declination and the deviation is called the Compass' Variation (noted W).
d (from dev curve)
This one is hard to normalize... It takes some intuition from the navigator. This intuition can be influenced by many
factors, like the sea state, the weather situation, the skills of the driver..., etc.
It depends on the Apparent Wind Angle (AWA), and a MaxLeeway value.
The formula we use here is Leeway = MaxLeeway × cos(AWA), when AWA ∈ [-90, 90], 0 otherwise.
The True wind is to be calculated with the GPS data.
Picture that (and draw a sketch if needed):
You are "sailing" in no wind at all (like in the San Francisco Bay in winter), and a 5 knot current is taking you out of the Bay (or inside, or wherever).
BSP is zero, True Wind Speed (TWS) is zero too, and in this case, AWS would be the speed of the current (5 knots), the AWA will depend on (but be equivalent to) the direction the current is taking you to.
If you calculate the TWS based on BSP, CMG, AWA and AWS, you will find a TWS equal to AWS - which is wrong because there is no wind, and a wrong TWA (and True Wind Direction (TWD) as well, no wind has no direction).
But, if you replace BSP with Speed Over Ground (SOG), and CMG with Course Over Ground (COG), you are back in business; COG is the current direction, SOG is the current speed.
Think about it.
This obviously requires the knowledge of SOG & COG, returned by a GPS.
When the boat is moving, that eventually means that an accurate TWA and TWS (and TWD) is elaborated by a accurate knowledge of
In short: this is not trivial. At all, by far, mostly because of CMG (see above for details).
The full picture.
A note about the current
On the figure above, the current is calculated by triangulation. This is an interesting trigonometry exercice, involving many angles and many parameters
as you can see.
The experience shows that the current estimation is much more accurate when the values are smoothed over a period of time (like 1 to 10 minutes).
We will get back to this in another document.