Placing Events After Merging¶
These are functions that are designed to place unbinned data into the bins generated by the Mergers.
Note
If the parameter map_at is given to a merger class from Mergers, then there is a mapping deposited into a tracker file and, if the merging was nonlocal, a bins file. The tracker file will be a .hdf5 file, and the bins file a .npy file.
- MiLoMerge.place_event_nonlocal(N: int, *observable: float, file_prefix: str, verbose: bool = False)[source]¶
This function takes in one N-dimensional observable from data and utilizes the mapping and saved physical bins from MiLoMerge.MergerNonlocal to output where that event would go in the final nonlocal binning.
- Parameters:
N (int) – The number of bins in the mapping to use
observable (float) – args input where one inputs observables in the same order as the input binning to MiLoMerge
file_prefix (str) – The entirety of the filepath before _tracker.hdf5 or “_physical_bins.npy”. This argument should be the same as f”{file_path} + {file_prefix}”, where file_path and file_prefix are the inputs given to MiLoMerge.MergerNonlocal.
verbose (bool, optional) – Whether additional print statements are turned on, by default False
- Returns:
The index of where the event is placed in the final binning.
- Return type:
- Raises:
FileNotFoundError – If the prefix is not suitable to find the appropriate tracker.hdf5 file, raise an error.
FileNotFoundError – If the prefix is not suitable to find the appropriate physical_bins.npy file, raise an error.
ValueError – If any observable is outside of the provided bins, raise an error
ValueError – If the dimensions of the observable and the dimensions of the bins are not compatible, raise an error
- MiLoMerge.place_array_nonlocal(N: int, observables: Iterable[Iterable[float]], file_prefix: str = '', verbose: bool = False)[source]¶
This function takes in an array of N-dimensional observables from data and utilizes the mapping and saved physical bins from MiLoMerge.MergerNonlocal to output where that event would go in the final nonlocal binning. The array version of place_event_nonlocal.
- Parameters:
N (int) – The number of bins in the mapping to use
observables (numpy.ndarray[float]) – Array should be of shape (#events, #observables). Contains all the observables to be binned.
file_prefix (str) – The entirety of the filepath before _tracker.hdf5 or “_physical_bins.npy”. This argument should be the same as f”{file_path} + {file_prefix}”, where file_path and file_prefix are the inputs given to MiLoMerge.MergerNonlocal.
verbose (bool, optional) – Whether additional print statements are turned on, by default False
- Returns:
A 1-d array of indices for where the events are placed in the final binning.
- Return type:
- Raises:
FileNotFoundError – If the prefix is not suitable to find the appropriate tracker.hdf5 file, raise an error.
FileNotFoundError – If the prefix is not suitable to find the appropriate physical_bins.npy file, raise an error.
ValueError – If any observable is outside of the provided bins, raise an error
ValueError – If the dimensions of the observable and the dimensions of the bins are not compatible, raise an error
KeyError – If any observable is outside the provided bins, raise an error
- MiLoMerge.place_local(N: int, observable_array: Iterable[float], file_prefix: str, verbose: bool = False)[source]¶
Places 1-dimensional data into the respective bins for a given bin number. Equivalent to running numpy.histogram for the given N+1 bin edges stored.
- Parameters:
N (int) – The number of bins that are desired
observable_array (numpy.ndarray) – A 1-d array of datapoints to be binned with N bins
file_prefix (str, optional) – The entirety of the filepath before _tracker.hdf5 or “_physical_bins.npy”. This argument should be the same as f”{file_path} + {file_prefix}”, where file_path and file_prefix are the inputs given to MiLoMerge.MergerNonlocal.
verbose (bool, optional) – Whether additional print statements are turned on, by default False, by default False
- Returns:
Returns the counts and bin edges for the data in the same fashion as numpy.histogram.
- Return type:
- Raises:
FileNotFoundError – If the prefix is not suitable to find the appropriate tracker.hdf5 file, raise an error.