Skip to content

Commit

Permalink
add docstrings for get_timestamps and get_data_in_units (#1878)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendichter authored Mar 31, 2024
1 parent 4fcf105 commit faa8884
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/pynwb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,31 @@ def time_unit(self):
return self.__time_unit

def get_timestamps(self):
"""
Get the timestamps of this TimeSeries. If timestamps are not stored in this TimeSeries, generate timestamps.
"""
if self.fields.get('timestamps'):
return self.timestamps
else:
return np.arange(len(self.data)) / self.rate + self.starting_time

def get_data_in_units(self):
"""
Get the data of this TimeSeries in the specified unit of measurement, applying the conversion factor and offset:
.. math::
out = data * conversion + offset
If the field 'channel_conversion' is present, the conversion factor is applied to each channel separately:
.. math::
out_{channel} = data * conversion_{channel} + offset
Returns
-------
np.ndarray
"""
if "channel_conversion" in self.fields:
scale_factor = self.conversion * self.channel_conversion[:, np.newaxis]
else:
Expand Down

0 comments on commit faa8884

Please sign in to comment.