|
14 | 14 | import joblib
|
15 | 15 | import numpy as np
|
16 | 16 | import pandas as pd
|
| 17 | +import warnings |
17 | 18 | from astropy.coordinates import SkyCoord, Angle
|
18 | 19 | from astropy.time import Time
|
19 | 20 | from pathlib import Path
|
@@ -78,8 +79,8 @@ def add_zd_interpolation_info(dl2table, training_pointings):
|
78 | 79 |
|
79 | 80 | """
|
80 | 81 |
|
81 |
| - alt_tel = dl2table['alt_tel'] |
82 |
| - az_tel = dl2table['az_tel'] |
| 82 | + alt_tel = np.array(dl2table['alt_tel']) |
| 83 | + az_tel = np.array(dl2table['az_tel']) |
83 | 84 |
|
84 | 85 | training_alt_rad = np.pi / 2 - training_pointings['zd'].to(u.rad).value
|
85 | 86 | training_az_rad = training_pointings['az'].to(u.rad).value
|
@@ -169,18 +170,24 @@ def predict_with_zd_interpolation(rf, param_array, features):
|
169 | 170 |
|
170 | 171 | features_copy = features.copy()
|
171 | 172 | alt_index_in_features = features_copy.index('alt_tel')
|
172 |
| - # First use alt_tel of closest MC training node: |
173 |
| - features_copy[alt_index_in_features] = 'alt0' |
174 |
| - if is_classifier: |
175 |
| - prediction_0 = rf.predict_proba(param_array[features_copy]) |
176 |
| - else: |
177 |
| - prediction_0 = rf.predict(param_array[features_copy]) |
178 |
| - # Now the alt_tel value of the second-closest node: |
179 |
| - features_copy[alt_index_in_features] = 'alt1' |
180 |
| - if is_classifier: |
181 |
| - prediction_1 = rf.predict_proba(param_array[features_copy]) |
182 |
| - else: |
183 |
| - prediction_1 = rf.predict(param_array[features_copy]) |
| 173 | + |
| 174 | + with warnings.catch_warnings(): |
| 175 | + warnings.simplefilter("ignore") |
| 176 | + # This is just to avoid the RFs to warn about the features |
| 177 | + # unnamed (passed as an array). We do this because we want to replace |
| 178 | + # alt_tel by alt0, then by alt1... |
| 179 | + # First use alt_tel of closest MC training node: |
| 180 | + features_copy[alt_index_in_features] = 'alt0' |
| 181 | + if is_classifier: |
| 182 | + prediction_0 = rf.predict_proba(param_array[features_copy].to_numpy()) |
| 183 | + else: |
| 184 | + prediction_0 = rf.predict(param_array[features_copy].to_numpy()) |
| 185 | + # Now the alt_tel value of the second-closest node: |
| 186 | + features_copy[alt_index_in_features] = 'alt1' |
| 187 | + if is_classifier: |
| 188 | + prediction_1 = rf.predict_proba(param_array[features_copy].to_numpy()) |
| 189 | + else: |
| 190 | + prediction_1 = rf.predict(param_array[features_copy].to_numpy()) |
184 | 191 |
|
185 | 192 | # Interpolated RF prediction:
|
186 | 193 | if is_classifier:
|
|
0 commit comments