validphys.plotoptions package

Submodules

validphys.plotoptions.core module

class validphys.plotoptions.core.KinLabel(value)[source]

Bases: Enum

An enumeration.

k1 = 1
k2 = 2
k3 = 3
class validphys.plotoptions.core.PlotInfo(kinlabels, dataset_label, *, experiment=None, x=None, extra_labels=None, func_labels=None, figure_by=None, line_by=None, kinematics_override=None, result_transform=None, y_label=None, x_label=None, x_scale=None, y_scale=None, ds_metadata=None, process_description='-', nnpdf31_process, **kwargs)[source]

Bases: object

property experiment
classmethod from_commondata(commondata, cuts=None, normalize=False)[source]
get_xcol(table)[source]

Return a numpy array with the x column or the index as appropriate

group_label(same_vals, groupby)[source]
name_to_label(name)[source]
property process_type
property xlabel
class validphys.plotoptions.core.PlottingFile(func_labels: dict = <factory>, dataset_label: Optional[str] = None, experiment: Optional[str] = None, nnpdf31_process: Optional[str] = None, data_reference: Optional[str] = None, theory_reference: Optional[str] = None, process_description: Optional[str] = None, y_label: Optional[str] = None, x_label: Optional[str] = None, kinematics_override: Optional[validphys.plotoptions.plottingoptions.TransformFunctions] = None, result_transform: Optional[validphys.plotoptions.plottingoptions.ResultTransformations] = None, x: Optional[str] = None, plot_x: Optional[str] = None, x_scale: Optional[validphys.plotoptions.plottingoptions.Scale] = None, y_scale: Optional[validphys.plotoptions.plottingoptions.Scale] = None, line_by: Optional[list] = None, figure_by: Optional[list] = None, extra_labels: Optional[Mapping[str, List]] = None, normalize: Optional[validphys.plotoptions.plottingoptions.PlottingOptions] = None, already_digested: Optional[bool] = False)[source]

Bases: PlottingOptions

normalize: PlottingOptions | None = None
validphys.plotoptions.core.dict_factory(key_value_pairs)[source]

A dictionary factory to be used in conjunction with dataclasses.asdict to remove nested None values and convert enums to their name.

https://stackoverflow.com/questions/59481989/dict-from-nested-dataclasses

validphys.plotoptions.core.get_info(data, *, normalize=False, cuts=None, use_plotfiles=True)[source]

Retrieve and process the plotting information for the input data (which could be a DatasetSpec or a CommonDataSpec).

If use_plotfiles is True (the default), the PLOTTING files will be used to retrieve the infromation. Otherwise the default configuration (which depends of the process type) will be used.

If cuts is None, the cuts of the dataset will be used, but no cuts for commondata.

If cuts is False, no cuts will be used.

If cuts is an instance of Cuts, it will be used.

If normalize is True, the specialization for ratio plots will be used to generate the PlotInfo objects.

validphys.plotoptions.core.get_xq2map(kintable, info)[source]

Return a tuple of (x,Q²) from the kinematic values defined in kitable (usually obtained by calling kitable) using the process type if available

Otherwise it will fallback to the legacy mode, i.e., “using machinery specified in``info``

validphys.plotoptions.core.kitable(data, info, *, cuts=None)[source]

Obtain a DataFrame with the kinematics for each data point

Parameters:
  • data ((DataSetSpec, CommonDataSpec, Dataset, CommonData)) – A data object to extract the kinematics from.

  • info (PlotInfo) – The description of the transformations to apply to the kinematics. See get_info()

  • cuts (Cuts or None, default=None) – An object to load the cuts from. It is an error to set this if data is a dataset. If data is a CommonData, these must be the same as those passed to get_info().

Returns:

table – A DataFrame containing the kinematics for all points after cuts.

Return type:

pd.DataFrame

validphys.plotoptions.core.transform_result(cv, error, kintable, info)[source]

validphys.plotoptions.kintransforms module

kintransforms.py

