def open_file(maindir):
"""
Creates the digital RF reading object.
Args:
maindir (:obj:'str'): The directory where the data is located.
Returns:
drfObj (obj:"DigitalRFReader"): Digital RF Reader object.
chandict (obj:"dict"): Dictionary that holds info for the channels.
start_indx (obj:'long'): Start index in samples.
end_indx (obj:'long'): End index in samples.
"""
mainpath = os.path.expanduser(maindir)
drfObj = drf.DigitalRFReader(mainpath)
chans = drfObj.get_channels()
chandict={}
start_indx, end_indx=[0, sp.inf]
# Get channel info
for ichan in chans:
curdict = {}
curdict['sind'], curdict['eind'] = drfObj.get_bounds(ichan)
# determine the read boundrys assuming the sampling is the same.
start_indx = sp.maximum(curdict['sind'], start_indx)
end_indx = sp.minimum(curdict['eind'], end_indx)
dmetadict = drfObj.read_metadata(start_indx, end_indx, ichan)
dmetakeys = dmetadict.keys()
curdict['sps'] = dmetadict[dmetakeys[0]]['samples_per_second']
curdict['fo'] = dmetadict[dmetakeys[0]]['center_frequencies'].ravel()[0]
chandict[ichan] = curdict
return (drfObj, chandict, start_indx, end_indx)
评论列表
文章目录