Example #1
0
def tdmsinfo(file, show_properties=False):
    tdmsfile = tdms.TdmsFile(file)

    level = 0
    display('/', level)
    try:
        root = tdmsfile.object()
        if show_properties:
            display_properties(root, level)
    except KeyError:
        # Root object isn't present
        pass
    for group in tdmsfile.groups():
        level = 1
        try:
            group_obj = tdmsfile.object(group)
            display("%s" % group_obj.path, level)
            if show_properties:
                display_properties(group_obj, level)
        except KeyError:
            # It is possible to have a group without an object
            display("/'%s'" % group, level)
        for channel in tdmsfile.group_channels(group):
            level = 2
            display("%s" % channel.path, level)
            if show_properties:
                level = 3
                if channel.data_type is not None:
                    display("data type: %s" % channel.data_type.__name__,
                            level)
                display_properties(channel, level)
Example #2
0
 def test_bigendian_format(self):
     """Test reading a file that encodes data in big endian mode"""
     tf = tdms.TdmsFile(_data_dir + '/big_endian.tdms')
     data = tf.object('Measured Data', 'Phase sweep').data
     np.testing.assert_almost_equal(data[:10], [
         0.0000000, 0.0634176, 0.1265799, 0.1892325, 0.2511234, 0.3120033,
         0.3716271, 0.4297548, 0.4861524, 0.5405928
     ])
def test_big_endian_format():
    """Test reading a file that encodes data in big endian mode"""
    test_file = tdms.TdmsFile(DATA_DIR + '/big_endian.tdms')
    data = test_file['Measured Data']['Phase sweep'].data
    np.testing.assert_almost_equal(data[:10], [
        0.0000000, 0.0634176, 0.1265799, 0.1892325, 0.2511234, 0.3120033,
        0.3716271, 0.4297548, 0.4861524, 0.5405928
    ])
Example #4
0
 def test_raw_format(self):
     """Test reading a file with DAQmx raw data"""
     tf = tdms.TdmsFile(_data_dir + '/raw1.tdms')
     objpath = tf.groups()[0]
     data = tf.object(objpath, 'First  Channel').data
     np.testing.assert_almost_equal(data[:10], [
         -0.18402661, 0.14801477, -0.24506363, -0.29725028, -0.20020142,
         0.18158513, 0.02380444, 0.20661031, 0.20447401, 0.2517777
     ])
def test_raw_format():
    """Test reading a file with DAQmx raw data"""
    test_file = tdms.TdmsFile(DATA_DIR + '/raw1.tdms')
    group = test_file.groups()[0]
    data = group['First  Channel'].data
    np.testing.assert_almost_equal(data[:10], [
        -0.18402661, 0.14801477, -0.24506363, -0.29725028, -0.20020142,
        0.18158513, 0.02380444, 0.20661031, 0.20447401, 0.2517777
    ])
Example #6
0
    def test_labview_file(self):
        """Test reading a file that was created by LabVIEW"""
        tf = tdms.TdmsFile(_data_dir + '/Digital_Input.tdms')
        group = ("07/09/2012 06:58:23 PM - " +
                 "Digital Input - Decimated Data_Level1")
        channel = "Dev1_port3_line7 - line 0"
        expected = np.array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1], dtype=np.uint8)

        data = tf.object(group, channel).data
        np.testing.assert_almost_equal(data[:10], expected)
Example #7
0
	def __init__(self, tdfile_path=None):
		self.initialized = False
		if tdfile_path is not None:
			self.tdfile = tdms.TdmsFile(tdfile_path)
			self.td_vib_channels = self.tdfile.group_channels('Vibration')
			self.td_channel_count = len(self.td_vib_channels)

			if self.td_channel_count < 1:
				print('Specified file is not a vibration TDMS file of understood format\n')
			else:
				self.initialize()

		else:
			self.tdfile = None
Example #8
0
def main():
    parser = ArgumentParser(
        description="List the contents of a LabView TDMS file.")
    parser.add_argument('-p',
                        '--properties',
                        action="store_true",
                        help="Include channel properties.")
    parser.add_argument('-d',
                        '--debug',
                        action="store_true",
                        help="Print debugging information to stderr.")
    parser.add_argument('tdms_file', help="TDMS file to read.")
    args = parser.parse_args()

    if args.debug:
        logging.getLogger(tdms.__name__).setLevel(logging.DEBUG)

    tdmsfile = tdms.TdmsFile(args.tdms_file)

    level = 0
    display('/', level)
    try:
        root = tdmsfile.object()
        if args.properties:
            display_properties(root, level)
    except KeyError:
        # Root object isn't present
        pass
    for group in tdmsfile.groups():
        level = 1
        try:
            group_obj = tdmsfile.object(group)
            display("%s" % group_obj.path, level)
            if args.properties:
                display_properties(group_obj, level)
        except KeyError:
            # It is possible to have a group without an object
            display("/'%s'" % group, level)
        for channel in tdmsfile.group_channels(group):
            level = 2
            display("%s" % channel.path, level)
            if args.properties:
                level = 3
                if channel.data_type is not None:
                    display("data type: %s" % channel.data_type.__name__,
                            level)
                display_properties(channel, level)
Example #9
0
def main():
    parser = ArgumentParser(
        description="List the contents of a LabView TDMS file.")
    parser.add_argument('-p',
                        '--properties',
                        action="store_true",
                        help="Include channel properties.")
    parser.add_argument('-d',
                        '--debug',
                        action="store_true",
                        help="Print debugging information to stderr.")
    parser.add_argument('tdms_file', help="TDMS file to read.")
    args = parser.parse_args()

    if args.debug:
        logging.getLogger(tdms.__name__).setLevel(logging.DEBUG)

    tdmsfile = tdms.TdmsFile(args.tdms_file)

    level = 0
    root = tdmsfile.object()
    display('/', level)
    if args.properties:
        display_properties(root, level)
    for group in tdmsfile.groups():
        level = 1
        group_obj = tdmsfile.object(group)
        display("%s" % group_obj.path, level)
        if args.properties:
            display_properties(group_obj, level)
        for channel in tdmsfile.group_channels(group):
            level = 2
            display("%s" % channel.path, level)
            if args.properties:
                level = 3
                display("data type: %s" % channel.data_type.name, level)
                display_properties(channel, level)
Example #10
0
 def load(self, *args, **kwargs):
     self.file.write(self.data)
     self.file.seek(0)
     return tdms.TdmsFile(self.file, *args, **kwargs)
Example #11
0
 def __init__(self, tdpath):
     self.tdmspath = tdpath
     self.tdmsfile = tdms.TdmsFile(self.tdmspath)
     self.mL = {}
     self.build_channels(self)
Example #12
0
    if return_errors:
        return indicies, ideal_vals, errors
    else:
        return indicies, ideal_vals


# if __name__ == '__main__':
# 	print('No test code available.\n')

if __name__ == '__main__':
    import matplotlib.pyplot as plt
    import pandas as pd
    from nptdms import tdms

    tdmspath = './TDMS/vib.tdms'
    tdfile = tdms.TdmsFile(tdmspath)
    data = tdfile.channel_data('Vibration', 'DOC X')
    dataProp = tdfile.group_channels('Vibration')[0].properties

    print(dataProp)

    DOCSensitivity = float(dataProp['Sensor Sensitivity (mV/EU)'])
    y = data / (DOCSensitivity / 1000)
    fs = 8533.33333333

    win_size = 2**13
    fft_size = win_size

    print('y shape:', y.shape)

    s = Stft(data=y,