OriginPro
 
Loading...
Searching...
No Matches
originpro.matrix.MSheet Class Reference
Inheritance diagram for originpro.matrix.MSheet:
originpro.base.DSheet originpro.base.BaseLayer originpro.base.BaseObject

Public Member Functions

 get_book (self)
 
 depth (self)
 
 depth (self, z)
 
 from_np (self, arr, dstack=False, mv=None)
 
 to_np2d (self, index=0, order='C')
 
 from_np2d (self, arr, index=0)
 
 to_np3d (self, dstack=False, order='C')
 
 show_image (self, show=True)
 
 show_thumbnails (self, show=True)
 
 show_slider (self, show=True)
 
 get_missing_value (self, index=0)
 
 xymap (self)
 
 xymap (self, xy)
 
 get_label (self, index, type_='L')
 
 get_labels (self, type_='L')
 
 set_label (self, index, val, type_='L')
 
 set_labels (self, labels, type_='L', offset=0)
 
 from_img (self, img)
 
- Public Member Functions inherited from originpro.base.DSheet
 __str__ (self)
 
 __repr__ (self)
 
 shape (self)
 
 shape (self, val)
 
 remove_DC (self)
 
 has_DC (self)
 
 from_file (self, fname, keep_DC=True, dctype='', sel='', sparks=False)
 
 lt_range (self, use_name=True)
 
 tabcolor (self)
 
 tabcolor (self, rgb)
 
- Public Member Functions inherited from originpro.base.BaseLayer
 activate (self)
 
 destroy (self)
 
 label (self, name)
 
 remove_label (self, label)
 
 add_label (self, text, x=None, y=None)
 
 add_line (self, x1, y1, x2, y2)
 
- Public Member Functions inherited from originpro.base.BaseObject
 __init__ (self, obj)
 
 __del__ (self)
 
 __bool__ (self)
 
 index (self)
 
 get_str (self, prop)
 
 get_int (self, prop)
 
 get_float (self, prop)
 
 set_str (self, prop, value)
 
 set_int (self, prop, value)
 
 set_float (self, prop, value)
 
 method_int (self, name, arg='')
 
 method_float (self, name, arg='')
 
 method_str (self, name, arg='')
 
 lt_exec (self, labtalk)
 
 name (self)
 
 name (self, value)
 
 lname (self)
 
 lname (self, value)
 
 comments (self)
 
 comments (self, value)
 
 show (self)
 
 show (self, value)
 
 usertree (self)
 
 usertree (self, tr)
 
 userprops (self)
 

Public Attributes

int depth = 1
 
 shape = row,col
 
- Public Attributes inherited from originpro.base.DSheet
 obj
 
- Public Attributes inherited from originpro.base.BaseLayer
 obj
 
- Public Attributes inherited from originpro.base.BaseObject
 obj = obj
 

Protected Member Functions

 _xyobj (self)
 
- Protected Member Functions inherited from originpro.base.DSheet
 _get_book (self)
 

Static Protected Member Functions

 _getlabel (mo, type_='L')
 
 _get_LT_label_name (type_)
 
 _setlabel (mo, val, type_='L')
 

Detailed Description

This class represents an Origin Matrix Sheet, it holds an instance of a PyOrigin MatrixSheet.

Member Function Documentation

◆ depth() [1/2]

originpro.matrix.MSheet.depth ( self)
Parameters:
    none
Returns:
    return the number of matrix objects in the matrix sheet
Examples:
    >>>ms = op.find_sheet('m')
    >>>ms.depth

◆ depth() [2/2]

originpro.matrix.MSheet.depth ( self,
z )
set the number of matrix objects in the matrix sheet
Parameters:
    z(int):number of matrix objects in the matrix sheet
Returns:
    number of matrix objects in the matrix sheet
Examples:
    ms=op.new_sheet('m', hidden=True)
    ms.depth = 100
    print(ms.depth)

◆ from_img()

originpro.matrix.MSheet.from_img ( self,
img )
Convert image to Matrix

Parameters:
    img(IPage): input image page
Returns:
    None
Examples:
    ms = op.find_sheet('m')
    img = op.find_image('Image1')
    ms.from_img(img)

◆ from_np()

originpro.matrix.MSheet.from_np ( self,
arr,
dstack = False,
mv = None )
Set a matrix sheet data from a multi-dimensional numpy array. Existing data and MatrixObjects will be deleted.

Parameters:
    arr (numpy array): 2D for a single MatrixObject, and 3D for multiple MatrixObjects (rows, cols, N)
    dstack (bool):   True if arr as row,col,depth, False if depth,row,col
    mv(float, int): if specified, to set the internal missing value for each MatrixObject. This is needed when arr contains nan and not double type
Returns:
    None

Examples:
    ms = op.new_sheet('m')
    arr = np.array([[[1, 2, 3], [4, 5, 6]], [[11, 12, 13], [14, 15, 16]]])
    ms.from_np(arr)

◆ from_np2d()

originpro.matrix.MSheet.from_np2d ( self,
arr,
index = 0 )
Transfers data from a numpy 2D array into a single MatrixObject.

Parameters:
    arr (numpy array) 2D
    index (int): MatrixObject index in the MatrixLayer

Returns:
    None

