-
Notifications
You must be signed in to change notification settings - Fork 8
/
ngb36utils.py
34 lines (27 loc) · 933 Bytes
/
ngb36utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
# -*- encoding: utf-8 -*-
'''
File:
ngb36utils.py
Description:
Implementation of time/frequency encoding in base36.
Change History:
2018-1-30 v0.1 created. github/zhenggao2
'''
from numpy import base_repr
def time2str36(hsfn, sfn, slot, symb):
#HSFN, range 0~1023, two base36 chars
strHsfn = base_repr(hsfn, base=36)
#SFN, range 0~1023, two base36 chars
strSfn = base_repr(sfn, base=36)
#slot, range 0~20, one base36 char
strSlot = base_repr(slot, base=36)
#symbol, range 0~7, one base36 char
strSymb = base_repr(symb, base=36)
return '[%s%s%s%s]' % (strHsfn.zfill(2), strSfn.zfill(2), strSlot, strSymb)
def freq2str36(prb, sc):
#prb, range 0~99, two base36 chars
strPrb = base_repr(prb, base=36)
#subcarrier, range 0~47, two base36 chars
strSc = base_repr(sc, base=36)
return '[%s%s]' % (strPrb.zfill(2), strSc.zfill(2))