Extracting curve statistics as a table

Michael Herve_21439
Michael Herve_21439
Altair Employee
edited December 2023 in Altair Exchange

Overview

The attached script populates automatically a table from the curves available in the session, and lists for each curve:

  • curve name
  • initial value
  • final value
  • min value
  • max value
  • mean value

image

 

Usage/Installation Instructions

  1. Load your session with all your curves of interest. An example session is attached to this article.
  2. File -> Load -> Script (.tcl, .tbc) and select the script file. The table will be appended to your session.

 

Where can I retrieve the list of existing operators?

HyperWorks applications (especially Hypergraph, HyperStudy, TableView, TextView) includes a comprehensive list of mathematical operators, moslty authored with Altair proprietary format Templex. These functions are available from online help:

https://2022.help.altair.com/2022.2/hwdesktop/hwd/topics/reference/math/standard_functions_r.htm

 

How to extract max/min/mean on a subrange/interval of my signal?

Let's say you want to extract the information between x=10.0 and 20.0.
Below the "# Writes curve information in the table" comment in the script, replace

"=min(${curveid}.y)"

by

"=min($curveid.y\[subrange(${curveid}.x,10.0,20.0)\])"

Same for  "=max(${curveid}.y)\" and "=mean(${curveid}.y)"

 

How to add extra columns?

Step1: update your header definition under the "# Table Header" comment.

image

Add as many cells G1, H1, ... than needed.

 

Step2: Complete the tcl array

image

Step3: Complete the writing of the cells in the loop:

image

 

 How to define mathematical operations?

TableView cells can be populated either through Templex statements or Compose functions, which will refer to curve identifier.

Curve identifier is built from page/window and curve id. Eg the second curve of the first window of the first page is p1w1c2, and the user can request either for x or y vector through p1w1c2.x/p1w1c2.y.

Templex is an Altair proprietary code which interprets any command between curly braces.

The list of Templex operators is available for HyperWorks Desktop Reference Guide.

Altair Compose is an environment for doing math calculations, manipulating, and visualizing

data, programming, and debugging scripts useful for repeated computations and process

automation.

Functions can be created and registered in Compose.

image

Once registered as shown in the capture, the Compose functions can be called as Templex operators between curly braces:

A Compose script for computing percentile value is also attached to this article.

Post-Requisite

Once the table populated, either it can be used for Report generation, or the user can export it as a csv.

Comments

  • Community Guest
    Community Guest New Altair Community Member
    edited December 2023

    Hi Michael,

    is it possible to get the Y Max Location and Y min Location?

    I have see it's something that is automatically prompted by HyperGraph but I didn't find the function in the list of existing operator or, maybe, I was looking to the wrong funcion's name.

     

    Thanks a lot for your help,

    Fabio

  • Michael Herve_21439
    Michael Herve_21439
    Altair Employee
    edited December 2023

    Hi Michael,

    is it possible to get the Y Max Location and Y min Location?

    I have see it's something that is automatically prompted by HyperGraph but I didn't find the function in the list of existing operator or, maybe, I was looking to the wrong funcion's name.

     

    Thanks a lot for your help,

    Fabio

     

    Hello Fabio,

     

    for such request can you please try the code below:

     

    set CurveStats($CurveRef.absforMax) "=${curveid}.x\[indexofmax(${curveid}.y)\]"

     

    Does that help?

     

    Best Regards,

    Michael

     

     

  • Shirdi_Partha_Sai_P
    Shirdi_Partha_Sai_P Altair Community Member
    edited February 16

    Is it possible to calculate the standard deviation and variance in addition to the statistics available? Can the script be extended for my request?

  • Michael Herve_21439
    Michael Herve_21439
    Altair Employee
    edited February 19

    Is it possible to calculate the standard deviation and variance in addition to the statistics available? Can the script be extended for my request?

    Hello @P S Partha Sai,

     

    the standard average function should be available with Templex function avgdev:

    https://2022.help.altair.com/2022.2/hwdesktop/hwd/topics/reference/math/avgdev.htm

     

    and the variance with Templex function variance:

    https://2022.help.altair.com/2022.2/hwdesktop/hwd/topics/reference/math/variance.htm

     

    Knowing these 2 functions, and with the help of the FAQ above, are you facing any issue to update the macro to your needs?

     

    Regards,

    Michael