pdg.api module
PDG API top-level class.
- class pdg.api.PdgApi(database_url: str, pedantic: bool = False)[source]
Bases:
object- Parameters:
database_url – URL of the PDG database to connect to. The default database is the SQLite file installed together with package pdg.
pedantic – Can be set True to enable pedantic mode, where, in cases where the choice of “PDG best value” might be ambiguous, no assumptions are made and instead a
PdgAmbiguousValueErrorexception is raised.
- doc_data_type_keys(as_text: bool = True) str | list[dict][source]
Get list of data type keys.
The PDG API uses a data type key as part of the PDG Identifier metadata to denote the kind of information described by a given identifier. These data type keys can be used to select desired particle properties in methods such as
PdgParticle.properties.- Parameters:
as_text – If True, returns the list as a formatted string suitable for printing. Otherwise, a list of mappings is returned, where each one (with string-valued keys value, indicator, description, etc.) describes a possible key value.
- Returns:
Documentation of all possible data_type values for a PDG identifiers.
- doc_item_type_keys(as_text: bool = True) str | list[dict][source]
Get list of PdgItem item_type keys.
A
PdgItemis used to represent a decay product. The item_type distinguishes between concrete particles, aliases for concrete particles, generic states (e.g. charge multiplets), unparsed text, etc.- Parameters:
as_text – If True, returns the list as a formatted string suitable for printing. Otherwise, a list of mappings is returned, where each one (with string-valued keys value, indicator, description, etc.) describes a possible key value.
- Returns:
Documentation of all possible item_type values for a
PdgItem.
- doc_key_value(table_name: str, column_name: str, key: str) dict[source]
Get documentation on the meaning of key values or flags used in the PDG API.
- Parameters:
table_name – The name of the SQLite table of interest.
column_name – The column of interest in the table.
key – The particle value or flag whose meaning to look up.
- Returns:
A mapping (with string-valued keys indicator, description, and comment) describing the meaning of the value or flag.
- Raises:
AttributeError – If no documentation is found.
- doc_value_type_keys(as_text: bool = True) str | list[dict][source]
Get list of summary value type keys.
For each summary value, the value_type key specifies how this value was derived, e.g. whether it is the result of a weighted average, of a fit, etc.
Note
The
PdgSummaryValue.value_typeproperty returns the human-readable indicator, not the machine-readable value.- Parameters:
as_text – If True, returns the list as a formatted string suitable for printing. Otherwise, a list of mappings is returned, where each one (with string-valued keys value, indicator, description, etc.) describes a possible key value.
- Returns:
Documentation of all possible value_type values for a summary value.
- property editions: list[str][source]
List of all editions of the Review for which the database has data.
- get(pdgid: str, edition: str | None = None) PdgData[source]
Get PdgData object for given PDG Identifier.
- Parameters:
pdgid – PDG Identifier to look up.
edition – Can be set to a specific edition, from which the data should later be retrieved.
- Returns:
An object of the most appropriate class (based on what the PDG Identifier refers to) derived from the
PdgDatabase class. For example, for a PDG Identifier describing a particle, an object of classPdgParticleListis returned, while for a branching fraction aPdgBranchingFractionobject is returned.
- get_all(data_type_key=None, edition=None) Iterator[PdgData][source]
Get iterator over all PDG Identifiers / quantities.
- Parameters:
data_type_key – If set, only quantities of the given type are returned. See
doc_data_type_keys()for the list of possible data type codes.edition – Can be set to a specific edition, from which data should later be retrieved.
- Returns:
Iterator over objects of class
PdgPropertyor derived classes.
- get_canonical_name(name: str) str[source]
Get the canonical name of a particle.
The canonical name can be used, for example, when matching decays that may have been encoded using different aliases for the same particle.
- Parameters:
name – A particle’s name (possibly an alias).
- Returns:
The particle’s canonical name, which will differ from the name argument when the latter is an alias.
- Raises:
ValueError – If no match is found.
PdgAmbiguousValueError – If more than one
PdgItemexists with the given name, or if thePdgItemrefers to more than one particle.
- get_particle_by_mcid(mcid: int, edition: str | None = None) PdgParticle[source]
Get particle by its MC ID.
- Parameters:
mcid – Monte Carlo ID
edition – Can be set to a specific edition, from which data should later be retrieved.
- Returns:
PdgParticleobject.
- get_particle_by_name(name: str, case_sensitive: bool = True, edition: str | None = None) PdgParticle[source]
Get particle by its name.
- Parameters:
name – Name of particle to look up.
case_sensitive – Can be set to False to indicate that the particle name should be considered not case-sensitive.
edition – Can be set to a specific edition, from which data should be retrieved.
- Returns:
PdgParticleobject.- Raises:
ValueError – If no match is found.
PdgAmbiguousValueError – If more than one
PdgItemexists with the given name, or if thePdgItemrefers to more than one particle.
- get_particles(edition: str | None = None) Iterator[PdgParticleList][source]
Get iterator over all particles.
- Parameters:
edition – Can be set to a specific edition, from which data should later be retrieved.
- Returns:
Iterator over
PdgParticleListobjects.
- get_particles_by_name(name: str, case_sensitive: bool = True, edition: str | None = None) list[PdgParticle][source]
Get all particles for a (possibly generic) name.
- Parameters:
name – Name of particle (or multiplet, etc.) to look up.
case_sensitive – Can be set to False to indicate that the particle name should be considered not case-sensitive.
edition – Can be set to a specific edition, from which data should later be retrieved.
- Returns:
List of
PdgParticleobjects.- Raises:
PdgValueError – If no match is found.
- info(key: str) str[source]
Get metadata info specified by key.
- Parameters:
key – Metadata key to look up. A list of keys can be obtained using
info_keys().- Returns:
Metadata info.