Harm -

Posted on 09.11.2012 12:37
Hi, I am trying to write a function to read d7d files directly with Matlab. So thank you for the DWDatareader DLL! It is however a puzzle to find the right functions, the example does not use both reduced and scaled data from one file. Is it possible to describe the functions in the DWDataReaderLib more explicit? There is a .doc file in the zip, but not all functions and their calls are explained. I also noticed that there might be a typing error in the function name?? When I make a list of the functions from the DLL, two names are strange: DWGet[b]Recuded[/b]DataChannelInfoF DWGet[b]Recude[/b]dDataF "Recuded"?? I suppose this must be "Reduced"!
Harm -

Posted on 16.11.2012 13:35
Well, just to let you know that I managed to read both the reduced and scaled data with matlab. The function for reading the reduced data, DWGetReducedValues, requires the use an array of structs as parameter. This is not supported by Matlab. So what you need to do is pass one struct as parameter, and read one value at a time. Fortunately, this is possible because of the "position" and "count" parameter. In other words, use a for loop and run through the data (use count=1).
Olav Olav

Posted on 20.05.2013 13:26
As an addition, I try to read the values of a modal analysis into matlab. I can read the correct values of the coherence. But the TransferFunction give a value of 0.0. I think the problem is that the C code and Dll in between are not able to handle complex numbers. The latest versions of C allow the use of complex numbers. Do you see a solution for this on the short term ?. Or is there a work around ?
Gaël Le Gigan

Posted on 12.03.2018 13:10


I am trying to read a Fast Fourier Transform into python with the help of the DEWESOFT DLL. As compared to other data that I read into python which are scalars, the Fast Fourier Transform and the Fast Fourier Transform reduced are vectors with sizes of 250 and 171 respectively. I can get the reduced data without any problem for the scalar channels but I get an empty array for those two channels when I try to compute reduce values. I tried some work around but without any success. I have no issues getting the full-speed data.

Here is my code that works for the scalar channels:

def _get_data_reduced(self, ch_list, i, unit):
    import numpy as np
    from ctypes import *
    import _ctypes

    sample_cnt = c_int()
    block_size = c_double()
    dw_ch_index = c_int(ch_list[i].index)
    offset = c_int64(0)
    # DWGetReducedValuesCount(int ch_index, int* count, double* block_size)
    if self._lib.DWGetReducedValuesCount(dw_ch_index,
                                         byref(block_size)) != DWStatus.DWSTAT_OK.value:
        DWRaiseError("DWDataReader: DWGetReducedValuesCount() failed")

    p_data = np.empty(sample_cnt.value, dtype=DWReducedValue)  # Allocate data
    if self._lib.DWGetReducedValues(dw_ch_index, offset, sample_cnt.value, p_data.ctypes) != DWStatus.DWSTAT_OK.value:
        DWRaiseError("DWDataReader: DWGetReducedValues() failed")
    data_array = zeros((sample_cnt.value, len(p_data.dtype) - 1))        
    time_array = p_data['time_stamp']
    data_array[:, 0] = p_data['ave']
    data_array[:, 1] = p_data['min']
    data_array[:, 2] = p_data['max']
    data_array[:, 3] = p_data['rms']

    data_array *= unit
    sample_rate = 1 / block_size.value
    return time_array, data_array, sample_rate

For those two channels, the sample_cnt value is 0 and the block size is 0.2 whereas for the scalar channels I get 7014 and 0.02 respectively.

Note that ch_list contains the information of the channel whereas i is the looping index trough the recorded channels. Thus ch_list[i] defines one channel.

DWStatus, DWReducedValue and DWRaiseError are standard DEWESOFT classes in python.

Any help would be very appreciated.

Best reagrds

Gaël Le Gigan

Posted on 14.03.2018 09:01


I finally found a work around to treat FFT and FFT reduced vectored channels in python by use of the DLL (note that I am using the 64 bits DLL but my guess is that is it the same for the 32 bits). It is not reduced thought as I wanted above. But, I guess that one cannot do for FFT.

Below is the code I used:

def _get_data_scaled(self, ch_list, i, unit):
    """Load and return full speed scaled data as Numpy array"""
import numpy as np
dw_ch_index = c_int(ch_list[i].index) # Get channel index
sample_cnt = self._lib.DWGetScaledSamplesCount(dw_ch_index) # Ge sample count, i.e. number of data length
if sample_cnt < 0:
raise IndexError('DWGetScaledSamplesCount({})={} should be non-negative'.format(
dw_ch_index, sample_cnt))
data = np.empty(sample_cnt * ch_list[i].array_size, dtype=np.double) # Allocate matrix size for data
time = np.empty_like(data) # Allocate matrix size for time
if self._lib.DWGetScaledSamples(dw_ch_index, 0, sample_cnt, data.ctypes, time.ctypes) != DWStatus.DWSTAT_OK.value:
raise RuntimeError('Could not obtain scaled channel data')
time, ix = np.unique(time, return_index=True) # use unique times
data *= unit # Assign unit to data numpy array
# Scalar channel type
if ch_list[i].array_size == 1:
data = data[ix]
# Vector channel type
elif ch_list[i].array_size > 1:
data_list = zeros((sample_cnt, ch_list[i].array_size)) # Matrix allocation size = (sample_cnt, ch_list[i].array_size)
for ii in range(0, ch_list[i].array_size):
data_list[:, ii] = data[ii*sample_cnt:(ii+1)*sample_cnt]
time = time[1: len(time)] # Identical time for all ch_list[i].array_size
data = data_list
data *= unit
# Unknown type
print('Error in _get_data_scaled. Channel array size is negative or null...')
return time, data, sample_cnt

If the channel as a size of 1 and a length of sample_cnt, both time and data have identical length, i.e. sample_cnt x ch_list[i].array_size = sample_cnt as ch_list[i].array_size = 1.

f the channel has a size > 1 and a length of sample_cnt, time as a length of sample_cnt whereas data has a length of sample_cnt and a size of ch_list[i].array_size (which in my case 250 for FFT and 171 for FFT reduced). In such a case, the time array of length sample_cnt has to be reused for all "columns" in data. However, the time array is not the truth here as this array should be frequency.

I still have one issue. Each "column" of the data numpy array needs to be splited even more as it seems that many FFTs are place in a raw. At least, when I managed to extract one FFT for a trigger event of 10 seconds, I can see 3 FFTs in those 10 seconds. Then, the next step is to "transform" the time vector into "frequency" as x-axis when plotting data[:, columnNumber] versus time (which should be frequency).

Best regards

DEWESoft Support
Technical support
Posted on 16.03.2018 09:08


I would just like to confirm that DEWESoft doesn't have reduced values for array channels. That is why you weren't able to read them with the DWDataReader.

Other than that, I think you're on a good track to reading FFT data. The general principle is that that you read the FFT values (amplitude), which will be a column of all FFT amplitudes across your measurement. Then you also have a list of time stamps for the FFT, which is much shorter. This represents when each FFT block was created. If you divide the length of the FFT amplitude vector and the length of the time vector, you will receive the block size, which represents the amount of samples per one FFT block. You can use this information to correctly split the amplitude data into columns. The only thing left then is the frequency sections, which is always the same. I think this one should be read as a channels as well.

I hope that helps at least a bit.

Login to reply to this topic. If you don't have account yet, you can signup for free account .
This website uses cookies to ensure you get the best experience on our website. Learn more