Utils¶
Module that contains helpper functions for all over the program
Functions and Classes¶
-
addFloat2AmplitudeString(value, val_len, decimal_len, front)¶ Function for parsing a float into a correct string format. Front works as the parser character which tells the program how the string has to be formatted.
Examples:
>> addFloat2String(0.71, 6, 3, '>') " 0.710"
Parameters: Returns: formatted string
-
addFloat2SNRString(value, val_len, decimal_len, front)¶ Handles decimals of SNR values. In nordic2, there are two of them. In standard nordic, there is one. The number of decimals printed is as in the original file.
Parameters: Returns: formatted string
-
addFloat2String(value, val_len, decimal_len, front)¶ Function for parsing a float into a correct string format. Front works as the parser character which tells the program how the string has to be formatted.
Examples:
>> addFloat2String(0.71, 6, 3, '>') " 0.710"
Parameters: Returns: formatted string
-
addInteger2String(value, val_len, front)¶ Function for parsing a integer into a correct string format. Front works as the parser character which tells the program how the string has to be formatted.
Examples:
>> addInteger2String(3, 5, 0) "00003"
Parameters: Returns: formatted string
Raises: ValueError
-
addString2String(value, val_len, front)¶ Function for parsing a string into correct format. Front works as the parser character which tells how the string has to be formatted. Only formatters you can give for the function are ‘<’ and ‘>’.
Examples:
>> add_string_to_string("test", 6, '<') "test "
Parameters: Returns: formatted string
Raises: ValueError
-
editFloat2String(value, val_len, decimal_len, front)¶ Function for parsing a float into a correct string format. Front works as the parser character which tells the program how the string has to be formatted. This is mainly for handling distance values in nordics.
Takes into account the convention that in nordic2 format: * distances smaller than 10 km have two decimals * distances equal to or greater than 10 km have one decimal * distances equal to or greater than 100 km have no decimals and are shown as integer look-alikes.
Examples:
>> editFloat2String(134, 5, 3, '>') " 134" >> editFloat2String(13.4, 5, 3, '>') " 13.4" >> editFloat2String(1.34, 5, 3, '>') " 1.34"
In standard nordic, distances have no decimals. This is also taken into account. However, all values looking like integers in nordic are stored in the database in float format.
Parameters: - value (float) – float (may be pseudo-integer) that will be formatted
- val_len (int) – value that tells how long the string needs to be
- decimal_len (int) – value that tells how many of the letters will be allocated for the fraction. For values already close to an integer (pseudo-integers), this is not taken into account.
- front (str) – formatting character
Returns: formatted string
-
editFloat2TimeString(value, val_len, decimal_len, front)¶ Handles decimals of time residuals.
Parameters: Returns: formatted string
-
stringToDate(sDate)¶ Function for converting a date in string format “YYYYDDD” or “YYYY-MMM-DD” to “YYYY-MM-DD”.
Parameters: sDate (str) – date string Returns: the date in correct format as a string
-
xstr(s)¶ Function for casting a value to string and None to a empty string
Parameters: s – Value to be converted Returns: a string value