Examples:
    index = 0
    ms = op.find_sheet('m')         # a matrix must be active
    npdata = ms.to_np2d(index)      # get as numpy array the data from one matrix object
    npdata *= 10                    # multiply every element by 10
    ms.from_np2d(npdata, index)     # set the modified array into the matrix object

◆ get_book()

originpro.matrix.MSheet.get_book ( self)
Returns parent book of sheet.

Parameters:

Returns:
    (MBook)

Examples:
    mb = ma.get_book().add_sheet()

Reimplemented from originpro.base.DSheet.

◆ get_label()

originpro.matrix.MSheet.get_label ( self,
index,
type_ = 'L' )
Return a Matrix object label text.

Parameters:
    index (int ): Matrix object index or 'x', 'y' for sheet XY labels
    type_ (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name

Returns:
    (str)

Examples:
    ms=op.find_sheet('m')
    comment = ms.get_label('y','C')

◆ get_labels()

originpro.matrix.MSheet.get_labels ( self,
type_ = 'L' )
Return Matrix Objects label text.

Parameters:
    type_ (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name

Returns:
    (list)

Examples:
    ms=op.find_sheet('M')
    comments = ms.get_labels('C')

Reimplemented from originpro.base.DSheet.

◆ get_missing_value()

originpro.matrix.MSheet.get_missing_value ( self,
index = 0 )
get the internal missing value, which is needed when data type is not double.
Parameters:
    index(int): matrix object index
Returns:
    (float) missing value
Examples:
    ms=op.find_sheet('m')
    print(ms.get_missing_value())

◆ set_label()

originpro.matrix.MSheet.set_label ( self,
index,
val,
type_ = 'L' )
Set Matrix object label text.

Parameters:
    index (int): Matrix object index or 'x', 'y' for sheet XY labels
    val   (list): the text to set
    type_  (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name
Returns:
    none
Examples:
    ms=op.find_sheet('m')
    ms.set_label('y', 'Lattitude')

◆ set_labels()

originpro.matrix.MSheet.set_labels ( self,
labels,
type_ = 'L',
offset = 0 )
Set Matrix objects label text.

Parameters:
    labels (list): the text to set
    type_ (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name
Returns:
    none
Examples:
    ms=op.find_sheet('m')
    ms.set_labels(['long name for col A', 'long name for col B'], 'L')

Reimplemented from originpro.base.DSheet.

◆ show_image()

originpro.matrix.MSheet.show_image ( self,
show = True )
Show MatrixObjects as images or as numeric values.

Parameters:
    show (bool): If True, show as images

Returns:
    None

Examples:
    ms.show_image()
    ms.show_image(False)

◆ show_slider()

originpro.matrix.MSheet.show_slider ( self,
show = True )
Show image slider for MatrixObjects.

Parameters:
    show (bool): If True, show slider

Returns:
    None

Examples:
    mat.show_slider()
    mat.show_slider(False)

◆ show_thumbnails()

originpro.matrix.MSheet.show_thumbnails ( self,
show = True )
Show thumbnail images for a MatrixObjects.

Parameters:
    show (bool): If True, show thumbnails

Returns:
    None

Examples:
    ms.show_thumbnails()
    ms.show_thumbnails(False)

◆ to_np2d()

originpro.matrix.MSheet.to_np2d ( self,
index = 0,
order = 'C' )
Transfers data from a single MatrixObject to a numpy 2D array.

Parameters:
    index (int): MatrixObject index in the MatrixLayer
    order (str): Order of numpy array. 'C' for C-style row major order, 'F' for Fortran-style column major order

Returns:
    (numpy array) 2D

Examples:
    arr = ms.to_np2d(0)
    print(arr)
    arr = ms.to_np2d(0, 'R')
    print(arr)

◆ to_np3d()

originpro.matrix.MSheet.to_np3d ( self,
dstack = False,
order = 'C' )
Transfers data from a MatrixSheet to a numpy 3D array.

Parameters:
    dstack (bool): True output arrays as row,col,depth, False if depth,row,col
    order (str): Order of numpy array. 'C' for C-style row major order, 'F' for Fortran-style column major order

Returns:
    (numpy array) 3D

Examples:
    arr=[]
    for i in range(10):
        tmp = np.arange(1,13).reshape(3,4)
        arr.append(tmp*(i+1))
    aa = np.dstack(arr)
    print(aa.shape)
    ma = op.new_sheet('m')
    ma.from_np(aa, True)

    bb = ma.to_np3d()
    print(bb.shape)
    mb = op.new_sheet('m')
    mb.from_np(bb)

    cc = ma.to_np3d(True)
    print(cc.shape)
    mc = op.new_sheet('m')
    mc.from_np(cc)
    mc.show_thumbnails()

◆ xymap() [1/2]

originpro.matrix.MSheet.xymap ( self)
Get Matrix xy values.
Parameters:
    none
Returns:
    (list): x1, x2, y1, y2

Examples:
    ms=op.find_sheet('M')
    x1, x2, y1, y2 = ms.xymap

◆ xymap() [2/2]

originpro.matrix.MSheet.xymap ( self,
xy )
Set Matrix xy values.

Parameters:
    xy(list): x1, x2, y1, y2
Returns:
    (list): x1, x2, y1, y2
Examples:
    ms=op.find_sheet('M')
    ms.xymap = x1, x2, y1, y2

The documentation for this class was generated from the following file: