diff --git a/tardis/gui/widgets.py b/tardis/gui/widgets.py index f90bf1a8685..b460967cac8 100644 --- a/tardis/gui/widgets.py +++ b/tardis/gui/widgets.py @@ -680,25 +680,25 @@ def plot_model(self): self.graph.cb = self.graph.figure.colorbar(t_rad_color_map) self.graph.cb.set_label('T (K)') self.graph.normalizing_factor = 0.2 * ( - self.model.tardis_config.structure.r_outer.value[-1] - - self.model.tardis_config.structure.r_inner.value[0]) / ( - self.model.tardis_config.structure.r_inner.value[0]) + self.model.tardis_config.model.structure.r_outer.value[-1] - + self.model.tardis_config.model.structure.r_inner.value[0]) / ( + self.model.tardis_config.model.structure.r_inner.value[0]) #self.graph.normalizing_factor = 8e-16 for i, t_rad in enumerate(self.model.t_rads.value): - r_inner = (self.model.tardis_config.structure.r_inner.value[i] * + r_inner = (self.model.tardis_config.model.structure.r_inner.value[i] * self.graph.normalizing_factor) - r_outer = (self.model.tardis_config.structure.r_outer.value[i] * + r_outer = (self.model.tardis_config.model.structure.r_outer.value[i] * self.graph.normalizing_factor) self.shells.append(Shell(i, (0,0), r_inner, r_outer, facecolor=t_rad_color_map.to_rgba(t_rad), picker=self.graph.shell_picker)) self.graph.ax2.add_patch(self.shells[i]) self.graph.ax2.set_xlim(0, - self.model.tardis_config.structure.r_outer.value[-1] * + self.model.tardis_config.model.structure.r_outer.value[-1] * self.graph.normalizing_factor) self.graph.ax2.set_ylim(0, - self.model.tardis_config.structure.r_outer.value[-1] * + self.model.tardis_config.model.structure.r_outer.value[-1] * self.graph.normalizing_factor) self.graph.figure.tight_layout() self.graph.draw() diff --git a/tardis/io/config_reader.py b/tardis/io/config_reader.py index 6fc603d5e9f..7a3327a88c8 100644 --- a/tardis/io/config_reader.py +++ b/tardis/io/config_reader.py @@ -41,15 +41,6 @@ class ConfigurationError(ValueError): pass -def parse_spectral_bin(spectral_bin_boundary_1, spectral_bin_boundary_2): - spectral_bin_boundary_1 = parse_quantity(spectral_bin_boundary_1).to('Angstrom', u.spectral()) - spectral_bin_boundary_2 = parse_quantity(spectral_bin_boundary_2).to('Angstrom', u.spectral()) - - spectrum_start_wavelength = min(spectral_bin_boundary_1, spectral_bin_boundary_2) - spectrum_end_wavelength = max(spectral_bin_boundary_1, spectral_bin_boundary_2) - - return spectrum_start_wavelength, spectrum_end_wavelength - def calculate_exponential_density(velocities, v_0, rho0): """ @@ -104,246 +95,6 @@ def calculate_power_law_density(velocities, velocity_0, rho_0, exponent): return densities -def parse_model_file_section(model_setup_file_dict, time_explosion): - def parse_artis_model_setup_files(model_file_section_dict, time_explosion): - - ###### Reading the structure part of the ARTIS file pair - structure_fname = model_file_section_dict['structure_fname'] - - for i, line in enumerate(file(structure_fname)): - if i == 0: - no_of_shells = np.int64(line.strip()) - elif i == 1: - time_of_model = u.Quantity(float(line.strip()), 'day').to('s') - elif i == 2: - break - - artis_model_columns = ['velocities', 'mean_densities_0', 'ni56_fraction', 'co56_fraction', 'fe52_fraction', - 'cr48_fraction'] - artis_model = np.recfromtxt(structure_fname, skip_header=2, usecols=(1, 2, 4, 5, 6, 7), unpack=True, - dtype=[(item, np.float64) for item in artis_model_columns]) - #converting densities from log(g/cm^3) to g/cm^3 and stretching it to the current ti - velocities = u.Quantity(np.append([0], artis_model['velocities']), 'km/s').to('cm/s') - mean_densities_0 = u.Quantity(10 ** artis_model['mean_densities_0'], 'g/cm^3') - - mean_densities = calculate_density_after_time(mean_densities_0, time_of_model, time_explosion) - - - #Verifying information - if len(mean_densities) == no_of_shells: - logger.debug('Verified ARTIS model structure file %s (no_of_shells=length of dataset)', structure_fname) - else: - raise ConfigurationError( - 'Error in ARTIS file %s - Number of shells not the same as dataset length' % structure_fname) - - v_inner = velocities[:-1] - v_outer = velocities[1:] - - volumes = (4 * np.pi / 3) * (time_of_model ** 3) * ( v_outer ** 3 - v_inner ** 3) - masses = (volumes * mean_densities_0 / constants.M_sun).to(1) - - logger.info('Read ARTIS configuration file %s - found %d zones with total mass %g Msun', structure_fname, - no_of_shells, sum(masses.value)) - - if 'v_lowest' in model_file_section_dict: - v_lowest = parse_quantity(model_file_section_dict['v_lowest']).to('cm/s').value - min_shell = v_inner.value.searchsorted(v_lowest) - else: - min_shell = 1 - - if 'v_highest' in model_file_section_dict: - v_highest = parse_quantity(model_file_section_dict['v_highest']).to('cm/s').value - max_shell = v_outer.value.searchsorted(v_highest) - else: - max_shell = no_of_shells - artis_model = artis_model[min_shell:max_shell] - v_inner = v_inner[min_shell:max_shell] - v_outer = v_outer[min_shell:max_shell] - mean_densities = mean_densities[min_shell:max_shell] - - ###### Reading the abundance part of the ARTIS file pair - abundances_fname = model_file_section_dict['abundances_fname'] - abundances = pd.DataFrame(np.loadtxt(abundances_fname)[min_shell:max_shell, 1:].transpose(), - index=np.arange(1, 31)) - - ni_stable = abundances.ix[28] - artis_model['ni56_fraction'] - co_stable = abundances.ix[27] - artis_model['co56_fraction'] - fe_stable = abundances.ix[26] - artis_model['fe52_fraction'] - mn_stable = abundances.ix[25] - 0.0 - cr_stable = abundances.ix[24] - artis_model['cr48_fraction'] - v_stable = abundances.ix[23] - 0.0 - ti_stable = abundances.ix[22] - 0.0 - - abundances.ix[28] = ni_stable - abundances.ix[28] += artis_model['ni56_fraction'] * np.exp( - -(time_explosion * inv_ni56_efolding_time).to(1).value) - - abundances.ix[27] = co_stable - abundances.ix[27] += artis_model['co56_fraction'] * np.exp( - -(time_explosion * inv_co56_efolding_time).to(1).value) - abundances.ix[27] += (inv_ni56_efolding_time * artis_model['ni56_fraction'] / - (inv_ni56_efolding_time - inv_co56_efolding_time)) * \ - (np.exp(-(inv_co56_efolding_time * time_explosion).to(1).value) - np.exp( - -(inv_ni56_efolding_time * time_explosion).to(1).value)) - - abundances.ix[26] = fe_stable - abundances.ix[26] += artis_model['fe52_fraction'] * np.exp( - -(time_explosion * inv_fe52_efolding_time).to(1).value) - abundances.ix[26] += ((artis_model['co56_fraction'] * inv_ni56_efolding_time - - artis_model['co56_fraction'] * inv_co56_efolding_time - + artis_model['ni56_fraction'] * inv_ni56_efolding_time - - artis_model['ni56_fraction'] * inv_co56_efolding_time - - artis_model['co56_fraction'] * inv_ni56_efolding_time * np.exp( - -(inv_co56_efolding_time * time_explosion).to(1).value) - + artis_model['co56_fraction'] * inv_co56_efolding_time * np.exp( - -(inv_co56_efolding_time * time_explosion).to(1).value) - - artis_model['ni56_fraction'] * inv_ni56_efolding_time * np.exp( - -(inv_co56_efolding_time * time_explosion).to(1).value) - + artis_model['ni56_fraction'] * inv_co56_efolding_time * np.exp( - -(inv_ni56_efolding_time * time_explosion).to(1).value)) - / (inv_ni56_efolding_time - inv_co56_efolding_time)) - - abundances.ix[25] = mn_stable - abundances.ix[25] += (inv_fe52_efolding_time * artis_model['fe52_fraction'] / - (inv_fe52_efolding_time - inv_mn52_efolding_time)) * \ - (np.exp(-(inv_mn52_efolding_time * time_explosion).to(1).value) - np.exp( - -(inv_fe52_efolding_time * time_explosion).to(1).value)) - - abundances.ix[24] = cr_stable - abundances.ix[24] += artis_model['cr48_fraction'] * np.exp( - -(time_explosion * inv_cr48_efolding_time).to(1).value) - abundances.ix[24] += ((artis_model['fe52_fraction'] * inv_fe52_efolding_time - - artis_model['fe52_fraction'] * inv_mn52_efolding_time - - artis_model['fe52_fraction'] * inv_fe52_efolding_time * np.exp( - -(inv_mn52_efolding_time * time_explosion).to(1).value) - + artis_model['fe52_fraction'] * inv_mn52_efolding_time * np.exp( - -(inv_fe52_efolding_time * time_explosion).to(1).value)) - / (inv_fe52_efolding_time - inv_mn52_efolding_time)) - - abundances.ix[23] = v_stable - abundances.ix[23] += (inv_cr48_efolding_time * artis_model['cr48_fraction'] / - (inv_cr48_efolding_time - inv_v48_efolding_time)) * \ - (np.exp(-(inv_v48_efolding_time * time_explosion).to(1).value) - np.exp( - -(inv_cr48_efolding_time * time_explosion).to(1).value)) - - abundances.ix[22] = ti_stable - abundances.ix[22] += ((artis_model['cr48_fraction'] * inv_cr48_efolding_time - - artis_model['cr48_fraction'] * inv_v48_efolding_time - - artis_model['cr48_fraction'] * inv_cr48_efolding_time * np.exp( - -(inv_v48_efolding_time * time_explosion).to(1).value) - + artis_model['cr48_fraction'] * inv_v48_efolding_time * np.exp( - -(inv_cr48_efolding_time * time_explosion).to(1).value)) - / (inv_cr48_efolding_time - inv_v48_efolding_time)) - - if 'split_shells' in model_file_section_dict: - split_shells = int(model_file_section_dict['split_shells']) - else: - split_shells = 1 - - if split_shells > 1: - logger.info('Increasing the number of shells by a factor of %s' % split_shells) - no_of_shells = len(v_inner) - velocities = quantity_linspace( - v_inner[0], v_outer[-1], no_of_shells * split_shells + 1) - v_inner = velocities[:-1] - v_outer = velocities[1:] - old_mean_densities = mean_densities - mean_densities = np.empty(no_of_shells * split_shells) * old_mean_densities.unit - new_abundance_data = np.empty((abundances.values.shape[0], no_of_shells * split_shells)) - for i in xrange(split_shells): - mean_densities[i::split_shells] = old_mean_densities - new_abundance_data[:, i::split_shells] = abundances.values - - abundances = pd.DataFrame(new_abundance_data, index=abundances.index) - - - - - #def parser_simple_ascii_model - - return v_inner, v_outer, mean_densities, abundances - - model_file_section_parser = {} - model_file_section_parser['artis'] = parse_artis_model_setup_files - - try: - parser = model_file_section_parser[model_setup_file_dict['type']] - except KeyError: - raise ConfigurationError('In abundance file section only types %s are allowed (supplied %s) ' % - (model_file_section_parser.keys(), model_file_section_parser['type'])) - - return parser(model_setup_file_dict, time_explosion) - - -def parse_density_file_section(density_file_dict, time_explosion): - density_file_parser = {} - - def parse_artis_density(density_file_dict, time_explosion): - density_file = density_file_dict['name'] - for i, line in enumerate(file(density_file)): - if i == 0: - no_of_shells = np.int64(line.strip()) - elif i == 1: - time_of_model = u.Quantity(float(line.strip()), 'day').to('s') - elif i == 2: - break - - velocities, mean_densities_0 = np.recfromtxt(density_file, skip_header=2, usecols=(1, 2), unpack=True) - #converting densities from log(g/cm^3) to g/cm^3 and stretching it to the current ti - velocities = u.Quantity(np.append([0], velocities), 'km/s').to('cm/s') - mean_densities_0 = u.Quantity(10 ** mean_densities_0, 'g/cm^3') - - mean_densities = calculate_density_after_time(mean_densities_0, time_of_model, time_explosion) - - - #Verifying information - if len(mean_densities) == no_of_shells: - logger.debug('Verified ARTIS file %s (no_of_shells=length of dataset)', density_file) - else: - raise ConfigurationError( - 'Error in ARTIS file %s - Number of shells not the same as dataset length' % density_file) - - min_shell = 1 - max_shell = no_of_shells - - v_inner = velocities[:-1] - v_outer = velocities[1:] - - volumes = (4 * np.pi / 3) * (time_of_model ** 3) * ( v_outer ** 3 - v_inner ** 3) - masses = (volumes * mean_densities_0 / constants.M_sun).to(1) - - logger.info('Read ARTIS configuration file %s - found %d zones with total mass %g Msun', density_file, - no_of_shells, sum(masses.value)) - - if 'v_lowest' in density_file_dict: - v_lowest = parse_quantity(density_file_dict['v_lowest']).to('cm/s').value - min_shell = v_inner.value.searchsorted(v_lowest) - else: - min_shell = 1 - - if 'v_highest' in density_file_dict: - v_highest = parse_quantity(density_file_dict['v_highest']).to('cm/s').value - max_shell = v_outer.value.searchsorted(v_highest) - else: - max_shell = no_of_shells - - v_inner = v_inner[min_shell:max_shell] - v_outer = v_outer[min_shell:max_shell] - mean_densities = mean_densities[min_shell:max_shell] - - return v_inner, v_outer, mean_densities, min_shell, max_shell - - density_file_parser['artis'] = parse_artis_density - - try: - parser = density_file_parser[density_file_dict['type']] - except KeyError: - raise ConfigurationError('In abundance file section only types %s are allowed (supplied %s) ' % - (density_file_parser.keys(), density_file_dict['type'])) - - return parser(density_file_dict, time_explosion) - - def parse_density_section(density_dict, v_inner, v_outer, time_explosion): density_parser = {} @@ -404,82 +155,6 @@ def parse_exponential(density_dict, v_inner, v_outer, time_explosion): return parser(density_dict, v_inner, v_outer, time_explosion) -def parse_abundance_file_section(abundance_file_dict, abundances, min_shell, max_shell): - abundance_file_parser = {} - - def parse_artis(abundance_file_dict, abundances, min_shell, max_shell): - #### ---- debug ---- - time_of_model = 0.0 - - #### - fname = abundance_file_dict['name'] - max_atom = 30 - logger.info("Parsing ARTIS Abundance section from shell %d to %d", min_shell, max_shell) - - abundances.values[:max_atom, :] = np.loadtxt(fname)[min_shell:max_shell, 1:].transpose() - - return abundances - - abundance_file_parser['artis'] = parse_artis - - try: - parser = abundance_file_parser[abundance_file_dict['type']] - except KeyError: - raise ConfigurationError('In abundance file section only types %s are allowed (supplied %s) ' % - (abundance_file_parser.keys(), abundance_file_dict['type'])) - - return parser(abundance_file_dict, abundances, min_shell, max_shell) - - -def parse_supernova_section(supernova_dict): - """ - Parse the supernova section - - Parameters - ---------- - - supernova_dict: dict - YAML parsed supernova dict - - Returns - ------- - - config_dict: dict - - """ - config_dict = {} - - #parse luminosity - luminosity_value, luminosity_unit = supernova_dict['luminosity_requested'].strip().split() - - if luminosity_unit == 'log_lsun': - config_dict['luminosity_requested'] = 10 ** ( - float(luminosity_value) + np.log10(constants.L_sun.cgs.value)) * u.erg / u.s - else: - config_dict['luminosity_requested'] = (float(luminosity_value) * u.Unit(luminosity_unit)).to('erg/s') - - config_dict['time_explosion'] = parse_quantity(supernova_dict['time_explosion']).to('s') - - if 'distance' in supernova_dict: - config_dict['distance'] = parse_quantity(supernova_dict['distance']) - else: - config_dict['distance'] = None - - if 'luminosity_wavelength_start' in supernova_dict: - config_dict['luminosity_nu_end'] = parse_quantity(supernova_dict['luminosity_wavelength_start']). \ - to('Hz', u.spectral()) - else: - config_dict['luminosity_nu_end'] = np.inf * u.Hz - - if 'luminosity_wavelength_end' in supernova_dict: - config_dict['luminosity_nu_start'] = parse_quantity(supernova_dict['luminosity_wavelength_end']). \ - to('Hz', u.spectral()) - else: - config_dict['luminosity_nu_start'] = 0.0 * u.Hz - - return config_dict - - def parse_spectrum_list2dict(spectrum_list): """ Parse the spectrum list [start, stop, num] to a list @@ -877,13 +552,6 @@ def from_config_dict(cls, config_dict, atom_data=None, test_parser=False, (r_outer ** 3 - r_inner ** 3)).cgs - - #### TODO the following is legacy code and should be removed - validated_config_dict['structure'] = \ - validated_config_dict['model']['structure'] - # ^^^^^^^^^^^^^^^^ - - abundances_section = model_section['abundances'] if abundances_section['type'] == 'uniform': @@ -1038,7 +706,7 @@ def __init__(self, config_dict, atom_data): self.atom_data = atom_data selected_atomic_numbers = self.abundances.index if atom_data is not None: - self.number_densities = (self.abundances * self.structure.mean_densities.to('g/cm^3').value) + self.number_densities = (self.abundances * self.model.structure.mean_densities.to('g/cm^3').value) self.number_densities = self.number_densities.div(self.atom_data.atom_data.mass.ix[selected_atomic_numbers], axis=0) else: diff --git a/tardis/io/tests/test_config_reader.py b/tardis/io/tests/test_config_reader.py index 073f8b39a68..d91d97d9ae2 100644 --- a/tardis/io/tests/test_config_reader.py +++ b/tardis/io/tests/test_config_reader.py @@ -89,15 +89,15 @@ def test_abundances(self): def test_velocities(self): assert_almost_equal(self.yaml_data['model']['structure']['velocity']['start'].cgs.value, - self.config.structure.v_inner[0].cgs.value) + self.config.model.structure.v_inner[0].cgs.value) assert_almost_equal(self.yaml_data['model']['structure']['velocity']['stop'].cgs.value, - self.config.structure.v_outer[-1].cgs.value) - assert len(self.config.structure.v_outer) == (self.yaml_data['model']['structure']['velocity']['num']) + self.config.model.structure.v_outer[-1].cgs.value) + assert len(self.config.model.structure.v_outer) == (self.yaml_data['model']['structure']['velocity']['num']) def test_densities(self): - assert_almost_equal(self.config['structure']['mean_densities'][0].cgs.value, + assert_almost_equal(self.config['model']['structure']['mean_densities'][0].cgs.value, (7.542803599143591e-14 * u.Unit('g/cm^3')).value) - assert_almost_equal(self.config['structure']['mean_densities'][-1].cgs.value, + assert_almost_equal(self.config['model']['structure']['mean_densities'][-1].cgs.value, (1.432259798833509e-15 * u.Unit('g/cm^3')).value) @@ -150,8 +150,8 @@ def setup(self): def test_velocities(self): - assert self.config.structure.v_inner.unit == u.Unit('cm/s') - assert_almost_equal(self.config.structure.v_inner[0].value, 1e4 * 1e5) + assert self.config.model.structure.v_inner.unit == u.Unit('cm/s') + assert_almost_equal(self.config.model.structure.v_inner[0].value, 1e4 * 1e5) def test_abundances(self): oxygen_abundance = self.yaml_data['model']['abundances']['O'] @@ -169,8 +169,8 @@ def setup(self): def test_velocities(self): - assert self.config.structure.v_inner.unit == u.Unit('cm/s') - assert_almost_equal(self.config.structure.v_inner[0].value, 1.259375e+03 * 1e5) + assert self.config.model.structure.v_inner.unit == u.Unit('cm/s') + assert_almost_equal(self.config.model.structure.v_inner[0].value, 1.259375e+03 * 1e5) def test_abundances(self): oxygen_abundance = self.yaml_data['model']['abundances']['O'] @@ -196,8 +196,8 @@ def setup(self): def test_velocities(self): - assert self.config.structure.v_inner.unit == u.Unit('cm/s') - assert_almost_equal(self.config.structure.v_inner[0].value, 1.259375e+03 * 1e5) + assert self.config.model.structure.v_inner.unit == u.Unit('cm/s') + assert_almost_equal(self.config.model.structure.v_inner[0].value, 1.259375e+03 * 1e5) def test_abundances(self): assert_almost_equal(self.config.abundances.ix[14, 54], 0.21864420000000001) @@ -220,8 +220,8 @@ def setup(self): def test_velocities(self): - assert self.config.structure.v_inner.unit == u.Unit('cm/s') - assert_almost_equal(self.config.structure.v_inner[0].to( + assert self.config.model.structure.v_inner.unit == u.Unit('cm/s') + assert_almost_equal(self.config.model.structure.v_inner[0].to( u.km / u.s).value, 9000) def test_abundances(self): @@ -241,7 +241,7 @@ def setup(self): config_dirname=data_path('')) def test_density(self): - assert_array_almost_equal(self.config.structure.mean_densities.to(u.Unit('g / cm3')).value, + assert_array_almost_equal(self.config.model.structure.mean_densities.to(u.Unit('g / cm3')).value, 1.e-14) class TestParseConfigTinner: @@ -277,8 +277,8 @@ def setup(self): def test_velocities(self): - assert self.config.structure.v_inner.unit == u.Unit('cm/s') - assert_almost_equal(self.config.structure.v_inner[0].to( + assert self.config.model.structure.v_inner.unit == u.Unit('cm/s') + assert_almost_equal(self.config.model.structure.v_inner[0].to( u.km / u.s).value, 11000) def test_abundances(self): @@ -298,13 +298,13 @@ def test_abundances(self): assert_almost_equal(self.config.abundances.ix[6, 6], 0.5) def test_densities(self): - assert_almost_equal(self.config.structure.mean_densities[0].to(u.Unit('g/cm3')).value, 9.7656229e-11 / 13.0**3 ) - assert_almost_equal(self.config.structure.mean_densities[1].to(u.Unit('g/cm3')).value, 4.8170911e-11/ 13.0**3 ) - assert_almost_equal(self.config.structure.mean_densities[2].to(u.Unit('g/cm3')).value, 2.5600000e-11/ 13.0**3 ) - assert_almost_equal(self.config.structure.mean_densities[3].to(u.Unit('g/cm3')).value, 1.4450533e-11/ 13.0**3 ) - assert_almost_equal(self.config.structure.mean_densities[4].to(u.Unit('g/cm3')).value, 8.5733893e-11/ 13.0**3 ) - assert_almost_equal(self.config.structure.mean_densities[5].to(u.Unit('g/cm3')).value, 5.3037103e-11/ 13.0**3 ) - assert_almost_equal(self.config.structure.mean_densities[6].to(u.Unit('g/cm3')).value, 3.3999447e-11/ 13.0**3 ) + assert_almost_equal(self.config.model.structure.mean_densities[0].to(u.Unit('g/cm3')).value, 9.7656229e-11 / 13.0**3 ) + assert_almost_equal(self.config.model.structure.mean_densities[1].to(u.Unit('g/cm3')).value, 4.8170911e-11/ 13.0**3 ) + assert_almost_equal(self.config.model.structure.mean_densities[2].to(u.Unit('g/cm3')).value, 2.5600000e-11/ 13.0**3 ) + assert_almost_equal(self.config.model.structure.mean_densities[3].to(u.Unit('g/cm3')).value, 1.4450533e-11/ 13.0**3 ) + assert_almost_equal(self.config.model.structure.mean_densities[4].to(u.Unit('g/cm3')).value, 8.5733893e-11/ 13.0**3 ) + assert_almost_equal(self.config.model.structure.mean_densities[5].to(u.Unit('g/cm3')).value, 5.3037103e-11/ 13.0**3 ) + assert_almost_equal(self.config.model.structure.mean_densities[6].to(u.Unit('g/cm3')).value, 3.3999447e-11/ 13.0**3 ) def test_ascii_reader_power_law(): @@ -320,7 +320,7 @@ def test_ascii_reader_power_law(): v_outer = yaml_data['model']['structure']['velocity']['stop'] my_conf = config_reader.Configuration.from_yaml(data_path('tardis_configv1_density_power_law_test.yml'), test_parser=True) - structure = my_conf['structure'] + structure = my_conf['model']['structure'] expected_densites = [3.29072513e-14, 2.70357804e-14, 2.23776573e-14, 1.86501954e-14, 1.56435277e-14, 1.32001689e-14, 1.12007560e-14, @@ -348,7 +348,7 @@ def test_ascii_reader_exponential_law(): v_outer = yaml_data['model']['structure']['velocity']['stop'] my_conf = config_reader.Configuration.from_yaml(data_path('tardis_configv1_density_exponential_test.yml'), test_parser=True) - structure = my_conf['structure'] + structure = my_conf['model']['structure'] expected_densites = [5.18114795e-14, 4.45945537e-14, 3.83828881e-14, 3.30364579e-14, 2.84347428e-14, 2.44740100e-14, 2.10649756e-14, 1.81307925e-14, 1.56053177e-14, 1.34316215e-14, 1.15607037e-14, 9.95038990e-15, 8.56437996e-15, 7.37143014e-15, 6.34464872e-15, 5.46088976e-15, 4.70023138e-15, 4.04552664e-15, 3.48201705e-15, 2.99699985e-15] expected_unit = 'g / (cm3)' diff --git a/tardis/model.py b/tardis/model.py index a55bc2761e2..7529ea5de3a 100644 --- a/tardis/model.py +++ b/tardis/model.py @@ -91,13 +91,13 @@ def __init__(self, tardis_config): self.t_inner = tardis_config.plasma.t_inner - self.v_inner = tardis_config.structure.v_inner - self.v_outer = tardis_config.structure.v_outer + self.v_inner = tardis_config.model.structure.v_inner + self.v_outer = tardis_config.model.structure.v_outer self.v_middle = 0.5 * (self.v_inner + self.v_outer) self.ws = self.calculate_geometric_w( - tardis_config.structure.r_middle, - tardis_config.structure.r_inner[0]) + tardis_config.model.structure.r_middle, + tardis_config.model.structure.r_inner[0]) if tardis_config.plasma.t_rads is None: self.t_rads = self._init_t_rad( @@ -177,14 +177,14 @@ def t_inner(self, value): self._t_inner = value self.luminosity_inner = ( 4 * np.pi * constants.sigma_sb.cgs * - self.tardis_config.structure.r_inner[0] ** 2 + self.tardis_config.model.structure.r_inner[0] ** 2 * self.t_inner ** 4).to('erg/s') self.time_of_simulation = (1.0 * u.erg / self.luminosity_inner) self.j_blues_norm_factor = ( constants.c.cgs * self.tardis_config.supernova.time_explosion / (4 * np.pi * self.time_of_simulation * - self.tardis_config.structure.volumes)) + self.tardis_config.model.structure.volumes)) @@ -227,7 +227,7 @@ def calculate_j_blues(self, init_detailed_j_blues=False): index=self.atom_data.lines.index, columns=np.arange(len(self.t_rads))) - for i in xrange(self.tardis_config.structure.no_of_shells): + for i in xrange(self.tardis_config.model.structure.no_of_shells): zero_j_blues = self.j_blues[i] == 0.0 self.j_blues[i][zero_j_blues] = ( w_epsilon * intensity_black_body( diff --git a/tardis/montecarlo/base.py b/tardis/montecarlo/base.py index 9ce42a283e6..d4adddd5c92 100644 --- a/tardis/montecarlo/base.py +++ b/tardis/montecarlo/base.py @@ -123,10 +123,10 @@ def run(self, model, no_of_packets, no_of_virtual_packets=0, nthreads=1,last_run :return: """ self.time_of_simulation = model.time_of_simulation - self.volume = model.tardis_config.structure.volumes + self.volume = model.tardis_config.model.structure.volumes self._initialize_estimator_arrays(self.volume.shape[0], model.plasma.tau_sobolevs.shape) - self._initialize_geometry_arrays(model.tardis_config.structure) + self._initialize_geometry_arrays(model.tardis_config.model.structure) self._initialize_packets(model.t_inner.value, no_of_packets) diff --git a/tardis/simulation/base.py b/tardis/simulation/base.py index 8890ea2c615..068254eab23 100644 --- a/tardis/simulation/base.py +++ b/tardis/simulation/base.py @@ -93,7 +93,7 @@ def estimate_t_inner(self, input_t_inner, luminosity_requested, def get_convergence_status(self, t_rad, w, t_inner, estimated_t_rad, estimated_w, estimated_t_inner): convergence_section = self.tardis_config.montecarlo.convergence_strategy - no_of_shells = self.tardis_config.structure.no_of_shells + no_of_shells = self.tardis_config.model.structure.no_of_shells convergence_t_rad = (abs(t_rad - estimated_t_rad) / estimated_t_rad).value diff --git a/tardis/util.py b/tardis/util.py index 3fe5174f75a..8979c6b9e44 100644 --- a/tardis/util.py +++ b/tardis/util.py @@ -211,9 +211,9 @@ def create_synpp_yaml(radial1d_mdl, fname, shell_no=0, lines_db=None): #raise Exception("there's a problem here with units what units does synpp expect?") - yaml_reference['opacity']['v_ref'] = float((radial1d_mdl.tardis_config.structure.v_inner[0].to('km/s') / + yaml_reference['opacity']['v_ref'] = float((radial1d_mdl.tardis_config.model.structure.v_inner[0].to('km/s') / (1000. * u.km / u.s)).value) - yaml_reference['grid']['v_outer_max'] = float((radial1d_mdl.tardis_config.structure.v_outer[-1].to('km/s') / + yaml_reference['grid']['v_outer_max'] = float((radial1d_mdl.tardis_config.model.structure.v_outer[-1].to('km/s') / (1000. * u.km / u.s)).value) #pdb.set_trace()