![]() |
Belle II Software development
|
Public Member Functions | |
__init__ (self, str listname, List[str] variables, str filename, Optional[str] hdf_table_name=None, int event_buffer_size=100, **writer_kwargs) | |
initialize (self) | |
buffer (self) | |
event_buffer (self) | |
clear_buffer (self) | |
append_buffer (self) | |
initialize_feather_writer (self) | |
initialize_parquet_writer (self) | |
initialize_csv_writer (self) | |
initialize_hdf5_writer (self) | |
fill_event_buffer (self) | |
buffer_full (self) | |
write_buffer (self) | |
event (self) | |
terminate (self) | |
Public Attributes | |
buffer = "hdf5": | |
buffer_full | |
Protected Attributes | |
_filename = filename | |
Output filename. | |
_listname = listname | |
Particle list name. | |
_variables = list(set(variables)) | |
List of variables. | |
str | _format = "csv" |
Output format. | |
tuple | _table_name |
Table name in the hdf5 file. | |
_event_buffer_size = event_buffer_size | |
Event buffer size. | |
int | _event_buffer_counter = 0 |
Event buffer counter. | |
_writer_kwargs = writer_kwargs | |
writer kwargs | |
list | _varnames |
variable names | |
_std_varnames = variables.std_vector(*self._varnames) | |
std.vector of variable names | |
_evtmeta = ROOT.Belle2.PyStoreObj("EventMetaData") | |
Event metadata. | |
_plist = ROOT.Belle2.PyStoreObj(self._listname) | |
Pointer to the particle list. | |
_dtypes = dtypes | |
The data type. | |
_buffer = np.empty(self._event_buffer_size * 10, dtype=self._dtypes) | |
event variables buffer (will be automatically grown if necessary) | |
int | _buffer_index = 0 |
current start index in the event variables buffer | |
list | _schema |
A list of tuples and py.DataTypes to define the pyarrow schema. | |
_feather_writer | |
a writer object to write data into a feather file | |
_parquet_writer | |
A list of tuples and py.DataTypes to define the pyarrow schema. | |
_csv_writer = CSVWriter(self._filename, schema=pa.schema(self._schema), **self._writer_kwargs) | |
A list of tuples and py.DataTypes to define the pyarrow schema. | |
_hdf5_writer | |
The pytable file. | |
_table | |
The pytable. | |
Base class to dump ntuples into a non root format of your choosing
Definition at line 38 of file b2pandas_utils.py.
__init__ | ( | self, | |
str | listname, | ||
List[str] | variables, | ||
str | filename, | ||
Optional[str] | hdf_table_name = None, | ||
int | event_buffer_size = 100, | ||
** | writer_kwargs ) |
Constructor to initialize the internal state Arguments: listname(str): name of the particle list variables(list(str)): list of variables to save for each particle filename(str): name of the output file to be created. Needs to end with `.csv` for csv output, `.parquet` or `.pq` for parquet output, `.h5`, `.hdf` or `.hdf5` for hdf5 output and `.feather` or `.arrow` for feather output hdf_table_name(str): name of the table in the hdf5 file. If not provided, it will be the same as the listname event_buffer_size(int): number of events to buffer before writing to disk, higher values will use more memory but write faster and result in smaller files **writer_kwargs: additional keyword arguments to pass to the writer. For details, see the documentation of the writer in the apache arrow documentation. Only use, if you know what you are doing!
Definition at line 43 of file b2pandas_utils.py.
append_buffer | ( | self | ) |
"Append" a new event to the buffer by moving the buffer index forward by particle list size Automatically replaces the buffer by a larger one if necessary
Definition at line 179 of file b2pandas_utils.py.
buffer | ( | self | ) |
The buffer slice across multiple entries
Definition at line 159 of file b2pandas_utils.py.
buffer_full | ( | self | ) |
check if the buffer is full
Definition at line 276 of file b2pandas_utils.py.
clear_buffer | ( | self | ) |
Reset the buffer event counter and index
Definition at line 172 of file b2pandas_utils.py.
event | ( | self | ) |
Event processing function executes the fill_buffer function and writes the data to the output file in chunks of event_buffer_size
Definition at line 299 of file b2pandas_utils.py.
event_buffer | ( | self | ) |
The buffer slice for the current event
Definition at line 166 of file b2pandas_utils.py.
fill_event_buffer | ( | self | ) |
Assign values for all variables for all particles in the particle list to the current event buffer
Definition at line 255 of file b2pandas_utils.py.
initialize | ( | self | ) |
Setup variable lists, pointers, buffers and file writers
Definition at line 102 of file b2pandas_utils.py.
initialize_csv_writer | ( | self | ) |
Initialize the csv writer using pyarrow
Definition at line 225 of file b2pandas_utils.py.
initialize_feather_writer | ( | self | ) |
Initialize the feather writer using pyarrow
Definition at line 197 of file b2pandas_utils.py.
initialize_hdf5_writer | ( | self | ) |
Initialize the hdf5 writer using pytables
Definition at line 236 of file b2pandas_utils.py.
initialize_parquet_writer | ( | self | ) |
Initialize the parquet writer using pyarrow
Definition at line 212 of file b2pandas_utils.py.
terminate | ( | self | ) |
save and close the output
Definition at line 312 of file b2pandas_utils.py.
write_buffer | ( | self | ) |
write the buffer to the output file
Definition at line 282 of file b2pandas_utils.py.
|
protected |
event variables buffer (will be automatically grown if necessary)
Definition at line 144 of file b2pandas_utils.py.
|
protected |
current start index in the event variables buffer
Definition at line 147 of file b2pandas_utils.py.
|
protected |
A list of tuples and py.DataTypes to define the pyarrow schema.
a writer object to write data into a csv file
Definition at line 234 of file b2pandas_utils.py.
|
protected |
The data type.
Definition at line 141 of file b2pandas_utils.py.
|
protected |
Event buffer counter.
Definition at line 98 of file b2pandas_utils.py.
|
protected |
Event buffer size.
Definition at line 96 of file b2pandas_utils.py.
|
protected |
Event metadata.
Definition at line 121 of file b2pandas_utils.py.
|
protected |
a writer object to write data into a feather file
Definition at line 206 of file b2pandas_utils.py.
|
protected |
Output filename.
Definition at line 70 of file b2pandas_utils.py.
|
protected |
Output format.
Definition at line 79 of file b2pandas_utils.py.
|
protected |
The pytable file.
Definition at line 241 of file b2pandas_utils.py.
|
protected |
Particle list name.
Definition at line 72 of file b2pandas_utils.py.
|
protected |
A list of tuples and py.DataTypes to define the pyarrow schema.
a writer object to write data into a parquet file
Definition at line 221 of file b2pandas_utils.py.
|
protected |
Pointer to the particle list.
Definition at line 125 of file b2pandas_utils.py.
|
protected |
A list of tuples and py.DataTypes to define the pyarrow schema.
Definition at line 202 of file b2pandas_utils.py.
|
protected |
std.vector of variable names
Definition at line 118 of file b2pandas_utils.py.
|
protected |
The pytable.
Definition at line 251 of file b2pandas_utils.py.
|
protected |
Table name in the hdf5 file.
Definition at line 92 of file b2pandas_utils.py.
|
protected |
List of variables.
Definition at line 74 of file b2pandas_utils.py.
|
protected |
variable names
Definition at line 110 of file b2pandas_utils.py.
|
protected |
writer kwargs
Definition at line 100 of file b2pandas_utils.py.
buffer = "hdf5": |
Definition at line 288 of file b2pandas_utils.py.
buffer_full |
Definition at line 308 of file b2pandas_utils.py.