Skip to content
Snippets Groups Projects
Commit c9d6a705 authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Update uproot & awkward import style

parent 78794069
No related branches found
No related tags found
No related merge requests found
Pipeline #16269 passed with warnings
...@@ -18,8 +18,8 @@ from io import StringIO ...@@ -18,8 +18,8 @@ from io import StringIO
from os import listdir from os import listdir
from os.path import isfile, join, abspath from os.path import isfile, join, abspath
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
import awkward1 import awkward as ak
import uproot4 import uproot
from scipy.interpolate import UnivariateSpline from scipy.interpolate import UnivariateSpline
from scipy.spatial.transform import Rotation from scipy.spatial.transform import Rotation
import scipy.constants as constants import scipy.constants as constants
...@@ -202,7 +202,7 @@ class GiBUUOutput: ...@@ -202,7 +202,7 @@ class GiBUUOutput:
Parameters Parameters
---------- ----------
roottuple_data: awkward1.highlevel.Array roottuple_data: awkward.highlevel.Array
""" """
d = roottuple_data d = roottuple_data
k_in = np.vstack([ k_in = np.vstack([
...@@ -233,7 +233,7 @@ class GiBUUOutput: ...@@ -233,7 +233,7 @@ class GiBUUOutput:
Parameters Parameters
---------- ----------
roottuple_data: awkward1.highlevel.Array roottuple_data: awkward.highlevel.Array
""" """
d = roottuple_data d = roottuple_data
y = 1 - np.divide(np.array(d.lepOut_E), np.array(d.lepIn_E)) y = 1 - np.divide(np.array(d.lepOut_E), np.array(d.lepIn_E))
...@@ -257,7 +257,7 @@ class GiBUUOutput: ...@@ -257,7 +257,7 @@ class GiBUUOutput:
GiBUU output data in pandas dataframe format GiBUU output data in pandas dataframe format
""" """
import pandas as pd import pandas as pd
df = awkward1.to_pandas(self.arrays) df = ak.to_pandas(self.arrays)
sec_df = df[df.index.get_level_values(1) == 0].copy() sec_df = df[df.index.get_level_values(1) == 0].copy()
sec_df.loc[:, "E"] = sec_df.lepOut_E sec_df.loc[:, "E"] = sec_df.lepOut_E
sec_df.loc[:, "Px"] = sec_df.lepOut_Px sec_df.loc[:, "Px"] = sec_df.lepOut_Px
...@@ -275,11 +275,11 @@ class GiBUUOutput: ...@@ -275,11 +275,11 @@ class GiBUUOutput:
@property @property
def arrays(self): def arrays(self):
""" """
GiBUU output data in awkward1 format GiBUU output data in awkward format
""" """
retval = None retval = None
for ifile in self.root_pert_files: for ifile in self.root_pert_files:
fobj = uproot4.open(join(self.data_path, ifile)) fobj = uproot.open(join(self.data_path, ifile))
if retval is None: if retval is None:
retval = fobj["RootTuple"].arrays() retval = fobj["RootTuple"].arrays()
else: else:
......
...@@ -16,7 +16,7 @@ import numpy as np ...@@ -16,7 +16,7 @@ import numpy as np
import scipy.constants as const import scipy.constants as const
import proposal as pp import proposal as pp
from particle import Particle from particle import Particle
import awkward1 as ak import awkward as ak
from collections import defaultdict from collections import defaultdict
from .config import Config from .config import Config
...@@ -61,7 +61,7 @@ def propagate_lepton(lepout_data, pdgid): ...@@ -61,7 +61,7 @@ def propagate_lepton(lepout_data, pdgid):
Parameters Parameters
---------- ----------
lepout_data: awkward1.highlevel.Array lepout_data: awkward.highlevel.Array
Lepton data in the GiBUU output shape containing the fields Lepton data in the GiBUU output shape containing the fields
'lepOut_E, lepOut_Px, lepOut_Py, lepOut_Pz' 'lepOut_E, lepOut_Px, lepOut_Py, lepOut_Pz'
pdgid: pdgid:
...@@ -69,7 +69,7 @@ def propagate_lepton(lepout_data, pdgid): ...@@ -69,7 +69,7 @@ def propagate_lepton(lepout_data, pdgid):
Returns Returns
------- -------
awkward1.highlevel.Array (E, Px, Py, Pz, x, y, z) awkward.highlevel.Array (E, Px, Py, Pz, x, y, z)
""" """
lepton_info = Particle.from_pdgid(pdgid) lepton_info = Particle.from_pdgid(pdgid)
prop_range = const.c * lepton_info.lifetime * 1e11 * np.max( prop_range = const.c * lepton_info.lifetime * 1e11 * np.max(
......
...@@ -13,7 +13,7 @@ __status__ = "Development" ...@@ -13,7 +13,7 @@ __status__ = "Development"
import csv import csv
import unittest import unittest
import numpy as np import numpy as np
import uproot4 import uproot
from os.path import abspath, join, dirname from os.path import abspath, join, dirname
from thepipe.logger import get_logger from thepipe.logger import get_logger
from km3net_testdata import data_path from km3net_testdata import data_path
...@@ -34,7 +34,7 @@ class TestTauPropagation(unittest.TestCase): ...@@ -34,7 +34,7 @@ class TestTauPropagation(unittest.TestCase):
log.setLevel("INFO") log.setLevel("INFO")
self.gibuu_output = GiBUUOutput(TESTDATA_DIR) self.gibuu_output = GiBUUOutput(TESTDATA_DIR)
fname = join(TESTDATA_DIR, self.gibuu_output.root_pert_files[0]) fname = join(TESTDATA_DIR, self.gibuu_output.root_pert_files[0])
fobj = uproot4.open(fname) fobj = uproot.open(fname)
data = fobj["RootTuple"].arrays() data = fobj["RootTuple"].arrays()
self.sec = propagate_lepton(data, 15) self.sec = propagate_lepton(data, 15)
......
...@@ -6,8 +6,8 @@ thepipe ...@@ -6,8 +6,8 @@ thepipe
particle particle
click click
f90nml f90nml
uproot4 uproot>=4.0.0
awkward1>=0.4.4 awkward>=1.0.0
pandas pandas
mendeleev mendeleev
proposal proposal
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment