diff --git a/disturbance-ty/figs/asd_east_marble.png b/disturbance-ty/figs/asd_east_marble.png index a49862c..d961788 100644 Binary files a/disturbance-ty/figs/asd_east_marble.png and b/disturbance-ty/figs/asd_east_marble.png differ diff --git a/disturbance-ty/figs/asd_east_sample.png b/disturbance-ty/figs/asd_east_sample.png index b2c476b..a575c82 100644 Binary files a/disturbance-ty/figs/asd_east_sample.png and b/disturbance-ty/figs/asd_east_sample.png differ diff --git a/disturbance-ty/figs/asd_z_direction.png b/disturbance-ty/figs/asd_z_direction.png index faefde5..9732b0f 100644 Binary files a/disturbance-ty/figs/asd_z_direction.png and b/disturbance-ty/figs/asd_z_direction.png differ diff --git a/disturbance-ty/figs/east_marble_sample.png b/disturbance-ty/figs/east_marble_sample.png index 5572864..d083d88 100644 Binary files a/disturbance-ty/figs/east_marble_sample.png and b/disturbance-ty/figs/east_marble_sample.png differ diff --git a/disturbance-ty/figs/tf_east_marble_sample.png b/disturbance-ty/figs/tf_east_marble_sample.png index ee2f9f3..103ae9e 100644 Binary files a/disturbance-ty/figs/tf_east_marble_sample.png and b/disturbance-ty/figs/tf_east_marble_sample.png differ diff --git a/disturbance-ty/figs/ty_e_time.png b/disturbance-ty/figs/ty_e_time.png index e42055e..41e236e 100644 Binary files a/disturbance-ty/figs/ty_e_time.png and b/disturbance-ty/figs/ty_e_time.png differ diff --git a/disturbance-ty/figs/ty_e_time_zoom.png b/disturbance-ty/figs/ty_e_time_zoom.png index 7628c10..97ae371 100644 Binary files a/disturbance-ty/figs/ty_e_time_zoom.png and b/disturbance-ty/figs/ty_e_time_zoom.png differ diff --git a/disturbance-ty/figs/ty_z_time.png b/disturbance-ty/figs/ty_z_time.png index 1f98891..efb630c 100644 Binary files a/disturbance-ty/figs/ty_z_time.png and b/disturbance-ty/figs/ty_z_time.png differ diff --git a/disturbance-ty/figs/ty_z_time_zoom.png b/disturbance-ty/figs/ty_z_time_zoom.png index edcac32..fdce6d2 100644 Binary files a/disturbance-ty/figs/ty_z_time_zoom.png and b/disturbance-ty/figs/ty_z_time_zoom.png differ diff --git a/disturbance-ty/index.html b/disturbance-ty/index.html index 9f048be..283124a 100644 Binary files a/disturbance-ty/index.html and b/disturbance-ty/index.html differ diff --git a/disturbance-ty/index.org b/disturbance-ty/index.org index 85bae6f..3a9c62f 100644 --- a/disturbance-ty/index.org +++ b/disturbance-ty/index.org @@ -102,11 +102,11 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: ** Matlab Init :noexport:ignore: #+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name) -<> + <> #+end_src #+begin_src matlab :exports none :results silent :noweb yes -<> + <> #+end_src ** Load data @@ -116,6 +116,19 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: e_of = load('mat/data_042.mat', 'data'); e_of = e_of.data; #+end_src +** Voltage to Velocity +We convert the measured voltage to velocity using the function =voltageToVelocityL22= (accessible [[file:~/MEGA/These/meas/src/index.org][here]]). + +#+begin_src matlab + z_ty(:, 1) = voltageToVelocityL22(z_ty(:, 1), z_ty(:, 3), 40); + e_ty(:, 1) = voltageToVelocityL22(e_ty(:, 1), e_ty(:, 3), 40); + e_of(:, 1) = voltageToVelocityL22(e_of(:, 1), e_of(:, 3), 40); + + z_ty(:, 2) = voltageToVelocityL22(z_ty(:, 2), z_ty(:, 3), 40); + e_ty(:, 2) = voltageToVelocityL22(e_ty(:, 2), e_ty(:, 3), 40); + e_of(:, 2) = voltageToVelocityL22(e_of(:, 2), e_of(:, 3), 40); +#+end_src + ** Time domain plots #+begin_src matlab figure; @@ -123,8 +136,8 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: plot(z_ty(:, 3), z_ty(:, 1), 'DisplayName', 'Marble - Z'); plot(z_ty(:, 3), z_ty(:, 2), 'DisplayName', 'Sample - Z'); hold off; - xlabel('Time [s]'); ylabel('Voltage [V]'); - xlim([0, 100]); ylim([-5, 5]); + xlabel('Time [s]'); ylabel('Velocity [m/s]'); + xlim([0, 100]); legend('Location', 'northeast'); #+end_src @@ -135,12 +148,12 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: #+end_src #+NAME: fig:ty_z_time -#+CAPTION: Z motion of the sample and marble when scanning with the translation stage +#+CAPTION: Z velocity of the sample and marble when scanning with the translation stage #+RESULTS: fig:ty_z_time [[file:figs/ty_z_time.png]] #+begin_src matlab :exports none - xlim([0, 1]) + xlim([0, 1]); #+end_src #+NAME: fig:ty_z_time_zoom @@ -150,7 +163,7 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: #+end_src #+NAME: fig:ty_z_time_zoom -#+CAPTION: Z motion of the sample and marble when scanning with the translation stage - Zoom +#+CAPTION: Z velocity of the sample and marble when scanning with the translation stage - Zoom #+RESULTS: fig:ty_z_time_zoom [[file:figs/ty_z_time_zoom.png]] @@ -161,8 +174,8 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: plot(e_ty(:, 3), e_ty(:, 1), 'DisplayName', 'Marble - X'); plot(e_ty(:, 3), e_ty(:, 2), 'DisplayName', 'Sample - X'); hold off; - xlabel('Time [s]'); ylabel('Voltage [V]'); - xlim([0, 100]); ylim([-10, 10]); + xlabel('Time [s]'); ylabel('Velocity [m/s]'); + xlim([0, 100]); legend('Location', 'northeast'); #+end_src @@ -173,7 +186,7 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: #+end_src #+NAME: fig:ty_e_time -#+CAPTION: Motion of the sample and marble in the east direction when scanning with the translation stage +#+CAPTION: Velocity of the sample and marble in the east direction when scanning with the translation stage #+RESULTS: fig:ty_e_time [[file:figs/ty_e_time.png]] @@ -188,11 +201,16 @@ Each of the measurement =mat= file contains one =data= array with 3 columns: #+end_src #+NAME: fig:ty_e_time_zoom -#+CAPTION: Motion of the sample and marble in the east direction when scanning with the translation stage - Zoom +#+CAPTION: Velocity of the sample and marble in the east direction when scanning with the translation stage - Zoom #+RESULTS: fig:ty_e_time_zoom [[file:figs/ty_e_time_zoom.png]] ** Frequency Domain analysis +We get the typical ground velocity to compare with the velocities measured. +#+begin_src matlab + [pxx_gm, f_gm] = getPSDGroundVelocity(); +#+end_src + We first compute some parameters that will be used for the PSD computation. #+begin_src matlab dt = z_ty(2, 3)-z_ty(1, 3); @@ -218,22 +236,23 @@ And for the geophone located at the sample position. [pxe_of_s, ~] = pwelch(e_of(:, 2), win, [], [], Fs); #+end_src -And we plot the ASD of the measured signals: -- figure [[fig:asd_east_marble]] compares the marble motion in the east direction when scanning and when Ty is OFF -- figure [[fig:asd_east_sample]] compares the sample motion in the east direction when scanning and when Ty is OFF -- figure [[fig:asd_z_direction]] shows the marble and sample motion in the Z direction when scanning with the translation stage +And we plot the ASD of the measured velocities: +- figure [[fig:asd_east_marble]] compares the marble velocity in the east direction when scanning and when Ty is OFF +- figure [[fig:asd_east_sample]] compares the sample velocity in the east direction when scanning and when Ty is OFF +- figure [[fig:asd_z_direction]] shows the marble and sample velocities in the Z direction when scanning with the translation stage #+begin_src matlab figure; hold on; plot(f, sqrt(pxe_ty_m), 'DisplayName', 'Ty 1Hz - Marble - X'); plot(f, sqrt(pxe_of_m), 'DisplayName', 'Ty OFF - Marble - X'); + plot(f_gm, sqrt(pxx_gm), 'k--', 'DisplayName', 'Ground Motion'); hold off; set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log'); - xlabel('Frequency [Hz]'); ylabel('ASD of the measured Voltage $\left[\frac{V}{\sqrt{Hz}}\right]$') + xlabel('Frequency [Hz]'); ylabel('ASD of the measured velocity $\left[\frac{m/s}{\sqrt{Hz}}\right]$') legend('Location', 'northwest'); - xlim([0.1, 500]); ylim([1e-5, 1e1]); + xlim([0.1, 500]); #+end_src #+NAME: fig:asd_east_marble @@ -243,7 +262,7 @@ And we plot the ASD of the measured signals: #+end_src #+NAME: fig:asd_east_marble -#+CAPTION: Amplitude spectral density of the measure voltage corresponding to the geophone in the east direction located on the marble when the translation stage is OFF and when it is scanning at 1Hz +#+CAPTION: Amplitude spectral density of the measured velocities corresponding to the geophone in the east direction located on the marble when the translation stage is OFF and when it is scanning at 1Hz #+RESULTS: fig:asd_east_marble [[file:figs/asd_east_marble.png]] @@ -253,12 +272,13 @@ And we plot the ASD of the measured signals: hold on; plot(f, sqrt(pxe_ty_s), 'DisplayName', 'Ty 1Hz - Sample - X'); plot(f, sqrt(pxe_of_s), 'DisplayName', 'Ty OFF - Sample - X'); + plot(f_gm, sqrt(pxx_gm), 'k--', 'DisplayName', 'Ground Motion'); hold off; set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log'); - xlabel('Frequency [Hz]'); ylabel('ASD of the measured Voltage $\left[\frac{V}{\sqrt{Hz}}\right]$') + xlabel('Frequency [Hz]'); ylabel('ASD of the measured velocity $\left[\frac{m/s}{\sqrt{Hz}}\right]$') legend('Location', 'northwest'); - xlim([0.1, 500]); ylim([1e-5, 1e1]); + xlim([0.1, 500]); #+end_src #+NAME: fig:asd_east_sample @@ -268,7 +288,7 @@ And we plot the ASD of the measured signals: #+end_src #+NAME: fig:asd_east_sample -#+CAPTION: Amplitude spectral density of the measure voltage corresponding to the geophone in the east direction located at the sample location when the translation stage is OFF and when it is scanning at 1Hz +#+CAPTION: Amplitude spectral density of the measured velocities corresponding to the geophone in the east direction located at the sample location when the translation stage is OFF and when it is scanning at 1Hz #+RESULTS: fig:asd_east_sample [[file:figs/asd_east_sample.png]] @@ -278,12 +298,13 @@ And we plot the ASD of the measured signals: hold on; plot(f, sqrt(pxz_ty_m), 'DisplayName', 'Ty 1Hz - Marble - Z'); plot(f, sqrt(pxz_ty_s), 'DisplayName', 'Ty 1Hz - Sample - Z'); + plot(f_gm, sqrt(pxx_gm), 'k--', 'DisplayName', 'Ground Motion'); hold off; set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log'); xlabel('Frequency [Hz]'); ylabel('ASD of the measured Voltage $\left[\frac{V}{\sqrt{Hz}}\right]$') legend('Location', 'northwest'); - xlim([0.1, 500]); ylim([1e-5, 1e1]); + xlim([0.1, 500]); #+end_src #+NAME: fig:asd_z_direction @@ -298,7 +319,7 @@ And we plot the ASD of the measured signals: [[file:figs/asd_z_direction.png]] ** Transfer function from marble motion in the East direction to sample motion in the East direction -Let's compute the transfer function for the marble motion in the east direction to the sample motion in the east direction. +Let's compute the transfer function for the marble velocity in the east direction to the sample velocity in the east direction. We first plot the time domain motions when every stage is off (figure [[fig:east_marble_sample]]). @@ -308,9 +329,9 @@ We first plot the time domain motions when every stage is off (figure [[fig:east plot(e_of(:, 3), e_of(:, 2), 'DisplayName', 'Sample - X'); plot(e_of(:, 3), e_of(:, 1), 'DisplayName', 'Marble - X'); hold off; - xlabel('Time [s]'); ylabel('Voltage [V]'); - xlim([0, 100]); ylim([-1, 1]); - legend('Location', 'northeast'); + xlabel('Time [s]'); ylabel('Velocity [m/s]'); + xlim([0, 100]); + legend('Location', 'southwest'); #+end_src #+NAME: fig:east_marble_sample @@ -320,7 +341,7 @@ We first plot the time domain motions when every stage is off (figure [[fig:east #+end_src #+NAME: fig:east_marble_sample -#+CAPTION: East motion of the marble and sample when all the stages are OFF +#+CAPTION: Velocity in the east direction of the marble and sample when all the stages are OFF #+RESULTS: fig:east_marble_sample [[file:figs/east_marble_sample.png]] @@ -366,7 +387,7 @@ The result is shown on figure [[fig:tf_east_marble_sample]]. #+end_src #+NAME: fig:tf_east_marble_sample -#+CAPTION: Estimation of the transfer function from marble motion in the east direction to sample motion in the east direction +#+CAPTION: Estimation of the transfer function from marble velocity in the east direction to sample velocity in the east direction #+RESULTS: fig:tf_east_marble_sample [[file:figs/tf_east_marble_sample.png]] diff --git a/disturbance-ty/matlab/disturbance_ty.m b/disturbance-ty/matlab/disturbance_ty.m index de5b524..336ffda 100644 --- a/disturbance-ty/matlab/disturbance_ty.m +++ b/disturbance-ty/matlab/disturbance_ty.m @@ -10,6 +10,18 @@ z_ty = load('mat/data_040.mat', 'data'); z_ty = z_ty.data; e_ty = load('mat/data_041.mat', 'data'); e_ty = e_ty.data; e_of = load('mat/data_042.mat', 'data'); e_of = e_of.data; +% Voltage to Velocity +% We convert the measured voltage to velocity using the function =voltageToVelocityL22= (accessible [[file:~/MEGA/These/meas/src/index.org][here]]). + + +z_ty(:, 1) = voltageToVelocityL22(z_ty(:, 1), z_ty(:, 3), 40); +e_ty(:, 1) = voltageToVelocityL22(e_ty(:, 1), e_ty(:, 3), 40); +e_of(:, 1) = voltageToVelocityL22(e_of(:, 1), e_of(:, 3), 40); + +z_ty(:, 2) = voltageToVelocityL22(z_ty(:, 2), z_ty(:, 3), 40); +e_ty(:, 2) = voltageToVelocityL22(e_ty(:, 2), e_ty(:, 3), 40); +e_of(:, 2) = voltageToVelocityL22(e_of(:, 2), e_of(:, 3), 40); + % Time domain plots figure; @@ -17,24 +29,24 @@ hold on; plot(z_ty(:, 3), z_ty(:, 1), 'DisplayName', 'Marble - Z'); plot(z_ty(:, 3), z_ty(:, 2), 'DisplayName', 'Sample - Z'); hold off; -xlabel('Time [s]'); ylabel('Voltage [V]'); -xlim([0, 100]); ylim([-5, 5]); +xlabel('Time [s]'); ylabel('Velocity [m/s]'); +xlim([0, 100]); legend('Location', 'northeast'); % #+NAME: fig:ty_z_time -% #+CAPTION: Z motion of the sample and marble when scanning with the translation stage +% #+CAPTION: Z velocity of the sample and marble when scanning with the translation stage % #+RESULTS: fig:ty_z_time % [[file:figs/ty_z_time.png]] -xlim([0, 1]) +xlim([0, 1]); % #+NAME: fig:ty_z_time_zoom -% #+CAPTION: Z motion of the sample and marble when scanning with the translation stage - Zoom +% #+CAPTION: Z velocity of the sample and marble when scanning with the translation stage - Zoom % #+RESULTS: fig:ty_z_time_zoom % [[file:figs/ty_z_time_zoom.png]] @@ -45,14 +57,14 @@ hold on; plot(e_ty(:, 3), e_ty(:, 1), 'DisplayName', 'Marble - X'); plot(e_ty(:, 3), e_ty(:, 2), 'DisplayName', 'Sample - X'); hold off; -xlabel('Time [s]'); ylabel('Voltage [V]'); -xlim([0, 100]); ylim([-10, 10]); +xlabel('Time [s]'); ylabel('Velocity [m/s]'); +xlim([0, 100]); legend('Location', 'northeast'); % #+NAME: fig:ty_e_time -% #+CAPTION: Motion of the sample and marble in the east direction when scanning with the translation stage +% #+CAPTION: Velocity of the sample and marble in the east direction when scanning with the translation stage % #+RESULTS: fig:ty_e_time % [[file:figs/ty_e_time.png]] @@ -60,6 +72,12 @@ legend('Location', 'northeast'); xlim([0, 1]) % Frequency Domain analysis +% We get the typical ground velocity to compare with the velocities measured. + +[pxx_gm, f_gm] = getPSDGroundVelocity(); + + + % We first compute some parameters that will be used for the PSD computation. dt = z_ty(2, 3)-z_ty(1, 3); @@ -88,27 +106,28 @@ win = hanning(ceil(10*Fs)); -% And we plot the ASD of the measured signals: -% - figure [[fig:asd_east_marble]] compares the marble motion in the east direction when scanning and when Ty is OFF -% - figure [[fig:asd_east_sample]] compares the sample motion in the east direction when scanning and when Ty is OFF -% - figure [[fig:asd_z_direction]] shows the marble and sample motion in the Z direction when scanning with the translation stage +% And we plot the ASD of the measured velocities: +% - figure [[fig:asd_east_marble]] compares the marble velocity in the east direction when scanning and when Ty is OFF +% - figure [[fig:asd_east_sample]] compares the sample velocity in the east direction when scanning and when Ty is OFF +% - figure [[fig:asd_z_direction]] shows the marble and sample velocities in the Z direction when scanning with the translation stage figure; hold on; plot(f, sqrt(pxe_ty_m), 'DisplayName', 'Ty 1Hz - Marble - X'); plot(f, sqrt(pxe_of_m), 'DisplayName', 'Ty OFF - Marble - X'); +plot(f_gm, sqrt(pxx_gm), 'k--', 'DisplayName', 'Ground Motion'); hold off; set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log'); -xlabel('Frequency [Hz]'); ylabel('ASD of the measured Voltage $\left[\frac{V}{\sqrt{Hz}}\right]$') +xlabel('Frequency [Hz]'); ylabel('ASD of the measured velocity $\left[\frac{m/s}{\sqrt{Hz}}\right]$') legend('Location', 'northwest'); -xlim([0.1, 500]); ylim([1e-5, 1e1]); +xlim([0.1, 500]); % #+NAME: fig:asd_east_marble -% #+CAPTION: Amplitude spectral density of the measure voltage corresponding to the geophone in the east direction located on the marble when the translation stage is OFF and when it is scanning at 1Hz +% #+CAPTION: Amplitude spectral density of the measured velocities corresponding to the geophone in the east direction located on the marble when the translation stage is OFF and when it is scanning at 1Hz % #+RESULTS: fig:asd_east_marble % [[file:figs/asd_east_marble.png]] @@ -118,17 +137,18 @@ figure; hold on; plot(f, sqrt(pxe_ty_s), 'DisplayName', 'Ty 1Hz - Sample - X'); plot(f, sqrt(pxe_of_s), 'DisplayName', 'Ty OFF - Sample - X'); +plot(f_gm, sqrt(pxx_gm), 'k--', 'DisplayName', 'Ground Motion'); hold off; set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log'); -xlabel('Frequency [Hz]'); ylabel('ASD of the measured Voltage $\left[\frac{V}{\sqrt{Hz}}\right]$') +xlabel('Frequency [Hz]'); ylabel('ASD of the measured velocity $\left[\frac{m/s}{\sqrt{Hz}}\right]$') legend('Location', 'northwest'); -xlim([0.1, 500]); ylim([1e-5, 1e1]); +xlim([0.1, 500]); % #+NAME: fig:asd_east_sample -% #+CAPTION: Amplitude spectral density of the measure voltage corresponding to the geophone in the east direction located at the sample location when the translation stage is OFF and when it is scanning at 1Hz +% #+CAPTION: Amplitude spectral density of the measured velocities corresponding to the geophone in the east direction located at the sample location when the translation stage is OFF and when it is scanning at 1Hz % #+RESULTS: fig:asd_east_sample % [[file:figs/asd_east_sample.png]] @@ -138,15 +158,16 @@ figure; hold on; plot(f, sqrt(pxz_ty_m), 'DisplayName', 'Ty 1Hz - Marble - Z'); plot(f, sqrt(pxz_ty_s), 'DisplayName', 'Ty 1Hz - Sample - Z'); +plot(f_gm, sqrt(pxx_gm), 'k--', 'DisplayName', 'Ground Motion'); hold off; set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log'); xlabel('Frequency [Hz]'); ylabel('ASD of the measured Voltage $\left[\frac{V}{\sqrt{Hz}}\right]$') legend('Location', 'northwest'); -xlim([0.1, 500]); ylim([1e-5, 1e1]); +xlim([0.1, 500]); % Transfer function from marble motion in the East direction to sample motion in the East direction -% Let's compute the transfer function for the marble motion in the east direction to the sample motion in the east direction. +% Let's compute the transfer function for the marble velocity in the east direction to the sample velocity in the east direction. % We first plot the time domain motions when every stage is off (figure [[fig:east_marble_sample]]). @@ -156,14 +177,14 @@ hold on; plot(e_of(:, 3), e_of(:, 2), 'DisplayName', 'Sample - X'); plot(e_of(:, 3), e_of(:, 1), 'DisplayName', 'Marble - X'); hold off; -xlabel('Time [s]'); ylabel('Voltage [V]'); -xlim([0, 100]); ylim([-1, 1]); -legend('Location', 'northeast'); +xlabel('Time [s]'); ylabel('Velocity [m/s]'); +xlim([0, 100]); +legend('Location', 'southwest'); % #+NAME: fig:east_marble_sample -% #+CAPTION: East motion of the marble and sample when all the stages are OFF +% #+CAPTION: Velocity in the east direction of the marble and sample when all the stages are OFF % #+RESULTS: fig:east_marble_sample % [[file:figs/east_marble_sample.png]] diff --git a/src/index.org b/src/index.org index 5db990b..836d697 100644 --- a/src/index.org +++ b/src/index.org @@ -36,6 +36,10 @@ This Matlab function is accessible [[file:voltageToVelocityL22.m][here]]. S = S0*(s/2/pi/f0)/(1+s/2/pi/f0); #+end_src +#+begin_src matlab + voltage = detrend(voltage); +#+end_src + #+begin_src matlab velocity = lsim((S*10^(gain/20))\1, voltage, time); #+end_src @@ -70,9 +74,128 @@ This Matlab function is accessible [[file:voltageToDisplacementL22.m][here]]. #+end_src #+begin_src matlab - voltage = voltage - mean(voltage); - velocity = voltageToVelocityL22(voltage, time, gain); disp = lsim(1/s, velocity, time); #+end_src +* getGroundVelocity + :PROPERTIES: + :header-args:matlab+: :tangle getGroundVelocity.m + :header-args:matlab+: :comments org :mkdirp yes + :header-args:matlab+: :eval no :results none + :END: + <> + +This Matlab function is accessible [[file:getGroundVelocity.m][here]]. + +#+begin_src matlab + function [time, velocity] = getGroundVelocity() + % getGroundVelocity - + % + % Syntax: [time, velocity] = voltageToVelocityL22() + % + % Inputs: + % - - + % + % Outputs: + % - time - in [s] + % - velocity - in [m/s] + + current_dir = pwd; + + src_dir = mfilename('fullpath'); + src_dir = strsplit(src_dir, '/'); + src_dir = strjoin(src_dir(1:end-1), '/'); + cd(src_dir); + + data = load('mat/data_028.mat', 'data'); data = data.data; + time = data(:, 3); + + [velocity] = voltageToVelocityL22(data(:, 1), time, 60); + + cd(current_dir); + end +#+end_src + +* getGroundDisplacement + :PROPERTIES: + :header-args:matlab+: :tangle getGroundDisplacement.m + :header-args:matlab+: :comments org :mkdirp yes + :header-args:matlab+: :eval no :results none + :END: + <> + +This Matlab function is accessible [[file:getGroundDisplacement.m][here]]. + +#+begin_src matlab + function [time, displacement] = getGroundDisplacement() + % getGroundDisplacement - + % + % Syntax: [time, displacement] = voltageToVelocityL22() + % + % Inputs: + % - - + % + % Outputs: + % - time - in [s] + % - displacement - in [m] + s = zpk('s'); + + [time, velocity] = getGroundVelocity(); + + displacement = lsim(1/s, velocity, time); + end +#+end_src + +* getPSDGroundVelocity + :PROPERTIES: + :header-args:matlab+: :tangle getPSDGroundVelocity.m + :header-args:matlab+: :comments org :mkdirp yes + :header-args:matlab+: :eval no :results none + :END: + <> + +This Matlab function is accessible [[file:getPSDGroundVelocity.m][here]]. + +#+begin_src matlab + function [pxx, f] = getPSDGroundVelocity() + % getPSDGroundVelocity - + % + % Syntax: [pxx, f] = voltageToVelocityL22(in_data) + % + % Outputs: + % - psd - + % - f - + + [time, velocity] = getGroundVelocity(); + + dt = time(2) - time(1); + Fs = 1/dt; + win = hanning(ceil(10*Fs)); + + [pxx, f] = pwelch(velocity, win, [], [], Fs); +#+end_src +* getPSDGroundDisplacement + :PROPERTIES: + :header-args:matlab+: :tangle getPSDGroundDisplacement.m + :header-args:matlab+: :comments org :mkdirp yes + :header-args:matlab+: :eval no :results none + :END: + <> + +This Matlab function is accessible [[file:getPSDGroundDisplacement.m][here]]. + +#+begin_src matlab + function [pxx, f] = getPSDGroundDisplacement() + % getPSDGroundDisplacement - + % + % Syntax: [pxx, f] = voltageToVelocityL22(in_data) + % + % Outputs: + % - pxx - + % - f - + + [pxx, f] = getPSDGroundVelocity(); + + pxx = (sqrt(pxx)./(2*pi*f)).^2; +#+end_src diff --git a/src/voltageToDisplacementL22.m b/src/voltageToDisplacementL22.m index d389820..d0f9fe3 100644 --- a/src/voltageToDisplacementL22.m +++ b/src/voltageToDisplacementL22.m @@ -13,8 +13,6 @@ function [disp] = voltageToDisplacementL22(voltage, time, gain) s = zpk('s'); -voltage = voltage - mean(voltage); - velocity = voltageToVelocityL22(voltage, time, gain); disp = lsim(1/s, velocity, time); diff --git a/src/voltageToVelocityL22.m b/src/voltageToVelocityL22.m index 4e89cb1..debf89a 100644 --- a/src/voltageToVelocityL22.m +++ b/src/voltageToVelocityL22.m @@ -18,4 +18,6 @@ f0 = 2; % Cut-off frequnecy [Hz] S = S0*(s/2/pi/f0)/(1+s/2/pi/f0); +voltage = detrend(voltage); + velocity = lsim((S*10^(gain/20))\1, voltage, time);