Skip to content

Commit

Permalink
add CustomStream
Browse files Browse the repository at this point in the history
  • Loading branch information
qian-chu committed Sep 29, 2024
1 parent 3840401 commit db00d7d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pyneon/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class NeonStream(NeonData):
Attributes
----------
file : :class:`pathlib.Path`
Path to the CSV file containing the stream data.
data : pandas.DataFrame
DataFrame containing the stream data.
timestamps : np.ndarray
Expand Down Expand Up @@ -56,6 +58,7 @@ def _get_attributes(self):
self.first_ts = int(self.ts[0])
self.last_ts = int(self.ts[-1])
self.times = (self.ts - self.first_ts) / 1e9
self.data.set_index(pd.to_datetime(self.ts, unit='ns'), inplace=True)
self.data["time [s]"] = self.times
self.duration = float(self.times[-1] - self.times[0])
self.sampling_freq_effective = self.data.shape[0] / self.duration
Expand Down Expand Up @@ -220,3 +223,15 @@ def __init__(self, file: Path):
"time [s]": float,
}
)


class CustomStream(NeonStream):
"""
Custom stream data that inherits attributes and methods from :class:`NeonStream`.
"""

def __init__(self, data: pd.DataFrame):
self.file = None
self.data = data
self.sampling_freq_nominal = None
self._get_attributes()
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ dev = [
"pre-commit",
]
doc = [
"jupyter",
"seaborn",
"sphinx",
"pydata-sphinx-theme",
"nbsphinx",
Expand Down

0 comments on commit db00d7d

Please sign in to comment.