How to use the nptdms.common.ObjectPath 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 / tdms.py View on Github external
group_channels[path.group].append(channel)
                else:
                    group_channels[path.group] = [channel]

        # Create group objects containing channels and properties
        for group_name, properties in group_properties.items():
            try:
                channels = group_channels[group_name]
            except KeyError:
                channels = []
            group_path = ObjectPath(group_name)
            self._groups[group_name] = TdmsGroup(group_path, properties, channels)
        for group_name, channels in group_channels.items():
            if group_name not in self._groups:
                # Group with channels but without any corresponding object metadata in the file:
                group_path = ObjectPath(group_name)
                self._groups[group_name] = TdmsGroup(group_path, {}, channels)

        if not read_metadata_only:
            self._read_data(tdms_reader)
github adamreeve / npTDMS / nptdms / tdms.py View on Github external
channel = TdmsChannel(
                    path, obj.data_type, obj.scaler_data_types, obj.num_values,
                    properties, channel_group_properties, self._properties,
                    tdms_reader, self._raw_timestamps, self._memmap_dir)
                if path.group in group_channels:
                    group_channels[path.group].append(channel)
                else:
                    group_channels[path.group] = [channel]

        # Create group objects containing channels and properties
        for group_name, properties in group_properties.items():
            try:
                channels = group_channels[group_name]
            except KeyError:
                channels = []
            group_path = ObjectPath(group_name)
            self._groups[group_name] = TdmsGroup(group_path, properties, channels)
        for group_name, channels in group_channels.items():
            if group_name not in self._groups:
                # Group with channels but without any corresponding object metadata in the file:
                group_path = ObjectPath(group_name)
                self._groups[group_name] = TdmsGroup(group_path, {}, channels)

        if not read_metadata_only:
            self._read_data(tdms_reader)
github adamreeve / npTDMS / nptdms / tdms.py View on Github external
def objects(self):
        """ (Deprecated) A dictionary of objects in the TDMS file, where the keys are the object paths.
        """

        _deprecated("TdmsFile.objects", "Use TdmsFile.groups() to access all groups in the file, " +
                    "and group.channels() to access all channels in a group.")

        objects = OrderedDict()
        root_path = ObjectPath()
        objects[str(root_path)] = RootObject(self._properties)

        for group in self.groups():
            objects[group.path] = group
            for channel in group.channels():
                objects[channel.path] = channel

        return objects
github adamreeve / npTDMS / nptdms / writer.py View on Github external
def path(self):
        """The string representation of this group's path
        """
        return str(ObjectPath(self.group))
github adamreeve / npTDMS / nptdms / tdms.py View on Github external
object("group_name", "channel_name")
        """

        _deprecated("TdmsFile.object",
                    "Use TdmsFile.properties to access properties of the root object, " +
                    "TdmsFile[group_name] to access a group object and " +
                    "TdmsFile[group_name][channel_name] to access a channel object.")

        def get_name(component):
            try:
                return component.name
            except AttributeError:
                return component

        path = [get_name(c) for c in path]
        object_path = ObjectPath(*path)
        try:
            return self.objects[str(object_path)]
        except KeyError:
            raise KeyError("Invalid object path: %s" % object_path)
github adamreeve / npTDMS / nptdms / writer.py View on Github external
def path(self):
        """The string representation of this channel's path
        """
        return str(ObjectPath(self.group, self.channel))
github adamreeve / npTDMS / nptdms / common.py View on Github external
def from_string(path_string):
        components = list(_path_components(path_string))
        return ObjectPath(*components)