Ejemplo n.º 1
0
    def test_works_fire1(self):

        self.particle_tracker = track.ParticleTracker(**fire1_data_p)
        self.particle_tracker.save_particle_tracks()

        f = h5py.File('tests/data/tracking_output/ptracks_test_fire1.hdf5',
                      'r')

        expected_snum = np.arange(600, 490, -50)
        actual_snum = f['snum'][...]
        npt.assert_allclose(expected_snum, actual_snum)

        expected_id = np.array([24565150, 24079833, 13109563, 14147322])
        actual_id = f['ID'][...]
        npt.assert_allclose(expected_id, actual_id)

        expected_rho_500 = np.array([
            2.98729116e-09, 3.12611002e-08, 8.95081308e-04, np.nan
        ]) * constants.UNITDENSITY_IN_NUMDEN
        actual_rho_500 = f['Den'][...][:, -1]
        npt.assert_allclose(expected_rho_500, actual_rho_500)

        expected_ptype_p0 = np.array([4, 0, 0])
        actual_ptype_p0 = f['PType'][...][0]
        npt.assert_allclose(expected_ptype_p0, actual_ptype_p0)
Ejemplo n.º 2
0
    def test_saves(self):

        # Check for existing output files and delete them.
        self.id_finder.drop_duplicates = True
        output_filepath = 'tests/data/tracking_output/ptracks_test.hdf5'
        if os.path.isfile(output_filepath):
            os.remove(output_filepath)

        # Update kwargs
        used_kwargs = copy.deepcopy(default_data_p)
        used_kwargs['custom_fns'] = test_apply_fns

        particle_tracker = track.ParticleTracker(**used_kwargs)

        # Run the function
        particle_tracker.save_particle_tracks()

        # Check results
        f = h5py.File(output_filepath, 'r')

        # The output for this function should be an integer
        assert np.issubdtype(f['IDx2'][...].dtype, np.integer)

        # None of the elements should be 0.
        assert not (0 in f['IDx2'][...])

        # None of the elements should be 0.
        assert not (0. in f['Potential'][...])
Ejemplo n.º 3
0
    def setUp(self):

        # Mock the code version so we don't repeatedly change test data
        patcher = patch('galaxy_dive.utils.utilities.get_code_version')
        self.addCleanup(patcher.stop)
        self.mock_code_version = patcher.start()

        kwargs = dict(default_data_p)
        kwargs['n_processors'] = 2

        self.particle_tracker = track.ParticleTracker(**kwargs)

        # The name of the function.
        self.fn = self.particle_tracker.save_particle_tracks
Ejemplo n.º 4
0
    def test_works_with_stars_early_on( self ):
        '''Test this works even in early snapshots, when there are no stars.'''

        self.particle_tracker = track.ParticleTracker( **early_star_data_p )
        self.particle_tracker.save_particle_tracks()

        f = h5py.File( 'tests/data/tracking_output/ptracks_test_star_early.hdf5', 'r' )

        expected_snum = np.array([ 11, 10 ])
        actual_snum = f['snum'][...]
        npt.assert_allclose( expected_snum, actual_snum )

        expected_id = np.array([2040268, 7909745, 8961984])
        actual_id = f['ID'][...]
        npt.assert_allclose( expected_id, actual_id )
Ejemplo n.º 5
0
    def setUp(self):

        # Mock the code version so we don't repeatedly change test data
        patcher = patch('galaxy_dive.utils.utilities.get_code_version')
        self.addCleanup(patcher.stop)
        self.mock_code_version = patcher.start()

        self.particle_tracker = track.ParticleTracker(**default_data_p)

        # The name of the function.
        self.fn = self.particle_tracker.save_particle_tracks

        # Check for existing output files and delete them.
        output_filepath = 'tests/data/tracking_output/ptracks_test.hdf5'
        if os.path.isfile(output_filepath):
            os.remove(output_filepath)
Ejemplo n.º 6
0
import linefinder.track as track

kwargs = {
    'sdir': './linefinder/tests/data/test_data_with_new_id_scheme',
    'p_types': [
        0,
    ],
    'snum_start': 500,
    'snum_end': 600,
    'snum_step': 50,
    'out_dir': './linefinder/tests/data/tracking_output',
    'ids_tag': 'test',
    'tag': 'test_jug',
}

particle_tracker = track.ParticleTracker(**kwargs)
particle_tracker.save_particle_tracks_jug()