Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove root numpy and process multiple run groups #177

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ Use the [conda package manager](https://docs.conda.io/projects/conda/en/latest/u
```
conda env create -f environment-vegas.yml
```
Sometimes conda fails, so as an alternative, install and use mamba as a direct replacement to the conda call during the installation.

```
conda install -c conda-forge mamba
mamba env create -f environment-vegas.yml
```

The environment ```v2dl3-vegas``` will be created and can be activated with:

```
Expand Down
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
Loading