Compose-3020: Reading CAE Data in OML

This tutorial explains how to:
  • Observe the hierarchy of CAE file using readvectorbuilder.
  • Read CAE Data using readvector.
  • Read CAE Data using readmultvectors.

Observe Hierarchy Using readvectorbuilder

readvectorbuilder is a utility tool that reads CAE results/data files supported byCompose. It helps you create the right readvector()and readmultvectors() commands. The tool opens the readvector utility dialog that can be used to select results files and navigate into the subcases, time steps, types, requests, and components contained in the selected file. Upon making your selections and selecting Print, the appropriate OML command (using either the readvector or readmultvectors command) is displayed.

  1. Reading values across all time steps.
    1. In the Compose Editor or OML Command window, run the readvectorbuilder command.
      The following dialog is displayed:
    2. In the File path field, choose the ANGACC file, located in <installation_dir/tutorials/.
      The Subcases field is inactive, which means the selected file does not have any subcase.
    3. For Time Step, select All, which indicates Compose reads values across all time steps.
    4. To view the file’s structure Types, Request and Component options, click the drop-down list for the corresponding boxes:
    5. Activate the Insert data as strings and Generate readvector command if possible options.
    6. Choose the type, request and component options as shown below and click Print in right lower corner of the dialogue to generate the corresponding command:
  2. Reading multiple requests and components on a selected time step.
    1. Continue to use the ANGACC file from previous example.
    2. From the Time Step drop-down menu, select 0 (seconds) as the Time Step for the example.
    3. The Request End and Component End columns will change from inactive to active. Set them to "50th% Hybrid3 - UPPER TORSO", and "Y-comp. ang. acc.", respectively.
    4. Deactivate the Insert data as strings and Generate readvector command if possible options.
    5. Click Print to produce this OML command:
      readmultvectors('<installation_dir/tutorials/ANGACC',2,1,3,2,3,1)
    6. Run this command in the OML Command window, which will display the following:

Read CAE Data Using readvector

In this second exercise, you will design a moving average filter and filter the data read from a CAE file.

  1. Plot the original data
    1. Open the file ANGACC in readvectorbuilder
    2. Select the following:
      • For Types, select "Angular Acceleration"
      • Define Request start as "50th% Hybrid3 - LOWER TORSO"
      • Define Component start as "Res. ang. acc."
      • Deactivte Insert data as strings and activate Generate readvector command if possible
    3. Click Print in right corner of the readvectorbuilder dialog to generate the OML command:
      readvector('<installation_dir\tutorials\ANGACC',2,1,1)
      Note: Although commands can be generated either with indices (integer) or strings (names), it is strongly recommended to generate commands using "Insert data as strings".

      The following two commands are equivalent:

      readvector('<installation_dir>\tutorials ANGACC',2,1,1)
      readvector('<installation_dir>\tutorials ANGACC','Angular
      Acceleration','50th% Hybrid3   - LOWER TORSO','Res. ang. acc.')
    4. Executing these commands in Compose produces the graph shown below:
      y = readvector(<installation_dir\tutorials \ANGACC',2,1,1);
      plot(y);
  2. Design a simple moving average filter.
    A simple moving average can be implemented in Compose using the filter command:
    % moving average filter
    b = 0.2*ones(1,5);
    a = 1;
    output = filter(b,a,input);
  3. Compare the results between the original data and filtered one.
    Use the script below to plot and check the difference between the original data, which extracted from the ANGACC file and the filtered data:
    y = readvector('ANGACC',2,1,1);
    plot(y,'g--');
    % moving average filter
    b = 0.2*ones(1,5);
    a = 1;
    y2 = filter(b,a,y);
    hold on;
    plot(y2,'r:');
    legend('Original data','Filtered data');
    title('readvector Demo');
    xlabel('Time(ms)');
    ylabel('Angular Acceleration(rad/s2)');
    The plot is shown below:

Read CAE Data Using readmultvectors

You may want to read vectors of data for a particular Type, at a particular time step, across contiguous requests and components. This can be achieved with the readmultvectors function. In this example, you will read the entire CAE file, then extract the data. If a file is passed to readmultvectors, it will return a cell containing all the information in the file in the following format:
  • The first column contains the Type
  • The second column contains the Request
  • The third column contains the Component
  • The fourth column contains the data vector specified by the information in the corresponding first three columns.
  • Each row contains a different data set. You can then use the extract function to extract the interested data afterwards.
For example:
function y = SMA(x)
       b = 0.2*ones(1,5);
       a = 1;
       y = filter(b,a,x);
end
filePath = '<installation_dir>\tutorials\ANGACC';
y = readmultvectors(filePath);
% extract interested data then do the moving average filtering
y_LT1 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3   - 
LOWER TORSO','Res. ang. acc.'));
y_LT2 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3   - 
LOWER TORSO','X-comp. ang. acc.'));
y_LT3 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3   - 
LOWER TORSO','Y-comp. ang. acc.'));
y_LT4 = SMA(extract(y,'Angular Acceleration','50th% Hybrid3   - 
LOWER TORSO','Z-comp. ang. acc.'));
x = extract(y,'Time','Time','Time');
% do the plot
plot(x,y_LT1,x,y_LT2,x,y_LT3,x,y_LT4);
xlabel('Time(ms)');
ylabel('Angular Acceleration(rad/s2)');
title('50th% Hybrid3 - LOWER TORSO');
legend('Res. ang. acc.','X-comp. ang. acc.','Y-comp. ang. 
acc.','Z-comp. ang. acc.');
This script produces this plot:

An example of extracting multiple data from this file can be found in the OML script located in <installation_dir>/tutorial/readvector_demo.oml.

Executing the script generates the following plots: