e15190.hira.spectra.LabPtransverseRapidity¶
- class e15190.hira.spectra.LabPtransverseRapidity(reaction: str, particle: str, df_hist: Optional[pandas.core.frame.DataFrame] = None, keyword: Optional[Union[str, list[str]]] = None)¶
Functions
__init__(reaction, particle[, df_hist, keyword])- param reaction
Reaction notation, e.g. "Ca40Ni58E140".
correct_coverage(df_slice)Correct the coverage of the given slice along the transverse momentum axis.
get_lab_kinergy_per_A_range(particle)get_ptA_spectrum(rapidity_range, ...[, ...])- param rapidity_range
Range of beam-normalized rapidity in lab frame.
is_inside(normed_rapidity, pt_over_A)Check if the given points are inside the phase space.
kinergy_curve(kinergy, mass)Return a function that calculates the transverse momentum for a given rapidity.
plot1d_ptA([ax, hist, rapidity_range, ...])plot2d([ax, hist, cmap])theta_curve(theta, mass)Return a function that calculates the transverse momentum for a given rapidity.
Properties
The beam rapidity in lab frame.
A 2-tuple of kinergy curves that sets the boundaries of the phase space.
lab_kinergy_per_A_rangeslab_theta_rangeA 2-tuple of theta curves that sets the boundaries of the phase space.
- __init__(reaction: str, particle: str, df_hist: Optional[pandas.core.frame.DataFrame] = None, keyword: Optional[Union[str, list[str]]] = None)¶
- Parameters
reaction (str) – Reaction notation, e.g. “Ca40Ni58E140”.
particle (str) – Particle name. It will be converted to the notation used in HiraFile.
df_hist (pandas.DataFrame, default None) – DataFrame with columns ‘x’, ‘y’, ‘z’, ‘zerr’ and ‘zferr’. ‘x’ represents the rapidity in lab frame (0 ~ 1), ‘y’ represents the transverse momentum in MeV/c, ‘z’ represents the cross section in ?? unit. If None, the program attempts to load histogram from file.
keyword (str or list of str or None, default None) – When df_hist is not specified, these keywords will be used to search for the histogram. When None, the program will use the default keywords, which are ‘rapidity’ and ‘geoeff’.
- property beam_rapidity: float¶
The beam rapidity in lab frame.
Returns the experimentally modified beam rapidity. The beam direction is defined as the +z-axis.
- static theta_curve(theta: float, mass: float) Callable[[Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]], Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]]¶
Return a function that calculates the transverse momentum for a given rapidity.
The theta and mass (particle) are fixed.
- Parameters
theta (float) – Polar angle in lab frame in radian.
mass (float) – Mass of the particle in MeV/c^2.
- Returns
transverse_momentum – Function that calculates the transverse momentum for a given rapidity in MeV/c.
- Return type
Callable[[Union[float, ArrayLike]], Union[float, ArrayLike]]
- static kinergy_curve(kinergy: float, mass: float) Callable[[Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]], Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]]¶
Return a function that calculates the transverse momentum for a given rapidity.
The kinetic energy and mass (particle) are fixed.
- Parameters
kinergy (float) – Kinetic energy in MeV. This should be the total kinetic energy of the whole isotope (particle). So if you are given the kinetic energy per nucleon, you should multiply it by the mass number.
mass (float) – Mass of the particle in MeV/c^2.
- Returns
transverse_momentum – Function that calculates the transverse momentum for a given rapidity in MeV/c.
- Return type
Callable[[Union[float, ArrayLike]], Union[float, ArrayLike]]
- property theta_curves: tuple[typing.Callable[[typing.Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[typing.Union[bool, int, float, complex, str, bytes]]]], typing.Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[typing.Union[bool, int, float, complex, str, bytes]]]]]¶
A 2-tuple of theta curves that sets the boundaries of the phase space.
- Returns
theta_curves – First element is the curve for the lower boundary, second element is the curve for the upper boundary.
- Return type
tuple[Callable[[Union[float, ArrayLike]], Union[float, ArrayLike]]]
- property kinergy_curves: tuple[typing.Callable[[typing.Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[typing.Union[bool, int, float, complex, str, bytes]]]], typing.Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[typing.Union[bool, int, float, complex, str, bytes]]]]]¶
A 2-tuple of kinergy curves that sets the boundaries of the phase space.
- Returns
kinergy_curves – First element is the curve for the lower boundary, second element is the curve for the upper boundary.
- Return type
tuple[Callable[[Union[float, ArrayLike]], Union[float, ArrayLike]]]
- is_inside(normed_rapidity: Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], pt_over_A: Union[float, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) Union[bool, numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]¶
Check if the given points are inside the phase space.
Under the hood, this method converts back both normalized rapidity and transverse momentum over A into lab kinetic energy and lab theta angle. Then it checks if the given points are inside the energy cuts and theta cuts.
- Parameters
normed_rapidity (Union[float, ArrayLike]) – The normalized rapidity in lab frame. Normalization is done by dividing the beam rapidity.
pt_over_A (Union[float, ArrayLike]) – The transverse momentum per nucleon in MeV/c.
- Returns
is_inside – True if the given points are inside the phase space, False otherwise. Points on the boundary are considered inside.
- Return type
Union[bool, ArrayLike[bool]]
- correct_coverage(df_slice: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame¶
Correct the coverage of the given slice along the transverse momentum axis.
- Parameters
df_slice (pandas.DataFrame) – The slice to correct, with columns ‘x’, ‘y’, ‘z’, ‘zerr’. ‘x’ is the normed rapidity, ‘y’ is the transverse momentum per nucleon, and ‘z’ is the yield.
- Returns
df_corrected – The corrected slice, with the same columns as the input.
- Return type
pandas.DataFrame
- static _drop_spectrum_outliers(df: pandas.core.frame.DataFrame, drop_outliers: float, yname='y') pandas.core.frame.DataFrame¶
Drop outliers in the dataframe.
This function assumes outliers only occur at the ends of the spectrum. In other words, if a point in the middle is an outlier, it will not be dropped. This decision is made to keep the resulting spectrum continuous. Empirically, for this purpose, if an outlier happens in the middle, it is likely that there is some problem with the data anyway.
- Parameters
df (pandas.DataFrame) – The dataframe to drop outliers from. Must have a column named defined by yname.
drop_outliers (float) – Outliers are defined as points whose ratio to the neighboring point is larger than drop_outliers.
yname (str, default 'y') – The name of the column in df that contains the values to check for outliers.
- get_ptA_spectrum(rapidity_range: Tuple[float, float], correct_coverage: bool, range: Tuple[float, float], bins: int, drop_outliers: float = - 1.0)¶
- Parameters
rapidity_range (2-tuple of float) – Range of beam-normalized rapidity in lab frame.
correct_coverage (bool) – If
True, missing data due to geometric coverage will be corrected. IfFalse, correction will not be applied.range (2-tuple) – Histogram range of \(p_T/A\) in MeV/c.
bins (int) – Number of bins for the histogram.
drop_outliers (float, default -1.0) – Outliers are defined as points whose ratio to the neighboring point is larger than drop_outliers. If negative, no outliers will be dropped.
- Returns
spectrum – DataFrame with columns ‘x’, ‘y’, ‘yerr’ and ‘yferr’.
- Return type
pandas.DataFrame