In [6]:
%matplotlib inline
import matplotlib.pyplot as plt
import pyecog as pg
In [8]:
pg
Out[8]:
In [2]:
ls
In [4]:
ndf_filepath = 'test_ndf_conversion/M1456819229.ndf'
ndf_filepath = 'M1493298027.ndf'
In [7]:
%%time
ndf_file = pg.NdfFile(ndf_filepath, verbose = True, fs = 'auto')
ndf_file.load(read_ids='all',
auto_glitch_removal=True,
auto_resampling=True,
auto_filter=True)
To access individual transmitters:
ndf_file.tid_set
ontains the valid transmitter id's the ndf file. And you can index the file with the transmitter number. Doing this returns a dictionary with data and time fields.
In [7]:
ndf_file.tid_set
Out[7]:
In [9]:
ndf_file[2]
Out[9]:
Can plot like so:
In [12]:
plt.plot(ndf_file[6]['time'], ndf_file[6]['data'])
Out[12]:
There is also a really small convienance funtion in the module that lets you select time in seconds.
In [13]:
pg.basic_plot(ndf_file[6], time_tuple=(1000,1500))
Out[13]:
To save to csv it is probably easiest to use pandas:
In [14]:
data = ndf_file[6]['data']
data.shape
Out[14]:
In [16]:
import pandas as pd
df = pd.DataFrame(data)
In [17]:
df.to_csv('transmitter_6.csv')
In [19]:
%%time
ndf_file = pg.NdfFile(ndf_filepath, verbose = True, fs = 'auto')
ndf_file.load(read_ids=[6])
In [20]:
%%time
ndf_file.save()
In [23]:
%time
h5file = pg.H5File('test_ndf_conversion/M1456819229_Tid_[6].h5')
In [24]:
h5file[6]
Out[24]:
In [25]:
pg.basic_plot(h5file[6], (1000,1500))
Out[25]:
In [26]:
handler = pg.DataHandler()
In [30]:
%%time
handler.convert_ndf_directory_to_h5(ndf_dir = 'test_ndf_conversion',
tids = 'all',
fs = 256,
n_cores = -1,
save_dir = 'h5_converted')
In [ ]: