trim curve

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hi,

 

im looking for a function to trim a curve. The goal is to create a new curve in a different plot, that represents only a portion of the original curve vectors. Further goal is to keep the right hand trimming point variable, meaning that i want to trim the curve on the right hand side not at a fixed x-value, but by meeting the criterion: 'trim at location where the y-value becomes zero' (occurs only once in every curve). This should also account for the case i reload the session containing the trim operation, but with varying curve values. Left hand trimming point may be a fixed x-value.

I already tried:

    1) the trim function: problem is, that right hand trimming point is not variable -> not workable

    2) macro Cut below limit: problem is, that after the limit, the newly created curve is extended by a horizontal line -> not workable  

 

Is there a function like this?

 

Curve_Screenshot.jpg.a0703b4a76719ad5f3914ef1e93431d7.jpg

 

Florian

 

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2017

    Hi Florian,

    Can you try with the modify curve option, where user can trim the data outside of the selected range.

    A tutorial, HG-1020: Modifying Plots, is also available in the Help Menu which shows about the various options available for editing curves. 

    <?xml version="1.0" encoding="UTF-8"?>1Capture.PNG

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2017

    Hi George,

     

    as i wrote, that option (it's what i meant by 'trim function' ) doesn't work for me because the right hand trimming point is not variable, but is fixed to a certain x-value. I want the x-value to vary, accordingly to the value y = 0

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2017

    Hi Florian

    As a workaround, using coordinate info option you can find the x-coordinate value  where the y coordinate value becomes zero. And you can provide these values (0 to _) in the 'From' 'To' options in the range thereby you can trim the curve within the range. Both the trimmings points are variable, please see the image attached.

     

     

    <?xml version="1.0" encoding="UTF-8"?>Capture2.PNG

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2017

    Hi,

     

    problem is, i want to automate the process.

    Meaning that i want to save the trimming operation of the curve in a session. By relaoding this session, the trimming should automatically happen for a new curve (which i read in with the same session), where the y=0-point of this new curve can slightly differ from the previous curve.

     

    So, if one used the suggestion in your last post:

    When reloading the session with a new curve, the trimming operation would not hit the right x-value because the y=0 abscissa value has changed. But the x-value of the trimming should change according to the new curve.

     

    Could you provide another solution? 

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2017

    Hi Florian,

    It is possible to automate this process. As per the user requirements customization is possible using Tcl/Tk scripting.

    Please refer Reference Guide which describes about Tcl/Tk scripting commands.

     

    Or,

    You can consult your local Altair team.

  • Rahul Rajan_21763
    Rahul Rajan_21763 New Altair Community Member
    edited March 2017

    Hi Florian,

     

    One of my colleague suggested to try Hypermath by creating own function.

    I have an example from HyperMath that takes the data only after a certain threshold is reached (for example, I want the force history after the displacement goes over 5).

     

    function trimXbasedOnY(x,y,value)

                    n,index = ZeroCrossings(y-value)

                    if (n == 0 ) then

                                    x_cut = []

                    else       

                                    x_cut = x[[index[1]+1:Length(x)]]

                    end

                    return x_cut

    end

    You could create something similar.