dd_to_hms
- ssapy.utils.dd_to_hms(degree_decimal)[source][source]
Converts Decimal Degrees (DD) to Hour-Minute-Second (HMS) format.
Parameters:
- degree_decimal (float or str):
A decimal degree value (float) to be converted to HMS format.
If the input is a string in DMS format (e.g., “12:34:56”), it will be converted to DD using the dms_to_dd function before processing.
Returns:
- str: A string representing the HMS format (e.g., “12:34:56”). The format includes:
Hours as an integer.
Minutes as an integer.
Seconds as a float (rounded to 4 decimal places if necessary).
Notes:
Decimal degrees are divided by 15 to convert to hours.
If the input DD value is negative, the function assumes the absolute value for conversion and prints a warning message.
Handles edge cases where seconds reach 60, incrementing minutes accordingly.
Returns seconds as an integer if the value is a whole number.
Example:
>>> dd_to_hms(188.73333333333332) '12:34:56'
>>> dd_to_hms(-236.375) '15:45:30' # Assumes positive value for conversion.
>>> dd_to_hms("12:34:56") # DMS string converted to DD first. '0:50:18.4'