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

[TEP006] Aggregate TARDIS restructure and configuration system cleanup #652

Merged
merged 127 commits into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from 126 commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
98f1250
Upgrade the model module to a python package.
ftsamis Jun 27, 2016
0c400a8
Introduce the basics of the new model/base.py.
ftsamis Jun 28, 2016
4bbd4b7
Add a dynamic density property to the new model.
ftsamis Jul 12, 2016
f74de3a
Add a volume and a no_of_shells property to the model.
ftsamis Jul 13, 2016
9ea458a
Add a radius property to the Radial1DModel.
ftsamis Jul 15, 2016
5a71008
Make t_radiative optional and initialize it accordingly to the legacy…
ftsamis Jul 15, 2016
3e4a9ce
Add properties for getting the indexes of the v_boundaries to the Rad…
ftsamis Jul 15, 2016
2847045
Add a model.density module and a model.base.from_config classmethod.
ftsamis Jul 15, 2016
674ab30
Convert the model's v_boundaries to properties.
ftsamis Jul 18, 2016
d3872fd
Introduce Radial1DModel cutting to v_boundaries.
ftsamis Jul 19, 2016
2968e63
Revert 'Add a model.density module' back to HomologousDensity.
ftsamis Jul 19, 2016
797e611
Change Radial1DModel.density to respect the v_boundaries.
ftsamis Jul 19, 2016
301584a
Change Radial1DModel.abundance to respect the v_boundaries.
ftsamis Jul 19, 2016
a601d2d
Allow model boundaries to be given as plain values.
ftsamis Jul 19, 2016
56c9f07
New model.density module to hold HomologousDensity and density functi…
ftsamis Jul 19, 2016
d069be7
Change MontecarloRunner so it doesn't depend on a Configuration object.
ftsamis Jul 26, 2016
7fdbb8d
Add a plasma parameter to MontecarloRunner.run
ftsamis Jul 26, 2016
7f027bc
Move and adapt calculate_j_blues from the old Radial1DModel to Montec…
ftsamis Aug 3, 2016
902dea8
Add the time_of_simulation property to the MontecarloRunner.
ftsamis Aug 4, 2016
66f763b
Add the plasma as an argument to montecarlo.montecarlo_radial1d.
ftsamis Aug 5, 2016
2123d61
Remove every Configuration object usage from the montecarlo.pyx
ftsamis Aug 5, 2016
3a96b67
Add a from_config classmethod to the MontecarloRunner.
ftsamis Aug 5, 2016
1e68a69
montecarlo.pyx: Access atomic_data from the plasma, instead of model.
ftsamis Aug 8, 2016
c03d951
Remove the legacy Radial1DModel.
ftsamis Aug 8, 2016
3adf6f7
Replace LegacyPlasmaArray with a function.
ftsamis Jul 25, 2016
3b18130
assemble_plasma: prepare() the atom_data before passing it to the pla…
ftsamis Jul 27, 2016
4069a9b
Rename LTEJBlues to JBluesBlackBody
ftsamis Aug 8, 2016
2690d6a
Add a JBluesDiluteBlackBody plasma property.
ftsamis Aug 8, 2016
bb725cd
Add a JBlueEstimator input plasma property.
ftsamis Aug 9, 2016
48ad9cd
Remove JBlues as an Input plasma property.
ftsamis Aug 9, 2016
134b715
Revert "Move and adapt calculate_j_blues from the old Radial1DModel t…
ftsamis Aug 9, 2016
1907ede
Add a calculate_time_of_simulation and a calculate_luminosity_inner t…
ftsamis Aug 9, 2016
2296737
Remove JBluesBlackBody from the nlte_properties collection.
ftsamis Aug 10, 2016
0f48a0a
Check the radiative_rates_type to add the appropriate JBlues plasma m…
ftsamis Aug 10, 2016
368790c
fixup! Add a JBluesDiluteBlackBody plasma property.
ftsamis Aug 10, 2016
11c21b2
Change JBluesBlackBody's output name to j_blues from lte_j_blues.
ftsamis Aug 10, 2016
c770bf3
Improve JBluesBlackBody's calculate method by using intensity_black_b…
ftsamis Aug 10, 2016
58e21eb
Implement the barebones of the restructured Simulation class.
ftsamis Aug 4, 2016
10bf4ec
Implement the Simulation.from_config classmethod.
ftsamis Aug 4, 2016
ee24013
Make Simulation take the Montecarlo runner as a parameter.
ftsamis Aug 5, 2016
0d7c472
Simulation: Add the logic for the last iteration.
ftsamis Aug 13, 2016
1a604b2
Move the sigma_thomson calculation from config_reader to montecarlo.
ftsamis Aug 13, 2016
f58cd0a
Move the spectrum frequency calculation from config_reader to monteca…
ftsamis Aug 13, 2016
43c780d
Remove supernova distance checking from config_dict
ftsamis Aug 13, 2016
0fb355d
Don't rename virtual_spectrum_range's stop and num to end and samples.
ftsamis Aug 13, 2016
1f5c11c
Add a FIXME note for supporting initialization of plasma properties.
ftsamis Aug 13, 2016
355b16e
Fix and move the NLTE species conversions from config_reader to assem…
ftsamis Aug 13, 2016
8971b58
model/density.py: Add support for all the specific density types.
ftsamis Aug 14, 2016
606d534
Remove time_0 from a required property in specific densities.
ftsamis Aug 14, 2016
bc730cd
Add a time_0 property to the uniform density type.
ftsamis Aug 14, 2016
285af6f
Add support for density files in the restructured Model.
ftsamis Aug 14, 2016
caa221a
Move the t_radiative calculation from config_reader to Model.from_con…
ftsamis Aug 14, 2016
d7f11d5
Properly pass the v_inner/outer_boundaries to the model, if proivded.
ftsamis Aug 14, 2016
f323371
Move the abundance calculations from config_reader to Radial1DModel.f…
ftsamis Aug 14, 2016
d6e002b
Move the t_inner calculation from config_reader to Radial1DModel
ftsamis Aug 14, 2016
58653fa
Remove unneeded model related code from config_reader.
ftsamis Aug 14, 2016
596c2ea
Simulation: Log the plasma state when advancing the simulation.
ftsamis Aug 16, 2016
346e514
Fix a bug when initializing the logger for montecarlo/base.py
ftsamis Aug 16, 2016
40f46bc
Make sure all no_of_packets variables are passed as integers.
ftsamis Aug 16, 2016
15d8b77
Fix accessing the abundance array from the config in assemble_plasma.
ftsamis Aug 16, 2016
d6c3880
Remove unecessary imports from the config_reader.
ftsamis Aug 16, 2016
30cda17
Make sure velocity and time_explosion are passed in CGS to the Model.
ftsamis Aug 16, 2016
99ac69a
Fix invalid access of the structure section of the configuration.
ftsamis Aug 16, 2016
f429b4e
Remove atom_data from the init arguments of Simulation.
ftsamis Aug 16, 2016
ed504ce
Move the luminosity_nu_[start|end] calculation from config_reader to …
ftsamis Aug 16, 2016
d1bec3b
Move atom_data calculation from config_reader to assemble_plasma.
ftsamis Aug 16, 2016
9cfc4ce
Don't duplicate information from the MontecarloRunner to the Simulation.
ftsamis Aug 18, 2016
7c1151d
Add convergence checking and hold_iterations logic.
ftsamis Aug 18, 2016
9a58984
Fix incorrect access of hold_iterations.
ftsamis Aug 18, 2016
2c0b675
Remove all the unused code from config_reader.
ftsamis Aug 18, 2016
9d48cf6
Properly set Configuration.config_dirname.
ftsamis Aug 18, 2016
f9a9a15
Initialize model's raw_velocity earlier.
ftsamis Aug 19, 2016
1fbb69b
Reintroduce and adjust various to_hdf methods.
ftsamis Aug 19, 2016
fe6e2f0
Implement a basic callback system for calling a custom function after…
ftsamis Aug 19, 2016
3df9525
assemble_plasma now takes an atom_data parameter as well.
ftsamis Aug 21, 2016
cacc66f
plasma conftest: Remove unused import.
ftsamis Aug 22, 2016
2cf6830
Move test_quantity_linspace to test_util
ftsamis Aug 22, 2016
1cff639
Remove two redundant configuration_namespace tests from test_config_r…
ftsamis Aug 22, 2016
9928a61
Allow overriding model,plasma,runner in Simulation.from_config.
ftsamis Aug 22, 2016
21b751d
Fix tests for simulation.
ftsamis Aug 22, 2016
8d51913
Remove unused fixture from test_complete_plasmas.
ftsamis Aug 22, 2016
a2b4b3b
Remove commented out code from test_property_nlte.
ftsamis Aug 22, 2016
77d0e89
Update test_plasmas_full to not use run_tardis.
ftsamis Aug 22, 2016
898128d
Remove test_legacy_model_properties.
ftsamis Aug 22, 2016
735a06d
Update test_tardis_full to use the post-restructure call interface.
ftsamis Aug 22, 2016
012457c
Add back the check for invalid volume in read_density_file.
ftsamis Aug 22, 2016
18810ef
Fix simulation trying to access hold_iterations value when convergenc…
ftsamis Aug 24, 2016
a02e83e
Make density array have the same length when read from a file as when…
ftsamis Aug 24, 2016
0abc70b
Update test_ascii_readers to test the restructured code.
ftsamis Aug 26, 2016
d357b7d
Fix a parsing bug in read_simple_ascii_density
ftsamis Aug 26, 2016
baf655c
fixup! Update test_plasmas_full to not use run_tardis.
ftsamis Aug 26, 2016
8e0bf33
Adjust io/tests/test_model_reader to the changed model_reader.
ftsamis Aug 30, 2016
89c4ca3
Simplify test_config_reader, only testing the functions it provides.
ftsamis Sep 1, 2016
06d77b0
Fix improperly accessing uniform density value in HomologousDensity f…
ftsamis Oct 4, 2016
0c30093
Add a test module for model
ftsamis Oct 6, 2016
a91c72e
Allow initialization of modules in the BasePlasma.
ftsamis Nov 1, 2016
72ffb02
fixup! Allow initialization of modules in the BasePlasma.
ftsamis Nov 1, 2016
ee52657
Remove the distinction of j_blues and lte_j_blues in the LevelBoltzma…
ftsamis Nov 1, 2016
480b73e
Access nlte_species from nlte_data instead of plasma_parent.
ftsamis Nov 6, 2016
a795903
Change references to Radial1DModel.t_rads to t_rad.
ftsamis Nov 6, 2016
aa38a2f
Adjust the tardis script to the restructured code.
ftsamis Nov 6, 2016
8ab42b6
Adjust run_tardis helper function to the restructured code.
ftsamis Nov 12, 2016
d9caf28
Move the j_blues properties from radiative_properties to a separate j…
ftsamis Dec 2, 2016
6b32da7
Reintroduce j_blues_detailed as a ProcessingPlasmaProperty instead of…
ftsamis Dec 2, 2016
5da19f2
Store some more montecarlo properties in the to_hdf method.
ftsamis Dec 2, 2016
9857db8
Set the default path of Simulation.to_hdf to 'simulation'.
ftsamis Dec 2, 2016
eb23a45
Adjust test_integration.py to the restructured code.
ftsamis Dec 2, 2016
9c40430
Skip test_plasma_simple.
ftsamis Dec 2, 2016
f5d5e39
Fix plasma properties accessing the plasma_parent. Also fix assemble_…
ftsamis Dec 2, 2016
e7c4a8d
Bring back storing the previous_properties in NLTE runs.
ftsamis Dec 2, 2016
4b97676
Fix JBluesDetailed.__init__ method not accepting plasma_parent.
ftsamis Dec 3, 2016
e55f4d1
Fix not adding the detailed j_blues input properties to the plasma.
ftsamis Dec 3, 2016
8929b5a
Fix JBluesDetailed.calculate accessing t_rad.value instead of just t_…
ftsamis Dec 3, 2016
50fde00
Return a numpy.array in the JBluesDetailed.calculate method instead o…
ftsamis Dec 3, 2016
1692e50
Use len(t_rad) instead of len(j_blues) in JBluesDetailed to represent…
ftsamis Dec 3, 2016
ea88f9d
Fix typo on parameter name of Simulation.to_hdf call from test_integr…
ftsamis Dec 3, 2016
848a64e
Fix model.t_radiative not being cut to the specified v boundaries.
ftsamis Dec 3, 2016
450fc17
Fix slicing the t_radiative twice in the getter if it was initialized…
ftsamis Dec 3, 2016
5640c5f
Fix a wrong check in Radial1DModel.t_radiative setter regarding bound…
ftsamis Dec 3, 2016
b85aea9
Fix the luminosity_inner hdf location in test_integration.
ftsamis Dec 8, 2016
02506b9
Add docstrings for some classes and methods affected by the restructure.
ftsamis Dec 16, 2016
329564b
Fix a PEP8 violation in model_reader.
ftsamis Dec 16, 2016
c3b7550
Rename the after_time method of HomologousDensity to calculate_densit…
ftsamis Dec 16, 2016
d3f5946
Use the return statement once in HomogolousDensity.from_config instea…
ftsamis Dec 16, 2016
782a0ab
Remove an outdated TODO comment.
ftsamis Dec 16, 2016
136f667
Use sigma_T from astropy constants instead of hardcoding it, also fix…
ftsamis Dec 17, 2016
1c79c5e
Revert "Use sigma_T from astropy constants instead of hardcoding it, …
ftsamis Dec 20, 2016
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
4 changes: 2 additions & 2 deletions docs/physics/physical_quantities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ as Astropy `Quantities <http://astropy.readthedocs.org/en/v0.2.1/_generated/astr

.. code-block:: python

model.t_rads.cgs
model.t_rad.cgs

will give you a list of the :math:`T_{\rm rad}`-values for the model zones
in cgs units. To obtain an array of the values (without units) use

.. code-block:: python

model.t_rads.cgs.value
model.t_rad.cgs.value

Similarly, the :math:`W`-values can be accessed using

Expand Down
15 changes: 7 additions & 8 deletions scripts/tardis
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python
from tardis.io import config_reader

from tardis import model
from tardis.simulation.base import run_radial1d
from tardis.simulation import Simulation
import numpy as np

import logging
Expand Down Expand Up @@ -63,20 +62,20 @@ if args.packet_log_file:
logger.addHandler(packet_logging_handler)

tardis_config = config_reader.Configuration.from_yaml(args.config_fname)
radial1d_mdl = model.Radial1DModel(tardis_config)
simulation = Simulation.from_config(tardis_config)

if args.gdb:
import os; print(os.getpid()); raw_input() # Workaround to attach gdb
if args.profile:
import cProfile
cProfile.runctx('run_radial1d(radial1d_mdl)', locals(),
cProfile.runctx('simulation.run()', locals(),
globals(), filename=args.profiler_log_file)
else:
run_radial1d(radial1d_mdl)
simulation.run()


if not np.all(radial1d_mdl.spectrum_virtual.luminosity_density_lambda.value
if not np.all(simulation.runner.spectrum_virtual.luminosity_density_lambda.value
== 0.0):
radial1d_mdl.spectrum_virtual.to_ascii(args.spectrum_fname)
simulation.runner.spectrum_virtual.to_ascii(args.spectrum_fname)
else:
radial1d_mdl.spectrum.to_ascii(args.spectrum_fname)
simulation.runner.spectrum.to_ascii(args.spectrum_fname)
19 changes: 9 additions & 10 deletions tardis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@ def run_tardis(config, atom_data=None):
atomic data will be loaded according to keywords set in the configuration
[default=None]
"""
from tardis.io import config_reader
from tardis import model, simulation, atomic
from tardis.io.config_reader import Configuration
from tardis.simulation import Simulation
from tardis.atomic import AtomData

if atom_data is not None:
try:
atom_data = atomic.AtomData.from_hdf5(atom_data)
atom_data = AtomData.from_hdf5(atom_data)
except TypeError:
atom_data = atom_data

try:
tardis_config = config_reader.Configuration.from_yaml(
config, atom_data=atom_data)
tardis_config = Configuration.from_yaml(config)
except TypeError:
tardis_config = config_reader.Configuration.from_config_dict(
config, atom_data=atom_data)
tardis_config = Configuration.from_config_dict(config)

radial1d_mdl = model.Radial1DModel(tardis_config)
simulation.run_radial1d(radial1d_mdl)
simulation = Simulation.from_config(tardis_config, atom_data=atom_data)
simulation.run()

return radial1d_mdl
return simulation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing scripts which expect that radial1d_mdl is returned by run_tardis.

I am tempted to swallow this and will update e.g. tardisanalysis.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, although having the entire simulation object returned is much more useful and takes the need to duplicate information, which we heavily did until now, i.e. copying various stuff to model.

So, swallowing this would be a fair trade-off, I believe. ☺

18 changes: 9 additions & 9 deletions tardis/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def change_model(self, model):
"""Reset the model set in the GUI."""
self.model = model
self.tablemodel.arraydata = []
self.tablemodel.add_data(model.t_rads.value.tolist())
self.tablemodel.add_data(model.t_rad.value.tolist())
self.tablemodel.add_data(model.ws.tolist())

def change_spectrum_to_spec_virtual_flux_angstrom(self):
Expand Down Expand Up @@ -626,7 +626,7 @@ def change_graph_to_ws(self):

def change_graph_to_t_rads(self):
"""Change the graph back to radiation Temperature."""
self.change_graph(self.model.t_rads.value, 't_rads', '(K)')
self.change_graph(self.model.t_rad.value, 't_rad', '(K)')

def change_graph(self, data, name, unit):
"""Called to change the shell plot by the two methods above."""
Expand Down Expand Up @@ -659,22 +659,22 @@ def plot_model(self):
self.graph.ax1.set_ylabel('Rad. Temp (K)')
self.graph.ax1.yaxis.get_major_formatter().set_powerlimits((0, 1))
self.graph.dataplot = self.graph.ax1.plot(
range(len(self.model.t_rads.value)), self.model.t_rads.value)
range(len(self.model.t_rad.value)), self.model.t_rad.value)
self.graph.ax2.clear()
self.graph.ax2.set_title('Shell View')
self.graph.ax2.set_xticklabels([])
self.graph.ax2.set_yticklabels([])
self.graph.ax2.grid = True

self.shells = []
t_rad_normalizer = colors.Normalize(vmin=self.model.t_rads.value.min(),
vmax=self.model.t_rads.value.max())
t_rad_normalizer = colors.Normalize(vmin=self.model.t_rad.value.min(),
vmax=self.model.t_rad.value.max())
t_rad_color_map = plt.cm.ScalarMappable(norm=t_rad_normalizer,
cmap=plt.cm.jet)
t_rad_color_map.set_array(self.model.t_rads.value)
t_rad_color_map.set_array(self.model.t_rad.value)
if self.graph.cb:
self.graph.cb.set_clim(vmin=self.model.t_rads.value.min(),
vmax=self.model.t_rads.value.max())
self.graph.cb.set_clim(vmin=self.model.t_rad.value.min(),
vmax=self.model.t_rad.value.max())
self.graph.cb.update_normal(t_rad_color_map)
else:
self.graph.cb = self.graph.figure.colorbar(t_rad_color_map)
Expand All @@ -685,7 +685,7 @@ def plot_model(self):
self.model.tardis_config.structure.r_inner.value[0])

#self.graph.normalizing_factor = 8e-16
for i, t_rad in enumerate(self.model.t_rads.value):
for i, t_rad in enumerate(self.model.t_rad.value):
r_inner = (self.model.tardis_config.structure.r_inner.value[i] *
self.graph.normalizing_factor)
r_outer = (self.model.tardis_config.structure.r_outer.value[i] *
Expand Down
Loading