Skip to content

Commit

Permalink
Calculate velocity if not given as input
Browse files Browse the repository at this point in the history
  • Loading branch information
KasukabeDefenceForce committed Jan 7, 2025
1 parent b499edf commit 24fb361
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tardis/visualization/tools/visualization_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
time_explosion,
v_inner,
v_outer,
velocity
):
"""
Initialize the SimulationPacketData with required properties of simulation model.
Expand Down Expand Up @@ -99,11 +100,22 @@ def __init__(
self.time_explosion = time_explosion
self.v_inner = v_inner
self.v_outer = v_outer
self.velocity = pd.concat(

# First check if both options are provided
if velocity is not None and (v_inner is not None or v_outer is not None):
raise ValueError(
"Cannot specify both velocity and (v_inner, v_outer). "
"Please provide either velocity OR the (v_inner, v_outer) pair."
)

if velocity is not None:
self.velocity = velocity

if v_inner is not None and v_outer is not None:
self.velocity = pd.concat(
[v_inner, pd.Series([v_outer.iloc[-1]])], ignore_index=True
).tolist() * (u.cm / u.s)


# Create dataframe of packets that experience line interaction
line_mask = (self.packets_df["last_interaction_type"] > -1) & (
self.packets_df["last_line_interaction_in_id"] > -1
Expand Down Expand Up @@ -165,6 +177,7 @@ def from_simulation(cls, sim, packets_mode):
t_inner = sim.simulation_state.packet_source.temperature
v_inner = sim.simulation_state.v_inner
v_outer = sim.simulation_state.v_outer
velocity = sim.simulation_state.velocity
time_of_simulation = (
transport_state.packet_collection.time_of_simulation * u.s
)
Expand Down Expand Up @@ -194,7 +207,8 @@ def from_simulation(cls, sim, packets_mode):
time_of_simulation=time_of_simulation,
time_explosion=time_explosion,
v_inner=v_inner,
v_outer=v_outer
v_outer=v_outer,
velocity=velocity
)
else: # real packets
# Packets-specific properties need to be only for those packets
Expand Down Expand Up @@ -226,7 +240,8 @@ def from_simulation(cls, sim, packets_mode):
time_of_simulation=time_of_simulation,
time_explosion=time_explosion,
v_inner=v_inner,
v_outer=v_outer
v_outer=v_outer,
velocity=velocity
)

@classmethod
Expand Down

0 comments on commit 24fb361

Please sign in to comment.