read.py 2.07 KB
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)