data#

import pawian.data

Data module of Pawian Tools.

This module allows you to parse and analyze ASCII data files of momentum tuples. The files have the following form:

0.99407
-0.00357645   0.0962561   0.0181079    0.170545
   0.224019    0.623156    0.215051     1.99057
  -0.174404   -0.719412   -0.233159      2.0243
0.990748
 -0.0328198   0.0524406   0.0310079    0.155783
  -0.619592    0.141315     0.32135     1.99619
   0.698477   -0.193756   -0.352357     2.03593

The lines with single values are weights, but do not have to be present. Whitespaces are arbitrary.

The allows you to import the ASCII file to a nicely formatted DataFrame that has additional PWA methods in the form of DataFrame accessors.

exception DataParserError[source]#

Bases: Exception

Exception for if a data file can’t be handled.

class PwaAccessor(pandas_object: PandasObject)[source]#

Bases: object

PWA-specific accessor for a DataFrame.

Additional namespace to interpret DataFrame as Pawian style dataframe, see Extending pandas.

property has_weights: bool[source]#

Check if dataframe contains weights.

property has_particles: bool[source]#

Check if dataframe contains a main column with particles.

property weights: Series[source]#

Get list of weights, if available.

property intensities: Series[source]#

Alias for weights() in the case of a fit intensity sample.

property particles: list[str][source]#

Get list of particles contained in the data frame.

property momentum_labels: list[str][source]#

Get list of momentum labels contained in the data frame.

property energy: DataFrame[source]#

Get a dataframe containing only the energies.

property p_xyz: DataFrame[source]#

Get a dataframe containing only the 3-momenta.

property rho2: DataFrame[source]#

Compute a dataframe containing the square sum of the 3-momenta.

property rho: DataFrame[source]#

Compute a dataframe with the absolute value of the 3-momenta.

property mass2: DataFrame[source]#

Compute the square of the invariant masses.

property mass: DataFrame[source]#

Compute the invariant masses.

write_ascii(filename: str, **kwargs: Any) None[source]#

Write to Pawian-like ASCII file.

Parameters:
create_skeleton_frame(particle_names: Iterable[str] | None = None, number_of_rows: int | None = None) DataFrame[source]#

Create skeleton DataFrame.

Create an empty DataFrame that complies with the standards of the registered PwaAccessor.

read_ascii(filename: str, particles: list[str] | int | None = None, **kwargs: Any) DataFrame[source]#

Import from a Pawian-like ASCII file.

Parameters:
  • filename – The name of the file to read.

  • particles – A list of particles to read. If None, all particles are read. If int, column names for the particles are numbered.

  • kwargs – Additional keyword arguments to pass to pandas.read_table().

read_pawian_hists(filename: str, type_name: Literal['data', 'fitted'] = 'data') DataFrame[source]#

Read a pawianHists.root.

Import one of the momentum tuple branches of a pawianHists.root.

Parameters:
  • filename (str) – Path to the file that you want to read.

  • type_name (str) – "data" or "fitted".