PyDV API Specification¶
pydvpy module¶
A python interface for PyDV functionality.
>>> import pydvpy as pydvif
-
pydvpy.
abs
(curvelist)¶ Take the absolute value of the y values of the Curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.abs(curves) OR
>>> pydvif.abs(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
-
pydvpy.
absx
(curvelist)¶ Take the absolute value of the x values of the Curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.absx(curves) OR
>>> pydvif.absx(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
-
pydvpy.
acos
(curvelist)¶ Take the arccosine of y values of a Curve or list of Curves
>>> curves = pydvif.read('testData.txt')
>>> pydvif.acos(curves) OR
>>> pydvif.acos(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of curves
-
pydvpy.
acosh
(curvelist)¶ Take the hyperbolic arccosine of y values of a Curve or list of Curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.acosh(curves) OR
>>> pydvif.acosh(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of curves
-
pydvpy.
acoshx
(curvelist)¶ Take the hyperbolic arccosine of x values of a Curve or list of Curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.acoshx(curves) OR
>>> pydvif.acoshx(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of curves
-
pydvpy.
acosx
(curvelist)¶ Take the arccosine of x values of a Curve or list of Curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.acosx(curves) OR
>>> pydvif.acosx(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of curves
-
pydvpy.
add
(curvelist)¶ Add one or more curves.
>>> curves = pydvif.read('testData.txt')
>>> c = pydvif.add(curves)
- Parameters
curvelist (list) – The list of curves
- Returns
curve – the curve containing the sum of the curves in curvelist
-
pydvpy.
alpha
(ac, ig, res, npts=- 1)¶
-
pydvpy.
appendcurves
(curvelist)¶ Merge two or more curves over the union of their domains. Where domains overlap, take the average of the curve’s y-values.
>>> curves = pydvif.read('testData.txt')
>>> newcurve = pydvif.appendcurve(curves)
- Parameters
curvelist (list) – the specified curves
- Returns
Curve – the merging of the two curves c1 and c2
-
pydvpy.
asin
(curvelist)¶ Take the arcsine of y values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.asin(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
asinh
(curvelist)¶ Take the hyperbolic arcsine of y values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.asinh(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
asinhx
(curvelist)¶ Take the hyperbolic arcsine of x values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.asinhx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
asinx
(curvelist)¶ Take the arcsine of x values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.asinx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
atan
(curvelist)¶ Take the arctangent of y values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.atan(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
atan2
(c1, c2, t=None)¶ Perform the atan2 method for a pair of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.atan2(curves[0], curves[1]) OR
>>> pydvif.atan2(curves[0], curves[1], tuple(['A', 'B']))
- Parameters
c1 (curve) – the first curve
c2 (curve) – the second curve
t (tuple) – A tuple containing exactly two values to insert into the name string for the new curve
- Returns
curve – a new curve with the results from this operation
-
pydvpy.
atanh
(curvelist)¶ Take the hyperbolic arctangent of y values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.atanh(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
atanhx
(curvelist)¶ Take the hyperbolic arctangent of x values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.atanhx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
atanx
(curvelist)¶ Take the arctangent of x values of a single curve or curves in a list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.atanx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
average_curve
(curvelist)¶ Average the specified curves over the intersection of their domains.
- Parameters
curvelist – the specified curves
- Returns
Curve – a new curve with the average values over the intersection of the domains of the specified curves.
-
pydvpy.
convolve
(c1, c2, npts=100)¶ Compute and return the convolution of two real curves: - -
(g*h)(x) = Int(-inf, inf, dt, g(t)*h(x-t))
- The Fourier Transform is used to perform the convolution.>>> curves = pydvif.read('testData.txt')
>>> newcurve = pydvif.convolve(curves[0], curves[1])
-
pydvpy.
convolve_int
(c1, c2, norm=True, npts=100)¶ Computes the convolution of the two curves (c1, c2). The integrals are computed directly which avoid padding and aliasing problems associated with FFT methods (it is however slower).
-
pydvpy.
convolveb
(c1, c2, npts=100)¶ Computes the convolution of the two given curves: - -
(g*h)(x) = Int(-inf, inf, dt*g(t)*h(x-t)) / Int(-inf, inf, dt*h(t))
- This computes the integrals directly which avoid padding and aliasing problems associated with FFT methods (it is however slower).
-
pydvpy.
convolvec
(c1, c2, npts=100)¶ Computes the convolution of the two given curves: - -
(g*h)(x) = Int(-inf, inf, dt*g(t)*h(x-t)) / Int(-inf, inf, dt*h(t))
- This computes the integrals directly which avoid padding and aliasing problems associated with FFT methods (it is however slower).
-
pydvpy.
correlate
(c1, c2, mode='valid')¶ Computes the cross-correlation of two 1D sequences (c1.y and c2.y) as defined by numpy.correlate.
- Parameters
c1 (Curve) – The first curve with 1D input sequence c1.y
c2 (Curve) – The second curve with 1D input sequence c2.y
mode ('full'(default), 'same' or 'valid') –
- full:
By default, mode is ‘full’. This returns the convolution at each point of overlap, with an output shape of (N+M-1,). At the end-points of the convolution, the signals do not overlap completely, and boundary effects may be seen.
- same:
Mode ‘same’ returns output of length
max(M, N)
. Boundary effects are still visible.- valid:
Mode ‘valid’ returns output of length
max(M, N) - min(M, N) + 1
. The convolution product is only given for points where the signals overlap completely. Values outside the signal boundary have no effect.
- Returns
Curve – the cross-correlation of c1.y and c2.y
-
pydvpy.
cos
(curvelist)¶ Take the cosine of y values of a Curve or list of Curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.cos(curves) OR
>>> pydvif.cos(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of Curves
-
pydvpy.
cosh
(curvelist)¶ Take the hyperbolic cosine of y values of a Curve or list of Curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.cosh(curves) OR
>>> pydvif.cosh(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of curves
-
pydvpy.
coshx
(curvelist)¶ Take the hyperbolic cosine of x values of a Curve or list of Curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.coshx(curves) OR
>>> pydvif.coshx(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of curves
-
pydvpy.
cosx
(curvelist)¶ Take the cosine of x values of a Curve or list of Curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.cosx(curves) OR
>>> pydvif.cosx(curves[0])
- Parameters
curvelist (Curve or list) – The Curve or list of Curves
-
pydvpy.
create_plot
(curvelist, **kwargs)¶ Create a plot from of the curves in curvelist. The available keyword arguments are: * Filename: fname=’myFile’ * Save Format: ftype=’pdf’ * Plot Title: title=’My Title’ * X-Axis Label: xlabel=’X’ * Y-Axis Label: ylabel=’Y’ * Show/Hide Plot Legend: legend=True * Plot Style: stylename=’ggplot’ * Show X-Axis in log scale: xls=True * Show Y-Axis in log scale: yls=True * Set the width of the figure in inches: fwidth=1.2 * Set the height of the figure in inches: fheight=2.1
>>> curves = pydvif.read('testData.txt')
>>> plot1 = pydvif.create_plot(curves, fname='myPlot1')
>>> plot2 = pydvif.create_plot(curves, fname='myPlot2', ftype='pdf', fwidth=10.1, fheight=11.3, title='My Plot', xlabel='X', ylabel='Y', legend=True, stylename='ggplot')
- Parameters
curvelist (list) – The curve or list of curves to plot
kwargs (dict) – The keyword arguments to modify the plot.
- Returns
matplotlib.pyplot – the plot of the curves
-
pydvpy.
derivative
(c, eo=1)¶ Take the derivative of the curve.
>>> curves = pydvif.read('testData.txt')
>>> newCurve = pydvif.derivative(curves[0])
- Parameters
c (Curve) – The curve
eo (int, optional) – edge_order, gradient is calculated using N-th order accurate differences at the boundaries. Default: 1.
- Returns
A new curve representing the derivate of c
-
pydvpy.
diffMeasure
(c1, c2, tol=1e-08)¶ Compare two curves. For the given curves a fractional difference measure and its average are computed.
>>> curves = pydvif.read('testData.txt')
>>> c1, c2 = pydvif.diffMeasure(curves[0], curves[1])
>>> curves.append(c1)
>>> curves.append(c2)
>>> pydvif.create_plot(curves, legend=True)
-
pydvpy.
disp
(c, domain=True)¶ Create a string formatted list of the curve’s x-values if domain is True, otherwise y-values.
>>> c = pydvif.span(1, 10)
>>> yvalues = pydvif.disp(c, False)
- Parameters
c – The given curve
domain (bool, optional) – if True, display the x-values of the curve. Otherwise, display the y-values of the curve
- Returns
list – The list of x- or y-values as strings
-
pydvpy.
divide
(curvelist)¶ Take quotient of curves.
>>> curves = pydvif.read('testData.txt')
>>> c = pydvif.divide(curves)
- Parameters
curvelist (list) – The list of curves
- Returns
curve – the curve containing the quotient of the curves
-
pydvpy.
divx
(curvelist, value)¶ Divide x values of the curve(s) by a constant value.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.divx(curves, 4)
- Parameters
curvelist (Curve or list) – The curve or curvelist
value (float) – The divisor
-
pydvpy.
divy
(curvelist, value)¶ Divide y values of the curve(s) by a constant value.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.divy(curves, 4)
- Parameters
curvelist (Curve or list) – The curve or curvelist
value (float) – The divisor
-
pydvpy.
dupx
(curvelist)¶ Duplicate the x-values such that y = x for each of the given curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.dupx(curves)
>>> pydvif.create_plot(curves, legend=True)
- Parameters
curvelist (Curve or list) – The curve or list of curves
-
pydvpy.
dx
(curvelist, value)¶ Shift x values of a curve or list of curves by a constant value.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.dx(curves, 4) OR
>>> pydvif.dx(curves[0], 4)
- Parameters
curvelist (Curve or list) – A curve or curvelist
value (float) – The amount to shift the x values by
-
pydvpy.
dy
(curvelist, value)¶ Shift y values of a curve or list of curves by a constant value.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.dy(curves, 4) OR
>>> pydvif.dy(curves[0], 4)
- Parameters
curvelist (Curve or list) – A curve or curvelist
value (float) – The amount to shift the y values by
-
pydvpy.
errorbar
(scur, cury1, cury2, curx1=None, curx2=None, mod=1)¶ Plot error bars on the given curve.
>>> curves = list()
>>> curves.append(pydvif.span(1,10))
>>> curves.append(pydvif.span(1,10))
>>> curves.append(pydvif.span(1,10))
>>> pydvif.dy(curves[0], 0.25)
>>> pydvif.dy(curves[2], -0.25)
>>> pydvif.errorbar(curves[1], curves[0], curves[2])
>>> pydvif.create_plot(curves, legend=True)
-
pydvpy.
errorrange
(scur, cury1, cury2)¶ Plot shaded error region on given curve.
>>> curves = list()
>>> curves.append(pydvif.span(1,10))
>>> curves.append(pydvif.span(1,10))
>>> curves.append(pydvif.span(1,10))
>>> pydvif.dy(curves[0], 0.25)
>>> pydvif.dy(curves[2], -0.25)
>>> pydvif.errorrange(curves[1], curves[0], curves[2])
>>> pydvif.create_plot(curves, legend=True)
-
pydvpy.
exp
(curvelist)¶ Exponentiate y values of the Curve or list of curves (e**y).
>>> curves = pydvif.read('testData.txt')
>>> pydvif.exp(curves) OR
>>> pydvif.exp(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
-
pydvpy.
expx
(curvelist)¶ Exponentiate x values of the Curve or list of curves (e**x).
>>> curves = pydvif.read('testData.txt')
>>> pydvif.expx(curves) OR
>>> pydvif.expx(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
-
pydvpy.
fft
(c, n=None, axis=- 1, norm=None)¶ Compute the one-dimensional discrete Fourier Transform for the x- or y-values of c.
This function computes the one-dimensional n-point discrete Fourier Transform (DFT) with the efficient Fast Fourier Transform (FFT) algorithm [CT].
Raises IndexError: if axes is larger than the last axis of a.
Notes: FFT (Fast Fourier Transform) refers to a way the discrete Fourier Transform (DFT) can be calculated efficiently, by using symmetries in the calculated terms. The symmetry is highest when n is a power of 2, and the transform is therefore most efficient for these sizes.
The DFT is defined, with the conventions used in this implementation, in the documentation for the numpy.fft module.
- Citation: Cooley, James W., and John W. Tukey, 1965, “An algorithm for the
machine calculation of complex Fourier series,” Math. Comput. 19: 297-301.
>>> curves = pydvif.read('testData.txt')
>>> realcurve, imagcurve = pydvif.fft(curves[0])
- Parameters
c (Curve) – Curve with x- or y-values as input array, can be complex.
n (int, optional) – Length of the transformed axis of the output. If n is smaller than the length of the input, the input is cropped. If it is larger, the input is padded with zeros. If n is not given, the length of the input along the axis specified by axis is used.
axis (int, optional) – Axis over which to compute the FFT. If not given, the last axis is used.
norm (None, "ortho", optional) – Normalization mode (see numpy.fft). Default is None.
- Returns
Curve tuple – Two curves with the real and imaginary parts.
-
pydvpy.
filtercurves
(curvelist, pattern)¶ Filters the list of curves based on the regular expression pattern.
>>> curves = pydvif.filtercurves(curves, "*_name")
- Parameters
curvelist (Curve) – the list of curves
pattern (str) – the regular expression pattern
- Returns
list – The list of filtered curves from curvelist based on the regular expression pattern
-
pydvpy.
fit
(c, n=1, logx=False, logy=False)¶ Make a new curve that is a polynomial fit to curve c.
>>> curves = list()
>>> curves.append(pydvif.span(1,10))
>>> pydvif.sin(curves)
>>> curves.append(pydvif.fit(curves[0], 2))
>>> pydvif.create_plot(curves, legend=True)
- Parameters
c (Curve) – The curve to fit
n (int) – Degree of the fitting polynomial
logx (bool) – Take the log(x-values) before fitting if True
logy (bool) – Take the log(y-values) before fitting if True
- Returns
Curve – The fitting polynomial
-
pydvpy.
gaussian
(amp, wid, center, num=100, nsd=3)¶ Generate a gaussian function.
>>> curve = pydvif.gaussian(5, 10, 0)
>>> pydvif.create_plot(curve, legend=True, stylename='ggplot')
- Parameters
amp (float) – amplitude
wid (float) – width
center (float) – center
num (int) – optional, number of points
nsd (float) – optional, number of half-widths
- Returns
Curve – representing the gaussian function
-
pydvpy.
get_styles
()¶ Get the list of available plot styles.
- Returns
list – the list of available style names or an empty list if no styles exist.
-
pydvpy.
getdomain
(curvelist)¶ Get domain of the curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> domains = pydvif.getdomain(curves)
>>> plotname, minx, maxx = domains[0]
- Parameters
curvelist (Curve or list) – The given curve or list of curves
- Returns
list – A list of tuples where each tuple contains the curve name, minimum x, and maximum x
-
pydvpy.
getnumpoints
(curve)¶ Return the given curve’s number of points.
- Parameters
curve – The given curve
- Returns
int – the number of points in curve
-
pydvpy.
getrange
(curvelist)¶ Get the range of the curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> ranges = pydvif.getrange(curves)
>>> plotname, miny, maxy = ranges[0]
- Parameters
curvelist (Curve or list) – The given curve or list of curves
- Returns
list – A list of tuples where each tuple contains the curve name, minimum y, and maximum y
-
pydvpy.
getx
(c, value, xmin=None, xmax=None)¶ Get the x values of the curve for a given y.
>>> curves = pydvif.read('testData.txt')
>>> vals = pydvif.getx(curves[0], 4)
>>> x, y = vals[0]
- Parameters
c (Curve) – The curve
value (float) – y value
- Returns
list – A list of tuples where each tuple contains the x value, and the given y
-
pydvpy.
gety
(c, value)¶ Get the y values of the curve for a given x.
>>> curves = pydvif.read('testData.txt')
>>> vals = pydvif.gety(curves[0], 2)
>>> x, y = vals[0]
- Parameters
c (Curve) – The curve
value (float) – x value
- Returns
list – A list of tuples where each tuple contains the y value, and the given x
-
pydvpy.
getymax
(c, xmin=None, xmax=None)¶ Get the maximum y-value for the curve within the specified domain.
- Parameters
c – the curve
xmin (float, optional) – the minimum x-value for the sub-domain
xmax (float, optional) – the maximum x-value for the sub-domain
- Returns
str – curve name list – a list of tuples where each tuple contains the x-value and
the max y-value.
-
pydvpy.
getymin
(c, xmin=None, xmax=None)¶ Get the minimum y-value for the curve within the specified domain.
- Parameters
c – the curve
xmin (float, optional) – the minimum x-value for the sub-domain
xmax (float, optional) – the maximum x-value for the sub-domain
- Returns
str – curve name list – a list of tuples where each tuple contains the x-value and
the min y-value.
-
pydvpy.
integrate
(curvelist, low=None, high=None)¶ Take the integral of the curve or curves in curvelist.
- Parameters
curvelist (curve or list) – A curve or list of curves
low (float) – The lower limit
high (float) – The maximum limit
- Returns
list – the list of integrated curves
-
pydvpy.
j0
(curvelist)¶ Take the Bessel function of the first kind of the zeroth order for the y values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
j0x
(curvelist)¶ Take the Bessel function of the first kind of the zeroth order for the x values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
j1
(curvelist)¶ Take the Bessel function of the first kind of the first order for the y values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
j1x
(curvelist)¶ Take the Bessel function of the first kind of the first order for the x values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
jn
(curvelist, n)¶ Take the Bessel function of the first kind of the nth order for the y values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
n (float) – The order
-
pydvpy.
jnx
(curvelist, n)¶ Take the Bessel function of the first kind of the nth order for the x values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
n (float) – The order
-
pydvpy.
l1
(c1, c2, xmin=None, xmax=None)¶ Make a new curve that is the L1 norm of curve c1 and curve c2. The L1-norm is the integral(|c1 - c2|) over the interval [xmin, xmax].
>>> c = pydvif.l1(curve1, curve2)
>>> c2 = pydvif.l1(curve1, curve2, 1.1, 10.9)
-
pydvpy.
l2
(c1, c2, xmin=None, xmax=None)¶ Make a new curve that is the L2 norm of curve c1 and curve c2. The L2-norm is (integral((c1 - c2)**2)**(1/2) over the interval [xmin, xmax].
>>> c = pydvif.l2(curve1, curve2)
>>> c2 = pydvif.l2(curve1, curve2, 3.1, 30.9)
-
pydvpy.
line
(m, b, xmin, xmax, numpts=100)¶ Generate a line with y = mx + b and an optional number of points.
>>> curves = list()
>>> curves.append(pydvif.line(2, 5, 0, 10))
>>> pydvif.create_plot(curves, legend=True, stylename='ggplot')
- Parameters
m (float) – The slope
b (float) – The y-intercept
xmin (float) – The minimum x value
xmax (float) – The maximum x value
numpts (int) – The number of points to use for the new line
- Returns
Curve – The curve representing the newly created line
-
pydvpy.
log
(curvelist, keep=True)¶ Take the natural logarithm of y values of the Curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.log(curves) OR
>>> pydvif.log(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
keep (optional, boolean) – flag to determine whether or not to discard zero or negative y-values before taking the log. keep is True by default.
-
pydvpy.
log10
(curvelist, keep=True)¶ Take the base 10 logarithm of y values of a Curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.log10(curves) OR
>>> pydvif.log10(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
keep (optional, boolean) – flag to determine whether or not to discard zero or negative y-values before taking the base 10 logarithm. keep is True by default.
-
pydvpy.
log10x
(curvelist, keep=True)¶ Take the base 10 logarithm of x values of a Curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.log10x(curves) OR
>>> pydvif.log10x(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
keep (optional, boolean) – flag to determine whether or not to discard zero or negative y-values before taking the base 10 logarithm. keep is True by default.
-
pydvpy.
logx
(curvelist, keep=True)¶ Take the natural logarithm of x values of the Curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.logx(curves) OR
>>> pydvif.logx(curves[0])
- Parameters
curvelist (Curve or list) – the Curve or list of curves
keep (optional, boolean) – flag to determine whether or not to discard zero or negative x-values before taking the log. keep is True by default.
-
pydvpy.
makecurve
(x, y, name='Curve', fname='', xlabel='', ylabel='', title='')¶ Generate a curve from two lists of numbers.
>>> c1 = pydvif.makecurve([1, 2, 3, 4], [5, 10, 15, 20])
>>> c2 = pydvif.makecurve([1, 2, 3, 4], [7, 8, 9, 10], 'Line')
- Parameters
x (list) – list of x values
y (list) – list of y values
name (str) – the name of the new curve
fname (str) – the name of the file containing this curves data.
- Returns
curve – the curve generated from the x and y list of values.
-
pydvpy.
makeextensive
(curvelist)¶ Set the y-values such that
y[i] *= (x[i+1] - x[i])
>>> curves = pydvif.read('testData.txt')
>>> pydvif.makeextensive(curves)
>>> pydvif.create_plot(curves, legend=True)
- Parameters
curvelist (Curve or list) – The curve or list of curves
-
pydvpy.
makeintensive
(curvelist)¶ Set the y-values such that y[i] /= (x[i+1] - x[i]).
>>> curves = pydvif.read('testData.txt')
>>> pydvif.makeintensive(curves)
>>> pydvif.create_plot(curves, legend=True)
- Parameters
curvelist (Curve or list) – The curve or list of curves
-
pydvpy.
max_curve
(curvelist)¶ Construct a curve from the maximum y values of the intersection of the curves domain.
- Parameters
curvelist – the specified curves
- Returns
Curve – a new curve with the maximum y-values over the intersection of the domains of the specified curves.
-
pydvpy.
min_curve
(curvelist)¶ Construct a curve from the minimum y values of the intersection of the curves domain.
- Parameters
curvelist – the specified curves
- Returns
Curve – a new curve with the minimum y-values over the intersection of the domains of the specified curves.
-
pydvpy.
multiply
(curvelist)¶ Take product of curves.
>>> curves = pydvif.read('testData.txt')
>>> c = pydvif.multiply(curves)
- Parameters
curvelist (list) – The list of curves
- Returns
Curve – the curve containing the product of the curves
-
pydvpy.
mx
(curvelist, value)¶ Scale x values of a curve or list of curves by a constant value.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.mx(curves, 4) OR
>>> pydvif.mx(curves[0], 4)
- Parameters
curvelist (Curve or list) – A curve or curvelist
value (float) – The amount to scale the x values by
-
pydvpy.
my
(curvelist, value)¶ Scale y values of a curve or list of curves by a constant value.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.my(curves, 4) OR
>>> pydvif.my(curves[0], 4)
- Parameters
curvelist (Curve or list) – A curve or curvelist
value (float) – The amount to scale the y values by
-
pydvpy.
norm
(c1, c2, p, xmin=None, xmax=None)¶ Make a new curve that is the p-norm of curve c1 and curve c2.
>>> curves = pydvif.read('testData.txt')
>>> c = pydvif.norm(curves[0], curves[1], 'inf')
>>> curves.append(c)
-
pydvpy.
powa
(curvelist, a)¶ Raise a fixed value, a, to the power of the y values of the Curve or list of curves. y = a^y
>>> curves = pydvif.read('testData.txt')
>>> pydvif.powa(curves, 2) OR
>>> pydvif.powa(curves[0], 2)
- Parameters
curvelist (Curve or list) – the Curve or list of curves
a (float) – the fixed value
-
pydvpy.
powax
(curvelist, a)¶ Raise a fixed value, a, to the power of the x values of the Curve or curves. x = a^x
>>> curves = pydvif.read('testData.txt')
>>> pydvif.powax(curves, 4.2) OR
>>> pydvif.powax(curves[0], 4.2)
- Parameters
curvelist (Curve or list) – the Curve or list of curves
a (float) – the fixed value
-
pydvpy.
powr
(curvelist, a)¶ Raise a the y values of a curve or list of curves to a fixed power, y = y^a.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.powr(curves, 4.2) OR
>>> pydvif.powr(curves[0], 4.2)
- Parameters
curvelist (curve or list) – the curve or list of curves
a (float) – the fixed value
-
pydvpy.
powrx
(curvelist, a)¶ Raise a the x values of a curve or list of curves to a fixed power, x = x^a.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.powrx(curves, 4.2) OR
>>> pydvif.powrx(curves[0], 4.2)
- Parameters
curvelist (curve or list) – the curve or list of curves
a (float) – the fixed value
-
pydvpy.
random
(curve)¶ Generate random y values between -1 and 1 for the specified curves.
>>> c = pydvif.span(1, 10)
>>> pydvif.random(c)
- Parameters
curve (Curve) – The curve to sort
-
pydvpy.
read
(file_name, gnu=False, xcol=0, verbose=False, pattern=None, matches=None)¶ Read the file and add parsed curves to a curvelist
>>> curves = pydvif.read('testData.txt')
>>> curves = pydvif.read('testData.txt', False, 0, False, '*_name', 20)
- Parameters
file_name (str) – ULTRA filename
gnu (bool) – optional, flag to determine if the file is a column oriented (.gnu) file.
xcol (int) – optional, x-column number for column oriented (.gnu) files
verbose (bool) – optional, prints the error stacktrace when True
pattern (str) – optional, the regular expression pattern
matches (int) – optional, maximum number of times to match pattern, if specified
- Returns
list – the list of curves from the file matching pattern, if specified
-
pydvpy.
readcsv
(fname, xcol=0, verbose=False)¶ Load a csv (comma separated values) data file, add parsed curves to a curvelist. ‘#’ is the comment character. First uncommented line must be the column labels. We assume the first column is the x-data, every other column is y-data. We also assume all columns are the same length.
>>> curves = readcsv('testData.csv')
- Parameters
fname (str) – csv filename
xcol (int) – x-column number for column oriented (.gnu) files
verbose (bool) – prints the error stacktrace when True
- Returns
list – the list of curves from the csv file
-
pydvpy.
readsina
(fname, verbose=False)¶ Load a Sina JSON data file, add parsed curves to a curvelist.
We assume JSON conforming to the Sina schema, with each curve defined in a curve_set. We assume there is only one record, and if there are more then we only read the first one. We also assume only one independent variable per curve_set; if there are more than one, then PyDV may exhibit undefined behavior.
>>> curves = readsina('testData.json')
- Parameters
fname (str) – Sina JSON filename
verbose (bool) – prints the error stacktrace when True
- Returns
list: the list of curves from the sina file
-
pydvpy.
recip
(curvelist)¶ Take the reciprocal of the y values of the curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.recip(curves[1])
>>> pydvif.create_plot(curves, legend=True, stylename='ggplot')
- Parameters
curvelist (Curve or list) – The curve or list of curves
-
pydvpy.
recipx
(curvelist)¶ Take the reciprocal of the x values of the curve or list of curves.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.dx(curves, 2)
>>> pydvif.recipx(curves)
>>> pydvif.create_plot(curves, legend=True, stylename='ggplot')
- Parameters
curvelist (Curve or list) – The curve or list of curves
- Returns
-
pydvpy.
rev
(curve)¶ Swap x and y values for the specified curves. You may want to sort after this one.
>>> c = pydvif.span(1, 10)
>>> pydvif.rev(c)
- Parameters
curve (Curve) – The curve to sort
-
pydvpy.
save
(fname, curvelist, verbose=False)¶ Saves the given Curve or list of Curves to a file named fname.
>>> curves = list()
>>> curves.append(pydvif.makecurve([1, 2, 3, 4], [5, 10, 15, 20]))
>>> pydvif.save('myfile.txt', curves) OR
>>> pydvif.save('myfile.txt', curves[0])
- Parameters
fname (str) – ULTRA filename
curvelist (Curve or list) – The curve or list of curves to save
verbose (bool) – prints the error stacktrace when True
-
pydvpy.
savecsv
(fname, curvelist, verbose=False)¶ Saves the Curve or list of Curves to file in comma separated values (csv) format. Assumes all curves have the same x basis.
>>> curves = list()
>>> curves.append(pydvif.makecurve([1, 2, 3, 4], [5, 10, 15, 20]))
>>> pydvif.savecsv('myfile.csv', curves)
- Parameters
fname (str) – ULTRA filename
curvelist (list) – The Curve or list of Curves to save
verbose (bool) – prints the error stacktrace when True
-
pydvpy.
sin
(curvelist)¶ Take the sine of y values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.sin(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
sinh
(curvelist)¶ Take the hyperbolic sine of y values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.sinh(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
sinhx
(curvelist)¶ Take the hyperbolic sine of x values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.sinhx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
sinx
(curvelist)¶ Take the sine of x values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.sinx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
smooth
(curvelist, factor=1)¶ Smooth the curve to the given degree.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.smooth(curves, 4)
>>> pydvif.create_plot(curves, legend=True)
- Parameters
curvelist (Curve or list) – The curve or list of curves
factor (int) – The smooth factor
-
pydvpy.
sort
(curve)¶ Sort the specified curve so that their points are plotted in order of ascending x values.
>>> c = pydvif.span(1, 10)
>>> pydvif.sort(c)
- Parameters
curve (Curve) – The curve to sort
-
pydvpy.
span
(xmin, xmax, numpts=100)¶ Generates a straight line of slope 1 and y intercept 0 in the specified domain with an optional number of points.
>>> c = pydvif.span(1, 10)
- Parameters
xmin (float) – The minimum x value
xmax (float) – The maximum x value
numpts (int) – The number of points used to plot the line
- Returns
curve – the curve object representing the straight line.
-
pydvpy.
sqr
(curvelist)¶ Take the square of the y values in a curve or list of curves.
- Parameters
curvelist (curve or list) – the curve or list of curves
-
pydvpy.
sqrt
(curvelist)¶ Take the square root of the y values in a curve or list of curves.
- Parameters
curvelist (curve or list) – the curve or list of curves
-
pydvpy.
sqrtx
(curvelist)¶ Take the square root of the x values in a curve or list of curves.
- Parameters
curvelist (curve or list) – the curve or list of curves
-
pydvpy.
sqrx
(curvelist)¶ Take the square of the x values in a curve or list of curves.
- Parameters
curvelist (curve or list) – the curve or list of curves
-
pydvpy.
subsample
(curvelist, stride=2, verbose=False)¶ Subsample the curve or list of curves, i.e., reduce to every nth value.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.subsample(curves, 4)
>>> pydvif.create_plot(curves, legend=True)
- Parameters
curvelist (Curve or list) – The curve or list of curves
stride (int) – The step size through the array
verbose (bool) – If True additional information will be printed to stdout
-
pydvpy.
subtract
(curvelist)¶ Take difference of curves.
>>> curves = pydvif.read('testData.txt')
>>> c = pydvif.subtract(curves)
- Parameters
curvelist (list) – The list of curves
- Returns
curve – the curve containing the difference of the curves
-
pydvpy.
tan
(curvelist)¶ Take the tangent of y values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.tan(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
tanh
(curvelist)¶ Take the hyperbolic tangent of y values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.tanh(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
tanhx
(curvelist)¶ Take the hyperbolic tangent of x values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.tanhx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
tanx
(curvelist)¶ Take the tangent of x values of a single curve or multiple curves in list.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.tanx(curves)
- Parameters
curvelist (curve or list) – A single curve or a list of curves
-
pydvpy.
vs
(c1, c2)¶ Create a new curve that will plot as the range of the first curve against the range of the second curve.
>>> curves = pydvif.read('testData.txt')
>>> c1 = pydvif.vs(curves[0], curves[1])
>>> curves.append(c1)
>>> pydvif.create_plot(curves, legend=True)
-
pydvpy.
xindex
(curvelist)¶ Create curves with y-values vs. integer index values.
>>> curves = pydvif.read('testData.txt')
>>> pydvif.xindex(curves)
>>> pydvif.create_plot(curves, legend=True)
- Parameters
curvelist (Curve or list) – The curve or list of curves
-
pydvpy.
xmax
(curvelist, limit)¶ Filter out points in the curve or list of curves whose x values are greater than limit.
- Parameters
curvelist (curve or list) – The curve or list of curves
limit (float) – The maximum value
-
pydvpy.
xmin
(curvelist, min)¶ Filter out points in the curve or list of curves whose x values are less than min.
- Parameters
curvelist (curve or list) – The curve or list of curves
min (float) – The minimum value
-
pydvpy.
xminmax
(curvelist, min, max)¶ Filter out points in the curve or list of curves whose x values are less than min or greater than max.
- Parameters
curvelist (curve or list) – The curve or list of curves
min (float) – The minimum value
max (float) – The maximum value
-
pydvpy.
y0
(curvelist)¶ Take the Bessel function of the second kind of the zeroth order for the y values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
y0x
(curvelist)¶ Take the Bessel function of the second kind of the zeroth order for the x values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
y1
(curvelist)¶ Take the Bessel function of the second kind of the first order for the y values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
y1x
(curvelist)¶ Take the Bessel function of the second kind of the first order for the x values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
-
pydvpy.
ymax
(curvelist, max)¶ Filter out points in the curve or list of curves whose y values are greater than limit.
- Parameters
curvelist (curve or list) – The curve or list of curves
max (float) – The maximum value
-
pydvpy.
ymin
(curvelist, min)¶ Filter out points in the curve or list of curves whose y values are less than min.
- Parameters
curvelist (curve or list) – The curve or list of curves
min (float) – The minimum value
-
pydvpy.
yminmax
(curvelist, min, max)¶ Filter out points in the curve or list of curves whose y values are less than min or greater than max.
- Parameters
curvelist (curve or list) – The curve or list of curves
min (float) – The minimum value
max (float) – The maximum value
-
pydvpy.
yn
(curvelist, n)¶ Take the Bessel function of the second kind of order n for the y values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
n (int) – The order
-
pydvpy.
ynx
(curvelist, n)¶ Take the Bessel function of the second kind of order n for the x values of curves in curvelist.
- Parameters
curvelist (curve or list) – The curve or list of curves
n (int) – The order
curve module¶
-
class
curve.
Curve
(filename='', name='')¶ Bases:
object
-
color
= ''¶
-
copy
()¶
-
dashes
= None¶
-
drawstyle
= 'default'¶
-
ebar
= None¶
-
edited
= False¶
-
erange
= None¶
-
filename
= ''¶
-
legend_show
= True¶
-
linespoints
= False¶
-
linestyle
= '-'¶
-
linewidth
= None¶
-
marker
= '.'¶
-
markeredgecolor
= None¶
-
markerfacecolor
= None¶
-
markersize
= 3¶
-
markerstyle
= None¶
-
name
= ''¶
-
normalize
()¶
-
plotname
= ''¶
-
plotprecedence
= 0¶
-
scatter
= False¶
-
title
= ''¶
-
x
= array([], dtype=float64)¶
-
xlabel
= ''¶
-
y
= array([], dtype=float64)¶
-
ylabel
= ''¶
-
-
curve.
append
(a, b)¶ Merge curve a and curve b over the union of their domains. Where domains overlap, take the average of the curve’s y-values.
- Parameters
a (curve) – Curve A
b (curve) – Curve B
- Returns
a new curve resulting from the merging of curve a and curve b
-
curve.
getinterp
(a, b, left=None, right=None, samples=100, match='domain')¶ Gets the interpolated and domain matched versions of the two curves.
- Parameters
a (curve) – Curve A
b (curve) – Curve B
left (float, optional) – Value to return for x < a.x[0], default is a.y[0].
right – Value to return for x > a.x[-1], default is a.y[-1].
{'domain','step'},optional (match) – A string indicating how to interpolate the two curves
- Type
right: float, optional
- Returns
curve pair – the interpolated and domain matched versions of a and b
-
curve.
interp1d
(a, num=100, retstep=False)¶ Gets the interpolated values of the curve with the specified number of samples.
- Parameters
a (curve) – Curve A
num – Number of samples to generate. Default is 100. Must be non-negative.
retstep – return the spacing between samples
- Type
num: int, optional
- Type
retstep: bool, optional
- Returns
ia: curve – the interpolated and dimensions matched version of a step: float, optional – only returned if retstep is True. Size of the spacing between samples
pdv module¶
pdvplot module¶
-
class
pdvplot.
Plotter
(pydvcmd)¶ Bases:
PySide2.QtWidgets.QMainWindow
-
canvas
= None¶
-
closeEvent
(self, event: PySide2.QtGui.QCloseEvent) → None¶
-
defaultPlotLayout
= None¶
-
fig
= None¶
-
figcolor
= 'white'¶
-
plotChanged
= False¶
-
showCurvelistDialog
()¶ Shows a dialog with the output of the list command in a table.
-
showMenuDialog
()¶ Shows a dialog with the output of the menu command in a table.
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
style
= 'ggplot'¶
-
updateDialogs
()¶ Updates the list and menu dialogs if visible.
-
updatePlotGeometry
(geometry='de')¶ Updates the size and location of the window. Using an action to trigger the update to ensure that the resizing is happening on the main GUI thread.
-
pdvutil module¶
-
exception
pdvutil.
CurveIndexError
¶ Bases:
ValueError
-
pdvutil.
getCurveIndex
(plotname, plotlist)¶
-
pdvutil.
get_actual_index
(origref, val)¶
-
pdvutil.
getletterargs
(line)¶
-
pdvutil.
getnumberargs
(line, filelist)¶
-
pdvutil.
parsemath
(line, plotlist, commander, xdomain)¶
-
pdvutil.
truncate
(string, size)¶