cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Jackie_
Level VI

Add/Subtract values from two jmp files

Hi,

@txnelson @pmroz 

I need help to offset the data set using the reference value in JSL 

 

First table contains reference value

Jacksmith12_0-1655397972661.png 
Second table contains strips tested measurements

Jacksmith12_1-1655398026429.png

 

I want to subtract mean of strip A from the reference data table and then add to to the data set 
for example :

step1. the mean value for strips A for current = (10+3)/2 = 6.5. So, 400 - 6.5 = 393.5 and likewise for other strips

step2. Add 393.5 to the 2nd data table of strip A >> 393.2 + 10 = 403.2 and likewise for other strips

 

The final table should have following values:

Jacksmith12_2-1655398395594.png

 

Refer attached file for details.

 

Thank you for your help!

This what I tried:

Names Default To Here( 1 );
dt = Current data table();
dtOffset = Open(Limits);

colList = dt << get column names(string);

For( i = 1, i <= N Items( colList ), i++, 
	
	theRow = dtOffset << get rows where( dtOffset:Tests == colList[i] );
	show(i,nrows(therow));
	
	If( N Rows( theRow ) == 1,
		offset = dtOffset:Offset[theRow[1]];
		For( k = 1, k <= N Rows( dt ), k++,
			Column( dt, i )[k] = Column( dt, i )[k] + offset
		);
	);
	);

 

15 REPLIES 15
txnelson
Super User

Re: Add/Subtract values from two jmp files

The calculation of "measure" can not be calculated.  You have written a line of JSL that assumes that it is looping through a data table, but no looping through the rows is happening.

 

Jim
Jackie_
Level VI

Re: Add/Subtract values from two jmp files

Thanks, @txnelson 

I used For each rows syntax but the loop takes 40 min to complete. Any alternate way?

For( c = 1, c <= N Col( dt2 ) -1, c++,
	theMatrix = [];
	name = Column( Col_List1[c] ) << Get name;
	if (Contains( Col_List1[c], "Current"),
	//For( r = 1, r <= N Rows( dt2 ), r++,
For Each Row( 
	
r = dt2 << get rows where(dt2:sitenumber == sitenum[1]); //mean = dt1:Mean[dt1 << Get Rows Where( :Tests == name )]; mean = column(dt2, Col_list1[c]) << get property("theMean"); //measure = mean - Col Mean( If( dt2:Strips == dt2:Strips[r], Column( dt2, c ), . ) ); measure = mean - Col Mean(as Column( dt2, c ),:Wafer ID); theMatrix = theMatrix || Column( dt2, c )[r] + measure; ); Column( dt2, c ) << Set Values( theMatrix ); ););
Jackie_
Level VI

Re: Add/Subtract values from two jmp files

any advice Jim? 

txnelson
Super User

Re: Add/Subtract values from two jmp files

Your code is confusing to me.  When you have 

     For Each Row

each separate row within the data table is processed.

When the Get Row Where() is used, it is only passing through the data once.  Can you provide a sample of the results you are expecting?

Jim
Jackie_
Level VI

Re: Add/Subtract values from two jmp files

@txnelson 
Below is the Screen short of the results that I am expecting. I have attached the final result data table

Here are the steps:

1. Read data table and reference data table

2. Generate a new window to select site number, 

3. Based on the user input (Site Number 1 or 2), align those data to the reference data table values

 Take mean by wafer Id, apply the offset to the main data table

 

Jacksmith12_0-1657137010586.png

 

Names Default To Here( 1 );
Clear globals();
Clear log();
dt1 = Data table( "Reference data table" );
dt2 = Current data table(); /// Select Data table.jmp




For(i=1,i<=nrows(dt1),i++,
	theTest = dt1:Tests[i];
	try(column(dt2,theTest) << set property("TheMean", dt1:Mean[i]));
);

New window( "", modal,
			ct = checkbox({"1","2"}),
			Buttonbox ("Ok",
				get = ct << Get Selected ();
			)
	
	
);


sitenum = Transform Each({str}, get, Num(str));	


Col_List1 = dt2 << Get Column Names( "String" );

//if (!contains(Col_List1, "SiteNumber"),
     // dt2 <<New Column("SiteNumber", "Numeric", "Continuous", <<Set Each Value( 1 ) );
     
   //   );


For( c = 1, c <= N Col( dt2 ) -1, c++,
	theMatrix = [];
	name = Column( Col_List1[c] ) << Get name;
	if (Contains( Col_List1[c], "Current 1.1") | Contains( Col_List1[c], "Current 2.1") | Contains( Col_List1[c], "Voltage 1.1"),
	For each row(
r = dt2 << get rows where(dt2:sitenumber == sitenum[1]); /// something needs to change here ****&&&**&&&&**&&& //mean = dt1:Mean[dt1 << Get Rows Where( :Tests == name )]; mean = column(dt2, Col_list1[c]) << get property("theMean"); //measure = mean - Col Mean( If( dt2:Strips == dt2:Strips[r], Column( dt2, c ), . ) ); measure = mean - Col Mean(as Column( dt2, c ),:Wafer ID); theMatrix = theMatrix || Column( dt2, c )[r] + measure; ); Column( dt2, c ) << Set Values( theMatrix ); ););

 

 

Jackie_
Level VI

Re: Add/Subtract values from two jmp files

@txnelson 
can you identify what's going wrong