Add stdev function, organize file
@@ -166,7 +166,7 @@ from itertools import product
import numpy as npy
from numpy.linalg import inv as npy_inv
-from numpy import fft, gradient, ndarray, reshape, shape, ones
+from numpy import fft, gradient, ndarray, reshape, shape, ones, std, dstack
from scipy import stats, signal # for Network.add_noise_*, and Network.windowed
from scipy.interpolate import interp1d # for Network.interpolate()
from scipy.ndimage.filters import convolve1d
@@ -4052,6 +4052,47 @@ def average(list_of_networks: Sequence[Network], polar: bool = False) -> Network
return out_ntwk
+def stdev(list_of_networks: Sequence[Network], polar: bool = False) -> Network:
+ '''
+ Calculates the standard deviation of network values from a list of Networks.
+
+ This is the standard deviation for complex values of the s-parameters for a list of Networks.
+
+
+ Parameters
+ -----------
+ list_of_networks : list of :class:`Network` objects
+ the list of networks to average
+
+ Returns
+ ---------
+ ntwk : :class:`Network`
+ the resultant averaged Network
+
+ Notes
+ ------
+ This same function can be accomplished with properties of a
+ :class:`~skrf.networkset.NetworkSet` class.
+
+ Examples
+ ---------
+
+ >>> ntwk_list = [rf.Network('myntwk.s1p'), rf.Network('myntwk2.s1p')]
+ >>> mean_ntwk = rf.stdev(ntwk_list)
+ '''
+ out_ntwk = list_of_networks[0].copy()
+
+ if polar:
+ # compute standard deviation of the mag/phase components individually
+ raise NotImplementedError
+ else:
+ # compute standard deviation of the re/im components individually
+ df_list = [network.to_dataframe() for network in list_of_networks]
+ # out_ntwk.s = out_ntwk.s / (len(list_of_networks))
+
+
+ return out_ntwk
+
def one_port_2_two_port(ntwk: Network) -> Network:
'''
calculates the two-port network given a symmetric, reciprocal and
