pint.pint_matrix.DesignMatrix
- class pint.pint_matrix.DesignMatrix(matrix, labels)[source]
Bases:
PintMatrix
A generic design matrix class for least square fitting.
- Parameters:
matrix (numpy.ndarray) – Design matrix values.
axis_labels (list of dictionary) – The labels of the axes. Each list element contains the names and indices of the labels for the dimension. [{dim0_label0: (start, end, unit), dim0_label1:(start, end, unit)},{dim1_label0:…}] The start and end follows the python slice convention (i.e., end = size + 1).
Note
Design matrix dim1 is the derivative quantities. Design matrix dim2 is the derivative parameters. TODO: 1. add index to unit mapping.
Methods
append_along_axis
(pint_matrix, axis)Append one pint matrix on a given axis.
diag
([k])Extract a diagonal.
get_axis_labels
(axis)Get the axis labels for the specified axis
get_label
(label[, axis])Get the label entry and its dimension.
get_label_along_axis
(axis, label_name)Get the request label from on axis.
get_label_matrix
(labels)Get a sub-matrix data according to the given labels.
get_label_names
([axis])Return only the names of the labels along the specified axis if requested.
get_label_size
(label[, axis])Get the size of the a label for all axes, or just the specified axis.
get_label_slice
(labels)Return the given label slices.
Return all unique label names (there may be duplications between axes).
map_labels
()match_labels_along_axis
(pint_matrix, axis)Match one axis' labels index between the current matrix and input pint matrix.
Attributes
derivative_params
derivative_quantity
label_units
labels
ndim
param_units
shape
- append_along_axis(pint_matrix, axis)
Append one pint matrix on a given axis.
- diag(k=0)
Extract a diagonal.
- Parameters:
k (int (optional)) – Diagonal in question. The default is 0. Use k>0 for diagonals above the main diagonal, and k<0 for diagonals below the main diagonal.
- Returns:
out – The extracted diagonal.
- Return type:
ndarray
- get_axis_labels(axis)
Get the axis labels for the specified axis
- get_label(label, axis=None)
Get the label entry and its dimension. If axis is specified, will only be along that axis
- get_label_along_axis(axis, label_name)
Get the request label from on axis.
DEPRECATED - use get_label(…, axis=axis)
- get_label_matrix(labels)
Get a sub-matrix data according to the given labels.
- get_label_names(axis=None)
Return only the names of the labels along the specified axis if requested.
- get_label_size(label, axis=None)
Get the size of the a label for all axes, or just the specified axis.
- get_label_slice(labels)
Return the given label slices.
- get_unique_label_names()
Return all unique label names (there may be duplications between axes).
- Returns:
labels (set of unique label names across all dimensions)
TODO (preserve order?)
- match_labels_along_axis(pint_matrix, axis)
Match one axis’ labels index between the current matrix and input pint matrix.
The labels will be matched along axes, not cross the axes.
- Parameters:
pint_matrix (PintMatrix object or its sub-classes.) – The input pint matrix for label matching.
axis (int) – The matching axis.
- Returns:
Index map between the current labels and input matrix labels along
axis.