hms_to_dd

ssapy.utils.hms_to_dd(hms)[source][source]

Converts Hour-Minute-Second (HMS) format to Decimal Degrees (DD).

Parameters:

hms (str or list of str): A single HMS string (e.g., “12:34:56”) or a list of HMS strings

(e.g., [“12:34:56”, “15:45:30”]). Each string should represent hours, minutes, and seconds separated by colons.

Returns:

float or list of float:
  • If the input is a single HMS string or a list with one element, returns a single float representing the decimal degree value.

  • If the input is a list of multiple HMS strings, returns a list of floats representing the decimal degree values.

Notes:

  • HMS values are converted to decimal degrees using the formula: Decimal Degrees = (Hours * 15) + (Minutes / 4) + (Seconds / 240).

  • Negative HMS values are not allowed, and the function will print an error message if encountered.

  • The function supports both single HMS strings and lists of HMS strings for batch conversion.

Example:

>>> hms_to_dd("12:34:56")
188.73333333333332
>>> hms_to_dd(["12:34:56", "15:45:30"])
[188.73333333333332, 236.375]