FloatDataArray#

class pyopenms.FloatDataArray#

Bases: object

Cython implementation of _FloatDataArray

Original C++ documentation is available here

– Inherits from [‘MetaInfoDescription’]

The representation of extra float data attached to a spectrum or chromatogram. Raw data access is proved by get_peaks and set_peaks, which yields numpy arrays

__init__()#

Overload:

__init__(self) None

Overload:

__init__(self, in_0: FloatDataArray) None

Methods

__init__

clear(self)

clearMetaInfo(self)

Removes all meta values

getDataProcessing(self)

Returns a reference to the description of the applied processing

getKeys(self, keys)

Fills the given vector with a list of all keys for which a value is set

getMetaValue(self, in_0)

Returns the value corresponding to a string, or

getName(self)

Returns the name of the peak annotations

get_data

Gets a copy of the data as a numpy array (safe).

get_data_mv

Gets the raw data for the float data array as a memory view (no copy).

isMetaEmpty(self)

Returns if the MetaInfo is empty

metaRegistry(self)

Returns a reference to the MetaInfoRegistry

metaValueExists(self, in_0)

Returns whether an entry with the given name exists

push_back(self, in_0)

removeMetaValue(self, in_0)

Removes the DataValue corresponding to name if it exists

reserve(self, n)

resize(self, n)

setDataProcessing(self, in_0)

Sets the description of the applied processing

setMetaValue(self, in_0, in_1)

Sets the DataValue corresponding to a name

setName(self, name)

Sets the name of the peak annotations

set_data

Sets the raw data for the float data array

size(self)

clear(self) None#
clearMetaInfo(self) None#

Removes all meta values

getDataProcessing(self) List[DataProcessing]#

Returns a reference to the description of the applied processing

getKeys(self, keys: List[bytes]) None#

Fills the given vector with a list of all keys for which a value is set

getMetaValue(self, in_0: bytes | str | String) int | float | bytes | str | List[int] | List[float] | List[bytes]#

Returns the value corresponding to a string, or

getName(self) bytes | str | String#

Returns the name of the peak annotations

get_data()#

Gets a copy of the data as a numpy array (safe).

This method creates a copy of the underlying data, so it’s safe to use even after the original FloatDataArray object is deleted or modified.

Returns:

np.ndarray: A numpy array (float32) containing a copy of the data.

Example usage:

fd = pyopenms.FloatDataArray()
fd.push_back(1.0)
fd.push_back(2.0)
data = fd.get_data()  # Safe copy
del fd  # Original can be deleted, data is still valid
print(data)  # [1.0, 2.0]
get_data_mv()#

Gets the raw data for the float data array as a memory view (no copy).

This method provides direct access to the underlying data without copying, which is more memory efficient for large datasets.

Warning

This returns a fast but unsafe view on the underlying vector data. Make sure that the object you are getting the data from survives the usage of this view! Specifically, do NOT use it like this: data = spectrum.getFloatDataArrays()[0].get_data_mv() since the underlying FloatDataArray is temporary for this line and will most likely be garbage collected right after that line.

For safe access, use get_data() instead.

Returns:
np.ndarray: A numpy array that is a view of the underlying data.

Returns None if no data present.

Example usage:

fd = pyopenms.FloatDataArray()
fd.push_back(1.0)
fd.push_back(2.0)
data = fd.get_data_mv()  # Memory view - changes affect original
isMetaEmpty(self) bool#

Returns if the MetaInfo is empty

metaRegistry(self) MetaInfoRegistry#

Returns a reference to the MetaInfoRegistry

metaValueExists(self, in_0: bytes | str | String) bool#

Returns whether an entry with the given name exists

push_back(self, in_0: float) None#
removeMetaValue(self, in_0: bytes | str | String) None#

Removes the DataValue corresponding to name if it exists

reserve(self, n: int) None#
resize(self, n: int) None#
setDataProcessing(self, in_0: List[DataProcessing]) None#

Sets the description of the applied processing

setMetaValue(self, in_0: bytes | str | String, in_1: int | float | bytes | str | List[int] | List[float] | List[bytes]) None#

Sets the DataValue corresponding to a name

setName(self, name: bytes | str | String) None#

Sets the name of the peak annotations

set_data()#

Sets the raw data for the float data array

Example usage:

fd = pyopenms.FloatDataArray() data = numpy.array( [1, 2, 3, 5 ,6] ).astype(numpy.float32) fd.set_data(data)

size(self) int#