# To run this script

Select **Scripts > Data > Smooth_S2P_Data_File** from the Menus.

Or, in versions that support the script, you can run the utility directly from this page using this button.

Select Help > Enable Guided Help in order to run the script from this page.

# Description

This script performs a moving average smoothing function on S-parameter data loaded into the project as data files. One, two, three and four port S-parameter data files are supported. Running the script first opens the dialog box. The sections in the dialog box are:

- Smoothing Window Weighting: The weighing function for each data point in the smoothing window.
- Data Type: The data type used for the smoothing operation
- Window Size
- Data file selection: Touchstone formatted data files currently loaded into the project

Click *OK* to begin the smoothing operation. Depending on data size, the smoothing operation may take a few minutes to complete. A dialog box will appear when the operation is complete:

At the completion of the script a new data file containing the smoothed S-parameter data will be created in the project. This new file name will be the original data file name with “_smooth” appended.

Below is an example of S-parameter data before and after smoothing:

# Implementation Details

__Smoothing Window Weighting__

- Uniform: All data inside the moving average window is equally weighted. This is the default weighting option and is best suited for most applications.
- Polynomial Interpolation: Data inside the moving average window is fitted to a polynomial curve. The center point of the moving window is interpolated on the polynomial curve. This weighting option can yield better results for data that contains regions of closely spaced ripple and regions of widely spaced ripple. Uniform weighting may not be able to optimize both regions with one setting, whereas polynomial interpolation often times can optimize both regions more effectively. Shown below is a comparison between Uniform weighting and Polynomial Interpolation:

Be aware that Polynomial Interpolation computation time is much longer than that for Uniform weighting.

Polynomial Order can be selected when choosing the Polynomial Interpolation weighting function. Values can range from 1 to 9

- Linear Ramp Weighting: The moving average window data points are weighted such that at the center of the window, the weighting equals a value of one. Weighting tapers off linearly to a value of zero at the edges of the moving average window. This selection biases the smoothed data due to the weighting function.

__Data Type__

- Mag/Phase: The S-parameter data is converted to magnitude and phase. Smoothing is performed separately on both the magnitude data and the phase data. This data type is the default and is recommended for most applications
- Complex: The S-parameter data is converted to real and imaginary. Smoothing is performed separately on both the real and imaginary data. This data type can tend to add a bias to Sxy data, where x and y are unique port numbers.

__Window Size__

The moving average window size can either be specified in terms of number of points or percent of span. Percent of span is number of points in the data file multiplied by the percentage. Number of points in the moving average window is rounded up to the next even value.