Skip to content

Commit

Permalink
initial fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ibsafa committed Apr 16, 2024
1 parent 1d479bd commit 1346d37
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 163 deletions.
69 changes: 34 additions & 35 deletions taurunner/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ def initialize_parser(): # pragma: no cover
parser.add_argument(
'-s',
dest='seed',
type=int,
type=int,
default=None,
help='just an integer seed to help with output file names'
)
parser.add_argument(
'-n',
dest='nevents',
type=int,
'-n',
dest='nevents',
type=int,
default=0,
help='how many events do you want?'
)
parser.add_argument(
'--flavor',
dest='flavor',
'--flavor',
dest='flavor',
type=int, default=16,
help='neutrino flavor (default is nutau): 12 for nue 14 for numu 16 for nutau'
)
Expand All @@ -47,7 +47,7 @@ def initialize_parser(): # pragma: no cover
)
# Energy arguments
parser.add_argument(
'-e',
'-e',
dest='energy',
default='',
help='Energy in GeV if numerical value greater than 0 passed.\n\
Expand All @@ -69,7 +69,7 @@ def initialize_parser(): # pragma: no cover

# Angular arguments
parser.add_argument(
'-t',
'-t',
dest='theta',
default='',
help='nadir angle in degrees if numerical value(0 is through the core).\n\
Expand All @@ -78,23 +78,23 @@ def initialize_parser(): # pragma: no cover
parser.add_argument(
'--th_max',
dest='th_max',
type=float,
type=float,
default=90,
help='If doing a theta range, maximum theta value. Default 90, i.e. skimming'
)
parser.add_argument(
'--th_min',
'--th_min',
type=float,
default=0,
help='If doing a theta range, minimum theta value. Default 0, i.e. through the core'
)

# Saving arguments
parser.add_argument(
'--save',
dest='save',
type=str,
default='',
'--save',
dest='save',
type=str,
default='',
help="If saving output, provide a path here, if not specified, output will be printed"
)

Expand Down Expand Up @@ -132,10 +132,9 @@ def initialize_parser(): # pragma: no cover
default=0,
help="Depth of the detector in km."
)

# Options
parser.add_argument('--no_losses',
dest='no_losses',
dest='no_losses',
default=False,
action='store_true',
help="Raise this flag if you want to turn off tau losses. In this case, taus will decay at rest."
Expand All @@ -145,12 +144,12 @@ def initialize_parser(): # pragma: no cover
action='store_true',
help="Raise this flag to turn off secondaries"
)
parser.add_argument('-d',
dest='debug',
default=False,
action='store_true',
parser.add_argument('-d',
dest='debug',
default=False,
action='store_true',
help='Do you want to print out debug statments? If so, raise this flag'
)
)
parser.add_argument('--e_cut',
dest='e_cut',
default=0.0,
Expand All @@ -162,10 +161,10 @@ def initialize_parser(): # pragma: no cover
return args

def run_MC(
eini: np.ndarray,
eini: np.ndarray,
thetas: np.ndarray,
body: Body,
xs: CrossSections,
body: Body,
xs: CrossSections,
seed: int = 0,
no_secondaries: bool = False,
flavor: int = 16,
Expand Down Expand Up @@ -203,7 +202,7 @@ def run_MC(
prev_th = thetas[0]
prev_track = make_track(prev_th)
secondary_basket = []
idxx = []
idxx = []
my_track = None
prv_theta = np.nan
# Run the algorithm
Expand All @@ -218,16 +217,16 @@ def run_MC(
if (cur_theta!=prv_theta and track_type=='chord') or my_track is None: # We need to make a new track
my_track = getattr(track, track_type)(theta=cur_theta, depth=depth)
particle = Particle(
particleIDs[i],
cur_e,
particleIDs[i],
cur_e,
0.0 ,
xs,
not no_secondaries,
not no_secondaries,
no_losses
)

out = Propagate(particle, my_track, body, clp, condition=condition)

if (out.survived==False):
#this muon/electron was absorbed. we record it in the output with outgoing energy 0
output.append((cur_e, 0., cur_theta, out.nCC, out.nNC, out.ID, i, out.position))
Expand All @@ -243,7 +242,7 @@ def run_MC(
del out
del particle
idxx = np.asarray(idxx).astype(np.int32)
if not no_secondaries:
if not no_secondaries:
#make muon propagator
secondary_basket = np.concatenate(secondary_basket)
for sec, i in zip(secondary_basket, idxx):
Expand Down Expand Up @@ -318,7 +317,7 @@ def run_MC(
savedir = '/'.join(TR_specs['save'].split('/')[:-1])
if not os.path.isdir(savedir):
raise ValueError('Savedir %s does not exist' % TR_specs['save'])

# Set up a random state
rand = np.random.RandomState(TR_specs['seed'])

Expand All @@ -330,7 +329,7 @@ def run_MC(
# Make an array of injected energies
from taurunner.utils.make_initial_e import make_initial_e
eini = make_initial_e(TR_specs['nevents'], TR_specs['energy'],
e_min=TR_specs['e_min'], e_max=TR_specs['e_max'], rand=rand)
e_min=TR_specs['e_min'], e_max=TR_specs['e_max'])

# Make an array of injected incident angles
from taurunner.utils.make_initial_thetas import make_initial_thetas
Expand All @@ -341,7 +340,7 @@ def run_MC(
thetas = make_initial_thetas(TR_specs['nevents'], theta, rand=rand, track_type=TR_specs['track'])
sorter = np.argsort(thetas)
thetas = thetas[sorter]

xs = CrossSections(getattr(XSModel, TR_specs['xs_model'].upper()))

prop = make_propagator(TR_specs['flavor'] - np.sign(TR_specs["flavor"]), body, TR_specs['xs_model'])
Expand Down
2 changes: 1 addition & 1 deletion taurunner/track/utils/spline_column_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import pickle as pkl

from taurunner.utils import FileLock
from taurunner.utils.file_lock import FileLock
import taurunner as tr


Expand Down
3 changes: 1 addition & 2 deletions taurunner/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
from .construct_body import construct_body
from .setup_outdir import setup_outdir
from .sample_powerlaw import sample_powerlaw
from .make_propagator import make_propagator
from .make_initial_thetas import make_initial_thetas
from .make_initial_e import make_initial_e
from .make_initial_e import make_initial_e
125 changes: 0 additions & 125 deletions taurunner/utils/make_propagator.py

This file was deleted.

0 comments on commit 1346d37

Please sign in to comment.