Skip to content

Commit

Permalink
Merge b828bb8 into b5ab813
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbird7112 authored Mar 13, 2022
2 parents b5ab813 + b828bb8 commit c19b0ec
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 41 deletions.
4 changes: 2 additions & 2 deletions docs/contributing/development/debug_numba.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ To facilitate more in-depth debugging when interfacing with the `montecarlo_numb
module, we provide a set of debugging configurations. PyCharm debugging
configurations, in addition to related scripts and .yml files, are contained in
`tardis.scripts.debug`. Currently, these include the ability to run TARDIS
in asingle-packet mode, with the packet seed identified at debug time.
`tardis_example_single.yml` is the configuration filethat is used to set up the
in a single-packet mode.
`tardis_example_single.yml` is the configuration file that is used to set up the
single-packet TARDIS run; `run_numba_single.py` is thePython script that runs
this .yml file; `run_numba_single.xml` is the PyCharmdebug configuration file
that can be used in conjunction with the above files.
Expand Down
5 changes: 0 additions & 5 deletions tardis/io/schemas/montecarlo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ properties:
type: number
default: 1
description: Provides option to not log every line.
single_packet_seed:
type:
- number
default: -1
description: If debug_packets is true, this is the seed for the only packet.

required:
- no_of_packets
Expand Down
1 change: 0 additions & 1 deletion tardis/io/schemas/montecarlo_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ definitions:
title: 'Damped Convergence Strategy'
type: object
additionalProperties: false
properties:
properties:
type:
enum:
Expand Down
3 changes: 0 additions & 3 deletions tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def __init__(
packet_source=None,
debug_packets=False,
logger_buffer=1,
single_packet_seed=None,
tracking_rpacket=False,
use_gpu=False,
):
Expand All @@ -119,7 +118,6 @@ def __init__(
self.enable_full_relativity = enable_full_relativity
numba_config.ENABLE_FULL_RELATIVITY = enable_full_relativity
self.line_interaction_type = line_interaction_type
self.single_packet_seed = single_packet_seed
self.integrator_settings = integrator_settings
self.v_packet_settings = v_packet_settings
self.spectrum_method = spectrum_method
Expand Down Expand Up @@ -687,7 +685,6 @@ def from_config(
packet_source=packet_source,
debug_packets=config.montecarlo.debug_packets,
logger_buffer=config.montecarlo.logger_buffer,
single_packet_seed=config.montecarlo.single_packet_seed,
virtual_packet_logging=(
config.spectrum.virtual.virtual_packet_logging
| virtual_packet_logging
Expand Down
1 change: 0 additions & 1 deletion tardis/montecarlo/montecarlo_configuration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from tardis import constants as const

full_relativity = True
single_packet_seed = -1
temporary_v_packet_bins = 0
number_of_vpackets = 0
montecarlo_seed = 0
Expand Down
12 changes: 3 additions & 9 deletions tardis/montecarlo/montecarlo_numba/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,8 @@ def montecarlo_main_loop(
total_iterations=total_iterations,
)

if montecarlo_configuration.single_packet_seed != -1:
seed = packet_seeds[montecarlo_configuration.single_packet_seed]
np.random.seed(seed)
else:
seed = packet_seeds[i]
np.random.seed(seed)
seed = packet_seeds[i]
np.random.seed(seed)
r_packet = RPacket(
numba_model.r_inner[0],
packet_collection.packets_input_mu[i],
Expand Down Expand Up @@ -260,9 +256,7 @@ def montecarlo_main_loop(
v_packets_idx = np.floor(
(vpackets_nu - spectrum_frequency[0]) / delta_nu
).astype(np.int64)
# if we're only in a single-packet mode
# if montecarlo_configuration.single_packet_seed == -1:
# break

for j, idx in enumerate(v_packets_idx):
if (vpackets_nu[j] < spectrum_frequency[0]) or (
vpackets_nu[j] > spectrum_frequency[-1]
Expand Down
1 change: 0 additions & 1 deletion tardis/montecarlo/montecarlo_numba/numba_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ def configuration_initialize(runner, number_of_vpackets):
montecarlo_configuration.temporary_v_packet_bins = number_of_vpackets
montecarlo_configuration.full_relativity = runner.enable_full_relativity
montecarlo_configuration.montecarlo_seed = runner.seed
montecarlo_configuration.single_packet_seed = runner.single_packet_seed
montecarlo_configuration.v_packet_spawn_start_frequency = (
runner.virtual_spectrum_spawn_range.end.to(
u.Hz, equivalencies=u.spectral()
Expand Down
19 changes: 1 addition & 18 deletions tardis/scripts/debug/run_numba_single.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
from tardis import run_tardis
import numpy as np
from tardis.montecarlo.montecarlo_numba.base import montecarlo_main_loop
import os
import numba
import sys
import yaml


SEED = eval(sys.argv[1].split("=")[1])[0]

yaml_file, params = "tardis_example_single.yml", None

with open(yaml_file) as f:
params = yaml.safe_load(f)

params["montecarlo"]["single_packet_seed"] = SEED

with open(yaml_file, "w") as f:
yaml.safe_dump(params, f)
yaml_file = "tardis_example_single.yml"

mdl = run_tardis(yaml_file)
1 change: 0 additions & 1 deletion tardis/scripts/debug/tardis_example_single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ montecarlo:
no_of_virtual_packets: 0
nthreads: 6
seed: 23111963
single_packet_seed: 46
plasma:
disable_electron_scattering: false
excitation: lte
Expand Down

0 comments on commit c19b0ec

Please sign in to comment.