Skip to content

Commit

Permalink
Reduce complexity of load_data function.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmerten committed Feb 28, 2024
1 parent 981d032 commit 4bb2a79
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions photonField.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def __init__(self):
self.load_data()

def load_data(self):
tmp_dict = {}
tmp_list = []

for i, z in enumerate(self.redshift):
data = pd.read_csv(self.files % z, sep="\s+", header=None)
Expand All @@ -573,13 +573,12 @@ def load_data(self):

# adding the energies only once, cause they are the same in every file
if i == 0:
tmp_dict['energy'] = eps
tmp_dict[str(z)] = n

df = pd.DataFrame(tmp_dict)
self.energy = df['energy'].to_numpy() # [eV]
self.photonDensity = [ (df.loc[i][1:] * (erg / eV) / (df.loc[i]['energy'])**2).to_numpy() for i in df.index ] # [1/cm^3/eV]
self.energy = eps
tmp_list.append( n * (erg / eV) / self.energy**2 ) # [1/cm^3/eV]

self.photonDensity = np.array(tmp_list).transpose()


# --------------------------------------------------------
# CRB (radio) models
# --------------------------------------------------------
Expand Down

0 comments on commit 4bb2a79

Please sign in to comment.