Blame view

modules/read.py 2.11 KB
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
1
2
3
4
5
6
from numpy import loadtxt

resultsFile="/results.dat"
profileFile="/profile.dat"

# READ SIMULATIONS FILES ===================================================================
d943e502   Thomas Fitoussi   Update 'analysis'...
7
def ReadResults(simulation,cols=[0,1,2,3,4,5,6,7,8,9]):
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
8
9
10
11
12
13
   '''
      Allowed to read results file of a simulation (all or part of it):
         0 - generation
         1 - weight
         2 - energy [GeV]
         3 - time delay [s]
d943e502   Thomas Fitoussi   Update 'analysis'...
14
15
16
         4,5,6,7 - arrival direction (polar coordinate - theta_pos, theta_dir, phi_pos, phi_dir) [rad]
         8 - arrival angle [rad]
         9 - source photon energy [GeV]
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
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
   '''
   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]): 
d943e502   Thomas Fitoussi   Update 'analysis'...
45
   return loadtxt(resultdir+fileName+"/arrival_Angle_distribution.txt",unpack=True,usecols=cols)
30f3bf5d   Thomas Fitoussi   Adapt reading of ...
46
47
48
49
50
51
52
53
54
55
56
57

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)