DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Copying a band of data to new channels within a script

Solved!
Go to solution

Hi,

 

I am trying to copy specific data between two sets of X values (which are specified in the script) and then plot a regression curve for them.

 

I have managed to set the cursor values and create a band but the only way I can see of copying it is to set flags and copy the data points which cannot be done in a script (as far as I can see)

 

Searching on the forum suggested using the x coordinate value to find the row but the data I am using has multiple Y values at X coordinates which means this won't work as it only returns the row of the first value it finds.

 

Any suggestions? Copying the data to new channels would be the most useful solution but if I can calculate a regression curve between the two x values then I might be able to work with that.

 

Here is the code as it stands:

 

Dim MyFileNames, iCount, Sheet, Area, Graph, Curve, chlength
Call FileNameGet("ANY", "FileRead", DataReadPath, "TDM data (*.tdm),*.tdm", "All.lst", True, "Data selection")
MyFileNames = Split(FileDlgFileName,"|")
For iCount = 0 To Ubound(MyFileNames)
  Call DataFileLoad(MyFileNames(iCount))
Next

Call View.LoadLayout("view1")

Set Sheet = View.Sheets(1)
Set Area = Sheet.Areas(1)
Area.DisplayObjType = "CurveChart2D"
Set Graph = Area.DisplayObj
Call Graph.Curves.RemoveAll
Set Curve = Graph.Curves.Add("Y_Accel","Strg_Angle")

Sheet.Cursor.Type = "Band"
Sheet.Cursor.X1 = -0.1
Sheet.Cursor.X2 = 0.1

'This is where I'd like to copy the data points from flags

Chlength=CL("CopyYStrg_Angle")

Call ChnApprXYCalc("CopyXY_Accel", "CopyYStrg_Angle", "Y_Accel_Strg_Torq_approx", "Strg_Torq_approx", "Partition complete area", Chlength, 1)

Set Sheet = View.Sheets(1)
Set Area = Sheet.Areas(1)
Area.DisplayObjType = "CurveChart2D"
Set Graph = Area.DisplayObj
Set Curve = Graph.Curves.Add("Y_Accel_Strg_Torq_approx","Strg_Torq_approx")

 

And the plot so you can see what I am attempting to complete (automatically though!)

 

Data.PNG

 

Many thanks for your help

 

0 Kudos
Message 1 of 6
(6,152 Views)

James,

I bet you will receive an answer from one of our AE's shortly, answering your specific question. Just out of curiosity: Is this a hysteresis curve and what you are trying to achieve is cleaning it up so that you can derive more details like slope, width etc?

0 Kudos
Message 2 of 6
(6,135 Views)

Yep, got it in one.

 

Will also be using the method for other more conventional pieces of data so will be useful either way

0 Kudos
Message 3 of 6
(6,125 Views)

I remember that one of our PSE's create an example which cleaned up noisy data from a hysteressis measurement. Not sure whether what he created would work with your data. If you're interested and willing to post an example data set, I could have check him whther it works.

Andreas

0 Kudos
Message 4 of 6
(6,123 Views)

I've managed to clean up other data using a butterworth filter but haven't attempted it on this set yet (as I'd prefer to do it after I have selected the bits I want). Thanks for the offer though, if I get stuck I may well take you up on it

0 Kudos
Message 5 of 6
(6,119 Views)
Solution
Accepted by topic author JamesChatz

I've managed to do this without using flags by manually allocating the data into new channels with an if function, based on Brad's code here http://forums.ni.com/t5/DIAdem/Can-I-copy-data-points-from-a-VBScript/m-p/1048090#M11359

 

Just changed the if function to check if the pieces of data were between certain values rather than check if they had been flagged (couldn't get the chnflagset command to work)

0 Kudos
Message 6 of 6
(6,088 Views)