Skip to content

Commit

Permalink
Merge 9a49ca9 into d6a2ac0
Browse files Browse the repository at this point in the history
  • Loading branch information
unoebauer committed Aug 7, 2018
2 parents d6a2ac0 + 9a49ca9 commit 496c580
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -74,8 +74,12 @@ before_install:
- if [[ $TEST_MODE == 'spectrum' ]]; then git lfs install --skip-smudge; fi
- if [[ $TEST_MODE == 'spectrum' ]]; then git clone $TARDIS_REF_DATA_URL $HOME/tardis-refdata; fi
- if [[ $TEST_MODE == 'spectrum' ]]; then cd $HOME/tardis-refdata; fi
# Use the following to get the ref-data from the master;
- if [[ $TEST_MODE == 'spectrum' ]]; then git fetch origin; fi
- if [[ $TEST_MODE == 'spectrum' ]]; then git checkout origin/master; fi
# Use the following to get the ref-data from a specific pull request;
# - if [[ $TEST_MODE == 'spectrum' ]]; then git fetch origin pull/10/head:formalintegral-ref; fi
# - if [[ $TEST_MODE == 'spectrum' ]]; then git checkout formalintegral-ref; fi
- if [[ $TEST_MODE == 'spectrum' ]]; then git lfs pull --include="atom_data/kurucz_cd23_chianti_H_He.h5" origin; fi
- if [[ $TEST_MODE == 'spectrum' ]]; then git lfs pull --include="atom_data/chianti_He.h5" origin; fi
- if [[ $TEST_MODE == 'spectrum' ]]; then git lfs pull --include="plasma_reference/" origin; fi
Expand Down
89 changes: 89 additions & 0 deletions tardis/tests/test_tardis_full_formal_integral.py
@@ -0,0 +1,89 @@
import os
import pytest
import numpy as np
import numpy.testing as npt
from astropy import units as u
from astropy.tests.helper import assert_quantity_allclose

from tardis.simulation.base import Simulation
from tardis.io.config_reader import Configuration


config_line_modes = ['downbranch', 'macroatom']


@pytest.fixture(scope='module', params=config_line_modes)
def config(request):
config = Configuration.from_yaml(
'tardis/io/tests/data/tardis_configv1_verysimple.yml')

config["plasma"]["line_interaction_type"] = request.param
config["montecarlo"]["no_of_packets"] = 4.0e+4
config["montecarlo"]["last_no_of_packets"] = 1.0e+5
config["montecarlo"]["no_of_virtual_packets"] = 0
config["spectrum"]["method"] = "integrated"

return config


class TestRunnerSimpleFormalInegral():
"""
Very simple run with the formal integral spectral synthesis method
"""
name = 'test_runner_simple_integral'

@pytest.fixture(scope="class")
def runner(
self, config, atomic_data_fname,
tardis_ref_data, generate_reference):
config.atom_data = atomic_data_fname

self.name = (self.name +
"_{:s}".format(config.plasma.line_interaction_type))

simulation = Simulation.from_config(config)
simulation.run()

if not generate_reference:
return simulation.runner
else:
simulation.runner.hdf_properties = [
'j_blue_estimator',
'spectrum',
'spectrum_integrated'
]
simulation.runner.to_hdf(
tardis_ref_data,
'',
self.name)
pytest.skip(
'Reference data was generated during this run.')

@pytest.fixture(scope='class')
def refdata(self, tardis_ref_data):
def get_ref_data(key):
return tardis_ref_data[os.path.join(
self.name, key)]
return get_ref_data

def test_j_blue_estimators(self, runner, refdata):
j_blue_estimator = refdata('j_blue_estimator').values

npt.assert_allclose(
runner.j_blue_estimator,
j_blue_estimator)

def test_spectrum(self, runner, refdata):
luminosity = u.Quantity(refdata('spectrum/luminosity'), 'erg /s')

assert_quantity_allclose(
runner.spectrum.luminosity,
luminosity)

def test_spectrum_integrated(self, runner, refdata):
luminosity = u.Quantity(
refdata('spectrum_integrated/luminosity'), 'erg /s')

assert_quantity_allclose(
runner.spectrum_integrated.luminosity,
luminosity)

0 comments on commit 496c580

Please sign in to comment.