Functions operating on waveforms¶
pycircuit.post.functions¶
This module contains functions that operates on wave objects or scalars
- pycircuit.post.functions.IIP2(output, input, fund1, fund2, fund0=None)¶
Calculate input referred second order intermodulation intercept point
The intermodulation product is evaluated at fund1 + fund2
- pycircuit.post.functions.IIP3(output, input, fund1, fund2, fund0=None)¶
Calculate input referred third order intermodulation intercept point
The intermodulation product is evaluated at fund1 + 2 * fund2
- pycircuit.post.functions.IM2(w, fund1, fund2, fund0=None)¶
Return input referred third order intermodulation tone
The intermodulation product is evaluated at fund1 + fund2
- pycircuit.post.functions.IM3(w, fund1, fund2, fund0=None)¶
Return input referred third order intermodulation tone
The intermodulation product is evaluated at fund1 + 2 * fund2
- pycircuit.post.functions.average(w, axis=-1)¶
Calculate average
Example:
>>> w1=Waveform([range(2), range(2)],array([[1.0, 3.0], [0.0, 5.0]])) >>> average(w1) Waveform(array([0, 1]), array([ 2. , 2.5]))
>>> w1=Waveform([range(2), range(2)],array([[1.0, 3.0], [0.0, 5.0]]), xlabels=['row','col']) >>> average(w1, axis='row') Waveform(array([0, 1]), array([ 0.5, 4. ]))
- pycircuit.post.functions.bandwidth(w, db=3.0, type='low')¶
Calculate bandwidth of transfer as function of frequency
Example
>>> w = 2 * pi * np.logspace(3,8) >>> w1 = -1e6 >>> H = Waveform(w, 1 / (1 - 1j*w / w1)) >>> bandwidth(H) 1000896.9666087811
- pycircuit.post.functions.calc_extrapolation_line(w_db, slope, extrapolation_point=None, axis=-1, plot=False, plotargs={})¶
Return linear extrapolation line and optionally plot it
- pycircuit.post.functions.clip(w, xfrom, xto=None)¶
- pycircuit.post.functions.compression_plot(w_db, extrapolation_point=None, compression=1, axis=-1)¶
Plot of compression point of a quantity in dB
Both x and y axis should be in dB units
- pycircuit.post.functions.compression_point(w_db, slope=1, compression=1, extrapolation_point=None, axis=-1)¶
Return input referred compression point
- pycircuit.post.functions.cross(w, crossval=0.0, n=0, crosstype=3, axis=-1)¶
Calculates the x-axis value where a particular crossing with the specified edge type occurs
Examples
1-d waveform
>>> phi = arange(0, 4*pi, pi/10)-pi/4 >>> y = Waveform(phi, sin(phi)) >>> cross(y) 0.0 >>> cross(y, crosstype=falling) 3.1415926535897931
2-d waveform
>>> x1 = [pi/4,pi/2] >>> x2 = arange(0, 4*pi, pi/10)-pi/4 >>> phi = vstack([x2 for p in x1]) >>> y = Waveform([x1,x2], sin(phi)) >>> cross(y) Waveform(array([ 0.78539816, 1.57079633]), array([ 0., 0.]))
No crossing
>>> cross(Waveform([[0,1,2,3]], array([1,1,1,1]))) nan
Todo
handle case where x-values are exactly at the crossing
- pycircuit.post.functions.db10(w)¶
Return x in dB where x is assumed to be a non-power quantity
>>> w1=Waveform(array([1,2,3]),array([complex(-1,0),complex(0,1),2])) >>> db10(w1) Waveform(array([1, 2, 3]), array([ 0. , 0. , 3.01029996]))
- pycircuit.post.functions.db20(w)¶
Return x in dB where x is assumed to be a non-power quantity
>>> w1=Waveform(array([1,2,3]),array([complex(-1,0),complex(0,1), complex(1,-1)]), ylabel='x') >>> db20(w1) Waveform(array([1, 2, 3]), array([ 0. , 0. , 3.01029996])) >>> db20(w1).ylabel 'db20(x)'
- pycircuit.post.functions.deriv(w)¶
Calculate derivative of a waveform with respect to the inner x-axis
- pycircuit.post.functions.dft(w)¶
Calculates the discrete Fourier transform of the input waveform
- pycircuit.post.functions.phase(w)¶
Return argument in degrees of complex values
Example:
>>> phase(1) 0.0 >>> phase(complex(0,1)) 90.0 >>> phase(Waveform((range(3),), array([1, complex(1,1), complex(0,-1)]))) Waveform(array([0, 1, 2]), array([ 0., 45., -90.]))
- pycircuit.post.functions.phase_margin(g)¶
Calculate phase margin of a loop gain vs frequency waveform
>>> w = 2 * pi * np.logspace(3,8,41) >>> w1 = -1e6 >>> H = Waveform(w, 1.5 * (1 / (1 - 1j*w / w1))**2) >>> '%0.4g'%phase_margin(H) '110.4'
- pycircuit.post.functions.rms(w, axis=-1)¶
Calculate root-mean-square
- pycircuit.post.functions.stddev(w, axis=-1)¶
Calculate the standard deviation
Returns the standard deviation over the highest dimension, a measure of the spread of a distribution.
Example
>>> w1=Waveform([range(2), range(4)], array([[1,2,3,4],[1,1,1,1]])) >>> stddev(w1) Waveform(array([0, 1]), array([ 1.11803399, 0. ]))
- pycircuit.post.functions.unityGainFrequency(g)¶
Calculate the frequency where the gain is unity