sgnligo.base.utils
¶
A module that contains utility functions for SGN-LIGO programs.
from_T050017(url)
¶
Parse a URL in the style of T050017-00.
Source code in sgnligo/base/utils.py
23 24 25 26 27 28 29 |
|
now()
¶
A convenience function to return the current gps time
Source code in sgnligo/base/utils.py
16 17 18 19 20 |
|
parse_list_to_dict(lst, value_transform=None, sep='=', key_is_range=False, range_sep=':')
¶
A general list to dict argument parsing coercion function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lst
|
list
|
list, a list of the form ['A=V1', 'B=V2', ...], where "=" only has to match the sep_str argument |
required |
value_transform
|
Optional[FunctionType]
|
Function, default None. An optional transformation function to apply on values of the dictionary |
None
|
sep
|
str
|
str, default '=', the separator string between dict keys and values in list elements |
'='
|
key_is_range
|
bool
|
bool, default False. If True, the keys of the list are compound and contain range information e.g. "start:stop:remaining,list,of,items" |
False
|
range_sep
|
str
|
str, default ':' the separator string for range key information |
':'
|
Returns:
Type | Description |
---|---|
dict
|
dict of the form {'A': value_transform('V1'), ...} |
Examples:
>>> parse_list_to_dict(["H1=LSC-STRAIN", "H2=SOMETHING-ELSE"])
{'H1': 'LSC-STRAIN', 'H2': 'SOMETHING-ELSE'}
>>> parse_list_to_dict(["0000:0002:H1=LSC_STRAIN_1,L1=LSC_STRAIN_2",
... "0002:0004:H1=LSC_STRAIN_3,L1=LSC_STRAIN_4",
... "0004:0006:H1=LSC_STRAIN_5,L1=LSC_STRAIN_6"],
... key_is_range=True)
{'0000': {'H1': 'LSC_STRAIN_1', 'L1': 'LSC_STRAIN_2'},
'0001': {'H1': 'LSC_STRAIN_1', 'L1': 'LSC_STRAIN_2'},
'0002': {'H1': 'LSC_STRAIN_3', 'L1': 'LSC_STRAIN_4'},
'0003': {'H1': 'LSC_STRAIN_3', 'L1': 'LSC_STRAIN_4'},
'0004': {'H1': 'LSC_STRAIN_5', 'L1': 'LSC_STRAIN_6'},
'0005': {'H1': 'LSC_STRAIN_5', 'L1': 'LSC_STRAIN_6'}}
Source code in sgnligo/base/utils.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
state_vector_on_off_bits(bit)
¶
Format the given bitmask appropriately as an integer
Source code in sgnligo/base/utils.py
32 33 34 35 36 37 38 39 40 41 42 43 |
|