Commit fe90ddbe authored by DavidWalz's avatar DavidWalz

improve python3 compatibility, sim.py: fix optional make dir

parent 89690194
......@@ -5,8 +5,8 @@ __all__ = [
"atmosphere",
"plotting"]
import shower
import utils
import gumbel
import atmosphere
import plotting
import airshower.shower
import airshower.utils
import airshower.gumbel
import airshower.atmosphere
import airshower.plotting
from __future__ import division, print_function
import numpy as np
from os import path
from scipy import integrate, interpolate, optimize
import os.path
R_E = 6.371 * 1e6 # radius of Earth
H_MAX = 112829.2 # height above sea level where the mass overburden vanishes
......@@ -226,7 +228,7 @@ class Atmosphere:
if filename is None:
filename = 'atmosphere_model%i.npz' % model
if os.path.exists(filename):
if path.exists(filename):
print('Reading constants from %s' % filename)
data = np.load(filename)
assert self.model == data['model'], 'File contains parameters for different model %i' % model
......
from __future__ import division
from __future__ import division, print_function
import numpy as np
......
""" Plotting routines
"""
from __future__ import division
from __future__ import division, print_function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from matplotlib.colors import Normalize
import seaborn.apionly as sns
import utils
from airshower import utils
def maybe_save(fig, fname):
......
from __future__ import division
from __future__ import division, print_function
import numpy as np
import utils
import atmosphere
import gumbel
import plotting
from airshower import atmosphere, gumbel, utils
HEIGHT = 1400
......@@ -146,7 +142,6 @@ def rand_events(logE, mass, v_stations, fname=None, wavefront='planar'):
S1 = np.zeros((nb_events, nb_stations, 80))
S2 = np.zeros((nb_events, nb_stations, 80))
for i in range(nb_events):
# print('%4i, logE = %.2f' % (i, logE[i]))
S1[i], S2[i] = detector_response(logE[i], mass[i], v_axis[i], v_core[i], v_max[i], v_stations)
if wavefront == 'planar':
T[i] = utils.arrival_time_planar(v_stations, v_core[i], v_axis[i])
......
from __future__ import division
from __future__ import division, print_function
import numpy as np
......
from __future__ import division, print_function
import numpy as np
from airshower import shower, utils, plotting
import argparse
import os
from airshower import shower, utils
parser = argparse.ArgumentParser()
parser.add_argument("--mass", default=1, type=int, help='mass number')
parser.add_argument("--nfiles", default=10, type=int, help='number of files')
parser.add_argument("--nevents", default=10000, type=int, help='number of events per file')
parser.add_argument("--path", default='./RawData', type=str, help='output folder')
args = parser.parse_args()
print 'Simulating'
print 'A', args.mass
print 'nfiles', args.nfiles
print 'nevents', args.nevents
print('A', args.mass)
print('nfiles', args.nfiles)
print('nevents', args.nevents)
print('path', args.path)
print('Simulating')
if not(os.path.exists(args.path)):
os.makedirs(args.path)
v_stations = utils.station_coordinates(9, layout='offset')
for i in range(args.nfiles):
fname = '%s/showers-A%i-%i.npz' % (args.path, args.mass, i)
print(fname)
logE = 18.5 + 1.5 * np.random.rand(args.nevents)
mass = args.mass * np.ones(args.nevents)
data = shower.rand_events(logE, mass, v_stations)
print "save package:", i
np.savez_compressed(
'./RawData/showers-A%i-%i.npz' % (args.mass, i),
fname,
detector=data['detector'],
logE=data['logE'],
mass=data['mass'],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment