Skip to content

Commit

Permalink
Merging Numpy Hotix
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-w-lundy committed Oct 2, 2023
2 parents 1db7536 + fa1189c commit 3ba51b9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 0 additions & 1 deletion environment-vegas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- python=3.8
- pyyaml
- root
- root_numpy
- scipy
- tqdm
- uproot
3 changes: 2 additions & 1 deletion pyV2DL3/script/v2dl3_for_vegas.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,13 @@ def runlist_to_file_pairs(runlist, event_class_mode, output):
eas = rl_dict["EA"]
st5s = rl_dict["RUNLIST"]

file_pairs = []
for runlist_id in st5s.keys():
if len(eas[runlist_id]) < 1:
raise Exception("No EA filenames defined for runlist tag: " + runlist_id)

ea_files = [EffectiveAreaFile(ea) for ea in eas[runlist_id]]
file_pairs = [(st5_file, ea_files) for st5_file in st5s[runlist_id]]
file_pairs.extend([(st5_file, ea_files) for st5_file in st5s[runlist_id]])

return file_pairs

Expand Down
21 changes: 16 additions & 5 deletions pyV2DL3/vegas/irfloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import numpy as np
import ROOT
from root_numpy import hist2array
from scipy.interpolate import RegularGridInterpolator


Expand Down Expand Up @@ -88,7 +87,19 @@ def get_irf_not_safe(manager, offset_arr, az, ze, noise, pointlike, psf_king=Fal
continue

# Get Ebias
a, e = hist2array(eb_dl3, return_edges=True)
n_bins_x = eb_dl3.GetNbinsX()
n_bins_y = eb_dl3.GetNbinsY()

bin_edges_x = [eb_dl3.GetXaxis().GetBinLowEdge(i) for i in range(1, n_bins_x + 2)]
bin_edges_y = [eb_dl3.GetYaxis().GetBinLowEdge(i) for i in range(1, n_bins_y + 2)]
a = np.zeros((n_bins_y, n_bins_x))
for i in range(1, n_bins_x + 1):
for j in range(1, n_bins_y + 1):
bin_content = eb_dl3.GetBinContent(i, j)
a[j - 1, i - 1] = bin_content
e = np.vstack((bin_edges_x, bin_edges_y))


eLow = np.power(10, [e[0][:-1]])[0]
eHigh = np.power(10, [e[0][1:]])[0]

Expand Down Expand Up @@ -130,9 +141,9 @@ def get_irf_not_safe(manager, offset_arr, az, ze, noise, pointlike, psf_king=Fal

# Get ABias
if not pointlike and not psf_king:
a, e = hist2array(
manager.getAngularBias_DL3(effectiveAreaParameters), return_edges=True
)
a = np.array([manager.getAngularBias_DL3(effectiveAreaParameters).GetBinContent(i) for i in range(1, manager.getAngularBias_DL3(effectiveAreaParameters).GetNbinsX() + 1)])
e = np.array([manager.getAngularBias_DL3(effectiveAreaParameters).GetBinLowEdge(i) for i in range(1, manager.getAngularBias_DL3(effectiveAreaParameters).GetNbinsX() + 2)])

eLow = np.power(10, [e[0][:-1]])[0]
eHigh = np.power(10, [e[0][1:]])[0]

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"scipy",
"tqdm",
"uproot",
"root_numpy",
],
entry_points="""
[console_scripts]
Expand Down

0 comments on commit 3ba51b9

Please sign in to comment.