Read binary data from DRS4 Evaluation Board

The data structure is described in the DRS4 Evaluation Board User’s Manual (download)

The file header is made of 12+2x(4+1024x4) = 8212 bytes

The event size is 2x(1024x2+8)+32 = 4144 bytes

The bytes can be accessed opening the file as binary open(FILE, 'rb') and read with a usual read().

The struct module in the standard library can be used to unpack data packed in bytes into variables

Example: reading and printing the first 10 bytes (expected charachters "DRS2TIMEB#")

The next 2 bytes contains the board number in a short integer (h)

Then 4 bytes with the channel headers ("COO1" and "C002") and 2 x 1024 floating points (4 bytes each) with the time binnings:

The total number of events into a single file can be derived from the size.

But there is a more conveniente way...

Building a custom data type

In order to import values directly into a structured numpy array, the fromfile() function can be used with proper data types.

Sources/examples:

Header data type (first 8212 bytes):

Read the first 8212 bytes (1 time):

Event data type (4144 bytes):

Rearrangin data (both time and ADC->V conversion)

Check the shape(s):

Plot of 1st event

Overlapping all signals

Trivial analysis