File: rangeDimensionLink.py

package info (click to toggle)
python-nixio 1.5.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,888 kB
  • sloc: python: 12,527; cpp: 832; makefile: 25
file content (23 lines) | stat: -rw-r--r-- 640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import nixio
import numpy as np


def create_data(duration, interval):
    times = np.around(np.cumsum(np.random.poisson(2.0 * 1000, int(1.5 * duration / interval))) / 1000., 3)
    times = times[times < duration]
    return times


def main():
    event_times = create_data(10., 1.0)
    nixfile = nixio.File.open("range_link.nix", nixio.FileMode.Overwrite)
    b = nixfile.create_block("session", "nix.session")

    data_array = b.create_data_array("event times", "nix.event.times", data=event_times, label="time", unit="s")
    data_array.append_range_dimension_using_self()

    nixfile.close()


if __name__ == "__main__":
    main()