Hi Folks,
I have some instrument data that periodically exhibits large changes in the data due to readjusting the instrument. I'm trying to create a new variable that does the following: If (data - data[i-1] > 4) or (data - data[i-1] < -4), Then adj_data = adj_data[i-1], Else, data = adj_data + (data - data[i-1]); Basically, if the current data value exceeds the previous value by 4 or -4, then make new adjusted value equal to previous adjusted value, Else, add difference between current and previous data value to adjusted value.
I've figured out how to read the data into a matrix and remove any missing data, but I'm not sure how to complete the math outlined above on the matrix. Any suggestions on how to accomplish this would be appreciated.
Clear Log();
Names Default To Here( 1 );
dt = New Table( "Adjust for missing data",
Add Rows( 24 ),
Compress file when saved( 1 ),
New Column( "Date",
Numeric,
Continuous,
Format( "m/d/y", 19 ),
Input Format( "m/d/y" ),
Set Values(
[3447619200, 3447705600, 3447792000, 3447878400, 3447964800,
3448051200, 3448137600, 3448224000, 3448310400, 3448396800,
3448483200, 3448569600, 3448656000, 3448742400, 3448828800,
3448915200, 3449001600, 3449088000, 3449174400, 3449260800,
3449347200, 3449433600, 3449520000, 3449606400]
)
),
New Column( "Data1",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values(
[11, 13, 50, 15, ., 17, 18, -20, 20, ., 21, 22, ., 24, 25, 23, ., .,
., ., 25, 26, 27, 28]
)
),
New Column( "Adj Data1",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values(
[0, 2, ., 4, ., 6, 7, ., 9, ., 10, 11, ., 13, 14, 12, ., ., ., ., 14,
15, 16, 17]
)
)
);
//Put relevant data into matrix
date_time = :Name( "Date" ) << Get Values;
data = :Name( "Data1" ) << Get Values;
//Determine rows that only include data that aren't missing
row_list = dt << get rows where(
And(
!Is Missing( :Data1 ),
Contains( data, :Data1 ),
Contains( data, :Data1 ) == Contains( date_time, Format( :Date, "m-d-y" ) )
)
);
// Converts row_list, currently a matrix [ ], to a list { }
Is List( row_list = As List( row_list ) );
date_time = date_time[Loc( !Is Missing( data ) )];
data = data[Loc( !Is Missing( data ) )];