Gruppo di Misure Meccaniche e Termiche UNIBS - DIMI A. File Formats At their lowest level, all files...
-
Upload
timothy-sheridan -
Category
Documents
-
view
213 -
download
1
Transcript of Gruppo di Misure Meccaniche e Termiche UNIBS - DIMI A. File Formats At their lowest level, all files...
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
A. File Formats
At their lowest level, all files written to your computer’s hard drive are a series of bits
1
Binary
TDMS
ASCII
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
A. File FormatsASCII TDMS Direct Binary
Numeric Precision
Good Best Best
Share data
Best (Any program easily) Better (NI Programs easily)
Good (only with detailed metadata)
Efficiency Good Best Best
Ideal Use Share data with other programs when file space and numeric precision are not important
Share data with programs when storing simple array data and metadata
Store numeric data compactly with ability to random access
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
A. Understanding File I/O
• File I/O writes to or reads from a file• A typical file I/O operation involves the following process:
3
Open/Create/
Replace File
Read and/or
Write to File
Close File
Check forErrors
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
A. Understanding File I/O – File Formats
LabVIEW can use or create the following file formats:• Binary—Underlying file format of all other file formats• ASCII—Specific type of binary file that is a standard used by
most programs• TDMS—Type of binary file created for NI products consisting
of two separate files: a binary file and a binary index file
4
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
A. Understanding File I/O – File Formats
• Use text files in the following situations: − You want to access the file from another application− Disk space and file I/O speed are not crucial− You must not perform random access reads or writes− Numeric precision is not important
5
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
B. Understanding High-level File I/O
• High-level VIs− Perform all three steps (open,
read/write, close) for common file I/O operations
− Might not be as efficient as the functions configured or designed for individual operations
• Low-level VIs− Individual VI for each step− If you are writing to a file in a loop, use
low-level file I/O functions
6
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
B. Understanding High-Level File I/O
Write to Spreadsheet File• Converts an array of double-precision numbers to a text string and
writes the string to an ASCII file
Read From Spreadsheet File• Reads a specified number of lines or rows
from a numeric text file and outputs a 2D array of double-precision numbers
Write to/Read from Measurement File• Express VIs that write data to or read data
from an LVM or TDMS file format
7
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
B. Binary Files—Sequential/Random Access
Two methods of accessing data: • Sequential Access—Read each item in order, starting at
the beginning of a file• Random Access—Access data at an arbitrary point within
the file
8
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
B. Binary Files—Sequential Access
• To sequentially access all of the data in a file, you can call the Get File Size function and use the result to calculate the number of items in the file, based upon the size of each item and the layout of the file• You can then wire the number of items to the count terminal
of the Read from Binary File function
9
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
B. Binary Files—Random Access
• Use the Set File Position function to set the read offset to the point in the file you want to begin reading
• The offset is in bytes; therefore, you must calculate the offset based upon the layout of the file
10
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files
TDMS• Technical Data Management Streaming
Use TDMS files for the following purposes: • To store test or measurement data• To create a structure for grouping your data• To store information about your data• To read and write data at high speeds
11
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—File Format
• TDMS file− Binary file (.tdms) that contains data and stores properties
about the data• TDMS_Index file
− Binary index file (*.tdms_index) that provides consolidated information on all the attributes and pointers in the TDMS file
− Speeds up access to the data while reading− Automatically regenerated if lost• TDMS file format internal structure is publicly documented
12
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—Data Hierarchy
• Channel − Stores measurement signals or raw data in a TDMS file− Each channel can have properties describing the data− The data stored in the signal is stored as binary data on disk to
conserve disk space and improve efficiency
• Channel Group− Segment of a TDMS file that contains properties and one or more
channels− Use channel groups to organize your data and to store information
that applies to multiple channels
13
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—Accessing TDMS Files
• Use the Write to Measurement File and Read from Measurement File Express VIs − Allows you to quickly save and retrieve data from TDMS format − Very little control over your data grouping and properties• Use the TDM Streaming API
− Set of functions for opening, writing to, reading from, and closing TDMS files
− Allows you to organize your data into channel groups and channels• Use the TDM Excel Add-In Tool
− Allows you to read TDMS files in Microsoft Excel
14
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—TDM Streaming API
15
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—Write Data
• Streams data to the specified TDMS file
• Data subset to write is determined by group name and channel name(s) inputs
16
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—Read Data
Reads the specified TDMS file and returns data from the specified channel and/or channel group
17
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—Set Properties
Sets the properties of the TDMS file, channel group, or channel
18
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—Get Properties
Returns the properties of the TDMS file, channel group, or channel
19
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
C. TDMS Files—File Viewer
Opens TDMS file and presents the file data in the TDMS File Viewer dialog box
20
Gruppo di Misure Meccaniche e TermicheUNIBS - DIMI
Practice
Generate a set of waveforms and export them as a single CSV file.
Compute the waveforms PSDs and export them as a single CSV file.
Open both files in excel and check the results.