Skip to content

Commit

Permalink
Protection against MC training nodes with identical zenith
Browse files Browse the repository at this point in the history
  • Loading branch information
moralejo committed Nov 28, 2024
1 parent 2acdf9f commit 588a248
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lstchain/reco/dl1_to_dl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ def add_zd_interpolation_info(dl2table, training_zd_deg, training_az_deg):
cos_tel_zd = np.cos(np.pi / 2 - alt_tel)

Check warning on line 151 in lstchain/reco/dl1_to_dl2.py

View check run for this annotation

Codecov / codecov/patch

lstchain/reco/dl1_to_dl2.py#L149-L151

Added lines #L149 - L151 were not covered by tests

# Compute the weights that multiplied times the RF predictions at the
# closest (0) and 2nd-closest (1) nodes result in the interpolated value:
w0 = 1 - (cos_tel_zd - c0) / (c1 - c0)
w1 = (cos_tel_zd - c0) / (c1 - c0)
# closest (0) and 2nd-closest (1) nodes result in the interpolated value.
# Take care of cases in which the two closest nodes happen to have the
# same zenith (or very close)! (if so, both nodes are set to have equal
# weight in the interpolation)
w1 = np.where(np.isclose(closest_alt, second_closest_alt, atol=1e-4, rtol=0),

Check warning on line 158 in lstchain/reco/dl1_to_dl2.py

View check run for this annotation

Codecov / codecov/patch

lstchain/reco/dl1_to_dl2.py#L158

Added line #L158 was not covered by tests
0.5, (cos_tel_zd - c0) / (c1 - c0))
w0 = 1 - w1

Check warning on line 160 in lstchain/reco/dl1_to_dl2.py

View check run for this annotation

Codecov / codecov/patch

lstchain/reco/dl1_to_dl2.py#L160

Added line #L160 was not covered by tests

# Update the dataframe:
dl2table = dl2table.assign(alt0=pd.Series(closest_alt).values,

Check warning on line 163 in lstchain/reco/dl1_to_dl2.py

View check run for this annotation

Codecov / codecov/patch

lstchain/reco/dl1_to_dl2.py#L163

Added line #L163 was not covered by tests
Expand Down

0 comments on commit 588a248

Please sign in to comment.