How to use the nptdms.types.Uint32 function in npTDMS

To help you get started, we’ve selected a few npTDMS examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adamreeve / npTDMS / nptdms / base_segment.py View on Github external
def read_property(f, endianness="<"):
    """ Read a property from a segment's metadata """

    prop_name = types.String.read(f, endianness)
    prop_data_type = types.tds_data_types[types.Uint32.read(f, endianness)]
    value = prop_data_type.read(f, endianness)
    log.debug("Property '%s' = %r", prop_name, value)
    return prop_name, value
github adamreeve / npTDMS / nptdms / tdms_segment.py View on Github external
# Read the data type
        try:
            self.data_type = types.tds_data_types[
                types.Uint32.read(f, self.endianness)]
        except KeyError:
            raise KeyError("Unrecognised data type")
        log.debug("Object data type: %s", self.data_type.__name__)

        if (self.data_type.size is None and
                self.data_type != types.String):
            raise ValueError(
                "Unsupported data type: %r" % self.data_type)

        # Read data dimension
        dimension = types.Uint32.read(f, self.endianness)
        # In TDMS version 2.0, 1 is the only valid value for dimension
        if dimension != 1:
            raise ValueError("Data dimension is not 1")

        # Read number of values
        self.number_values = types.Uint64.read(f, self.endianness)

        # Variable length data types have total size
        if self.data_type in (types.String,):
            self.data_size = types.Uint64.read(f, self.endianness)
        else:
            self.data_size = self.number_values * self.data_type.size

        log.debug(
            "Object number of values in segment: %d", self.number_values)
github adamreeve / npTDMS / nptdms / tdms_segment.py View on Github external
def read_raw_data_index(self, f, raw_data_index_header):
        # Metadata format is standard (non-DAQmx) TDMS format.
        # raw_data_index_header gives the length of the index information.

        # Read the data type
        try:
            self.data_type = types.tds_data_types[
                types.Uint32.read(f, self.endianness)]
        except KeyError:
            raise KeyError("Unrecognised data type")
        log.debug("Object data type: %s", self.data_type.__name__)

        if (self.data_type.size is None and
                self.data_type != types.String):
            raise ValueError(
                "Unsupported data type: %r" % self.data_type)

        # Read data dimension
        dimension = types.Uint32.read(f, self.endianness)
        # In TDMS version 2.0, 1 is the only valid value for dimension
        if dimension != 1:
            raise ValueError("Data dimension is not 1")

        # Read number of values
github adamreeve / npTDMS / nptdms / daqmx.py View on Github external
# size of vector of format changing scalers
        scaler_vector_length = types.Uint32.read(f, endianness)
        self.scalers = [
            DaqMxScaler(f, endianness, scaler_type)
            for _ in range(scaler_vector_length)]

        # Read raw data widths.
        # This is an array of widths in bytes, which should be the same
        # for all channels that have DAQmx data in a segment.
        # There is one element per acquisition card, as data is interleaved
        # separately for each card.
        raw_data_widths_length = types.Uint32.read(f, endianness)
        self.raw_data_widths = np.zeros(raw_data_widths_length, dtype=np.int32)
        for width_idx in range(raw_data_widths_length):
            self.raw_data_widths[width_idx] = types.Uint32.read(f, endianness)
github adamreeve / npTDMS / nptdms / types.py View on Github external
def read_values(cls, file, number_values, endianness="<"):
        """ Read string raw data

            This is stored as an array of offsets
            followed by the contiguous string data.
        """
        offsets = [0]
        for i in range(number_values):
            offsets.append(Uint32.read(file, endianness))
        strings = []
        for i in range(number_values):
            s = file.read(offsets[i + 1] - offsets[i])
            strings.append(s.decode('utf-8'))
        return strings
github adamreeve / npTDMS / nptdms / daqmx.py View on Github external
def _get_attr_repr(obj, attr_name):
    val = getattr(obj, attr_name)
    if isinstance(val, type):
        return val.__name__
    return repr(val)


# Type codes for DAQmx scalers don't match the normal TDMS type codes:
DAQMX_TYPES = {
    0: types.Uint8,
    1: types.Int8,
    2: types.Uint16,
    3: types.Int16,
    4: types.Uint32,
    5: types.Int32,
}