DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Doing drift analysis over many files

Solved!
Go to solution

Hi, 

 

I'm going to do a drift analysis to some current values (sleep/load).

Therefore I will look over the values of a day and filter for special temperatures.

Afterwards there's a mean calculation and I will save the day in a Time channel and the value in a data channel.

 

Is there any better solution for this or does this seem ok? Values I get are valid but it seems not that elegant.

 

So my solution works fine for one day and one device. 

Is there a possibility to look over all files in a root folder and get only the data analized, which belongs to one device?

Maximum number of devices is 6.

 

folder strucure is like this:

 

Root

 - 20230701 (day 1)

   - device 1

   ...

   - device 6

 - 20230701 (day 2)

   - device 1

   ...

   - device 6

 - 20230701 (day 3)

   - device 1

   ...

   - device 6

 - 20230701 (day 4)

   - device 1

   ...

   - device 6

 - 20230701 (day 5)

   - device 1

   ...

   - device 6

 

in each device folder there is one file and there is much data that isn't needed.

I only need 4 channel groups out of 16 in each file but they shouldn't be deleted because they could be needed for other calculations.

 

Is there a possibility to walk through the devices and to the calculation to it and go on with the next?

I need the means of all 6 devices for about 3 months so at the end 90 times and 90 mean values in the result channel for each device.

 

As mentioned I already have it working for one day, but loading the data seems not that easy to me or am I wrong on this point?

 

Thanks in advance for your help.

 

Regards

 

Thorsten

0 Kudos
Message 1 of 3
(1,799 Views)
Solution
Accepted by topic author TLG90

Hi TLG90

 

I would suggest you use scripting in python or vbs to carry out your task. This is a very typical task which is often required. I've copied some python lines below from a similar script I've used with amendments to assist your task which you might find useful.

 

import os # import os library, first time used go to settingss and install os library in settings
for path in os.listdir(requiredFolder): # Iterate requiredFolder change this to your folder path
   if os.path.isfile(os.path.join(requiredFolder, path)) and ".tdm" in path: # ensure path is a file and .tdm file
      dd.DataFileLoad(path, "tdm", "Load|ChnXYRelation") # Load file
         channelGroupName = dd.Data.Root.ActiveChannelGroup.Name # get Group Name which is usually the filename
         myChannels = dd.Data.GetChannels(channelGroupName+"/*") # get the channels. Could select here
         for myChannel in myChannels:   # Loop channels        
            if not (myChannel.Name == "Time"): # Could add further exceptions
               dd.ChnResult = dd.ChnStatisticsChannelCalc(myChannel,dd.eStatsArithmeticMean)
               print("The mean value from " + channelGroupName + " and channel " + myChannel.Name + " is :{:.2f}".format(dd.StatsResult(dd.eStatsArithmeticMean))
Message 2 of 3
(1,738 Views)

Thanks for your suggestions and script.

I guess I have to do it with the os library. 

 

This will help me to go further.

 

Thanks again

 

0 Kudos
Message 3 of 3
(1,718 Views)