Skip to main content

UFF (Universal File Format) read/write.

Project description

Universal File Format read and write

This module defines an UFF class to manipulate with the UFF (Universal File Format) files.

Read from and write of data-set types 15, 55, 58, 58b, 82, 151, 164, 2411, 2412, 2414, 2420 are supported.

Check out the documentation.

To install the package, run:

pip install pyuff

Showcase

To analyse UFF file we first load the uff module and example file:

import pyuff
uff_file = pyuff.UFF('data/beam.uff')

To check which datasets are written in the file use:

uff_file.get_set_types()

Reading from the UFF file

To load all datasets from the UFF file to data object use:

data = uff_file.read_sets()

The first dataset 58 contains following keys:

data[4].keys()

Most important keys are x: x-axis and data: y-axis that define the stored response:

plt.semilogy(data[4]['x'], np.abs(data[4]['data']))
plt.xlabel('Frequency  [Hz]')
plt.ylabel('FRF Magnitude [dB m/N]')
plt.xlim([0,1000])
plt.show()

Writing measurement data to UFF file

Loading the accelerance data:

measurement_point_1 = np.genfromtxt('data/meas_point_1.txt', dtype=complex)
measurement_point_2 = np.genfromtxt('data/meas_point_2.txt', dtype=complex)
measurement_point_3 = np.genfromtxt('data/meas_point_3.txt', dtype=complex)
measurement_point_1[0] = np.nan*(1+1.j)
measurement = [measurement_point_1, measurement_point_2, measurement_point_3]

Creating the UFF file where we add dataset 58 for measurement consisting of the dictionary-like keys containing the measurement data and the information about the measurement:

for i in range(3):
    print('Adding point {:}'.format(i + 1))
    response_node = 1
    response_direction = 1
    reference_node = i + 1
    reference_direction = 1
    acceleration_complex = measurement[i]
    frequency = np.arange(0, 1001)
    name = 'TestCase'
    data = {'type':58,
            'func_type': 4,
            'rsp_node': response_node,
            'rsp_dir': response_direction,
            'ref_dir': reference_direction,
            'ref_node': reference_node,
            'data': acceleration_complex,
            'x': frequency,
            'id1': 'id1',
            'rsp_ent_name': name,
            'ref_ent_name': name,
            'abscissa_spacing':1,
            'abscissa_spec_data_type':18,
            'ordinate_spec_data_type':12,
            'orddenom_spec_data_type':13}
    uffwrite = pyuff.UFF('./data/measurement.uff')
    uffwrite._write_set(data,'add')

Or we can use support function prepare_58 to prepare the dictionary for creating the UFF file. Functions for other datasets can be found in supported datasets.

for i in range(3):
print('Adding point {:}'.format(i + 1))
response_node = 1
response_direction = 1
reference_node = i + 1
reference_direction = 1
acceleration_complex = measurement[i]
frequency = np.arange(0, 1001)
name = 'TestCase'
pyuff.prepare_58(func_type=4,
            rsp_node=response_node,
            rsp_dir=response_direction,
            ref_dir=reference_direction,
            ref_node=reference_node,
            data=acceleration_complex,
            x=frequency,
            id1='id1',
            rsp_ent_name=name,
            ref_ent_name=name,
            abscissa_spacing=1,
            abscissa_spec_data_type=18,
            ordinate_spec_data_type=12,
            orddenom_spec_data_type=13)

travis

binder to test the pyuff Showcase.ipynb online.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyuff-2.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyuff-2.0-py3-none-any.whl (56.1 kB view details)

Uploaded Python 3

File details

Details for the file pyuff-2.0.tar.gz.

File metadata

  • Download URL: pyuff-2.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for pyuff-2.0.tar.gz
Algorithm Hash digest
SHA256 8a7078951b6ecfb720afdaa195ff778523a86a339e512156f3b24e07642e95dc
MD5 d1a8131104bc6c3df9b58407e8a1c33b
BLAKE2b-256 45000e655ada7d92a4f39477437314c53fb4019be519d02569b56433c5ad5522

See more details on using hashes here.

File details

Details for the file pyuff-2.0-py3-none-any.whl.

File metadata

  • Download URL: pyuff-2.0-py3-none-any.whl
  • Upload date:
  • Size: 56.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for pyuff-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98bd10ff7b57d4f361425d84b5986c06edcac46da34f04e5ef88a504faba8f5d
MD5 c74521f3aa9a1023f90fef46ec60d942
BLAKE2b-256 d60397bc121c9bb890711aed877b9f0c9de84e7de219f28539b771f9dc9ed0bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page