Skip to content

Commit

Permalink
Add else statement to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
KasukabeDefenceForce committed Jan 7, 2025
1 parent 33aa8af commit 1a7684a
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions tardis/visualization/tools/simulation_packet_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,35 @@ def from_simulation(cls, sim, packets_mode):
t_inner=t_inner,
time_of_simulation=time_of_simulation,
)
# Packets-specific properties need to be only for those packets
# which got emitted
mask = transport_state.emitted_packet_mask
return cls(
last_interaction_type=transport_state.last_interaction_type[mask],
last_line_interaction_in_id=transport_state.last_line_interaction_in_id[
mask
],
last_line_interaction_out_id=transport_state.last_line_interaction_out_id[
mask
],
last_line_interaction_in_nu=transport_state.last_interaction_in_nu[
mask
],
last_interaction_in_r=transport_state.last_interaction_in_r[mask],
lines_df=lines_df,
packet_nus=transport_state.packet_collection.output_nus[mask],
packet_energies=transport_state.packet_collection.output_energies[
mask
],
r_inner=r_inner,
spectrum_delta_frequency=spectrum.delta_frequency,
spectrum_frequency_bins=spectrum._frequency,
spectrum_luminosity_density_lambda=spectrum.luminosity_density_lambda,
spectrum_wavelength=spectrum.wavelength,
t_inner=t_inner,
time_of_simulation=time_of_simulation,
)
else: # real packets
# Packets-specific properties need to be only for those packets
# which got emitted
mask = transport_state.emitted_packet_mask
return cls(
last_interaction_type=transport_state.last_interaction_type[mask],
last_line_interaction_in_id=transport_state.last_line_interaction_in_id[
mask
],
last_line_interaction_out_id=transport_state.last_line_interaction_out_id[
mask
],
last_line_interaction_in_nu=transport_state.last_interaction_in_nu[
mask
],
last_interaction_in_r=transport_state.last_interaction_in_r[mask],
lines_df=lines_df,
packet_nus=transport_state.packet_collection.output_nus[mask],
packet_energies=transport_state.packet_collection.output_energies[
mask
],
r_inner=r_inner,
spectrum_delta_frequency=spectrum.delta_frequency,
spectrum_frequency_bins=spectrum._frequency,
spectrum_luminosity_density_lambda=spectrum.luminosity_density_lambda,
spectrum_wavelength=spectrum.wavelength,
t_inner=t_inner,
time_of_simulation=time_of_simulation,
)

@classmethod
def from_hdf(cls, hdf_fpath, packets_mode):
Expand Down

0 comments on commit 1a7684a

Please sign in to comment.