分データ アナライザーのステータス値 (文字値) の大規模な時系列 (~250,000) があります。 アナライザが正常に動作している場合の値は NORMAL であり、校正中の値は CALIB です。 キャリブレーションは毎日行われますが、さまざまな時間 (毎日同じ時間ではありません) に行われ、通常は約 30 分間続きます。 1 分のデータ ポイントごとにタイムスタンプが付けられます。 各校正期間 (特定の日の校正ステータス CALIB の開始から校正ステータス CALIB の終了まで) に一意の識別子を割り当て、各校正期間の開始時刻と終了時刻を含むテーブルを生成する必要があります。
私はJSLの完全な初心者です。 JSLでこれを達成する方法の例を誰かが提供できますか?
助けてくれてありがとう。
1 つのアプローチを見つけてください (間違いなく多くのアプローチがあります)。 サマリー テーブルを使用すると、ソース テーブルにリンクできるので便利です。 「ファイル > 新規 > 新規スクリプト」を実行し、以下のコードをカット アンド ペーストしてから、「編集 > スクリプトの実行」を実行します。
NamesDefaultToHere(1);
// Make some fake data to play with
n = 1000;
startDate = Date DMY( 01, 1, 2016 );
endDate = Date DMY( 12, 10, 2016 );
dates = Sort Ascending(J( n, 1, Random Integer(startDate, endDate) ) );
status = J( n, 1, Random Integer(1, 2) );
dt1 = New Table( "Callibrations",
New Column( "Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Set Values( dates )),
New Column( "Status", Numeric, "Nominal", Set Values( status ), Value Labels( {1 = "NORMAL", 2 = "CALIB"} ) )
);
/************************************************************************************************/
/* Start here . . . */
/************************************************************************************************/
dt1 = CurrentDataTable();
// Define a column that increments when the 'Status' changes:
// https://community.jmp.com/t5/Discussions/Formula-for-automatic-counter-by-group-of-rows/td-p/20120
dt1 << New Column( "Counter", Numeric, "Ordinal", Formula( If( Row() == 1, 1, Lag( :Counter, 1 ) + (Lag( :Status, 1 ) != :Status)) ) );
// Get the start dates
dt1 << New Column( "Start Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Formula( Col Min( :Date, :Counter ) ));
// Get the end dates
dt1 << New Column( "End Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Formula( Col Max( :Date, :Counter ) ));
// Make the required summary table
dt2 = dt1 << Summary(
Group( :Counter, :Status ),
Min( :Start Date ),
Max( :End Date ),
statistics column name format( "column" ),
output table name( "Calibration Periods" )
);
dt2 << deleteProperty("Source");