Previous topic

pycrtools.core.htypes

Next topic

pycrtools.core.vector

This Page

pycrtools.core.plot

BoolArray
BoolVec c++ standard template library (STL) vector of type ‘bool’
ComplexArray
ComplexVec c++ standard template library (STL) vector of type ‘complex’
CoordinateTypes
FFTWPlanManyDft
FFTWPlanManyDftC2r
FFTWPlanManyDftR2c
FloatArray
FloatVec c++ standard template library (STL) vector of type ‘float’
IntArray
IntVec c++ standard template library (STL) vector of type ‘int’
StringArray
StringVec c++ standard template library (STL) vector of type ‘str’
TBB2Data
TBBData
TYPE
VecToString(self[, maxlen]) see help of ‘hPrettyString’
Vec_add(vec1, val) Provides the + operator for adding two vectors or a vector and a scalar.
Vec_div(vec1, val) Provides the / operator for dividing two vectors or a vector by a scalar.
Vec_iadd(vec1, vec2) Provides the += operator for adding two vectors in place.
Vec_idiv(vec1, vec2) Provides the /= operator for adding two vectors in place.
Vec_imul(vec1, vec2) Provides the *= operator for addig two vectors in place.
Vec_isub(vec1, vec2) Provides the -= operator for adding two vectors in place.
Vec_mul(vec1, val) Provides the * operator for multiplying two vectors or a vector and a scalar.
Vec_neg(vec1) Provides the - operator for a vector.
Vec_pos(vec1) Provides the + operator for a vector (which is its identity: +vec = vec).
Vec_pow(vec1, val) Provides the ** operator for raising a vector to a power.
Vec_rdiv(vec1, val) Provides the / operator for dividing two vectors or a vector by a scalar.
Vec_rsub(vec1, val) Provides the - operator for subtracting two vectors or a vector and a scalar.
Vec_sub(vec1, val) Provides the - operator for subtracting two vectors or a vector and a scalar.
Vector([Type, size, fill, copy, properties]) The basic Boost Python STL vector constructor takes no arguments and hence is a litte cumbersome to use.
asList(val) Usage:
ashArray(val) Usage:
asharray(self) Return the argument as an hArray, if possible, otherwise as list.
asval(self) Return the argument as a single value.
asvec(self) Return the argument as a vector, if possible, otherwise as list.
atype
basetype((IntVec) -> <type >) basetype(FloatArray) -> <type ‘float’>
btype str(object=’‘) -> string
extendflat(self, l) Appending all elements in a list of lists to a one-dimensional vector with a flat data structure (just 1D).
fftw_flags
fftw_sign
get_filename(filename, ext) Returns the folder name and its proper extention.
hArray([Type, dimensions, fill, name, copy, ...]) Usage:
hArrayRead(filename[, block, restorevar, ...]) Usage:
hArrayReadDictArray(dictionary, path[, ...]) Recursively goes through a dict (of dicts) and replaces all placeholder (hFileContainer) with hArrays or Vectors read from disk.
hArrayWriteDictArray(dictionary, path, prefix) Recursively goes through a dict (of dicts) and replaces all values which are hArray with a placeholder and writes the array to disk.
hArray_Find(self, operator[, threshold1, ...]) Usage:
hArray_Select(self, *args, **kwargs) Usage:
hArray_Set(self, value, *args, **kwargs) Usage:
hArray_array(self) array.array() -> hArray(array.vec,properties=array)
hArray_checksum(self) array.checksum() -> Returns CRC32 checksum of a ‘list’ representation of the array
hArray_copy_resize(self, ary) Retrieve the first element of the currently selected slice from the stored vector.
hArray_getHeader(self[, parameter_name]) Usage:
hArray_getSlicedArray(self, indexlist) self[n1,n2,n3]-> return Element with these indices
hArray_getinitargs(self) Get arguments for hArray constructor.
hArray_getitem(self, indexlist[, asvec]) ary[n1,n2,n3]-> return Element with these indices
hArray_getstate(self) Get current state of hArray object for pickling.
hArray_hasHeader(self[, parameter_name]) Usage:
hArray_list(self) array.list() -> [x1,x2,x3, ...]
hArray_mprint(self) ary.mprint() - > print the array in matrix style
hArray_new(self) ary.new() -> new_array
hArray_newreference(self) array.newreference() -> copy of array referencing the same vector
hArray_none(self) array.none() -> None
hArray_par Parameter attribute.
hArray_read(self, datafile, key[, block, ...]) array.read(file,”Time”,block=-1) -> read key Data Array “Time” from file into array.
hArray_repr(self[, maxlen])
hArray_return_slice_end(val) Reduces a slice to its end value
hArray_return_slice_start(val) Reduces a slice to its start value
hArray_setHeader(self, **kwargs) Usage:
hArray_setPar(self, key, value) array.setPar(“keyword”,value) -> array.par.keyword=value
hArray_setUnit(self, *arg)
hArray_setitem(self, dims, fill) vec[n1,n2,..] = [0,1,2] -> set slice of array to input vector/value
hArray_setstate(self, state) Restore state of hArray object for unpickling.
hArray_toNumpy(self) Returns a copy of the array as a numpy.ndarray object with the correct dimensions.
hArray_toslice(self) Usage: ary.toslice() -> slice(ary1,ary2,ary3)
hArray_transpose(self[, ary]) Usage:
hArray_val(self) ary.val() -> a : if length == 1
hArray_vec(self) array.vec() -> Vector([x1,x2,x3, ...])
hArray_write(self, filename[, nblocks, ...]) Usage:
hArray_writeheader(self, filename[, ...]) Usage:
hFileContainer(path, name[, vector]) Dummy class to hold a filename where an hArray is stored.
hNone2Value(none, defval) Returns a default value if the the first input is the None object, otherwise return the value of the first argument.
hPlot_plot(self[, xvalues, xerr, yerr, ...]) Method of arrays.
hSemiLogX(x, y, **args) Total frustration avoid EDP64 crash on new Mac function
hSemiLogXY(x, y, **args) Total frustration avoid EDP64 crash on new Mac function
hSemiLogY(x, y, **args) Total frustration avoid EDP64 crash on new Mac function
hSliceListElementToNormalValuesEnd(s, dim)
hSliceListElementToNormalValuesStart(s, dim)
hSliceToNormalValues(s, dim) Returns a slice object where none and negative numbers are replaced by the appropriate integers, given a dimension (length) dim of the full slice.
hVector_getinitargs(self) Get arguments for hVector constructor.
hVector_getstate(self) Get current state of hVector object for pickling.
hVector_list(self) Retrieve the STL vector as a python list.
hVector_repr(self[, maxlen]) Returns a human readable string representation of the vector.
hVector_setstate(self, state) Restore state of hVector object for unpickling.
hVector_val(self) Retrieve the contents of the vector as python values: either as a single value, if the vector just contains a single value, or otherwise return a python list.
hVector_vec(self) Convenience method that allows one to treat hArrays and hVectors in the same way, i.e.
hWEIGHTS
isVector(vec) Returns true if the argument is one of the standard c++ vectors i.e.
ishArray((array) -> True or False) Returns true if the argument is one of the hArray arrays, i.e.
multiply_list(l) Multiplies all elements of a list with each other and returns the result.
plot_draw_class(*args, **kwargs) Just calls plt.draw - can be used in place of plotfinish in tasks to just plot and do nothing fancy
plotconst(xvalues, y) Plot a constant line.
plotfinish([name, plotpause, doplot, ...]) Usage:
type2array((float) -> Vec(0)=[]) Creates an array with elements of type ‘basetype’.
type2vector((float) -> Vec(0)=[]) Creates a vector with elements of type ‘basetype’.
typename(btype) basetype(float) -> “float”
v
vtype c++ standard template library (STL) vector of type ‘str’

