|
1 | | -# DEMO: アプリを使用した特徴量調査 |
2 | | - |
3 | | -MATLAB/Simulink による予知保全ビデオシリーズの「[Part 3:予知保全を可能にする特徴量選択](https://jp.mathworks.com/videos/part-3-feature-extraction-for-predictive-maintenance-1545052389165.html)」では Diagnostic Feature Explorer アプリ ([https://jp.mathworks.com/matlabcentral/fileexchange/69101-diagnostic-feature-explorer](https://jp.mathworks.com/matlabcentral/fileexchange/69101-diagnostic-feature-explorer)) を使用して特徴量を抽出するデモを紹介しています。その際に使用するサンプルデータを作成するスクリプトです。アプリの使用には Predictive Maintenance Toolbox が必要ですが、このスクリプト自体は MATLAB だけで実行することができます。 |
4 | | - |
5 | | -# Dataset |
6 | | - |
7 | | -もともとの1 日当たり 6 秒間の振動信号を連続 50 日間取得したものですが、ここでは計算量軽減のため、1 日当たり 1 秒間、1 日おき 25 日分のデータに削減します。 |
8 | | - |
9 | | -20 歯のピニオンギヤで駆動する 2 MW 風力タービン高速シャフトから収集されたデータを使用します[1]。まず、[https://github.com/mathworks/WindTurbineHighSpeedBearingPrognosis-Data](https://github.com/mathworks/WindTurbineHighSpeedBearingPrognosis-Data) からリポジトリ全体を zip ファイルとしてダウンロードして、本スクリプトと同じディレクトリに保存してください。以下のコマンドを使用してファイルを解凍します。こちらのデータでは計測間隔は 1 日間隔です。 |
10 | | - |
11 | | -```matlab:Code |
12 | | -if exist('WindTurbineHighSpeedBearingPrognosis-Data-main.zip', 'file') |
13 | | - unzip('WindTurbineHighSpeedBearingPrognosis-Data-main.zip') |
14 | | -end |
15 | | -``` |
16 | | - |
17 | | -# Data Import |
18 | | - |
19 | | -まず風力タービンデータに対して fileDatastore を作成します。使用するデータには振動とタコメータの信号が含まれています。各 mat ファイルからcutomreader 関数で読み取りますが、1 秒分の振動データに加えてファイル名から日付情報も合わせて取得します。 |
20 | | - |
21 | | -```matlab:Code |
22 | | -dir = 'WindTurbineHighSpeedBearingPrognosis-Data-main'; |
23 | | -ds = fileDatastore(fullfile('.', dir,'*.mat'),'ReadFcn',@customreader,'UniformRead',true); |
24 | | -data = readall(ds) |
25 | | -``` |
26 | | - |
27 | | -| |Date|vibration| |
28 | | -|:--:|:--:|:--:| |
29 | | -|1|2013/03/07|97656x1 timetable| |
30 | | -|2|2013/03/08|97656x1 timetable| |
31 | | -|3|2013/03/09|97656x1 timetable| |
32 | | -|4|2013/03/10|97656x1 timetable| |
33 | | -|5|2013/03/11|97656x1 timetable| |
34 | | -|6|2013/03/12|97656x1 timetable| |
35 | | -|7|2013/03/13|97656x1 timetable| |
36 | | -|8|2013/03/14|97656x1 timetable| |
37 | | -|9|2013/03/15|97656x1 timetable| |
38 | | -|10|2013/03/16|97656x1 timetable| |
39 | | -|11|2013/03/17|97656x1 timetable| |
40 | | -|12|2013/03/17|97656x1 timetable| |
41 | | -|13|2013/03/18|97656x1 timetable| |
42 | | -|14|2013/03/20|97656x1 timetable| |
43 | | - |
44 | | -# Data Reduction |
45 | | - |
46 | | -ここでは計算量軽減のため、さらに1 日おき 25 日分のデータに削減します。 |
47 | | - |
48 | | -```matlab:Code |
49 | | -sampleData = data; |
50 | | -sampleData(1:2:end,:) = []; |
51 | | -``` |
52 | | - |
53 | | -さらに前半のデータには faultCode = 0、後半のデータについては faultcode = 1 とラベル付けします。 |
54 | | - |
55 | | -```matlab:Code |
56 | | -sampleData.faultcode = [zeros(13,1); ones(12,1)]; |
57 | | -save('sampleData.mat','sampleData'); |
58 | | -``` |
59 | | - |
60 | | -任意に変更して、他にもアプリで使用するサンプルデータを作成して試してみてください。 |
61 | | - |
62 | | -# References |
63 | | - |
64 | | -[1] [<http://data-acoustics.com/measurements/bearing-faults/bearing-3/](http://data-acoustics.com/measurements/bearing-faults/bearing-3/)> Bechhoefer, Eric, Brandon Van Hecke, and David He. "Processing for improved spectral analysis." *Annual Conference of the Prognostics and Health Management Society, New Orleans, LA, Oct*. 2013. |
65 | | - |
66 | | -# Helper Function |
67 | | - |
68 | | -```matlab:Code |
69 | | -function data = customreader(filename) |
70 | | -% Read variables for the fileEnsemble |
71 | | -% Inputs: |
72 | | -% filename - a string of the mat file name to read from. |
73 | | -% Output: |
74 | | -% data - return a table with a single row |
75 | | -% Copyright 2018 The MathWorks, Inc. |
76 | | -
|
77 | | -data = table; |
78 | | -% Extract the datetime information from the file names |
79 | | -[~, fname] = fileparts(filename); |
80 | | -token = regexp(fname, 'data-(\d+)', 'tokens'); |
81 | | -data.Date = datetime(token{1}{1}, 'InputFormat', 'yyyyMMdd'); |
82 | | -
|
83 | | -% Load the vibration signal from the mat file |
84 | | -mfile = matfile(filename); % Allows partial loading |
85 | | -vib = mfile.vibration; |
86 | | -
|
87 | | -% Extract the first 1s of signal and convert it to timetable |
88 | | -fs = 97656; % Sampling rate |
89 | | -tVibration = timetable(vib(1:fs),'SampleRate',fs); |
90 | | -data.vibration = {tVibration}; |
91 | | -
|
92 | | -end |
93 | | -
|
94 | | -``` |
95 | | - |
| 1 | +# DEMO: アプリを使用した特徴量調査 |
| 2 | + |
| 3 | +MATLAB/Simulink による予知保全ビデオシリーズの「[Part 3:予知保全を可能にする特徴量選択](https://jp.mathworks.com/videos/part-3-feature-extraction-for-predictive-maintenance-1545052389165.html)」では Diagnostic Feature Explorer アプリ ([https://jp.mathworks.com/matlabcentral/fileexchange/69101-diagnostic-feature-explorer](https://jp.mathworks.com/matlabcentral/fileexchange/69101-diagnostic-feature-explorer)) を使用して特徴量を抽出するデモを紹介しています。その際に使用するサンプルデータを作成するスクリプトです。アプリの使用には Predictive Maintenance Toolbox が必要ですが、このスクリプト自体は MATLAB だけで実行することができます。 |
| 4 | + |
| 5 | +# Dataset |
| 6 | + |
| 7 | +もともとの1 日当たり 6 秒間の振動信号を連続 50 日間取得したものですが、ここでは計算量軽減のため、1 日当たり 1 秒間、1 日おき 25 日分のデータに削減します。 |
| 8 | + |
| 9 | +20 歯のピニオンギヤで駆動する 2 MW 風力タービン高速シャフトから収集されたデータを使用します[1]。まず、[https://github.com/mathworks/WindTurbineHighSpeedBearingPrognosis-Data](https://github.com/mathworks/WindTurbineHighSpeedBearingPrognosis-Data) からリポジトリ全体を zip ファイルとしてダウンロードして、本スクリプトと同じディレクトリに保存してください。以下のコマンドを使用してファイルを解凍します。こちらのデータでは計測間隔は 1 日間隔です。 |
| 10 | + |
| 11 | +```matlab:Code |
| 12 | +if exist('WindTurbineHighSpeedBearingPrognosis-Data-main.zip', 'file') |
| 13 | + unzip('WindTurbineHighSpeedBearingPrognosis-Data-main.zip') |
| 14 | +end |
| 15 | +``` |
| 16 | + |
| 17 | +# Data Import |
| 18 | + |
| 19 | +まず風力タービンデータに対して fileDatastore を作成します。使用するデータには振動とタコメータの信号が含まれています。各 mat ファイルからcutomreader 関数で読み取りますが、1 秒分の振動データに加えてファイル名から日付情報も合わせて取得します。 |
| 20 | + |
| 21 | +```matlab:Code |
| 22 | +dir = 'WindTurbineHighSpeedBearingPrognosis-Data-main'; |
| 23 | +ds = fileDatastore(fullfile('.', dir,'*.mat'),'ReadFcn',@customreader,'UniformRead',true); |
| 24 | +data = readall(ds) |
| 25 | +``` |
| 26 | + |
| 27 | +| |Date|vibration| |
| 28 | +|:--:|:--:|:--:| |
| 29 | +|1|2013/03/07|97656x1 timetable| |
| 30 | +|2|2013/03/08|97656x1 timetable| |
| 31 | +|3|2013/03/09|97656x1 timetable| |
| 32 | +|4|2013/03/10|97656x1 timetable| |
| 33 | +|5|2013/03/11|97656x1 timetable| |
| 34 | +|6|2013/03/12|97656x1 timetable| |
| 35 | +|7|2013/03/13|97656x1 timetable| |
| 36 | +|8|2013/03/14|97656x1 timetable| |
| 37 | +|9|2013/03/15|97656x1 timetable| |
| 38 | +|10|2013/03/16|97656x1 timetable| |
| 39 | +|11|2013/03/17|97656x1 timetable| |
| 40 | +|12|2013/03/17|97656x1 timetable| |
| 41 | +|13|2013/03/18|97656x1 timetable| |
| 42 | +|14|2013/03/20|97656x1 timetable| |
| 43 | + |
| 44 | +# Data Reduction |
| 45 | + |
| 46 | +ここでは計算量軽減のため、さらに1 日おき 25 日分のデータに削減します。 |
| 47 | + |
| 48 | +```matlab:Code |
| 49 | +sampleData = data; |
| 50 | +sampleData(1:2:end,:) = []; |
| 51 | +``` |
| 52 | + |
| 53 | +さらに前半のデータには faultCode = 0、後半のデータについては faultcode = 1 とラベル付けします。 |
| 54 | + |
| 55 | +```matlab:Code |
| 56 | +sampleData.faultcode = [zeros(13,1); ones(12,1)]; |
| 57 | +save('sampleData.mat','sampleData'); |
| 58 | +``` |
| 59 | + |
| 60 | +任意に変更して、他にもアプリで使用するサンプルデータを作成して試してみてください。 |
| 61 | + |
| 62 | +# References |
| 63 | + |
| 64 | + |
| 65 | +[1] Bechhoefer, Eric, Brandon Van Hecke, and David He. 2013. “Processing for Improved Spectral Analysis”. Annual Conference of the PHM Society 5 (1). https://doi.org/10.36001/phmconf.2013.v5i1.2220. |
| 66 | + |
| 67 | +# Helper Function |
| 68 | + |
| 69 | +```matlab:Code |
| 70 | +function data = customreader(filename) |
| 71 | +% Read variables for the fileEnsemble |
| 72 | +% Inputs: |
| 73 | +% filename - a string of the mat file name to read from. |
| 74 | +% Output: |
| 75 | +% data - return a table with a single row |
| 76 | +% Copyright 2018 The MathWorks, Inc. |
| 77 | +
|
| 78 | +data = table; |
| 79 | +% Extract the datetime information from the file names |
| 80 | +[~, fname] = fileparts(filename); |
| 81 | +token = regexp(fname, 'data-(\d+)', 'tokens'); |
| 82 | +data.Date = datetime(token{1}{1}, 'InputFormat', 'yyyyMMdd'); |
| 83 | +
|
| 84 | +% Load the vibration signal from the mat file |
| 85 | +mfile = matfile(filename); % Allows partial loading |
| 86 | +vib = mfile.vibration; |
| 87 | +
|
| 88 | +% Extract the first 1s of signal and convert it to timetable |
| 89 | +fs = 97656; % Sampling rate |
| 90 | +tVibration = timetable(vib(1:fs),'SampleRate',fs); |
| 91 | +data.vibration = {tVibration}; |
| 92 | +
|
| 93 | +end |
| 94 | +
|
| 95 | +``` |
| 96 | + |
96 | 97 | *Copyright 2018-2022 The MathWorks, Inc.* |
0 commit comments