Skip to content

Commit

Permalink
Merge pull request #309 from NNPDF/modify-tutorial
Browse files Browse the repository at this point in the history
Replace recipes with jupyter notebook
  • Loading branch information
Radonirinaunimi committed Sep 26, 2024
2 parents 8d89208 + 04ad54d commit a30d3b5
Show file tree
Hide file tree
Showing 10 changed files with 1,227 additions and 277 deletions.
184 changes: 0 additions & 184 deletions examples/python/dyaa.py

This file was deleted.

21 changes: 12 additions & 9 deletions examples/python/positivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ def main(filename, Q2):
pid = 4

# init pineappl objects
lumi_entries = [pineappl.lumi.LumiEntry([(pid, lepton_pid, 1.0)])]
lumi_entries = [pineappl.boc.Channel([(pid, lepton_pid, 1.0)])]
orders = [pineappl.grid.Order(0, 0, 0, 0)]
bins = len(xgrid)
bin_limits = list(map(float, range(0, bins + 1)))
# NOTE: `bin_limits` have to be `np.ndarray`
bin_limits = np.array([float(i) for i in range(0, bins + 1)])
# subgrid params - default is just sufficient
params = pineappl.subgrid.SubgridParams()
# inti grid
grid = pineappl.grid.Grid.create(lumi_entries, orders, bin_limits, params)
grid = pineappl.grid.Grid(lumi_entries, orders, bin_limits, params)
limits = []
# add each point as a bin
for bin_, x in enumerate(xgrid):
Expand All @@ -31,13 +32,15 @@ def main(filename, Q2):
# create and set
subgrid = pineappl.import_only_subgrid.ImportOnlySubgridV1(
array[np.newaxis, :, np.newaxis],
[Q2],
xgrid,
[1.0],
np.array([Q2]), # `q2_grid` has to be `np.ndarrary`
np.array(xgrid), # `x_grid` has to be `np.ndarrary`
np.array([1.0]), # `x_grid` has to be `np.ndarrary`
)
grid.set_subgrid(0, bin_, 0, subgrid)
grid.set_subgrid(0, bin_, 0, subgrid.into())
# set the correct observables
normalizations = [1.0] * bins
normalizations = np.array(
[1.0] * bins
) # `normalizations` has to be `np.ndarray`
remapper = pineappl.bin.BinRemapper(normalizations, limits)
grid.set_remapper(remapper)

Expand All @@ -55,4 +58,4 @@ def main(filename, Q2):


if __name__ == "__main__":
main("charm-positivity.pineappl", 1.5 ** 2)
main("charm-positivity.pineappl", 1.5**2)
3 changes: 2 additions & 1 deletion pineappl_py/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

.ipynb_checkpoints
docs/source/*.pineappl.lz4
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
Loading

0 comments on commit a30d3b5

Please sign in to comment.