Provides an n-dimensional array class.

pycrtools.core.plot.hPlot_plot(self, xvalues=None, xerr=None, yerr=None, xlabel=None, ylabel=None, title=None, clf=True, logplot=None, xlim=None, ylim=None, legend=None, highlight=None, nhighlight=None, highlightcolor=None, highlightlabel=None, **plotargs)

Method of arrays. Plots the current slice. If the array is in looping mode, multiple curves are plotted in one windows.

Usage:

>>> array[0].plot(self,xvalues=vec,xlabel='x',ylabel='y',title='Title',clf=True,logplot='xy')
-> plot the array (loglog)

You can set the plotting parameters also as attributes to the par class of the array, e.g., array.par.xvalues=x_vector; array.plot()

Parameters:

Parameter Description
xvalues an array with corresponding x values, if None numbers from 0 to length of the array are used.
xerr/yerr if not None, errors in along x and y-axis for each point.
xlabel the x-axis label, if not specified, use the name keyword of the xvalues array - units will be added automatically.
ylabel the y-axis label, if not specified, use the name keyword of the array - units will be added automatically.
xlim tuple with minimum and maximum limits for the x-axis.
ylim tuple with minimum and maximum limits for the y-axis.
legend plots a legend, taking a tuple of strings for each plotted line as input, e.g. legend=('A','B',...).
title the title for the plot
clf if True (default) clear the screen beforehand (use False to compose plots with multiple lines from different arrays.
logplot
can be used to make loglog or semilog plots:
False -> linear plot None -> take defaults from array if present ‘x’ -> semilog in x ‘y’ -> semilog in y ‘xy’ -> loglog plot
highlightcolor color (e.g. ‘red’), used to highlight sections of the plot
highlighlabel text used to label the highlighted regions in a legend
nhighlight determines how many (if any) sections of the data to highlight.
highlight ylist, vector, or array of tuples with start and end indices of sections to highlight
plotarg1 =..., plotarg2=...: you can add any plotting parameter that is understood by .plot of scipy, e.g. color = ‘green’ (see following parameters)
color = scipy name of plotting color (e.g. ‘green’)
linestyle = scipy style of line plotting (e.g. ‘dashed’, or ‘’ for none)
marker = scipy style for data points (e.g. ‘x’ or ‘o’)

Example:

# Plotting an hArray with errorbars a=hArray(float,10,fill=range(1,11)); b=hArray(copy=a,yerr=a,xerr=a,logplot=”y”); a*=0.1; b.plot()

pycrtools.core.plot.hSemiLogX(x, y, **args)

Total frustration avoid EDP64 crash on new Mac function

pycrtools.core.plot.hSemiLogXY(x, y, **args)

Total frustration avoid EDP64 crash on new Mac function

pycrtools.core.plot.hSemiLogY(x, y, **args)

Total frustration avoid EDP64 crash on new Mac function

class pycrtools.core.plot.plot_draw_class(*args, **kwargs)

Just calls plt.draw - can be used in place of plotfinish in tasks to just plot and do nothing fancy

pycrtools.core.plot.plotconst(xvalues, y)

Plot a constant line.

Usage:

>>> plotconst(xvalues,y).plot()
-> will plot a constant line with y-value 'y' for the xvalues provided.
class pycrtools.core.plot.plotfinish(name='', plotpause=True, doplot=True, refresh=True, filename='', filetype='png', counter=0, plotfiles=[])

Usage:

plot_finish_instance=plotfinish(name="",plotpause=True,doplot=True,refresh=True,filename="",filetype="png",counter=0,plotfiles=[])

plot_finish_instance(txt="",name="",filename="",filetype="",setcounter=0,counter=None,savefig=False,same_row=False)

Description

Class creating a function to be called after a plotting command. If plotpause.plotpause = True it will pause and ask for user input whether and how to continue calculation and plotting. If a filename is provided the figure will be saved to disk.

The following parameters can be specified during initialization of the class or during a call to the instance of the plotfinish class.

plotpause = True Pause for manual input after each plot.
doplot = True Plot at all.
refresh = True Refresh (redraw) plot window after each plotting command also in batch mode.
filename = “” If set, save figure to this file (w/o extension)
filetype = “png” Extension of the figure file to also determine format.
txt = “” Text to print after plotting and before user input (parameter not available at initialization)
plotfiles = [] Provide a list, which contains the plotfiles generated so far. (parameter not available at initialization)
same_row   If true, then put the next plotfile in the same ‘row’ as the previous, i.e. create a sub list. Can be used for output formatting. (parameter only available during call)
setcounter   Reset the counter for the plotfiles (added to names) to this value (parameter only available during call)
counter   Temporarily set the counter for the plotfiles (added to names) to this value (parameter only available during call)
name = “” Name identifying current plot. Will also be appended to filename. (parameter not available at initialization)

May modify plotpause and doplot, depending on user input.

Filename of the image file will be filename+("-"+name+)"."+filetype

All filenames that were written to disk can be retrieved as a list from the attribute self.files.

Example:

>>> pp=plotfinish(filename="test")
>>> pp("Test","a")
-> (a) Test
-> Saved plot in Test-a.png
-> Press [return] to continue. Press [q]+[return] to proceed without pausing, [n]+[return] to continue without plotting...q
-> Continue without pausing from now on.

>>> pp.plotpause
-> False

>>> pp("Try again")
-> Nothing happens (i.e. no pause)....