read.py
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from numpy import loadtxt
resultsFile="/results.dat"
profileFile="/profile.dat"
# READ SIMULATIONS FILES ===================================================================
def ReadResults(simulation,cols=[0,1,2,3,4,5,6,7]):
'''
Allowed to read results file of a simulation (all or part of it):
0 - generation
1 - weight
2 - energy [GeV]
3 - time delay [s]
4,5 - arrival direction (polar coordinate - theta, phi) [rad]
6 - arrival angle [rad]
7 - source photon energy [GeV]
'''
return loadtxt(simulation+resultsFile,unpack=True,usecols=cols)
# READ RESULTS FILES =======================================================================
resultdir="Results/"
def ReadProfile(fileName,cols=[0,1,2,3,4,5]):
'''
Allowed to read simulation profile
0 - magnetic field amplitude [Gauss]
1 - maximum source energy [TeV]
2 - source distance [Mpc]
3 - source redshift
4 - number of photons emitted
5 - number of leptons produced during the cascade
'''
return loadtxt(resultdir+fileName+profileFile,unpack=True,usecols=cols)
def ReadSpectrum(fileName,cols=[0,1,2,3,4,5,6,7,8]):
return loadtxt(resultdir+fileName+"/Spectrum.txt",unpack=True,usecols=cols)
def ReadSourceSpectrum(fileName,cols=[0,1,2,3,4]):
return loadtxt(resultdir+fileName+"/Source_spectrum.txt",unpack=True,usecols=cols)
def ReadAngleVsEnergy(fileName,cols=[0,1,2,3,4]):
return loadtxt(resultdir+fileName+"/Angle_vs_Energy.txt",unpack=True,usecols=cols)
def ReadRadial(fileName,cols=[0,1,2,3,4]):
return loadtxt(resultdir+fileName+"/Radial_distribution.txt",unpack=True,usecols=cols)
def ReadTiming(fileName,cols=[0,1,2,3,4]):
'''
'''
return loadtxt(resultdir+fileName+"/Timing.txt",unpack=True,usecols=cols)
def ReadGeneration(fileName,cols=[0,1]):
return loadtxt(resultdir+fileName+"/Generation.txt",unpack=True,usecols=cols)
def ReadDelayVsAngle(fileName,cols=[0,1,2,3,4]):
return loadtxt(resultdir+fileName+"/Delay_versus_angle.txt",unpack=True,usecols=cols)