Blame view

Modules/Read.py 2.11 KB
7030f150   Thomas Fitoussi   Full reorganisati...
1
2
3
4
5
6
from numpy import loadtxt

resultDirectory="Results/"
positionFile="/position"
momentumFile="/momentum"
extraFile="/extra"
8011cc96   Thomas Fitoussi   Add profile readi...
7
profileFile="/profile"
8ffbee93   Thomas Fitoussi   Analytic expressi...
8
ElmagFile="/Elmag_spectrum"
7030f150   Thomas Fitoussi   Full reorganisati...
9

65135318   Thomas Fitoussi   Reset modules
10
11
12
13
14
15
16
17
18
19
20
21
22
def ReadExtraFile(fileName,cols=[0,1,2,3,4,5]):
   '''
      charge, arrival redshift, weight, generation, arrival angle, emitting energy (source)
   '''
   return loadtxt(resultDirectory+fileName+extraFile,unpack=True,usecols=cols)

def ReadProfile(fileName,cols=[0,1,2,3,4,5]): 
   '''
      Source: Emin, redshift, dist (Mpc), total number of photons emitted, EGMF amplitude, 
              number of leptons producted
   '''
   return loadtxt(resultDirectory+fileName+profileFile,unpack=True,usecols=cols)

7030f150   Thomas Fitoussi   Full reorganisati...
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
def ReadTime(fileName):
   return loadtxt(resultDirectory+fileName+positionFile,unpack=True,usecols=[0])

def ReadPosition(fileName):
   return loadtxt(resultDirectory+fileName+positionFile,unpack=True,usecols=[1,2,3])

def ReadPositionAngle(fileName):
   return loadtxt(resultDirectory+fileName+positionFile,unpack=True,usecols=[4,5])

def ReadEnergy(fileName):
   return loadtxt(resultDirectory+fileName+momentumFile,unpack=True,usecols=[0])

def ReadMomentum(fileName):
   return loadtxt(resultDirectory+fileName+momentumFile,unpack=True,usecols=[1,2,3])

def ReadMomentumAngle(fileName):
   return loadtxt(resultDirectory+fileName+momentumFile,unpack=True,usecols=[4,5])

def ReadCharge(fileName):
   return loadtxt(resultDirectory+fileName+extraFile,unpack=True,usecols=[0])

def ReadRedshift(fileName):
   return loadtxt(resultDirectory+fileName+extraFile,unpack=True,usecols=[1])

def ReadWeight(fileName):
   return loadtxt(resultDirectory+fileName+extraFile,unpack=True,usecols=[2])

def ReadGeneration(fileName):
   return loadtxt(resultDirectory+fileName+extraFile,unpack=True,usecols=[3])

65135318   Thomas Fitoussi   Reset modules
53
54
55
def ReadArrivalAngle(fileName):
   return loadtxt(resultDirectory+fileName+extraFile,unpack=True,usecols=[4])

7030f150   Thomas Fitoussi   Full reorganisati...
56
57
58
def ReadElmag(fileName):
   Elmag=resultDirectory+fileName+ElmagFile
   energy,fluxGamma,fluxLepton = loadtxt(Elmag,unpack=True,usecols=[0,1,2])
374f3d52   Thomas Fitoussi   add Weight distri...
59
60
   energy *= 10**(-9) #GeV
   flux=(fluxGamma+fluxLepton)*1e-9 #GeV normalized to 1 initial photon
7030f150   Thomas Fitoussi   Full reorganisati...
61
   return energy,flux