03-21-2023 10:20 AM
Hello,
I'm trying to work with waveform data and having a bit of trouble with time calculations.
The challenge is that the data type of start time / offset and increment are not compatible.
For example simply adding start time and increment like this:
dd.Data.Root.ActiveChannelGroup.Channels("DUT 01").Properties("wf_start_time").Value
+ dd.Data.Root.ActiveChannelGroup.Channels("DUT 01").Properties("wf_increment").Value
results in a
TypeError: unsupported operand type(s) for +: 'pywintypes.datetime' and 'float'
I'm not familiar with pywintypes and haven't really looked into this library yet.
But i have tried converting to datetime with no luck.
Is there maybe a simple "How-to" for handling time data in with Python in DIAdem?
Solved! Go to Solution.
03-24-2023 05:19 AM
Hi,
to add those values it is possible to import "datetime" and to use the function "timedelta".
Below you find a short example, adding step width of one day to the waveform start time.
"timedelta" offers also options to add the value to month, year etc.
import datetime StartTimeVal=dd.Data.Root.ChannelGroups(1).Channels("DUT 01").Properties("wf_start_time").Value StepWidthVal=dd.Data.Root.ChannelGroups(1).Channels("DUT 01").Properties("wf_increment").Value StartTimeVal=StartTimeVal+datetime.timedelta(days=StepWidthVal)
With
wf_start_time: 01.08.2012 00:00:00.000000000
wf_increment: 1
you receive:
wf_start_time 02.08.2012 00:00:00.000000000
03-24-2023 11:55 PM
Thank you!