-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserving raw LabVIEW timestamp #198
Comments
Hi. There isn't currently any way to access the raw timestamps. When reading the timestamps the raw integers are discarded after converting to a numpy datetime. It would make sense to expose these raw integers though, I'll have to think about how best to do this. |
I appreciate you looking into it. Thanks for your work on the library. |
In case anyone is curious - class TimeStamp(TdmsType):
#...
@classmethod
def read(cls, file, endianness="<"):
data = file.read(16)
if endianness == "<":
(second_fractions, seconds) = _struct_unpack(
endianness + 'Qq', data)
else:
(seconds, second_fractions) = _struct_unpack(
endianness + 'qQ', data)
micro_seconds = int(
float(second_fractions) / cls._fractions_per_microsecond)
# CHANGE: Preserve raw timestamp values
converted_time = (cls._tdms_epoch + np.timedelta64(seconds, 's') +
np.timedelta64(micro_seconds, 'us'))
return {"raw": [seconds, second_fractions], "converted": converted_time}
#... |
This is now implemented on the master branch (see #200) and documented at https://nptdms.readthedocs.io/en/latest/reading.html#timestamps |
I have an existing TDMS --> H5 conversion process (in .NET) that I am porting to Python, mainly because of the DAQmx support in this library. One issue I am running into involves the LabVIEW timestamp.
Currently, we directly copy the LabVIEW timestamp (two 64-bit ints) as a dataset in the H5 file.
It looks like this library is converting the timestamp into a NumPy
datetime64
, hence the limitation stated in the README:This is fine and all for convenience, but I am looking for access to the actual timestamp integers.
TdmsChannel
class or wherever you see fit).Again, losing precision to conveniently work with a datetime object is a fine feature, but I think the user should at least still be able to access the original values in full precision.
The text was updated successfully, but these errors were encountered: