Storable Data Types¶
- class larcv.Particle¶
A Particle represents an abstract label more relevant to experimental data. Typically created from simulation data, there are fields to hold a variety of per-particle information as well as reconstructing hierarchy information.
Technically, for storage reasons, there is an underlying “ParticleHolder” that stores the data in a contiguous memory region with appropriate data types. You can access this object directly by calling
as_array
and get anumpy
structured array data object.- ancestor_pdg_code(*args, **kwargs)¶
Overloaded function.
ancestor_pdg_code(self: larcv.pylarcv.Particle) -> int
Get the value of ancestor_pdg_code for this particle.
ancestor_pdg_code(self: larcv.pylarcv.Particle, ancestor_pdg_code: int) -> None
Set the value of
ancestor_pdg_code
for this particle.
- ancestor_position(*args, **kwargs)¶
Overloaded function.
ancestor_position(self: larcv.pylarcv.Particle) -> larcv.pylarcv.Vertex
Return the ancestor position of this particle.
ancestor_position(self: larcv.pylarcv.Particle, vertex: larcv.pylarcv.Vertex) -> None
Set the ancestor position of this particle.
ancestor_position(self: larcv.pylarcv.Particle, x: float, y: float, z: float, t: float) -> None
Set the ancestor position of this particle.
- ancestor_t(self: larcv.pylarcv.Particle) float ¶
Get the ancestor_t of this particle.
- ancestor_track_id(*args, **kwargs)¶
Overloaded function.
ancestor_track_id(self: larcv.pylarcv.Particle) -> int
Get the value of ancestor_track_id for this particle.
ancestor_track_id(self: larcv.pylarcv.Particle, ancestor_track_id: int) -> None
Set the value of
ancestor_track_id
for this particle.
- ancestor_x(self: larcv.pylarcv.Particle) float ¶
Get the ancestor_x of this particle.
- ancestor_y(self: larcv.pylarcv.Particle) float ¶
Get the ancestor_y of this particle.
- ancestor_z(self: larcv.pylarcv.Particle) float ¶
Get the ancestor_z of this particle.
- as_array(self: larcv.pylarcv.Particle) numpy.ndarray[larcv3::ParticleHolder] ¶
Return the underlying
ParticleHolder
object of this particle as anumpy
structured array.
- creation_process(*args, **kwargs)¶
Overloaded function.
creation_process(self: larcv.pylarcv.Particle) -> str
Get the value of creation_process for this particle.
creation_process(self: larcv.pylarcv.Particle, creation_process: str) -> None
Set the value of
creation_process
for this particle.
- distance_travel(*args, **kwargs)¶
Overloaded function.
distance_travel(self: larcv.pylarcv.Particle) -> float
Get the value of distance_travel for this particle.
distance_travel(self: larcv.pylarcv.Particle, distance_travel: float) -> None
Set the value of
distance_travel
for this particle.
- dump(self: larcv.pylarcv.Particle) str ¶
Return a string representation for this particle.
- end_position(*args, **kwargs)¶
Overloaded function.
end_position(self: larcv.pylarcv.Particle) -> larcv.pylarcv.Vertex
Get the value of end_position for this particle.
end_position(self: larcv.pylarcv.Particle, end_position: larcv.pylarcv.Vertex) -> None
Set the value of end_position with a
Vertex
object.end_position(self: larcv.pylarcv.Particle, x: float, y: float, z: float, t: float) -> None
Set the value of end_position with
x
,y
,z
, andt
.
- energy_deposit(*args, **kwargs)¶
Overloaded function.
energy_deposit(self: larcv.pylarcv.Particle) -> float
Get the value of energy_deposit for this particle.
energy_deposit(self: larcv.pylarcv.Particle, energy_deposit: float) -> None
Set the value of
energy_deposit
for this particle.
- energy_init(*args, **kwargs)¶
Overloaded function.
energy_init(self: larcv.pylarcv.Particle) -> float
Get the value of energy_init for this particle.
energy_init(self: larcv.pylarcv.Particle, energy_init: float) -> None
Set the value of
energy_init
for this particle.
- first_step(*args, **kwargs)¶
Overloaded function.
first_step(self: larcv.pylarcv.Particle) -> larcv.pylarcv.Vertex
Get the value of first_step for this particle.
first_step(self: larcv.pylarcv.Particle, first_step: larcv.pylarcv.Vertex) -> None
Set the value of first_step with a
Vertex
object.first_step(self: larcv.pylarcv.Particle, x: float, y: float, z: float, t: float) -> None
Set the value of first_step with
x
,y
,z
, andt
.
- id(*args, **kwargs)¶
Overloaded function.
id(self: larcv.pylarcv.Particle) -> int
Get the id for this particle.
id(self: larcv.pylarcv.Particle, id: int) -> None
Set the
id
for this particle.
- last_step(*args, **kwargs)¶
Overloaded function.
last_step(self: larcv.pylarcv.Particle) -> larcv.pylarcv.Vertex
Get the value of last_step for this particle.
last_step(self: larcv.pylarcv.Particle, last_step: larcv.pylarcv.Vertex) -> None
Set the value of last_step with a
Vertex
object.last_step(self: larcv.pylarcv.Particle, x: float, y: float, z: float, t: float) -> None
Set the value of last_step with
x
,y
,z
, andt
.
- mcst_index(*args, **kwargs)¶
Overloaded function.
mcst_index(self: larcv.pylarcv.Particle) -> int
Get the mcst_index for this particle.
mcst_index(self: larcv.pylarcv.Particle, mcst_index: int) -> None
Set the
mcst_index
for this particle.
- mct_index(*args, **kwargs)¶
Overloaded function.
mct_index(self: larcv.pylarcv.Particle) -> int
Get the mct_index for this particle.
mct_index(self: larcv.pylarcv.Particle, mct_index: int) -> None
Set the
mct_index
for this particle.
- momentum(self: larcv.pylarcv.Particle, arg0: float, arg1: float, arg2: float) None ¶
Get the momentum of this particle.
- nu_current_type(*args, **kwargs)¶
Overloaded function.
nu_current_type(self: larcv.pylarcv.Particle) -> int
Get the nu_current_type for this particle.
nu_current_type(self: larcv.pylarcv.Particle, nu_current_type: int) -> None
Set the
nu_current_type
for this particle.
- nu_interaction_type(*args, **kwargs)¶
Overloaded function.
nu_interaction_type(self: larcv.pylarcv.Particle) -> int
Get the nu_interaction_type for this particle.
nu_interaction_type(self: larcv.pylarcv.Particle, nu_interaction_type: int) -> None
Set the
nu_interaction_type
for this particle.
- p(self: larcv.pylarcv.Particle) float ¶
Get the p of this particle.
- parent_pdg_code(*args, **kwargs)¶
Overloaded function.
parent_pdg_code(self: larcv.pylarcv.Particle) -> int
Get the value of parent_pdg_code for this particle.
parent_pdg_code(self: larcv.pylarcv.Particle, parent_pdg_code: int) -> None
Set the value of
parent_pdg_code
for this particle.
- parent_position(*args, **kwargs)¶
Overloaded function.
parent_position(self: larcv.pylarcv.Particle) -> larcv.pylarcv.Vertex
Get the value of parent_position for this particle.
parent_position(self: larcv.pylarcv.Particle, parent_position: larcv.pylarcv.Vertex) -> None
Set the value of
parent_position
for this particle.parent_position(self: larcv.pylarcv.Particle, x: float, y: float, z: float, t: float) -> None
Set the value of parent_position with
x
,y
,z
, andt
.
- parent_t(self: larcv.pylarcv.Particle) float ¶
Get the parent_t of this particle.
- parent_track_id(*args, **kwargs)¶
Overloaded function.
parent_track_id(self: larcv.pylarcv.Particle) -> int
Get the value of parent_track_id for this particle.
parent_track_id(self: larcv.pylarcv.Particle, parent_track_id: int) -> None
Set the value of
parent_track_id
for this particle.
- parent_x(self: larcv.pylarcv.Particle) float ¶
Get the parent_x of this particle.
- parent_y(self: larcv.pylarcv.Particle) float ¶
Get the parent_y of this particle.
- parent_z(self: larcv.pylarcv.Particle) float ¶
Get the parent_z of this particle.
- pdg_code(*args, **kwargs)¶
Overloaded function.
pdg_code(self: larcv.pylarcv.Particle) -> int
Get the pdg_code for this particle.
pdg_code(self: larcv.pylarcv.Particle, pdg_code: int) -> None
Set the
pdg_code
for this particle.
- position(*args, **kwargs)¶
Overloaded function.
position(self: larcv.pylarcv.Particle) -> larcv.pylarcv.Vertex
position(self: larcv.pylarcv.Particle, vertex: larcv.pylarcv.Vertex) -> None
Set the position of the particle with a
Vertex
object.position(self: larcv.pylarcv.Particle, x: float, y: float, z: float, t: float) -> None
Set the position of the particle with
x
,y
,z
,t
object.
- px(self: larcv.pylarcv.Particle) float ¶
Get the px of this particle.
- py(self: larcv.pylarcv.Particle) float ¶
Get the py of this particle.
- pz(self: larcv.pylarcv.Particle) float ¶
Get the pz of this particle.
- shape(*args, **kwargs)¶
Overloaded function.
shape(self: larcv.pylarcv.Particle) -> larcv3::ShapeType_t
Get the shape for this particle.
shape(self: larcv.pylarcv.Particle, shape: larcv3::ShapeType_t) -> None
Set the
shape
for this particle.
- t(self: larcv.pylarcv.Particle) float ¶
Get the t of this particle.
- track_id(*args, **kwargs)¶
Overloaded function.
track_id(self: larcv.pylarcv.Particle) -> int
Get the track_id for this particle.
track_id(self: larcv.pylarcv.Particle, track_id: int) -> None
Set the
track_id
for this particle.
- x(self: larcv.pylarcv.Particle) float ¶
Get the x of this particle.
- y(self: larcv.pylarcv.Particle) float ¶
Get the y of this particle.
- z(self: larcv.pylarcv.Particle) float ¶
Get the z of this particle.
Bounding Boxes are available in 2D and 3D. Only the 2D api is shown here for brevity, but the function calls are identical in 3D.
- class larcv.BBox2D¶
Represents a bounding box in N dimensions, defined by a centroid and half_length in each axis from the centroid. The rotation component is currently not used but provided in the data store implementation for future use. Used to represent, for example, the location of a particle interaction, a bounding box for an instance of an object, etc.
- centroid(self: larcv.pylarcv.BBox2D) List[float[2]] ¶
Get the value of the centroid.
- dump(self: larcv.pylarcv.BBox2D) str ¶
Return a string representation of the BBox
- half_length(self: larcv.pylarcv.BBox2D) List[float[2]] ¶
Get the value of the half_length.
- identity_rotation(self: larcv.pylarcv.BBox2D) List[float[4]] ¶
Get the value of the identity rotation.
- rotation_matrix(self: larcv.pylarcv.BBox2D) List[float[4]] ¶
Get the value of the rotation matrix.
(Dense) Tensors are available in 1D, 2D, 3D and 4D. Only the 2D api is shown here for brevity, but the function calls are identical in other dimensions.
- class larcv.Tensor2D¶
A Tensor is a densely stored, memory-contiguous representation of image-like data. Tensors have ImageMeta associated to them to provide external context for the image. In this case, the coordinates of a pixel (X/Y/Z …) map to a 1D index through the ImageMeta interface, and are identical to the indexing required in various array interfaces.
For example, a set of coordinates in 2D (for example) x and y might map to an index through the ImageMeta object. In that case, the following techniques should provide identical data:
>>> # Access directly: >>> tensor.pixel((x,y)) # use the pixel method of the tensor.
>>> # Same as numpy: >>> tensor.as_array[x][y] # convert this tensor to numpy and access with numpy's array indexing.
>>> # Using indexes: >>> index = tensor.meta().index((x,y)) # get the index from the image meta >>> tensor.pixel(index) # access the pixel via the index
>>> # Using numpy methods: >>> dims = tensor.meta.number_of_voxels() >>> index = numpy.ravel_multi_index((x,y), dims) >>> tensor.pixel(index) # use numpy constructed index to get the data directly
The availablitity of both interfaces is to serve as a bridge between
numpy.ndarray
and SparseTensors, which have only theindex
-style access (through Voxel IDs).- as_array(self: larcv.pylarcv.Tensor2D) numpy.ndarray[numpy.float32] ¶
Return the numpy view of this tensor.
- as_vector(self: larcv.pylarcv.Tensor2D) List[float] ¶
Get the single-dimensioned array of memory-contiguous data.
- binarize(self: larcv.pylarcv.Tensor2D, threshold: float, lower: float, upper: float) None ¶
Replace all pixels with either the
lower
orupper
value, based onthreshold
.
- clear_data(self: larcv.pylarcv.Tensor2D) None ¶
Set the image data to 0.
- compress(*args, **kwargs)¶
Overloaded function.
compress(self: larcv.pylarcv.Tensor2D, compression: List[int[2]], pooltype: larcv.pylarcv.PoolType_t) -> larcv.pylarcv.Tensor2D
Return a new tensor that is compressed/downsampled according to the PoolType, with
compression
unique per axis.compress(self: larcv.pylarcv.Tensor2D, compression: int, pool_type: larcv.pylarcv.PoolType_t) -> larcv.pylarcv.Tensor2D
Return a new tensor that is compressed/downsampled equally along all axes.
- eltwise(*args, **kwargs)¶
Overloaded function.
eltwise(self: larcv.pylarcv.Tensor2D, other: larcv.pylarcv.Tensor2D) -> None
Element wise multiplication with another array. Equivalent to dot product in 1D.
eltwise(self: larcv.pylarcv.Tensor2D, other: List[float], allow_longer: bool = False) -> None
Element wise multiplication with another array. Equivalent to dot product in 1D.
- meta(self: larcv.pylarcv.Tensor2D) larcv.pylarcv.ImageMeta2D ¶
Get the meta of this tensor.
- paint(self: larcv.pylarcv.Tensor2D, value: float) None ¶
Set ALL pixels to the specified
value
.
- pixel(*args, **kwargs)¶
Overloaded function.
pixel(self: larcv.pylarcv.Tensor2D, coordinates: List[int]) -> float
Access a pixel via a list of coordinates.
pixel(self: larcv.pylarcv.Tensor2D, index: int) -> float
Access the pixel at a specified index.
- reset(self: larcv.pylarcv.Tensor2D, arg0: larcv.pylarcv.ImageMeta2D) None ¶
Reset the Tensor to an empty state.
- set_pixel(*args, **kwargs)¶
Overloaded function.
set_pixel(self: larcv.pylarcv.Tensor2D, coordinates: List[int], value: float) -> None
Set an individual pixel’s
value
atcoordinates
.set_pixel(self: larcv.pylarcv.Tensor2D, index: int, value: float) -> None
Set an individual pixel’s
value
atindex
.
- set_projection_id(self: larcv.pylarcv.Tensor2D, id: int) None ¶
Set the projection id of the meta for this tensor to
id
.
- size(self: larcv.pylarcv.Tensor2D) int ¶
Return the total number of points in the data array.
- threshold(self: larcv.pylarcv.Tensor2D, threshold: float, lower: bool = True) None ¶
If
lower
is true, this is minimum threshold. Otherwise, this is a maximum threshold.
Sparse Tensors are available in 2D and 3D. Only the 2D api is shown here for brevity, but the function calls are identical in 3D.
- class larcv.SparseTensor2D¶
A SparseTensor is a VoxelSet + an ImageMeta to map voxel ids to spatial locations. Available in 2D and 3D.
SparseTensor inherits from VoxelSet and has an ImageMeta attribute, so any methods available in VoxelSet to manipulate the voxels are available here.
This can be used for storing sparse image data, in 2D or 3D, include segmentation labels.
- clear_data(self: larcv.pylarcv.SparseTensor2D) None ¶
Clear all voxels and reset the ImageMeta.
- compress(*args, **kwargs)¶
Overloaded function.
compress(self: larcv.pylarcv.SparseTensor2D, compression: List[int[2]], pooltype: larcv.pylarcv.PoolType_t) -> larcv.pylarcv.SparseTensor2D
Return a new sparse tensor that is compressed/downsampled according to the PoolType, with
compression
unique per axis.compress(self: larcv.pylarcv.SparseTensor2D, compression: int, pooltype: larcv.pylarcv.PoolType_t) -> larcv.pylarcv.SparseTensor2D
Return a new sparse tensor that is compressed/downsampled equally along all axes.
- dense(self: larcv.pylarcv.SparseTensor2D) numpy.ndarray[numpy.float32] ¶
Convert this data to a dense representation and return as a
numpy.ndarray
.
- emplace(self: larcv.pylarcv.SparseTensor2D, arg0: larcv.pylarcv.Voxel, arg1: bool) None ¶
Add a new voxel.
- meta(*args, **kwargs)¶
Overloaded function.
meta(self: larcv.pylarcv.SparseTensor2D) -> larcv.pylarcv.ImageMeta2D
Get the meta for this SparseTensor.
meta(self: larcv.pylarcv.SparseTensor2D, meta: larcv.pylarcv.ImageMeta2D, check: bool = True) -> None
Set the image meta, optionally check if it is valid (default
true
.
- set(self: larcv.pylarcv.SparseTensor2D, voxel_set: larcv.pylarcv.VoxelSet, meta: larcv.pylarcv.ImageMeta2D) None ¶
Set the
voxel_set
and themeta
simultaneously.
- to_tensor(self: larcv.pylarcv.SparseTensor2D) larcv.pylarcv.Tensor2D ¶
Return the data in this SparseTensor as a corresponding dense Tensor.
Sparse Clusters are available in 2D and 3D. Only the 2D api is shown here for brevity, but the function calls are identical in 3D.
- class larcv.SparseCluster2D¶
A SparseCluster is a VoxelSetArray + an ImageMeta to map voxel ids to spatial locations. Available in 2D and 3D.
SparseCluster inherits from VoxelSetArray and has an ImageMeta attribute, so any methods available in VoxelSetArray to manipulate the voxels are available here.
In a way, SparseCluster is aset of SparseTensors that all share an ImageMeta. This can be used for instance segmentation labels in particular.
- clear_data(self: larcv.pylarcv.SparseCluster2D) None ¶
Clear all data
- meta(*args, **kwargs)¶
Overloaded function.
meta(self: larcv.pylarcv.SparseCluster2D) -> larcv.pylarcv.ImageMeta2D
Get the meta
meta(self: larcv.pylarcv.SparseCluster2D, arg0: larcv.pylarcv.ImageMeta2D) -> None
Set the meta