-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e97ed5
commit 1be5704
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import logging | ||
|
||
from numba import objmode | ||
from numba.core import dispatcher | ||
|
||
from tardis.montecarlo import ( | ||
montecarlo_configuration as montecarlo_configuration, | ||
) | ||
|
||
logger = logging.getLogger("tardis_montecarlo") | ||
logger.setLevel(logging.DEBUG) | ||
|
||
# if montecarlo_configuration.packet_tracking: | ||
# logging.basicConfig( | ||
# filename="montecarlolog.log", | ||
# filemode="w", | ||
# level=logger.getEffectiveLevel(), | ||
# ) | ||
|
||
file_handler = logging.FileHandler("montecarlo_packet_properties.csv", mode="w") | ||
# file_rotator = logging.handlers.RotatingFileHandler( | ||
# "montecarlo_log.log", maxBytes=2000, backupCount=10 | ||
# ) | ||
logger.addHandler(file_handler) | ||
# logger.addHandler(file_rotator) | ||
logger.info( | ||
"seed, index, status, nu, mu, r, energy, current_shell, interaction, distance" | ||
) | ||
|
||
|
||
def montecarlo_tracker(r_packet, distance, last_run): | ||
if last_run: | ||
if ( | ||
montecarlo_configuration.packet_seed | ||
and r_packet.seed == montecarlo_configuration.packet_seed | ||
): | ||
if ( | ||
len(montecarlo_configuration.packet_indices) != 0 | ||
and r_packet.index in montecarlo_configuration.packet_indices | ||
): | ||
packet_tracking(r_packet, distance) | ||
else: | ||
packet_tracking(r_packet, distance) | ||
|
||
elif ( | ||
len(montecarlo_configuration.packet_indices) != 0 | ||
and r_packet.index in montecarlo_configuration.packet_indices | ||
): | ||
packet_tracking(r_packet, distance) | ||
|
||
|
||
def packet_tracking(r_packet, distance): | ||
logger.info( | ||
"{seed}, {index}, {status}, {nu:.3g}, {mu:.3g}, {r:.3g}, {energy:.3g}, {current_shell}, {interaction:.3g}, {distance:.3g}".format( | ||
status=r_packet.status, | ||
nu=r_packet.nu, | ||
mu=r_packet.mu, | ||
r=r_packet.r, | ||
index=r_packet.index, | ||
energy=r_packet.energy, | ||
current_shell=r_packet.current_shell_id, | ||
seed=r_packet.seed, | ||
interaction=r_packet.last_interaction_type, | ||
distance=distance, | ||
) | ||
) |