Skip to content

Commit

Permalink
Restore comments in scaler
Browse files Browse the repository at this point in the history
  • Loading branch information
APJansen committed Jul 10, 2023
1 parent e92b706 commit 5bcf169
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions n3fit/src/n3fit/scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def generate_scaler(input_list: List[np.ndarray], interpolation_points: int = No
input_arr = np.sort(input_arr)
input_arr_size = input_arr.size

# Define an evenly spaced grid in the domain [0,1]
# force_set_smallest is used to make sure the smallest point included in the scaling is
# 1e-9, to prevent trouble when saving it to the LHAPDF grid
force_set_smallest = input_arr.min() > 1e-9
if force_set_smallest:
new_xgrid = np.linspace(
Expand All @@ -31,17 +34,23 @@ def generate_scaler(input_list: List[np.ndarray], interpolation_points: int = No
else:
new_xgrid = np.linspace(start=0, stop=1.0, endpoint=False, num=input_arr_size)

# When mapping the FK xgrids onto our new grid, we need to consider degeneracies among
# the x-values in the FK grids
unique, counts = np.unique(input_arr, return_counts=True)
map_to_complete = []
for cumsum_ in np.cumsum(counts):
# Make sure to include the smallest new_xgrid value, such that we have a point at
# x<=1e-9
map_to_complete.append(new_xgrid[cumsum_ - counts[0]])
map_to_complete = np.array(map_to_complete)
map_from_complete = unique

# If needed, set feature_scaling(x=1e-9)=0
if force_set_smallest:
map_from_complete = np.insert(map_from_complete, 0, 1e-9)
map_to_complete = np.insert(map_to_complete, 0, 0.0)

# Select the indices of the points that will be used by the interpolator
onein = map_from_complete.size / (int(interpolation_points) - 1)
selected_points = [round(i * onein - 1) for i in range(1, int(interpolation_points))]
if selected_points[0] != 0:
Expand Down

0 comments on commit 5bcf169

Please sign in to comment.