Example 1: Simply PSD


The idea of the first exercise is the following:

  1. simulate a time-series of white noise data
  2. evaluate the Power Spectrum of the data
  3. calculate the square root of the calculated power spectrum
  4. plot the results
In a flow diagram, the representation is as follows:



Dataflow for the 1st example of ao/psd

Simulate a time-series of white noise data

There are many different ways to simulate a white noise time series data. Here we choose a pretty powerful one: the "From Waveform" AO constructor.

Let's start building a plist to tune the parameters of the ao constructor: among the available constructor methods, we choose the noise generator via the key WAVEFORM assigning the value "noise". Then let's make the time series last longer by setting the number of seconds (nsecs) to 1000.

    pl_noise  = plist('waveform', 'noise', 'fs', 1, 'nsecs', 1000);
Eventually, we set the units of the noise to be meters by selecting means of the plist method pset: the "Yunits" parameter and entering 'm'.
    pl_noise.pset('yunits', 'm');
To actually build the time-series AO, we then call the ao constructor with the plist we just prepared:
    n = ao(pl_noise);



Evaluate the Power Spectrum of the data

The next step is to choose the parameters for the psd method of the ao class. In order to know the key name, the description, the default and possible values for the parameters, we can type

    help ao/psd
and then click the "Parameters Description" link. Let's discuss the parameters and their meaning:

If the user does not specify any value for the parameters, the routine applies the default values.

In this case, we will use the default parameters:

In this case, we would not need any specification plist, but let's prepare one. The we can go ahead and do the calculation:
    pl_psd = plist('Scale', 'PSD');
    s = psd(n, pl_psd);



Extract the square root of the calculated power spectrum

For this exercise, we proceed by computing the square root of the calculated spectrum. Notice: by default, as described in its help, ao/sqrt applied to fsdata and tsdata objects acts only on the y (dependent) variable. We'll see later that is possible to choose different outputs for the ao/psd method so as to avoid this step, if we wanted to, by selecting the "Value" 'ASD' for the "Key" 'Scale'.

For now, let's add the sqrt step to the flow by applying it to the output of the ao/psd method.

    a = sqrt(s);



Plot the results

What remains is just to plot the calculated square root of the PSD of the input white noise. Just call ao/iplot. The output one should be similar to the following:

PSD 1: evaluated PSD

Please notice:



©LTP Team