[S8445] トルク波形の時系列データから最大・最小の値を抽出するスクリプト

 

トルク波形の時系列データから最大・最小の値を抽出するスクリプトを例示します。

app = designer.GetApplication()

# FFT実行対象となるデータセットのトルクを指定

ref1 = app.GetCurrentStudy().GetDataSet("Torque", 1)

# 初期値を設定します。

max_torque = ref1.GetValue(0, 1)

min_torque = ref1.GetValue(0, 1)

max_step = 1 

min_step = 1 

# 点列値の大小を点列の最後まで比較します。

for i in range(1, ref1.GetRows()):

   current_torque_value = ref1.GetValue(i, 1)

   # i番目のトルク値が現在の最大トルク値より大きい場合、値を更新します。

   if max_torque < current_torque_value:

       max_torque = current_torque_value

       max_step = i + 1 

   # i番目のトルク値が現在の最小トルク値より小さい場合、値を更新します。

   if min_torque > current_torque_value:

       min_torque = current_torque_value

       min_step = i + 1 

# 取得した値を表示します。

print(f"最大トルク : {max_torque} Nm ({max_step}ステップ)")

print(f"最小トルク : {min_torque} Nm ({min_step}ステップ)")

ファイルご利用の注意点

JMAGスクリプトライブラリをご利用されるに際し、以下の利用規約をよくお読みいただき、ご同意の上ご利用下さるようお願い申し上げます。