From 94d6e80cd1d5c58f65051bda21c0cfc1086094ef Mon Sep 17 00:00:00 2001 From: RoyStegeman Date: Mon, 10 Jul 2023 11:17:36 +0100 Subject: [PATCH 1/5] remove mention that vp-comparefit doesn't always have to be the first step --- doc/sphinx/source/tutorials/run-fit.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/doc/sphinx/source/tutorials/run-fit.md b/doc/sphinx/source/tutorials/run-fit.md index f0a1d10201..0a5c5bb2b8 100644 --- a/doc/sphinx/source/tutorials/run-fit.md +++ b/doc/sphinx/source/tutorials/run-fit.md @@ -122,15 +122,6 @@ following the points presented above you can proceed with a fit. downloaded automatically. Alternatively they can be obtained with the ``vp-get`` tool. - ```eval_rst - .. note:: - This step is not strictly necessary when producing a standard fit with - ``n3fit`` but it is required by :ref:`validphys ` - and it should therefore always be done. Note that :ref:`vp-upload ` - will fail unless this step has been followed. If necessary, this step can - be done after the fit has been run. - ``` - 2. The ``n3fit`` program takes a ``runcard.yml`` as input and a replica number, e.g. ```n3fit runcard.yml replica``` where ``replica`` goes from 1-n where n is the maximum number of desired replicas. Note that if you desire, for example, a 100 From 883cb192f741c6f81134ee676ab0e941d2d5fe9a Mon Sep 17 00:00:00 2001 From: Aron Jansen Date: Mon, 10 Jul 2023 13:05:09 +0200 Subject: [PATCH 2/5] Implement FkRotation as subclass of Rotation by rewriting using a rotation tensor --- n3fit/src/n3fit/layers/rotations.py | 53 +++++++++++++---------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/n3fit/src/n3fit/layers/rotations.py b/n3fit/src/n3fit/layers/rotations.py index 686d3c5bbb..6001a312bc 100644 --- a/n3fit/src/n3fit/layers/rotations.py +++ b/n3fit/src/n3fit/layers/rotations.py @@ -56,7 +56,7 @@ def __init__( super().__init__(rotation_matrix, axes=1, **kwargs) -class FkRotation(MetaLayer): +class FkRotation(Rotation): """ Applies a transformation from the dimension-8 evolution basis to the dimension-14 evolution basis used by the fktables. @@ -64,36 +64,31 @@ class FkRotation(MetaLayer): The input to this layer is a `pdf_raw` variable which is expected to have a shape (1, None, 8), and it is then rotated to an output (1, None, 14) """ - - # TODO: Generate a rotation matrix in the input and just do tf.tensordot in call - # the matrix should be: (8, 14) so that we can just do tf.tensordot(pdf, rotmat, axes=1) - # i.e., create the matrix and inherit from the Rotation layer above def __init__(self, output_dim=14, name="evolution", **kwargs): self.output_dim = output_dim - super().__init__(name=name, **kwargs) - - def call(self, pdf_raw): - # Transpose the PDF so that the flavour index is the first one - x = op.transpose(pdf_raw) - pdf_raw_list = [ - 0 * x[0], # photon - x[0], # sigma - x[1], # g - x[2], # v - x[3], # v3 - x[4], # v8 - x[8], # v15 - x[2], # v24 - x[2], # v35 - x[5], # t3 - x[6], # t8 - x[0] - 4 * x[7], # t15 (c-) - x[0], # t24 - x[0], # t35 - ] - ret = op.concatenate(pdf_raw_list) - # Concatenating destroys the batch index so we have to regenerate it - return op.batchit(ret) + rotation_matrix = self._create_rotation_matrix() + super().__init__(rotation_matrix, axes=1, name=name, **kwargs) + + def _create_rotation_matrix(self): + """Create the rotation matrix""" + array = np.array([ + [0, 0, 0, 0, 0, 0, 0, 0, 0], # photon + [1, 0, 0, 0, 0, 0, 0, 0, 0], # sigma + [0, 1, 0, 0, 0, 0, 0, 0, 0], # g + [0, 0, 1, 0, 0, 0, 0, 0, 0], # v + [0, 0, 0, 1, 0, 0, 0, 0, 0], # v3 + [0, 0, 0, 0, 1, 0, 0, 0, 0], # v8 + [0, 0, 0, 0, 0, 0, 0, 0, 1], # v15 + [0, 0, 1, 0, 0, 0, 0, 0, 0], # v24 + [0, 0, 1, 0, 0, 0, 0, 0, 0], # v35 + [0, 0, 0, 0, 0, 1, 0, 0, 0], # t3 + [0, 0, 0, 0, 0, 0, 1, 0, 0], # t8 + [1, 0, 0, 0, 0, 0, 0,-4, 0], # t15 (c-) + [1, 0, 0, 0, 0, 0, 0, 0, 0], # t24 + [1, 0, 0, 0, 0, 0, 0, 0, 0], # t35 + ]) + tensor = op.numpy_to_tensor(array.T) + return tensor class AddPhoton(MetaLayer): From e7a91405a59b13b5662541d38dc48e887e99c5e4 Mon Sep 17 00:00:00 2001 From: Aron Jansen Date: Mon, 10 Jul 2023 13:56:52 +0200 Subject: [PATCH 3/5] Change 8 to 9 in docstring --- n3fit/src/n3fit/layers/rotations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/n3fit/src/n3fit/layers/rotations.py b/n3fit/src/n3fit/layers/rotations.py index 6001a312bc..ed58cdbe15 100644 --- a/n3fit/src/n3fit/layers/rotations.py +++ b/n3fit/src/n3fit/layers/rotations.py @@ -58,11 +58,11 @@ def __init__( class FkRotation(Rotation): """ - Applies a transformation from the dimension-8 evolution basis + Applies a transformation from the dimension-9 evolution basis to the dimension-14 evolution basis used by the fktables. The input to this layer is a `pdf_raw` variable which is expected to have - a shape (1, None, 8), and it is then rotated to an output (1, None, 14) + a shape (1, None, 9), and it is then rotated to an output (1, None, 14) """ def __init__(self, output_dim=14, name="evolution", **kwargs): self.output_dim = output_dim From 52ddc1d98e9b3e3b96cfbc4ab9d01a17707c60b1 Mon Sep 17 00:00:00 2001 From: Zahari Kassabov Date: Wed, 12 Jul 2023 11:05:34 +0100 Subject: [PATCH 4/5] Fix consistency of lumy plot label Make the absolute value bars both double. --- validphys2/src/validphys/pdfplots.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validphys2/src/validphys/pdfplots.py b/validphys2/src/validphys/pdfplots.py index 07cc497f4c..3c6a74fffd 100644 --- a/validphys2/src/validphys/pdfplots.py +++ b/validphys2/src/validphys/pdfplots.py @@ -824,7 +824,7 @@ def plot_lumi1d( ax.set_title( f"${LUMI_CHANNELS[lumi_channel]}$ luminosity\n" f"$\\sqrt{{s}}={format_number(sqrts/1000)}$ TeV " - f"$\\|y|<{format_number(y_cut)}$" + f"$\\|y\\|<{format_number(y_cut)}$" ) return fig From f13a50669e14cb58b5ce14fda9cb2d7359656c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Thu, 13 Jul 2023 09:55:38 +0200 Subject: [PATCH 5/5] Change fiatlux_dis_F{2,L} -> FIATLUX_DIS_F{2,L} --- validphys2/src/validphys/photon/compute.py | 7 +++---- validphys2/src/validphys/tests/photon/test_compute.py | 4 ++-- .../src/validphys/tests/photon/test_structurefunctions.py | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/validphys2/src/validphys/photon/compute.py b/validphys2/src/validphys/photon/compute.py index c9a5805f07..7a0c1638b7 100644 --- a/validphys2/src/validphys/photon/compute.py +++ b/validphys2/src/validphys/photon/compute.py @@ -75,9 +75,8 @@ def __init__(self, theoryid, lux_params, replicas): self.additional_errors = lux_params["additional_errors"] self.luxseed = lux_params["luxseed"] - # TODO : maybe find a different name for fiatlux_dis_F2 - path_to_F2 = theoryid.path / "fastkernel/fiatlux_dis_F2.pineappl.lz4" - path_to_FL = theoryid.path / "fastkernel/fiatlux_dis_FL.pineappl.lz4" + path_to_F2 = theoryid.path / "fastkernel/FIATLUX_DIS_F2.pineappl.lz4" + path_to_FL = theoryid.path / "fastkernel/FIATLUX_DIS_FL.pineappl.lz4" self.path_to_eko_photon = theoryid.path / "eko_photon.tar" with EKO.read(self.path_to_eko_photon) as eko: self.q_in = np.sqrt(eko.mu20) @@ -97,7 +96,7 @@ def __init__(self, theoryid, lux_params, replicas): fl = sf.InterpStructureFunction(path_to_FL, self.luxpdfset.members[replica]) if not np.isclose(f2.q2_max, fl.q2_max): log.error( - "FKtables for fiatlux_dis_F2 and fiatlux_dis_FL have two different q2_max" + "FKtables for FIATLUX_DIS_F2 and FIATLUX_DIS_FL have two different q2_max" ) fiatlux_runcard["q2_max"] = float(f2.q2_max) diff --git a/validphys2/src/validphys/tests/photon/test_compute.py b/validphys2/src/validphys/tests/photon/test_compute.py index 82787e7492..bd7a65c862 100644 --- a/validphys2/src/validphys/tests/photon/test_compute.py +++ b/validphys2/src/validphys/tests/photon/test_compute.py @@ -111,8 +111,8 @@ def test_photon(): photon = Photon(test_theory, fiatlux_runcard, [replica]) # set up fiatlux - path_to_F2 = test_theory.path / "fastkernel/fiatlux_dis_F2.pineappl.lz4" - path_to_FL = test_theory.path / "fastkernel/fiatlux_dis_FL.pineappl.lz4" + path_to_F2 = test_theory.path / "fastkernel/FIATLUX_DIS_F2.pineappl.lz4" + path_to_FL = test_theory.path / "fastkernel/FIATLUX_DIS_FL.pineappl.lz4" pdfs = fiatlux_runcard["luxset"].load() f2 = sf.InterpStructureFunction(path_to_F2, pdfs.members[replica]) fl = sf.InterpStructureFunction(path_to_FL, pdfs.members[replica]) diff --git a/validphys2/src/validphys/tests/photon/test_structurefunctions.py b/validphys2/src/validphys/tests/photon/test_structurefunctions.py index 5e83e6458f..879f552c73 100644 --- a/validphys2/src/validphys/tests/photon/test_structurefunctions.py +++ b/validphys2/src/validphys/tests/photon/test_structurefunctions.py @@ -44,8 +44,8 @@ def test_zero_pdfs(): pdfs = ZeroPdfs() test_theory = API.theoryid(theoryid=THEORY_QED) theory = test_theory.get_description() - path_to_F2 = test_theory.path / "fastkernel/fiatlux_dis_F2.pineappl.lz4" - path_to_FL = test_theory.path / "fastkernel/fiatlux_dis_FL.pineappl.lz4" + path_to_F2 = test_theory.path / "fastkernel/FIATLUX_DIS_F2.pineappl.lz4" + path_to_FL = test_theory.path / "fastkernel/FIATLUX_DIS_FL.pineappl.lz4" f2 = sf.InterpStructureFunction(path_to_F2, pdfs) fl = sf.InterpStructureFunction(path_to_FL, pdfs) @@ -78,7 +78,7 @@ def test_params(): test_theory = API.theoryid(theoryid=THEORY_QED) theory = test_theory.get_description() for channel in ["F2", "FL"]: - tmp = "fastkernel/fiatlux_dis_" + channel + ".pineappl.lz4" + tmp = "fastkernel/FIATLUX_DIS_" + channel + ".pineappl.lz4" path_to_fktable = test_theory.path / tmp struct_func = sf.InterpStructureFunction(path_to_fktable, pdfs.members[replica]) np.testing.assert_allclose(struct_func.q2_max, 1e8) @@ -94,7 +94,7 @@ def test_interpolation_grid(): test_theory = API.theoryid(theoryid=THEORY_QED) for replica in [1, 2, 3]: for channel in ["F2", "FL"]: - tmp = "fastkernel/fiatlux_dis_" + channel + ".pineappl.lz4" + tmp = "fastkernel/FIATLUX_DIS_" + channel + ".pineappl.lz4" path_to_fktable = test_theory.path / tmp fktable = pineappl.fk_table.FkTable.read(path_to_fktable) x = np.unique(fktable.bin_left(1))