LTPDA Toolbox™ | contents | ![]() ![]() |
In the second exercise we will use again the graphical programming environment called LTPDA Workbench. After checking that the workbench is loaded, let's go ahead and create a new pipeline, or analysis diagram.
Let's use the command "Pipeline -> Rename Pipeline" to give this diagram a more significant name, such as, for instance, "LTPDA Training Session PSD2".
The idea of the second exercise is the following:
In a flow diagram, the representation is as follows:
Let's create a new pipeline and then use the command "Pipeline -> Rename Pipeline" to give this diagram a more significant name, like "LTPDA Training Session PSD2".
This step was touched upon in previous steps and in the user manual. Here we go ahead by adding an ao constructor method/block, that we can retrieve from the library or with the "quick block" shortcut.
We give the block a sensible name by double-clicking on it, and then we proceed with setting the parameters as follows:
To add parameters, we click on the "+" button, subsequently define the "Key" entry, which is the parameter name, and the "Value" entry, which contains the parameter value. |
Key | Value | Description |
---|---|---|
FILENAME |
'topic3/EGSE_FEE_x1.dat' |
The name of the file to read the data from. |
TYPE |
'tsdata' |
Interpret the data in the file as time-series data. |
COLUMNS |
[1 2] |
Load the data x-y pairs from columns 1 (as x) and 2 (as y). |
XUNITS |
's' |
Set the units of the x-data to seconds (s). |
YUNITS |
'F' |
Set the units of the y-data to farad (F). |
COMMENT_CHAR |
'%' |
Indicateds which header lines to skip in the ASCII data file. |
FS |
[] |
Indicates to load time series from the first data column. |
ROBUST |
'yes' |
Use robust data reading for this file format. |
DESCRIPTION |
'EGSE FEE x1 data' |
Set some text to the 'description' field of the AO. |
This procedure can be repeated for all 4 channels we want to analyze:
Key | Value |
---|---|
FILENAME |
'topic3/EGSE_FEE_x1.dat' |
FILENAME |
'topic3/EGSE_FEE_x2.dat' |
FILENAME |
'topic3/EGSE_FEE_y1.dat' |
FILENAME |
'topic3/EGSE_FEE_y2.dat' |
To speed up the procedure, we can copy & paste (using the contextual menu or the menu items or the shortcuts) the ao constructor block we just set up, and just change the filenames. We can also 'duplicate' blocks using ctrl-d (cmd-d on OS X), or by "Edit->duplicate".
Now let's proceed by adding the psd block to the diagram, as we did previously. Once we're done with this, we realize we want to call the method only once, without the need of putting 4 identical blocks; we also want to be sure to apply the same parameters to all the input objects. There are different ways to achieve this; one possibility is to take advantage of the multiple input handling allowed by the ao/psd method. So we go ahead and add 3 inputs to the block; to do that, place the mouse over the block, right-click and select "Add input":
Then obviously we need to connect each of the ao constructor blocks to an input of the psd block.
The parameters that we will choose for the psd method will be applied to all the 4 objects.
The spectral leakage is different with different windows. In order to choose the proper one for our needs, we can use the specwin helper, to visualize the window object both in time-domain and frequency domain.
Once we are happy with the choice, we can go back to the workbench, double click on the "Value" field for the "Key" Win in the parameters of the psd block. Then let's set the little panel to select the window. One parameter is alreay selected, based on the user preferences. Here I choose to use the Blackman-Harris window, called 'BH92'.
The length of the specwin object is irrelevant, because it will be ignored by the psd method, that will rebuild the window only based on the definition (the name). The effective window length is decided by setting the "Nfft" parameter! |
In order to reduce the variance in the estimated PSD, the user may decide to split the input data objects into shorter segments, estimate the fft of the individual segments and then average them. This is set by the "Nfft" parameter. A value of -1 will mean one single window.
Let's choose a window length of 20000 points (2000 seconds at 10 Hz).
In principle, we can decide the amount of overlap among consecutive windows, by entering a percentage value.
Let's do nothing here, leave -1 and let the psd use the reccomended value which is stored inside the window object and shown as "Rov".
We can decide to give as an output directly the 'ASD' (Amplitude Spectral Density), rather than the 'PSD' (Power Spectral Density). We can also have 'AS' (Amplitude Spectrum) or 'PS' (Power Spectrum).
Here I choose to use ASD, so I double-click on the "Value" corresponding to the "Scale" entry and go ahead and enter the string, 'ASD'.
Detrending here refers to an additional detrending performed for each individual segment, prior to applying the window.
In this case we want to subtract a linear drift, so just enter 1.
We should be ending in some parameter section like:
By default, psd would give as an output an array of aos corresponding to each input. So in our case, we'd have an array with 4 aos. We can also make them individuals, by adding outputs to the psd block. We just need to right-click and select "Add output":
We can now go ahead and plot the individual aos in many plots, just by adding iplot blocks and connecting them to each output port of the psd block.
We can also define parameters for each plot, such as colors an so on. Just to exercise let's set the colors to:
Object | Color |
---|---|
x1 data PSD |
{[1 0 0]} |
x2 data PSD |
{[0 1 0]} |
y1 data PSD |
{[0 0 1]} |
y2 data PSD |
{[1 1 1]} |
So the workbench is ready for execution, and it should be similar to:
We can go ahead and execute it ...
At the end we can look at the output plots and check the results, the units, the frequency range.
We can extract more informations about the results we obtained, by exploiting the toolbox functionality via the buttons located in the right-bottm side of the GUI:
They allow us to:
One useful option is storing the data to the workspace, for further investigations or to store them to a database. After selecting the psd block, we hit the "Store to workspace" button.
Now, if we switch to the Matlab terminal, we can see beteween our variables that we have stored the outputs corresponding to the output ports of the psd block:
>> whos Name Size Bytes Class Attributes LWB_195554 1x1 2480 struct ans 1x1 112 ao psd_block_PORT0 1x1 112 ao psd_block_PORT1 1x1 112 ao psd_block_PORT2 1x1 112 ao psd_block_PORT3 1x1 112 ao
As we did from the GUI, we can display the objects simply by:
>> psd_PORT0 ----------- ao 01: ASD(x1) ----------- name: ASD(x1) data: (0,2.5372422083703e-18) (0.00051203275,4.68581398941709e-18) ... ----------- fsdata 01 ----------- fs: 10.2407 x: [10001 1], double y: [10001 1], double dx: [0 0], double dy: [10001 1], double xunits: [Hz] yunits: [F Hz^(-1/2)] t0: 01-01-1970 00:00:00.000 navs: 31 --------------------------------- hist: ao / psd / SId: psd.m,v 1.52 2009/09/05 05:57:32 mauro Exp S mdlfile: empty description: EGSE FEE x1 data UUID: 4702fadd-d37a-49a7-be00-bc651258d31f -------------------------------------- >>
Once we dumped the objects we are interested on, we can go ahead and save at least the x1 data as described here and here.
We could also include a save step in the pipeline, tough, by inserting a save block. Let's grab it from the library, typing "save" in the "search" box, or selecting it under ao -> Output. Then let's connect it to the output of the psd block. After selecting, as usual, the "Default" parameter set from the parameters drop-down list, we can go ahead and enter a suitable file name and file location.
![]() |
Example 1: Simply PSD | Example 3: Log-scale PSD on MDC1 data | ![]() |
©LTP Team