Beispiel #1
0
    def test_absorption_spectrum_with_continuum(self):
        """
        This test generates an absorption spectrum from a simple light ray on a
        grid dataset and adds Lyman alpha and Lyman continuum to it
        """

        ds = load(ISO_GALAXY)
        lr = LightRay(ds)

        ray_start = ds.domain_left_edge
        ray_end = ds.domain_right_edge
        lr.make_light_ray(
            start_position=ray_start,
            end_position=ray_end,
            fields=['temperature', 'density', 'H_number_density'],
            data_filename='lightray.h5')

        sp = AbsorptionSpectrum(800.0, 1300.0, 5001)

        my_label = 'HI Lya'
        field = 'H_number_density'
        wavelength = 1215.6700  # Angstromss
        f_value = 4.164E-01
        gamma = 6.265e+08
        mass = 1.00794

        sp.add_line(my_label,
                    field,
                    wavelength,
                    f_value,
                    gamma,
                    mass,
                    label_threshold=1.e10)

        my_label = 'Ly C'
        field = 'H_number_density'
        wavelength = 912.323660  # Angstroms
        normalization = 1.6e17
        index = 3.0

        sp.add_continuum(my_label, field, wavelength, normalization, index)

        filename = "spectrum.h5"
        wavelength, flux = sp.make_spectrum('lightray.h5',
                                            output_file=filename,
                                            line_list_file='lines.txt',
                                            use_peculiar_velocity=True)
        return filename
Beispiel #2
0
    def test_absorption_spectrum_cosmo(self):
        """
        This test generates an absorption spectrum from a compound light ray on a
        grid dataset
        """

        lr = LightRay(COSMO_PLUS, 'Enzo', 0.0, 0.03)

        lr.make_light_ray(
            seed=1234567,
            fields=['temperature', 'density', 'H_number_density'],
            data_filename='lightray.h5')

        sp = AbsorptionSpectrum(900.0, 1800.0, 10000)

        my_label = 'HI Lya'
        field = 'H_number_density'
        wavelength = 1215.6700  # Angstromss
        f_value = 4.164E-01
        gamma = 6.265e+08
        mass = 1.00794

        sp.add_line(my_label,
                    field,
                    wavelength,
                    f_value,
                    gamma,
                    mass,
                    label_threshold=1.e10)

        my_label = 'HI Lya'
        field = 'H_number_density'
        wavelength = 912.323660  # Angstroms
        normalization = 1.6e17
        index = 3.0

        sp.add_continuum(my_label, field, wavelength, normalization, index)

        filename = "spectrum.h5"
        wavelength, flux = sp.make_spectrum('lightray.h5',
                                            output_file=filename,
                                            line_list_file='lines.txt',
                                            use_peculiar_velocity=True)
        return filename
Beispiel #3
0
    def test_absorption_spectrum_fits(self):
        """
        This test generates an absorption spectrum and saves it as a fits file.
        """

        lr = LightRay(COSMO_PLUS_SINGLE)

        ray_start = [0, 0, 0]
        ray_end = [1, 1, 1]
        lr.make_light_ray(
            start_position=ray_start,
            end_position=ray_end,
            fields=['temperature', 'density', 'H_number_density'],
            data_filename='lightray.h5')

        sp = AbsorptionSpectrum(900.0, 1800.0, 10000)

        my_label = 'HI Lya'
        field = 'H_number_density'
        wavelength = 1215.6700  # Angstromss
        f_value = 4.164E-01
        gamma = 6.265e+08
        mass = 1.00794

        sp.add_line(my_label,
                    field,
                    wavelength,
                    f_value,
                    gamma,
                    mass,
                    label_threshold=1.e10)

        my_label = 'HI Lya'
        field = 'H_number_density'
        wavelength = 912.323660  # Angstroms
        normalization = 1.6e17
        index = 3.0

        sp.add_continuum(my_label, field, wavelength, normalization, index)

        wavelength, flux = sp.make_spectrum('lightray.h5',
                                            output_file='spectrum.fits',
                                            line_list_file='lines.txt',
                                            use_peculiar_velocity=True)