Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix virt energy #592

Merged
merged 3 commits into from
Jun 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import warnings

from astropy import units as u, constants as const

Expand Down Expand Up @@ -156,6 +157,36 @@ def output_nu(self):
def output_energy(self):
return u.Quantity(self._output_energy, u.erg)

@property
def virtual_packet_nu(self):
try:
return u.Quantity(self.virt_packet_nus, u.Hz)
except AttributeError:
warnings.warn("MontecarloRunner.virtual_packet_nu:"
"compile with --with-vpacket-logging"
"to access this property", UserWarning)
return None

@property
def virtual_packet_energy(self):
try:
return u.Quantity(self.virt_packet_energies, u.erg)
except AttributeError:
warnings.warn("MontecarloRunner.virtual_packet_energy:"
"compile with --with-vpacket-logging"
"to access this property", UserWarning)
return None

@property
def virtual_packet_luminosity(self):
try:
return self.virtual_packet_energy / self.time_of_simulation
except TypeError:
warnings.warn("MontecarloRunner.virtual_packet_luminosity:"
"compile with --with-vpacket-logging"
"to access this property", UserWarning)
return None

@property
def packet_luminosity(self):
return self.output_energy / self.time_of_simulation
Expand Down Expand Up @@ -248,4 +279,4 @@ def calculate_f_lambda(self, wavelength):

def save_spectra(self, fname):
self.spectrum.to_ascii(fname)
self.spectrum_virtual.to_ascii('virtual_' + fname)
self.spectrum_virtual.to_ascii('virtual_' + fname)