From 40d0b4481c5ab98f4b0034e36d6fad0d6681ecd3 Mon Sep 17 00:00:00 2001 From: yuyizh Date: Sat, 20 Mar 2021 14:00:33 +0800 Subject: [PATCH] add docstring --- tardis/base.py | 7 ++++++ tardis/montecarlo/base.py | 45 +++++++++++++++++++++++++++++++++++++++ tardis/simulation/base.py | 4 ++++ 3 files changed, 56 insertions(+) diff --git a/tardis/base.py b/tardis/base.py index 3b9ef9ca4e3..d4d44da34c7 100644 --- a/tardis/base.py +++ b/tardis/base.py @@ -19,6 +19,13 @@ def run_tardis( the atomic data. Atomic data to use for this TARDIS simulation. If set to None, the atomic data will be loaded according to keywords set in the configuration [default=None] + virtual_packet_logging : bool + option to enable virtual packet logging + [default=False] + + Returns + ------- + Simulation """ from tardis.io.config_reader import Configuration from tardis.io.atom_data.base import AtomData diff --git a/tardis/montecarlo/base.py b/tardis/montecarlo/base.py index 2fd6ee7e1d7..e88237adc14 100644 --- a/tardis/montecarlo/base.py +++ b/tardis/montecarlo/base.py @@ -425,7 +425,18 @@ def montecarlo_virtual_luminosity(self): def calculate_emitted_luminosity( self, luminosity_nu_start, luminosity_nu_end ): + """ + Calculate emitted luminosity. + + Parameters + ---------- + luminosity_nu_start : astropy.units.Quantity + luminosity_nu_end : astropy.units.Quantity + Returns + ------- + astropy.units.Quantity + """ luminosity_wavelength_filter = ( self.emitted_packet_nu > luminosity_nu_start ) & (self.emitted_packet_nu < luminosity_nu_end) @@ -439,7 +450,18 @@ def calculate_emitted_luminosity( def calculate_reabsorbed_luminosity( self, luminosity_nu_start, luminosity_nu_end ): + """ + Calculate reabsorbed luminosity. + Parameters + ---------- + luminosity_nu_start : astropy.units.Quantity + luminosity_nu_end : astropy.units.Quantity + + Returns + ------- + astropy.units.Quantity + """ luminosity_wavelength_filter = ( self.reabsorbed_packet_nu > luminosity_nu_start ) & (self.reabsorbed_packet_nu < luminosity_nu_end) @@ -484,6 +506,17 @@ def calculate_radiationfield_properties(self): return t_rad * u.K, w def calculate_luminosity_inner(self, model): + """ + Calculate inner luminosity. + + Parameters + ---------- + model : model.Radial1DModel + + Returns + ------- + astropy.units.Quantity + """ return ( 4 * np.pi @@ -493,6 +526,17 @@ def calculate_luminosity_inner(self, model): ).to("erg/s") def calculate_time_of_simulation(self, model): + """ + Calculate time of montecarlo simulation. + + Parameters + ---------- + model : model.Radial1DModel + + Returns + ------- + float + """ return 1.0 * u.erg / self.calculate_luminosity_inner(model) def calculate_f_nu(self, frequency): @@ -509,6 +553,7 @@ def from_config(cls, config, packet_source=None, virtual_packet_logging=False): Parameters ---------- config : tardis.io.config_reader.Configuration + virtual_packet_logging : bool Returns ------- diff --git a/tardis/simulation/base.py b/tardis/simulation/base.py index 0f7f1feddf0..b8136a2ccfe 100644 --- a/tardis/simulation/base.py +++ b/tardis/simulation/base.py @@ -349,6 +349,9 @@ def iterate(self, no_of_packets, no_of_virtual_packets=0, last_run=False): self.iterations_executed += 1 def run(self): + """ + run the simulation + """ start_time = time.time() while self.iterations_executed < self.iterations - 1: self.store_plasma_state( @@ -509,6 +512,7 @@ def from_config(cls, config, packet_source=None, virtual_packet_logging=False, * Parameters ---------- config : tardis.io.config_reader.Configuration + **kwargs Allow overriding some structures, such as model, plasma, atomic data and the runner, instead of creating them from the configuration