Skip to content

Commit

Permalink
Add detailed documentation for remap subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Dec 31, 2021
1 parent 563081e commit 25fc84a
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion pineappl_cli/src/remap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,35 @@ use std::path::PathBuf;

/// Modifies the bin dimensions, widths and normalizations.
#[derive(Parser)]
#[clap(name = "remap")]
#[clap(
after_help = "For performance/simplicity reasons Monte Carlo programs (and the PineAPPL
`Grid::fill` method) typically do not support 1) multi-dimensional distributions or 2)
distributions whose bin sizes are not equally sized *during generation*. To work around this
problem a grid with a one-dimensional distribution can be generated instead, and afterwards the
bins can be 'remapped' to an N-dimensional distribution using the limits specified with the
REMAPPING string.
The remapping string uses the following special characters to achieve this:
- ',': In the easiest case, when mapping bins to 1-dimensional bins, the bin limits can be given by
separating them using ',' as in the following example: '0,0.2,0.4,0.6,1'. This remapping string
will expect the grid to have 4 bins which cover the range from 0 to 0.6 with 3 bins of equal size
and the range 0.6 to 1 with another (single) bin
- ';': If higher-dimensional bins are needed, the bin limits are constructed using a cartesian
product where the bin limits for each dimension is separated using a semicolon, for example:
'0,0.5,1;0,1,2' expects the grid to have 4 bins, whose 2-dimensional bin limits are: (0-0.5;0-1),
(0-0.5;1-2), (00.5-1;0-1), (0.5-1;1-2)
- '|': When constructing bin limits for higher-dimensional distributions, it is sometimes necessary
to have bin limits that are dependent on other dimensions; the pipe '|' can be used to achieve
this. For example the remapping string '0,1,2;0,1,2|0,2,4' expects a grid with a total of 4 bins
and produces the following bin limits: (0-1;0-1), (0-1;1-2), (1-2;0-2), (1-2;2-4). Leaving out the
bin limits means that the previous limits are repeated; for example, the following remapping string
for six bins '0,1,2;0,1,2|0,1,2|0,2,4' can be more succinctly written as '0,1,2;0,1,2||0,2,4'
- ':': Finally, the colon can be used to 'cut' out bins from the left and right for
dimension-dependent bins. For example, the remapping string '0,1,2;0,1,2,3:2|:1||:1|2:' is a more
succinct way of writing the following remapping string: '0,1,2;0,1|0,1,2|0,1,2,3|0,1,2|2,3'",
name = "remap"
)]
pub struct Opts {
/// Path to the input grid.
#[clap(parse(from_os_str), value_hint = ValueHint::FilePath)]
Expand Down Expand Up @@ -213,6 +241,33 @@ OPTIONS:
--norm <NORM>
Normalization factor in addition to the given bin widths [default: 1.0]
For performance/simplicity reasons Monte Carlo programs (and the PineAPPL
`Grid::fill` method) typically do not support 1) multi-dimensional distributions or 2)
distributions whose bin sizes are not equally sized *during generation*. To work around this
problem a grid with a one-dimensional distribution can be generated instead, and afterwards the
bins can be 'remapped' to an N-dimensional distribution using the limits specified with the
REMAPPING string.
The remapping string uses the following special characters to achieve this:
- ',': In the easiest case, when mapping bins to 1-dimensional bins, the bin limits can be given by
separating them using ',' as in the following example: '0,0.2,0.4,0.6,1'. This remapping string
will expect the grid to have 4 bins which cover the range from 0 to 0.6 with 3 bins of equal size
and the range 0.6 to 1 with another (single) bin
- ';': If higher-dimensional bins are needed, the bin limits are constructed using a cartesian
product where the bin limits for each dimension is separated using a semicolon, for example:
'0,0.5,1;0,1,2' expects the grid to have 4 bins, whose 2-dimensional bin limits are: (0-0.5;0-1),
(0-0.5;1-2), (00.5-1;0-1), (0.5-1;1-2)
- '|': When constructing bin limits for higher-dimensional distributions, it is sometimes necessary
to have bin limits that are dependent on other dimensions; the pipe '|' can be used to achieve
this. For example the remapping string '0,1,2;0,1,2|0,2,4' expects a grid with a total of 4 bins
and produces the following bin limits: (0-1;0-1), (0-1;1-2), (1-2;0-2), (1-2;2-4). Leaving out the
bin limits means that the previous limits are repeated; for example, the following remapping string
for six bins '0,1,2;0,1,2|0,1,2|0,2,4' can be more succinctly written as '0,1,2;0,1,2||0,2,4'
- ':': Finally, the colon can be used to 'cut' out bins from the left and right for
dimension-dependent bins. For example, the remapping string '0,1,2;0,1,2,3:2|:1||:1|2:' is a more
succinct way of writing the following remapping string: '0,1,2;0,1|0,1,2|0,1,2,3|0,1,2|2,3'
";

#[test]
Expand Down

0 comments on commit 25fc84a

Please sign in to comment.