Welcome to PyDV 2.4.4 Documentation!¶
The Python Data Visualizer (PyDV) is a replacement for ULTRA writtern in python. PyDV allows the presentation, manipulation, and analysis of 1D data sets, i.e. (x,y) pairs. Presentation refers to the capability to display, and make hard copies of data plots. Manipulation refers to the capability to excerpt, shift, and scale data sets. Analysis refers to the capability to combine data sets in various ways to create new data sets.
The principal object with which PyDV works is the curve. A curve is an object which consists of an array of x values, an array of y values, a number of points (the length of the x and y arrays), and an ASCII label. PyDV operates on curves.
Users¶
Release Notes For PyDV 2.4.4¶
Bug Fixes¶
- Fixed the jn and jnx commands
- guilims command now working as expected
- Fixed the appendcurves command
Enhancements¶
- Added the fill command
- Added capability to add curve letters to the legend label
- Added the histogram command
- guilims command now persists its values when zooming in/out of the plot
.pdvrc File Format¶
Note
The .pdvrc file allows the user to initialize PyDV settings at startup time. PyDV expects the .pdvrc file to be located in the User’s Home Directory. The format of the .pdvrc file is ‘key=value’. Below are all of the currently recognized settings.
xlabel=label¶
Set the label for the x-axis to label.
ylabel=label¶
Set the label for the y-axis to label.
title=str¶
Set the title for the plot to str.
key=ON | OFF¶
Show the legend if key=ON, otherwise hide it if key=OFF.
letters=ON | OFF¶
Show or hide letter markers on plotted curves.
geometry=val1 val2 val3 val4¶
Change the PyDV window size and location in pixels where val1 is the x-size, val2 is the y-size, val3 is the x-location, and val4 is the y-location.
initcommands=filename¶
Specify a file to run the initial commands.
namewidth=width¶
Change the width of teh first column of the menu and lst output.
fontsize=size¶
Change the font size
lnwidth=width¶
Change the default line width of the curves.
Getting started¶
This section gives a tutorial introduction to PyDV. A sample session is run which highlights the basic PyDV commands.
Note
In PyDV commands, spaces are used to delimit items on the input line. More precisely items on a command line are either space delimited, are preceded by a left parenthesis if the first item in a list, or terminated by a right parenthesis if the last item in a list. Semicolons may be used to stack multiple commands on a single interactive input line. In interactive mode, ranges of curve numbers or data-id’s may be indicated using colon notation. For example, a:f or 5:9
Run PyDV¶
/usr/gapps/pydv/pdv
Run PyDV With a Command File¶
/usr/gapps/pydv/pdv -i <command-file>
Run PyDV In Column Format Mode¶
/usr/gapps/pydv/pdv -gnu <file.gnu>
Create a curve consisting of a straight line y=x over the interval (0,6.28).¶
[PyDV]: span 0 6.28
Print a list of curves on the display.¶
[PyDV]: lst
Take the sine of curve A¶
[PyDV]: sin a
Take the product of curves A and B¶
[PyDV]: * A B
Write all of the curves to an ASCII file¶
[PyDV]: save foo.txt a:c
Read file foo.txt¶
[PyDV]: rd foo.txt
Display curves in all open files¶
[PyDV]: menu
Shift curve A by one unit to the right¶
[PyDV]: dx A 1
Delete curve A from the display¶
[PyDV]: del A
Exit PyDV¶
[PyDV]: quit
I/O Commands¶
These commands access disk files either for reading or writing.
Note
< > = Required user input.
[< >] = Optional user input.
[PyDV] = Python Data Visualizer command-line prompt.
read¶
Read curves from the specified ASCII file and optionally filter by regex. The next available prefix (see the prefix command) is automatically assigned the menu index of the first curve in each data file read. For column oriented (.gnu) files optionally specify the x-column number before the file name. Shortcut: rd
[PyDV]: read [(regex) matches] [x-col] <filename>
readcsv¶
Read CSV data file. The next available prefix (see the prefix command) is automatically assigned the menu index of the first curve in each data file read. For column oriented (.gnu) files optionally specify the x-column number before the file name. Shortcut: rdcsv
[PyDV]: readcsv [x-col] <filename.csv>
savecsv¶
Save curves to file in comma separated values (CSV) format. Assumes all curves have the same x basis.
[PyDV]: savecsv <filename> <curve-list>
Math Operations¶
Note
< > = Required user input.
[ ] = Optional user input.
[PyDV]: = Python Data Visualizer command-line prompt.
abs¶
Take the absolute value of the y values of the curves. Modifies the existing curve.
[PyDV]: abs <curve-list>
absx¶
Take the absolute value of the x values of the curves. Modifies the existing curve.
[PyDV]: absx <curve-list>
average¶
Average the specified curvelist over the intersection of their domains.
[PyDV]: average <curve-list>
convolve¶
Computes the convolution of the two given curves. This is similar to the slower convolc method in ULTRA that uses direct integration and minimal interpolations. Shortcut: convol
[PyDV]: convolve <curve1> <curve2> [points]
convolveb¶
Computes the convolution of the two given curves and normalizing the second curve by the area under the curve. This computes the integrals directly which avoid padding and aliasing problems associated with FFT methods (it is however slower). Shortcut: convolb
[PyDV]: convolveb <curve1> <curve2> [points]
convolvec¶
Computes the convolution of the two given curves with no normalization. This computes the integrals directly which avoid padding and aliasing problems associated with FFT methods (it is however slower). Shortcut: convolb
[PyDV]: convolveb <curve1> <curve2> [points]
error-bar¶
Plot error bars on the given curve.
[PyDV]: errorbar <curve> <y-error-curve> <y+error-curve> [x-error-curve x+error-curve] [point-skip]
errorrange¶
Plot shaded error region on given curve, Shortcut: error-range
[PyDV]: errorrange <curve> <y-error-curve> <y+error-curve>
fft¶
Compute the one-dimensional discrete Fourier Transform for the y-values of the curves.
[PyDV]: fft <curve-list>
fftx¶
Compute the one-dimensional discrete Fourier Transform for the x-values of the curves.
[PyDV]: fftx <curve-list>
gaussian¶
Generate a gaussian function.
[PyDV]: gaussian <amplitude> <width> <center> [<# points> [<# half-widths>]]
L1¶
Makes new curve that is the L1 norm of two args; the L1 norm is integral( |curve1 - curve2| ) over the interval [xmin,xmax]. Also prints value of integral to command-line.
[PyDV]: L1 <curve1> <curve2> [<xmin> <xmax>]
L2¶
Makes new curve that is the L2 norm of two args; the L2 norm is integral( (curve1 - curve2)**2 )**(1/2) over the interval [xmin,xmax]. Also prints value of integral to command-line.
[PyDV]: L2 <curve1> <curve2> [<xmin> <xmax>]
log¶
Take the natural logarithm of the y values of the curves. If the optional argument keep-neg-vals is set to false, then zero and negative y-values will be discarded. keep-neg-vals is true by default. Shortcut: ln
[PyDV]: log <curve-list> [keep-neg-vals: True | False]
logx¶
Take the natural logarithm of the x values of the curves. If the optional argument keep-neg-vals is set to false, then zero and negative x-values will be discarded. keep-neg-vals is true by default. Shortcut: lnx
[PyDV]: logx <curve-list> [keep-neg-vals: True | False]
log10¶
Take the base 10 logarithm of the y values of the curves. If the optional argument keep-neg-vals is set to false, then zero and negative y-values will be discarded. keep-neg-vals is true by default.
[PyDV]: log10 <curve-list> [keep-neg-vals: True | False]
log10x¶
Take the base 10 logarithm of the x values of the curves. If the optional argument keep-neg-vals is set to false, then zero and negative y-values will be discarded. keep-neg-vals is true by default.
[PyDV]: log10x <curve-list> [keep-neg-vals: True | False]
makeintensive - 2.4.2¶
Set the y-values such that y[i] = y[i] / (x[i+1] - x[i]). Shortcut: mkint
[PyDV]: makeintensive <curve-list>
makeextensive - 2.4.2¶
Set the y-values such that y[i] = y[i] * (x[i+1] - x[i]). Shortcut: mkext
[PyDV]: makeextensive <curve-list>
norm¶
Makes a new curve that is the norm of two args. Also prints the value of the integral to command line.
[PyDV]: norm <curve> <curve> <p> <xmin> <xmax>
Note
The p-norm is (integral( (curve1 - curve2)**p )**(1/p) over the interval [xmin, xmax], where p = order.
powa¶
Raise a fixed value, a, to the power of the y values of the curves.
[PyDV]: powa <curve-list> <a>
powax¶
Raise a fixed value, a, to the power of the x values of the curves.
[PyDV]: powax <curve-list> <a>
xmax¶
Filter out points in curves whose x-values greater than limit
[PyDV]: xmax <curve-list> <limit>
y0¶
Take the zeroth order Bessel function of the second kind of the y values of the curves.
[PyDV]: y0 <curve-list>
y0x¶
Take the zeroth order Bessel function of the second kind of the x values of the curves.
[PyDV]: y0x <curve-list>
y1¶
Take the first order Bessel function of the second kind of the y values of the curves.
[PyDV]: y1 <curve-list>
y1x¶
Take the first order Bessel function of the second kind of the x values of the curves.
[PyDV]: y1x <curve-list>
ymax¶
Filter out points in curves whose y-values greater than limit
[PyDV]: ymax <curve-list> <limit>
yminmax¶
Trim the selected curves. Shortcut: ymm
[PyDV]: yminmax <curve-list> <low-limit> <high-lim>
yn¶
Take the nth order Bessel function of the second kind of y values of curves
[PyDV]: yn <curve-list> <n>
ynx¶
Take the nth order Bessel function of the second kind of x values of curves
[PyDV]: ynx <curve-list> <n>
diffMeasure¶
Compare two curves. For the given curves a fractional difference measure and its average is computed
[PyDV]: diffMeasure <curve1> <curve2> [tolerance]
fit¶
Make new curve that is polynomial fit to argument. n=1 by default, logy means take log(y-values) before fitting, logx means take log(x-values) before fitting
[PyDV]: fit <curve> [n] [logx] [logy]
integrate¶
Compute the definite integral of each curve in the list over the specified domain. Shortcut: int
[PyDV]: integrate <curve-list> [low-limit high-limit]
span¶
Generates a straight line of slope 1 and y intercept 0 in the specified domain with an optional number of points
[PyDV]: span <xmin> <xmax> [points]
vs¶
Plot the range of the first curve against the range of the second curve
[PyDV]: vs <curve1> <curve2>
Environmental Inquiry Commands¶
These functions are provided to gain access to information about the state of the PyDV session. Information such as the state of global variables and system help packages is made available through these functions.
Note
< > = Required user input.
[ ] = Optional user input.
[PyDV]: = Python Data Visualizer command-line prompt.
help¶
Return infroamtion about the specified command, variable, or command category. If no argument is supplied, return a list of available commands.
[PyDV]: help [command]
lst¶
Return a list of the curves currently displayed. A regular expression may be supplied for matching against the curve label to be listed.
[PyDV]: lst <label-pattern>
system - 2.4.2¶
Allows passing commands to the operating system. Shortcut: ! or shell
[PyDV]: system ls
Curve Inquiry Commands¶
These functions provide a mechanism for obtaining information about specified curves.
Note
< > = Required user input.
[ ] = Optional user input.
[PyDV]: = Python Data Visualizer command-line prompt.
getattributes¶
Return (to the terminal) the attributes of a curve, such as: color, style, width, etc.
[PyDV]: getattributes <curve>
getdomain¶
Return (to the terminal) the domains for the list of curves.
[PyDV]: getdomain <curve-list>
stats¶
Calculate the mean and standard deviation for the curves and display the results on the terminal.
[PyDV]: stats <curve-list>
getymin - 2.4.2¶
Return the minimum y-value for the curve within the specified domain. If no domain is given, then the full domain range is used.
[PyDV]: getymin <curve> [<xmin> <xmax>]
getymax - 2.4.2¶
Return the maximum y-value for the curve within the specified domain. If no domain is given, then the full domain range is used.
[PyDV]: getymax <curve> [<xmin> <xmax>]
Environmental Control Commands¶
These functions allow you to manipulate the environment of PyDV on a global level. They are useful to avoid repeated use of other commands or to change the state of PyDV in dramatic ways.
Note
< > = Required user input.
[ ] = Optional user input.
[PyDV]: = Python Data Visualizer command-line prompt.
custom¶
Load a file of custom functions to extend PyDV. Functions must be of the form ‘def do_commandname(self, line): …
[PyDV]: custom <file-name>
namewidth¶
Change the width of the first column of the menu and lst output.
[PyDV]: namewidth <integer>
Plot Control Commands¶
These functions control the plotting characteristics of PyDV which affect all displayed curves.
Note
< > = Required user input.
[ ] = Optional user input.
[PyDV]: = Python Data Visualizer command-line prompt.
bkgcolor - 2.4¶
Change the background color of the plot, window, or both
[PyDV]: bkgcolor <[plot | window] color-name | reset>
dashstyle¶
Set the style of dash or dot dash lines. The python list is a list of integers, alternating how many pixels to turn on and off, for example:
[2, 2] : Two pixels on, two off (will result in a dot pattern).
[4, 2, 2, 2] : 4 on, 2 off, 2 on, 2 off (results in a dash-dot pattern).
[4, 2, 2, 2, 4, 2] : Gives a dash-dot-dash pattern.
[4, 2, 2, 2, 2, 2] : Gives a dash-dot-dot pattern.
See matplotlib ‘set_dashes’ command for more information.
[PyDV]: dashstyle <curve-list> <[...]>
domain¶
Set the domain for plotting. Using de (for default) will let the curves determine the domain.
[PyDV]: domain <low-lim> <high-lim>
OR
[PyDV]: domain de
fontcolor¶
Change the font color of given plot component.
[PyDV]: fontcolor [<component: xlabel | ylabel | title | xaxis | yaxis>] <color-name>
fontsize¶
Change the font size of given component, or overall scaling factor.
[PyDV]: fontsize [<component: title | xlabel | ylabel | key | tick | curve | annotation>] <numerical-size | small | medium | large | default>
geometry¶
Change the PyDV window size and location in pixels.
[PyDV]: geometry <xsize> <ysize> <xlocation> <ylocation>
guilims¶
Set whether or not to use the GUI min/max values for the X and Y limits. Default is off.
[PyDV]: guilims <on | off>
image¶
Save the current figure to image file.
[PyDV]: image <file-name> <file-type: png | ps | pdf | svg>
labelFileNames¶
Change the key and list labels for all curves to append the filename.
[PyDV]: labelFileNames
legend¶
Show/Hide the legend with on | off or set legend position with ur, ul, ll, lr, cl, cr, uc, lc. Shortcuts: leg, key
[PyDV]: legend <on | off> [position]
lnstyle¶
Set the line style of the specified curves.
[PyDV]: lnstyle <curve-list> <style: solid | dash | dot | dotdash>
lnwidth¶
Set the line widths of the specified curves. A line width of 0 will give the thinnest line which the host graphics system supports.
[PyDV]: lnwidth <curve-list> <width>
marker¶
Set the marker symbol and scale (optionally) for scatter plots. You can also use any of the matplotlib supported marker types as well. See the matplotlib documentation on markers for further information.
[PyDV]: marker <curve-list> <marker-style: + | . | circle | square | diamond> [marker-size]
minorticks¶
Minor ticks are not visible by default. On will make the minor ticks visible and off will hide the minor ticks.
[PyDV]: minorticks <on | off>
range¶
Set the range for plotting. Using de (for default) will let the curves determine the range. Shortcut: ran
[PyDV]: range <low-lim> <high-lim> | de
style¶
Use matplotlib style settings from a style specification. The style name of default (if available) is reserved for reverting back to the default style settings.
[PyDV]: style <style-name>
xlogscale¶
Set log scale on or off for the x-axis. Alternative Form: x-log-scale, Shortcut: xls
[PyDV]: xlogscale <on | off>
xtickcolor¶
Set the color of the ticks on the x-axis. Default is to apply to major ticks only.
[PyDV]: xticks <de | color> [which: major | minor | both]
xticks¶
Set the locations of major ticks on the x-axis
[PyDV]: xticks de | <number> | <list of locations> | <list of locations, list of labels>
xtickformat¶
Set the format of major ticks on the x axis. Default is plain.
[PyDV]: xtickformat <plain | sci | exp | 10**>
xticklength¶
Set the length (in points) of x ticks on the axis. Default is apply to major ticks only.
[PyDV]: xticklength <number> [which: major | minor | both]
xtickwidth¶
Set the width (in points) of x ticks on the x axis. Default is to apply to major ticks only.
[PyDV]: xtickwidth <number> [which: major | minor | both]
ylogscale¶
Set log scale on or off for the y-axis. Alternative Form: y-log-scale, Shortcut: yls
[PyDV]: ylogscale <on | off>
ytickcolor¶
Set the color of the ticks on the y-axis. Default is to apply to major ticks only.
[PyDV]: ytickcolor <de | color> [which: major | minor | both]
ytickformat¶
Set the format of major ticks on the y axis. Default is plain.
[PyDV]: ytickformat <plain | sci | exp | 10**>
yticklength¶
Set the length (in points) of y ticks on the y axis. Default is to apply to major ticks only.
[PyDV]: yticklength <number> [which: major | minor | both]
ytickwidth¶
Set the width (in points) of y ticks on the y axis. Default is to apply to major ticks only.
[PyDV]: ytickwidth <number> [which: major | minor | both]
yticks¶
Set the locations of major ticks on the y axis.
[PyDV]: yticks de | <number> | <list of locations> | <list of locations, list of labels>
Curve Control Commands¶
These functions control the individual curves that are currently being displayed. They range in type from controlling the appearance of the curve to deleting it. They also include the “non-mathematical” mechanisms which may generate curves.
Note
< > = Required user input.
[ ] = Optional user input.
[PyDV]: = Python Data Visualizer command-line prompt.
appendcurves - 2.4¶
Merge a list of curves over the union of their domains. Where the domains overlap, take the average of the curve’s y-values.
[PyDV]: appendcurves <curve-list>
color¶
Set the color of curves. Color names can be “blue”, “red”, etc., or “#eb70aa”, a 6 digit set of hexadecimal red-green-blue values (RRGGBB). The entire set of HTML-standard color names is available. Type showcolormap to see the available named colors.
[PyDV]: color <curve-list> <color>
curve¶
Select curves from the menu for plotting. Shortcut: cur
[PyDV]: curve [menu <regex>] <list-of-menu-numbers>
dupx - 2.4¶
Duplicate x-values so that y=x for each of the specified curves.
[PyDV]: dupx <curve-list>
linemarker¶
Set the marker symbol for the curves.
[PyDV]: linemarker <curve-list> <marker-style: + | . | circle | square | diamond> [<marker-size>]
Note
When setting this value through the interface or the curve object directly, use ONLY matplotlib supported marker types. Matplotlib marker types are also supported here as well. See matplotlib documentation on markers for further information.
markerfacecolor¶
Set the markerface color of curves. Color names can be “blue”, “red”, etc, or “#eb70aa”, a 6 digit set of hexadecimal red-green-blue values (RRGGBB). The entire set of HTML-standard color names is available. Try “showcolormap” to see the available named colors.
[PyDV]: markerfacecolor <curve-list> <color-name>
markeredgecolor¶
Set the markeredge color of curves. Color names can be “blue”, “red”, etc, or “#eb70aa”, a 6 digit set of hexadecimal red-green-blue values (RRGGBB). The entire set of HTML-standard color names is available. Try “showcolormap” to see the available named colors.
[PyDV]: markeredgecolor <curve-list> <color-name>
dupx - 2.4¶
Duplicate the x-values such that y=x for each of the given curves
[PyDV]: dupx <curve-list>
line¶
Generate a line with y = mx + b and an optional number of points.
[PyDV]: line <m> <b> <xmin> <xmax> [# pts]
makecurve¶
Generate a curve from two lists of numbers. Each list must be delimited by parentheses. Alternative Form: make-curve
[PyDV]: makecurve (<list of x-values) (<list of y-values>)
newcurve¶
Creates a new curve from an expression.
[PyDV]: newcurve <numpy expression>
Note
For convenience, both math and numpy modules have been imported into the namespace. Just FYI, this feature is way outside the ULTRA syntax that PyDV is mostly based on. EXAMPLE:
[PyDV]: newcurve sin(a.x*2*pi)/(h.y**2)
This creates a new curve according to the above expression. Shortcut: nc
Warning
- Currently, newcurve is hard-wired to only handle single-letter labels. Curve names used in the expression cannot be the @N type we use after we run out of letters. Sorry (April 2015).
- A common error is to forget the .x or .y on the curve label name.
- All the arrays in your expression have to span the same domain! Currently (4/2015), newcurve will generate a curve from different domains (with no error message), and that curve will almost certainly not be what you intended.
random¶
Generate random y values between -1 and 1 for the specified curves.
[PyDV]: random <curve-list>
rev¶
Swap x and y values for the specified curves. You may want to sort after this one.
[PyDV]: rev <curve-list>
scatter¶
Plot curves as scatter diagrams or connected lines.
[PyDV]: scatter <curve-list> <on | off>
sort¶
Sort the specified curves so that their points are plotted in order of ascending x values.
[PyDV]: sort <curve-list>
subsample¶
Subsample the curves by the optional stride. Default value for stride is 2.
[PyDV]: subsample <curve-list> [stride]
UI Features¶
The PyDV User Interface (UI) has many different windows and toolbar items that provide information and alternative ways of executing PyDV commands (see Figure 1). Below is a description of the different UI components that are available.
Toolbar¶
An annotated toolbar for the PyDV UI is shown in Figure 2. Button 1 allows the user to reset the plot window to the original view, button 2 allows the user to step back to the previous view, and button 3 allows the user to step through to the next view. Button 4 allows panning the axis with the left mouse button and zooming the axis with the right mouse button. Button 5 allows zooming to a rectangle. Button 6 allows configuring of the subplots, button 7 is for saving the displayed figure, and button 8 is for editing curve lines and axes parameters. The area highlighted in 9 tracks the mouse location over the plot.
Developers¶
PyDV 2.4.4 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 a two 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])
Parameters: Returns: nc: Curve – the convolution of the two curves c1 and c2
-
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).
Parameters: Returns: nc: Curve – the convolution of the two curves c1 and c2
-
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).
Parameters: Returns: Curve – the convolution of the two curves c1 and c2 using integration and normalizing c2
-
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).
Parameters: Returns: Curve – the convolution of the two curves c1 and c2 using integration and no normalization
-
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 (str) –
{‘full’, ‘same’, ‘valid’}, optional ‘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)
Parameters: Returns: tuple – Two curves representing the fractional difference measure and its average
-
pydvpy.
disp
(c, domain=True)¶ Create a tuple for the given curve that contains the name of the curve and a string formatted list of the curve’s x- or y-values.
>>> c = pydvif.span(1, 10)
>>> name, 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: tuple – A tuple consisting of the curve name and 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)
Parameters:
-
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)
Parameters:
-
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].
- 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.
- out : Curve tuple
- Two curves with the real and imaginary parts.
- IndexError
- if axes is larger than the last axis of a.
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.
[CT] 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])
-
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)¶ 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 ymax – the maximum y-value for the specified domain
-
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 ymin – the minimum y-value for the specified domain
-
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)
Parameters: Returns Curve: A new curve that is the L1 norm of c1 and c2
-
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)
Parameters: Returns Curve: A new curve that is the L2 norm of c1 and c2
-
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='')¶ 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)
Parameters: Returns Curve: A new curve that is the p-norm of c1 and c2
-
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
(fname, 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: - fname (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.
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)
Parameters: Returns: Curve – the new curve
-
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
= ''¶
-
linespoints
= False¶
-
linestyle
= '-'¶
-
linewidth
= None¶
-
marker
= '.'¶
-
markeredgecolor
= None¶
-
markerfacecolor
= None¶
-
markersize
= 6¶
-
markerstyle
= None¶
-
name
= ''¶
-
normalize
()¶
-
plotname
= ''¶
-
plotprecedence
= 0¶
-
scatter
= False¶
-
x
= array([], dtype=float64)¶
-
y
= array([], dtype=float64)¶
-
-
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