This modules defines classes that transform the kinematics as defined in the CommonData files into some function of these kinematics that is more convenient for representation.The kinematic transforms should also define an ‘xq2map’, that maps each kinematic point into zero or more points in (x, Q²), as a function of the new kinematics.

The expected interface of the classes is:

class mytransform:
    def __call__(
        self, k1: np.array, k2: np.array, k3: np.array
    ) -> (np.array, np.array, np.array):
        # Transform kinematics
        ...
        return trasformed_k1, transformed_k2, transformed_k3

    def new_labels(
        self, old_label1: str, old_label2: str, old_label3: str
    ) -> (str, str, str):
        # Transform labels
        return transformed_label1, transformed_label2, transformed_label3

    # Using as input the result of __call__ as well as any new labels
    def xq2map(
        self, k1: np.array, k2: np.array, k3: np.array, **extra_labels
    ) -> (np.array, np.array):
        # calculate (x,Q²)
        return x, Q2

The kinematic labels are:

{
    "DIS": ("$x$", "$Q^2 (GeV^2)$", "$y$"),
    "DYP": ("$y$", "$M^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWJ_JPT": ("$p_T$ (GeV)", "$M^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWJ_JRAP": ("$\eta/y$", "$M^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWJ_MLL": ("$M_{ll}$ (GeV)", "$M_{ll}^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWJ_PT": ("$p_T$ (GeV)", "$M^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWJ_PTRAP": ("$\eta/y$", "$p_T^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWJ_RAP": ("$\eta/y$", "$M^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWK_MLL": ("$M_{ll}$ (GeV)", "$M_{ll}^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWK_PT": ("$p_T$ (GeV)", "$M^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWK_PTRAP": ("$\eta/y$", "$p_T^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "EWK_RAP": ("$\eta/y$", "$M^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "HIG_RAP": ("$y$", "$M_H^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "HQP_MQQ": ("$M^{QQ}$ (GeV)", "$\mu^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "HQP_PTQ": ("$p_T^Q$ (GeV)", "$\mu^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "HQP_PTQQ": ("$p_T^{QQ}$ (GeV)", "$\mu^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "HQP_YQ": ("$y^Q$", "$\mu^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "HQP_YQQ": ("$y^{QQ}$", "$\mu^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "INC": ("$0$", "$\mu^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "JET": ("$\eta$", "$p_T^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "DIJET": ("$\eta$", "$m_{12}$ (GeV)", "$\sqrt{s}$ (GeV)"),
    "PHT": ("$\eta_\gamma$", "$E_{T,\gamma}^2 (GeV^2)$", "$\sqrt{s}$ (GeV)"),
    "SIA": ("$z$", "$Q^2 (GeV^2)$", "$y$"),
}
class validphys.plotoptions.kintransforms.DIJET3DXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

k1 is the rapidity difference, k2 is pTavg, k3 is boost rapidity TODO: NB!! HARDCODING sqrt(s) = 8 TeV, the c.m. energy of 1705.02628.pdf plotting both x1 and x2

class validphys.plotoptions.kintransforms.DIJETATLASXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

k1 is rapidity difference and k2 is m12 plotting both x1 and x2

class validphys.plotoptions.kintransforms.DIJETXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

k1 is max(|y1|,|y2|) and k2 is m12 plotting both x1 and x2

class validphys.plotoptions.kintransforms.DISXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

in DIS-like experiment k1 is x, k2 is Q

class validphys.plotoptions.kintransforms.DYMXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

in DYM-like experiments the k1 is the mass, k2 is the mass

class validphys.plotoptions.kintransforms.DYXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

in DY-like experiments k1 is (pseudo)-rapidity and k2 is Q for each point in the experiment there are two points in the xQ2 map

class validphys.plotoptions.kintransforms.EWPTXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

in ZPt-like Experiments k1 is the pt, k2 is Q

class validphys.plotoptions.kintransforms.HQPTXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

in HQPt-like Experiments k1 is the pt, k2 is Q

class validphys.plotoptions.kintransforms.HQQPTXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

in ZPt-like Experiments k1 is the pt, k2 is Q

class validphys.plotoptions.kintransforms.JETXQ2MapMixin[source]

Bases: object

xq2map(k1, k2, k3, **extra_labels)[source]

k1 is (pseudo)-rapidity and k2 is pT plotting both x1 and x2

class validphys.plotoptions.kintransforms.Kintransform[source]

Bases: object

class validphys.plotoptions.kintransforms.SqrtScaleMixin[source]

Bases: object

new_labels(s1, s2, s3)[source]
qlabel = NotImplemented
class validphys.plotoptions.kintransforms.dijet_CMS_3D[source]

Bases: SqrtScaleMixin, DIJET3DXQ2MapMixin

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.dijet_CMS_5TEV[source]

Bases: SqrtScaleMixin, DIJET3DXQ2MapMixin

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.dijet_sqrt_scale[source]

Bases: SqrtScaleMixin, DIJETXQ2MapMixin

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.dijet_sqrt_scale_ATLAS[source]

Bases: SqrtScaleMixin, DIJETATLASXQ2MapMixin

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.dis_sqrt_scale[source]

Bases: DISXQ2MapMixin

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.dyp_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$M$ (GeV)'
class validphys.plotoptions.kintransforms.ewj_jpt_sqrt_scale[source]

Bases: SqrtScaleMixin, EWPTXQ2MapMixin

qlabel = '$M$ (GeV)'
class validphys.plotoptions.kintransforms.ewj_jrap_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$M$ (GeV)'
class validphys.plotoptions.kintransforms.ewj_mll_sqrt_scale[source]

Bases: SqrtScaleMixin, DYMXQ2MapMixin

qlabel = '$M_{ll}$ (GeV)'
class validphys.plotoptions.kintransforms.ewj_pt_sqrt_scale[source]

Bases: SqrtScaleMixin, EWPTXQ2MapMixin

qlabel = '$M$ (GeV)'
class validphys.plotoptions.kintransforms.ewj_ptrap_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$p_T$ (GeV)'
class validphys.plotoptions.kintransforms.ewj_rap_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$M$ (GeV)'
class validphys.plotoptions.kintransforms.ewk_mll_sqrt_scale[source]

Bases: SqrtScaleMixin, DYMXQ2MapMixin

qlabel = '$M_{ll}$ (GeV)'
class validphys.plotoptions.kintransforms.ewk_pseudorapity_sqrt_scale[source]

Bases: ewk_rap_sqrt_scale

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.ewk_pt_sqrt_scale[source]

Bases: SqrtScaleMixin, EWPTXQ2MapMixin

qlabel = '$M$ (GeV)'
class validphys.plotoptions.kintransforms.ewk_ptrap_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$p_T$ (GeV)'
class validphys.plotoptions.kintransforms.ewk_rap_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$M$ (GeV)'
class validphys.plotoptions.kintransforms.hig_rap_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$M_H$ (GeV)'
class validphys.plotoptions.kintransforms.hqp_mqq_sqrt_scale[source]

Bases: SqrtScaleMixin, DYMXQ2MapMixin

qlabel = '$\\mu$ (GeV)'
class validphys.plotoptions.kintransforms.hqp_ptq_sqrt_scale[source]

Bases: SqrtScaleMixin, HQPTXQ2MapMixin

qlabel = '$\\mu$ (GeV)'
class validphys.plotoptions.kintransforms.hqp_ptqq_sqrt_scale[source]

Bases: SqrtScaleMixin, HQQPTXQ2MapMixin

qlabel = '$\\mu$ (GeV)'
class validphys.plotoptions.kintransforms.hqp_yq_sqrt_scale[source]

Bases: SqrtScaleMixin, JETXQ2MapMixin

qlabel = '$\\mu$ (GeV)'
class validphys.plotoptions.kintransforms.hqp_yqq_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$\\mu$ (GeV)'
class validphys.plotoptions.kintransforms.identity[source]

Bases: object

The identity transformation is a transitional operation for the implementation of the new commondata

It takes the kinematics as they come and leave them unchanged. The final version will either

  1. Remove the necessitity for the key in the PlotOptions

  2. Change all “identities” to utilize one of the transformations

The selection depends on the final decision on the x-q2 map and the possibilities are either:

  1. Include the xq2 information as part of the kinematics when no override is provided

  2. Enforce that all datasets include an override to define how the x-q2 map should be computed.

new_labels(k1, k2, k3)[source]
xq2map(k1, k2, k3, **extra_labels)[source]
class validphys.plotoptions.kintransforms.inc_sqrt_scale[source]

Bases: SqrtScaleMixin, DYMXQ2MapMixin

qlabel = '$\\mu$ (GeV)'
class validphys.plotoptions.kintransforms.jet_sqrt_scale[source]

Bases: SqrtScaleMixin, JETXQ2MapMixin

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.nmc_process[source]

Bases: DISXQ2MapMixin

new_labels(*old_labels)[source]
class validphys.plotoptions.kintransforms.pht_sqrt_scale[source]

Bases: SqrtScaleMixin, DYXQ2MapMixin

qlabel = '$E_{T,\\gamma}$ (GeV)'
class validphys.plotoptions.kintransforms.sia_sqrt_scale[source]

Bases: SqrtScaleMixin, DISXQ2MapMixin

qlabel = '$Q$ (GeV)'

validphys.plotoptions.labelers module

Created on Fri Mar 11 20:44:21 2016

@author: Zahari Kassabov

validphys.plotoptions.labelers.high_xq(k1, k2, k3, **kwargs)[source]
validphys.plotoptions.labelers.jet_eta(k1, k2, k3, **kwargs)[source]
validphys.plotoptions.labelers.k2bins10(k1, k2, k3, **kwargs)[source]
validphys.plotoptions.labelers.k2bins5(k1, k2, k3, **kwargs)[source]
validphys.plotoptions.labelers.k2bins6(k1, k2, k3, **kwargs)[source]
validphys.plotoptions.labelers.pt_ratio(k1, k2, k3, **kwargs)[source]
validphys.plotoptions.labelers.two_Q2_bins(k1, k2, k3, **kwargs)[source]

validphys.plotoptions.plottingoptions module

This module is separated from other plotoptions modules to avoid circular dependencies

The class PlottingOptions is used by the commondata reader to check that the plotting options set in plotting are acceptable.

class validphys.plotoptions.plottingoptions.PlottingOptions(func_labels: dict = <factory>, dataset_label: Optional[str] = None, experiment: Optional[str] = None, nnpdf31_process: Optional[str] = None, data_reference: Optional[str] = None, theory_reference: Optional[str] = None, process_description: Optional[str] = None, y_label: Optional[str] = None, x_label: Optional[str] = None, kinematics_override: Optional[validphys.plotoptions.plottingoptions.TransformFunctions] = None, result_transform: Optional[validphys.plotoptions.plottingoptions.ResultTransformations] = None, x: Optional[str] = None, plot_x: Optional[str] = None, x_scale: Optional[validphys.plotoptions.plottingoptions.Scale] = None, y_scale: Optional[validphys.plotoptions.plottingoptions.Scale] = None, line_by: Optional[list] = None, figure_by: Optional[list] = None, extra_labels: Optional[Mapping[str, List]] = None, normalize: Optional[dict] = None, already_digested: Optional[bool] = False)[source]

Bases: object

property all_labels
already_digested: bool | None = False
data_reference: str | None = None
dataset_label: str | None = None
experiment: str | None = None
extra_labels: Mapping[str, List] | None = None
figure_by: list | None = None
func_labels: dict
kinematics_override: TransformFunctions | None = None
line_by: list | None = None
nnpdf31_process: str | None = None
normalize: dict | None = None
parse_figure_by()[source]
parse_line_by()[source]
parse_x()[source]
plot_x: str | None = None
process_description: str | None = None
result_transform: ResultTransformations | None = None
theory_reference: str | None = None
x: str | None = None
x_label: str | None = None
x_scale: Scale | None = None
y_label: str | None = None
y_scale: Scale | None = None
class validphys.plotoptions.plottingoptions.ResultTransformations(value)

Bases: Enum

An enumeration.

bins = 1
half = 2
qbinEMC = 3
qbindis = 4
qbindyp = 5
qbinexp = 6
qbinjets = 7
class validphys.plotoptions.plottingoptions.Scale(value)[source]

Bases: Enum

An enumeration.

linear = 1
log = 2
symlog = 3
class validphys.plotoptions.plottingoptions.TransformFunctions(value)

Bases: Enum

An enumeration.

dijet_CMS_3D = 1
dijet_CMS_5TEV = 2
dijet_sqrt_scale = 3
dijet_sqrt_scale_ATLAS = 4
dis_sqrt_scale = 5
dyp_sqrt_scale = 6
ewj_jpt_sqrt_scale = 7
ewj_jrap_sqrt_scale = 8
ewj_mll_sqrt_scale = 9
ewj_pt_sqrt_scale = 10
ewj_ptrap_sqrt_scale = 11
ewj_rap_sqrt_scale = 12
ewk_mll_sqrt_scale = 13
ewk_pseudorapity_sqrt_scale = 14
ewk_pt_sqrt_scale = 15
ewk_ptrap_sqrt_scale = 16
ewk_rap_sqrt_scale = 17
hig_rap_sqrt_scale = 18
hqp_mqq_sqrt_scale = 19
hqp_ptq_sqrt_scale = 20
hqp_ptqq_sqrt_scale = 21
hqp_yq_sqrt_scale = 22
hqp_yqq_sqrt_scale = 23
identity = 24
inc_sqrt_scale = 25
jet_sqrt_scale = 26
nmc_process = 27
pht_sqrt_scale = 28
sia_sqrt_scale = 29

validphys.plotoptions.resulttransforms module

Created on Tue Apr 19 09:52:43 2016

@author: Zahari Kassabov

Transform the result (central value and error) for plotting.

The functions here receive as arguments the original cental value and error (from e.g. the convolution or commondata) as well as all the labels defined in the plotting file, as keyword arguments. They are expected to return a new central value and a new error. Therefore the signature is:

def xbinexp(cv, error, **labels):
    ...
    return newcv, newerror
exception validphys.plotoptions.resulttransforms.MissingLabelError(key_error)[source]

Bases: KeyError

validphys.plotoptions.resulttransforms.half(cv, error, **labels)[source]
validphys.plotoptions.resulttransforms.qbinEMC(cv, error, **labels)[source]
validphys.plotoptions.resulttransforms.qbindis(cv, error, **labels)[source]
validphys.plotoptions.resulttransforms.qbindyp(cv, error, **labels)[source]
validphys.plotoptions.resulttransforms.qbinexp(cv, error, **labels)[source]
validphys.plotoptions.resulttransforms.qbinjets(cv, error, **labels)[source]

validphys.plotoptions.utils module

Created on Tue Mar 15 12:49:39 2016

@author: Zahari Kassabov

validphys.plotoptions.utils.apply_to_all_columns(df, func)[source]

Apply a function to all columns of a dataframe at the saem time. The parameter names are the names of the column and the values are arrays containing the each column’s values.

validphys.plotoptions.utils.bins(arr)[source]

Return bins corresponding to unique values of arr sorted by value.

bins([-3, 5, -3, -3, 0, 1,1,0])

array([0, 3, 0, 0, 1, 2, 2, 1])
validphys.plotoptions.utils.get_subclasses(obj, base)[source]

Return the classes in obj that are subclasses of base

validphys.plotoptions.utils.label(label)[source]
validphys.plotoptions.utils.new_labels(k1label, k2lebel, k3label)[source]

Module contents