NNPDF / pineappl

PineAPPL is not an extension of APPLgrid
https://nnpdf.github.io/pineappl/
GNU General Public License v3.0
13 stars 3 forks source link

Apply grid normalization #90

Closed alecandido closed 2 years ago

alecandido commented 2 years ago

Hi @cschwan, as you know from #89 we are dealing with normalizations, and I proposed to skip pineappl remap and write instead something in python.

The idea is:

  1. load the grid
  2. apply normalization
  3. dump the grid

Nevertheless, point 2 is not that easy, so I tried to figure a way out of it, as easy as possible.

I had a look inside pineappl remap, and I found that you use BinRemapper to apply normalization: https://github.com/N3PDF/pineappl/blob/32e63c92cd9ea8358d6e193e068a9ee33d917979/pineappl_cli/src/remap.rs#L155-L161 and this is the only place where the CLI argument norm appears.

So my idea for point 2 would be:

  1. get the remapper (grid.more_members.upgrade() should guarantee is available)
  2. copy the limits
  3. copy normalizations and multiply by norm
  4. create a new BinRemapper
  5. set the new remapper

Unfortunately, I noticed the remapper inside the more_members is an option, so it might not be available, then: what should I do in the case?

Moreover, I would need to implement a getter for bin_remapper in python, and before even in pineappl crate. Then I was wondering:

P.S.: I needed a commit to open the PR, but I had nothing to commit, so the moment we start I'll just squash it and remove the empty help file

codecov[bot] commented 2 years ago

Codecov Report

Merging #90 (9576553) into master (32e63c9) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #90   +/-   ##
=======================================
  Coverage   85.64%   85.64%           
=======================================
  Files          14       14           
  Lines        2076     2076           
=======================================
  Hits         1778     1778           
  Misses        298      298           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 32e63c9...9576553. Read the comment docs.

cschwan commented 2 years ago

The situation with BinRemapper is unfortunately complicated, as I didn't forsee something like it would be needed when I designed the Grid struct. I think what you want to do is to use BinInfo, for which you can get an instance using Grid::bin_info. With a BinInfo object you can get all limits using BinInfo::left and BinInfo::right, and also the normalizations using BinInfo::normalizations, irrespectively of whether there's a remapper or not. This you can use to a set a remapper.

cschwan commented 2 years ago

See also https://github.com/N3PDF/pineappl/issues/83#issue-1039614822.

alecandido commented 2 years ago

I took the chance to add grid.scale to python API.

It's doing nothing else, then I would merge.

cschwan commented 2 years ago

All right, go ahead!