PyMcaCore Package¶
DataObject
Module¶
-
class
PyMca5.PyMcaCore.DataObject.
DataObject
[source]¶ Bases:
object
Simple container of an array and associated information. Basically it has the members: info: A dictionnary data: An array, usually 2D, 3D, ...
In the past also incorporated selection methods. Now each different data source implements its selection methods.
Plotting routines may add additional members
x: A list containing arrays to be considered axes y: A list of data to be considered as signals m: A list containing the monitor data
-
GETDATA_DEPRECATION_WARNING
= True¶
-
GETINFO_DEPRECATION_WARNING
= True¶
-
SELECT_DEPRECATION_WARNING
= True¶
-
EdfFileDataSource
Module¶
-
class
PyMca5.PyMcaCore.EdfFileDataSource.
EdfFileDataSource
(nameInput, fastedf=False)[source]¶ Bases:
object
-
getDataObject
(key, selection=None)[source]¶ - selection: a dictionnary with the keys pos and size: (x), (x,y) or (x,y,z)
- tuples defining a roi If not defined, takes full array
-
getSourceInfo
()[source]¶ Returns information about the EdfFile object created by SetSource, to give application possibility to know about it before loading. Returns a dictionary with the key “KeyList” (list of all available keys in this source). Each element in “KeyList” has the form ‘n1.n2’ where n1 is the source number and n2 image number in file starting at 1.
-
EdfFileLayer
Module¶
-
class
PyMca5.PyMcaCore.EdfFileLayer.
EdfFileLayer
(refresh_interval=None, info={}, fastedf=None)[source]¶ Bases:
object
Specializes Data class in order to access Edf files. Interface: Data class interface.
-
GetPageArray
(index=0)[source]¶ Returns page’s data (NumPy array) Parameters: index: Either an integer meaning the sequencial position of the page
or a dictionary that logically index the page based on keys of the page’s Info dictionary.
-
GetSourceInfo
(key=None)[source]¶ Returns information about the EdfFile object created by SetSource, to give application possibility to know about it before loading. Returns a dictionary with the keys “Size” (number of possible keys to this source) and “KeyList” (list of all available keys in this source). Each element in “KeyList” is an integer meaning the index of the array in the file.
-
LoadSource
(key_list='ALL', append=0, invalidate=1, pos=None, size=None)[source]¶ Creates a given number of pages, getting data from the actual source (set by SetSource) Parameters: key_list: list of all keys to be read from source. It is a list of
keys, meaning the indexes to be read from the file. It can be also one integer, if only one array is to be read.- append: If non-zero appends to the end of page list.
- Otherwise, initializes the page list
- invalidate: if non-zero performas an invalidade call after
- loading
- pos and size: (x), (x,y) or (x,y,z) tuples defining a roi
- If not defined, takes full array Stored in page’s info
-
LoadSourceSingle
(key_list='ALL', append=0, invalidate=1, pos=None, size=None)[source]¶ Creates a given number of pages, getting data from the actual source (set by SetSource) Parameters: key_list: list of all keys to be read from source. It is a list of
keys, meaning the indexes to be read from the file. It can be also one integer, if only one array is to be read.- append: If non-zero appends to the end of page list.
- Otherwise, initializes the page list
- invalidate: if non-zero performas an invalidade call after
- loading
- pos and size: (x), (x,y) or (x,y,z) tuples defining a roi
- If not defined, takes full array Stored in page’s info
-
EventHandler
Module¶
-
class
PyMca5.PyMcaCore.EventHandler.
EventHandler
[source]¶ Bases:
object
-
create
(fulleventstr, myid=None)[source]¶ Create the event. This call will take a full classname a.b.c and create the event calls and all the parent classes if necessary. It returns the eventclassobject which can be used to fire the event later. It is no error to create the class after registering for it, but it is an error to fire an event before creating it. Normally the event producer is responsible for creating it
-
register
(fulleventstr, callback, myid=None, source=None)[source]¶ Register the event a.b.c with callback . You have to specify the full name of the event class as it might be created during this call. A later create call with the same event will just confirm this creation. You can specify an id for yourself and an id for the source you would like to listen to. The source restrictions are not yet implemented because of performance considerations.
-
HtmlIndex
Module¶
NexusDataSource
Module¶
Plugin1DBase
Module¶
A 1D plugin is a module that can be added to the PyMca 1D window in order to perform user defined operations of the plotted 1D data.
Plugins can be automatically installed provided they are in the appropriate place:
- In the user home directory: ${HOME}/PyMca/plugins (POSIX systems)
- In “My Documents\PyMca\plugins” (Windows)
A plugin inherit the Plugin1DBase.Plugin1DBase class and implement the methods:
- getMethods
- getMethodToolTip (optional but convenient)
- getMethodPixmap (optional)
- applyMethod
and modify the static module variable MENU_TEXT and the static module function getPlugin1DInstance according to the defined plugin.
These plugins will be compatible with any 1D-plot window that implements the Plot1D interface. The plot window interface is described in the Plot1DBase class.
The main items are reproduced here and can be directly accessed as plugin methods.
- addCurve
- getActiveCurve
- getAllCurves
- getGraphXLimits
- getGraphYLimits
- getGraphTitle
- getGraphXLabel
- getGraphXTitle
- getGraphYLabel
- getGraphYTitle
- removeCurve
- setActiveCurve
- setGraphTitle
- setGraphXLimits
- setGraphYLimits
- setGraphXLabel
- setGraphYLabel
- setGraphXTitle
- setGraphYTitle
A simple plugin example, normalizing each curve to its maximum and vertically shifting the curves.
from PyMca5 import Plugin1DBase
class Shifting(Plugin1DBase.Plugin1DBase):
def getMethods(self, plottype=None):
return ["Shift"]
def getMethodToolTip(self, methodName):
if methodName != "Shift":
raise InvalidArgument("Method %s not valid" % methodName)
return "Subtract minimum and shift up by 100"
def applyMethod(self, methodName):
if methodName != "Shift":
raise InvalidArgument("Method %s not valid" % methodName)
allCurves = self.getAllCurves()
increment = 0.1
for i in range(len(allCurves)):
x, y, legend, info = allCurves[i][:4]
delta = float(y.max() - y.min())
if delta < 1.0e-15:
delta = 1.0
y = (y - y.min())/delta + i * increment
if i == len(allCurves):
replot = True
else:
replot = False
if i == 0:
replace = True
else:
replace = False
self.addCurve(x, y, legend=legend + " %.2f" % (i * increment),
info=info, replace=replace, replot=replot)
MENU_TEXT="Simple Shift Example"
def getPlugin1DInstance(plotWindow, **kw):
ob = Shifting(plotWindow)
return ob
-
class
PyMca5.PyMcaCore.Plugin1DBase.
Plugin1DBase
(plotWindow, **kw)[source]¶ Bases:
object
-
addCurve
(x, y, legend=None, info=None, replace=False, replot=True, **kw)[source]¶ Add the 1D curve given by x an y to the graph.
Parameters: - x (list or numpy.ndarray) – The data corresponding to the x axis
- y (list or numpy.ndarray) – The data corresponding to the y axis
- legend (string or None) – The legend to be associated to the curve
- info (dict or None) – Dictionary of information associated to the curve
- replace (boolean default False) – Flag to indicate if already existing curves are to be deleted
- replot (boolean default True) – Flag to indicate plot is to be immediately updated
- **kw –
Additional keywords recognized by the plot window
-
getActiveCurve
(just_legend=False)[source]¶ Parameters: just_legend (boolean) – Flag to specify the type of output required Returns: legend of the active curve or list [x, y, legend, info] Return type: string or list Function to access the graph currently active curve. It returns None in case of not having an active curve.
- Default output has the form:
- xvalues, yvalues, legend, dict where dict is a dictionnary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel.
- If just_legend is True:
- The legend of the active curve (or None) is returned.
-
getAllCurves
(just_legend=False)[source]¶ Parameters: just_legend (boolean) – Flag to specify the type of output required Returns: legend of the curves or list [[x, y, legend, info], ...] Return type: list of strings or list of curves It returns an empty list in case of not having any curve. If just_legend is False:
- It returns a list of the form:
- [[xvalues0, yvalues0, legend0, dict0],
- [xvalues1, yvalues1, legend1, dict1], [...], [xvaluesn, yvaluesn, legendn, dictn]]
or just an empty list.
- If just_legend is True:
- It returns a list of the form:
- [legend0, legend1, ..., legendn]
or just an empty list.
-
getGraphYLimits
()[source]¶ Get the graph Y (left) limits.
Returns: Two floats with the Y (left) axis limits
-
getMethodPixmap
(name)[source]¶ Parameters: name – The method for which a pixmap is asked Return type: QPixmap or None
-
getMethodToolTip
(name)[source]¶ Returns the help associated to the particular method name or None.
Parameters: name – The method for which a tooltip is asked Return type: string
-
getMethods
(plottype=None)[source]¶ Parameters: plottype – string or None for the case the plugin only support one type of plots. Implemented values “SCAN”, “MCA” or None Returns: A list with the NAMES associated to the callable methods that are applicable to the specified type plot. The list can be empty. Return type: list[string]
-
getMonotonicCurves
()[source]¶ Convenience method that calls getAllCurves and makes sure that all of the X values are strictly increasing.
Returns: It returns a list of the form: [[xvalues0, yvalues0, legend0, dict0], [xvalues1, yvalues1, legend1, dict1], [...], [xvaluesn, yvaluesn, legendn, dictn]]
-
removeCurve
(legend, replot=True)[source]¶ Remove the curve associated to the supplied legend from the graph. The graph will be updated if replot is true.
Parameters: - legend (string or None) – The legend associated to the curve to be deleted
- replot (boolean default True) – Flag to indicate plot is to be immediately updated
-
setActiveCurve
(legend)[source]¶ Funtion to request the plot window to set the curve with the specified legend as the active curve.
Parameters: legend (string) – The legend associated to the curve
-
setGraphXLimits
(xmin, xmax, replot=False)[source]¶ Set the graph X limits.
Parameters: - xmin (float) – minimum value of the axis
- xmax (float) – minimum value of the axis
- replot (boolean default False) – Flag to indicate plot is to be immediately updated
-
-
PyMca5.PyMcaCore.Plugin1DBase.
getPlugin1DInstance
(plotWindow, **kw)[source]¶ This function will be called by the plot window instantiating and calling the plugins. It passes itslef as first argument, but the default implementation of the base class only keeps a weak reference to prevent cirvular references.
PyMcaBatchBuildOutput
Module¶
PyMcaDirs
Module¶
PyMcaLogo
Module¶
PyMcaMatplotlibSave
Module¶
-
class
PyMca5.PyMcaCore.PyMcaMatplotlibSave.
PyMcaMatplotlibSave
(size=(7, 3.5), logx=False, logy=False, legends=True, bw=False)[source]¶ Bases:
matplotlib.backends.backend_agg.FigureCanvasAgg
-
class
PyMca5.PyMcaCore.PyMcaMatplotlibSave.
PyMcaMatplotlibSaveImage
(imageData=None, fileName=None, dpi=300, size=(5, 5), xaxis='off', yaxis='off', xlabel='', ylabel='', nxlabels=0, nylabels=0, colorbar=None, title='', interpolation='nearest', colormap=None, linlogcolormap='linear', origin='lower', contour='off', contourlabels='on', contourlabelformat='%.3f', contourlevels=10, contourlinewidth=10, xorigin=0.0, yorigin=0.0, xpixelsize=1.0, ypixelsize=1.0, xlimits=None, ylimits=None, vlimits=None, extent=None)[source]¶
SPSLayer
Module¶
-
class
PyMca5.PyMcaCore.SPSLayer.
SPSLayer
(refresh_interval=None, info={})[source]¶ Bases:
object
Specializes Data class to access Spec shared memory. Interface: Data class interface.
-
GetSourceInfo
(key=None)[source]¶ Returns information about the Spec version set by SetSource, to give application possibility to know about it before loading. Returns a dictionary with the keys “Size” (number of possible keys to this source) and “KeyList” (list of all available keys in this source). Each element in “KeyList” is an shared memory array name. If key is set as an array name, returns information about it.
-
LoadSource
(key_list='ALL', append=0, invalidate=1, row='ALL', col='ALL')[source]¶ Creates a given number of pages, getting data from the actual source (set by SetSource) Parameters: key_list: list of all keys to be read from source. It is a list of
string, shared memory array names, to be read from the file. It can be also one single string, if only one array is to be read.- append: If non-zero appends to the end of page list.
- Otherwise, initializes the page list
- invalidate: if non-zero performas an invalidade call after
- loading
row: If set to an integer, loads a single row (0-based indexed) col: If set to an integer, loads a single column (0-based indexed)
-
SpecFileDataSource
Module¶
-
class
PyMca5.PyMcaCore.SpecFileDataSource.
SpecFileDataSource
(nameInput)[source]¶ Bases:
object
-
Error
= 'SpecFileDataError'¶
-
getDataObject
(key, selection=None)[source]¶ Parameters: * key: key to be read from source. It is a string
using the following formats:- “s.o”: loads all counter values (s=scan number, o=order)
- if ScanType==SCAN: in a 2D array (mot*cnts)
- if ScanType==MESH: in a 3D array (mot1*mot2*cnts)
- if ScanType==MCA: single MCA in 1D array (0:channels)
- “s.o.n”: loads a single MCA in a 1D array (0:channels)
- if ScanType==NMCA: n is the MCA number from 1 to N
- if ScanType==SCAN+MCA: n is the scan point number (from 1)
- if ScanType==MESH+MCA: n is the scan point number (from 1)
- “s.o.p.n”: loads a single MCA in a 1D array (0:channels)
- if ScanType==SCAN+NMCA:
p is the point number in the scan n is the MCA device number
- if ScanType==MESH+MCA:
p is first motor index n is second motor index
- “s.o.MCA”: loads all MCA in an array
if ScanType==SCAN+MCA: 2D array (pts*mca)
if ScanType==NMCA: 2D array (mca_det*mca)
if ScanType==MESH+MCA: 3D array (pts_mot1*pts_mot2*mca)
if ScanType==SCAN+NMCA: 3D array (pts_mot1*mca_det*mca)
- if ScanType==MESH+NMCA:
creates N data page, one for each MCA device, with a 3D array (pts_mot1*pts_mot2*mca)
-
getSourceInfo
()[source]¶ Returns information about the specfile object created by the constructor to give application possibility to know about it before loading. Returns a dictionary with the key “KeyList” (list of all available keys in this source). Each element in “KeyList” has the form ‘n1.n2’ where n1 is the scan number and n2 the order number in file starting at 1.
-
SpecFileLayer
Module¶
-
class
PyMca5.PyMcaCore.SpecFileLayer.
SpecFileLayer
(refresh_interval=None, info={})[source]¶ Bases:
object
Specializes Data class to access Spec files. Interface: Data class interface.
-
Error
= 'SpecFileDataError'¶
-
GetSourceInfo
(key=None)[source]¶ Returns information about the Specfile object created by SetSource, to give application possibility to know about it before loading. Returns a dictionary with the keys “Size” (number of possible keys(to this source) and “KeyList” (list of all available keys in this source). Each element in “KeyList” is an string in the format “x.y” where x is the number of scan and y is the order. “x.y” works as the key to retrieve the information of this scan. There’s also the key “NumMca” in the returned dictionary, which value is a list of numbers of mcas, for each value of “KeyList”. If key given returns information of a perticular key instead.
-
LoadSource
(key_list='ALL', append=0, invalidate=1)[source]¶ Creates a given number of pages, getting data from the actual source (set by SetSource). Parameters: * key_list: list of all keys to be read from source. It is a list of strings
using the following formats:- “ALL”: creates one data page for each scan.
- valid for ScanType==SCAN or MESH or MCA
- “s.o”: loads all counter values (s=scan number, o=order)
- if ScanType==SCAN: in a 2D array (mot*cnts)
- if ScanType==MESH: in a 3D array (mot1*mot2*cnts)
- if ScanType==MCA: single MCA in 1D array (0:channels)
- “s.o.n”: loads a single MCA in a 1D array (0:channels)
- if ScanType==NMCA: n is the MCA number from 1 to N
- if ScanType==SCAN+MCA: n is the scan point number (from 1)
- if ScanType==MESH+MCA: n is the scan point number (from 1)
- “s.o.p.n”: loads a single MCA in a 1D array (0:channels)
- if ScanType==SCAN+NMCA:
p is the point number in the scan n is the MCA device number
NOT TRUE: Just follow previous. if ScanType==MESH+MCA:
p is first motor index n is second motor index
- “s.o.MCA”: loads all MCA in an array
if ScanType==SCAN+MCA: 2D array (pts*mca)
if ScanType==NMCA: 2D array (mca_det*mca)
if ScanType==MESH+MCA: 3D array (pts_mot1*pts_mot2*mca)
if ScanType==SCAN+NMCA: 3D array (pts_mot1*mca_det*mca)
- if ScanType==MESH+NMCA:
creates N data page, one for each MCA device, with a 3D array (pts_mot1*pts_mot2*mca)
- append: if non-zero, appends to the end of the page list,
Otherwise, initializes the page list
invalidate: if non-zero performs an invalidade call after loading
-
SpsDataSource
Module¶
-
PyMca5.PyMcaCore.SpsDataSource.
DataSource
(name='', object=None, copy=True, source_type='SPS')[source]¶
-
class
PyMca5.PyMcaCore.SpsDataSource.
SpsDataSource
(name)[source]¶ Bases:
object
StackBase
Module¶
-
class
PyMca5.PyMcaCore.StackBase.
StackBase
[source]¶ Bases:
object
-
addCurve
(x, y, legend=None, info=None, replace=False, replot=True)[source]¶ Add the 1D curve given by x an y to the graph.
-
addImage
(image, name, info=None, replace=False, replot=True)[source]¶ Add image data to the RGB correlator
-
getActiveCurve
()[source]¶ Function to access the currently active curve. It returns None in case of not having an active curve.
- Default output has the form:
- xvalues, yvalues, legend, dict where dict is a dictionnary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel.
- If just_legend is True:
- The legend of the active curve (or None) is returned.
-
getPlugins
()[source]¶ Import or reloads all the available plugins. It returns the number of plugins loaded.
-
isStackFinite
()[source]¶ Returns True if stack does not contain inf or nans Returns False if stack is not finite
-
StackPluginBase
Module¶
A Stack plugin is a module that will be automatically added to the PyMca stack windows in order to perform user defined operations on the data stack. It has to inherit the StackPluginBase.StackPluginBase class and implement the methods:
- getMethods
- getMethodToolTip (optional but convenient)
- getMethodPixmap (optional)
- applyMethod
and modify the static module variable MENU_TEXT and the static module function getStackPluginInstance according to the defined plugin.
These plugins will be compatible with any stack window that provides the functions:
#data related
- getStackDataObject
- getStackData
- getStackInfo
- setStack
- getStackROIImagesAndNames
- isStackFinite
#mask related
- setStackSelectionMask
- getStackSelectionMask
#displayed curves
- getActiveCurve
- getGraphXLimits
- getGraphYLimits
#images
- addImage
- removeImage
- replaceImage
#information method
- stackUpdated
- selectionMaskUpdated
-
class
PyMca5.PyMcaCore.StackPluginBase.
StackPluginBase
(stackWindow, **kw)[source]¶ Bases:
object
-
getActiveCurve
()[source]¶ Function to access the currently active curve. It returns None in case of not having an active curve.
- Output has the form:
- xvalues, yvalues, legend, dict where dict is a dictionnary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel.
-
XiaCorrect
Module¶
-
PyMca5.PyMcaCore.XiaCorrect.
correctFiles
(xiafiles, deadtime=1, livetime=0, sums=None, avgflag=0, outdir=None, outname='corr', force=0, verbose=0, log_cb=None, done_cb=None, error_cb=None)[source]¶