-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Description
An error occurs when attempting to read data from a dataset that has a non-integer, but rational, sampling frequency. The issue appears to give one less sample than originally desired in the read_vector command. This has something to do with how the start sample it seems as changing the start sample time from this exact one does not resolve in an error.
drfpath = "hftestrf1"
chan='ch1'
subchan=0
nfft=1024
length=128
nint=2
nsamps=nint*nfft
bnds = drfObj.get_bounds(chan)
props = drfObj.get_properties(chan)
sps = props['samples_per_second']
drfObj = drf.DigitalRFReader(drfpath)
st_time="2025-06-18T20:14:14"
end_time = "2025-06-18T20:14:23"
st_samp = drf.util.parse_identifier_to_sample(st_time,sps)
nsamps = int(8*2e6)
x1 = drfObj.read_vector(st_samp,nsamps,chan)Gives the following error
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[15], line 6
4 st_samp = drf.util.parse_identifier_to_sample(st_time,sps)
5 nsamps = int(8*2e6)
----> 6 x1 = drfObj.read_vector(st_samp,nsamps,chan)
File ~/anaconda3/envs/radioconda/lib/python3.10/site-packages/digital_rf/digital_rf_hdf5.py:1412, in DigitalRFReader.read_vector(self, start_sample, vector_length, channel_name, sub_channel)
1366 def read_vector(self, start_sample, vector_length, channel_name, sub_channel=None):
1367 """Read a vector of data beginning at the given sample index.
1368
1369 This method returns the vector of the data beginning at `start_sample`
(...)
1410
1411 """
-> 1412 z = self.read_vector_raw(start_sample, vector_length, channel_name, sub_channel)
1414 if z.dtype.names is not None:
1415 out_dtype = np.promote_types("c8", z.dtype["r"])
File ~/anaconda3/envs/radioconda/lib/python3.10/site-packages/digital_rf/digital_rf_hdf5.py:1499, in DigitalRFReader.read_vector_raw(self, start_sample, vector_length, channel_name, sub_channel)
1497 if len(z) != vector_length:
1498 errstr = "Requested %i samples, but got %i"
-> 1499 raise IOError(errstr % (vector_length, len(z)))
1501 return z
OSError: Requested 16000000 samples, but got 15999999