def tmp_data_dir(tmp_path): pre_test_data_dir = ytcfg["yt", "test_data_dir"] ytcfg.set("yt", "test_data_dir", str(tmp_path)) yield tmp_path ytcfg.set("yt", "test_data_dir", pre_test_data_dir)
def tmp_data_dir(tmp_path): from yt.config import ytcfg pre_test_data_dir = ytcfg["yt", "test_data_dir"] ytcfg.set("yt", "test_data_dir", str(tmp_path)) yield tmp_path ytcfg.set("yt", "test_data_dir", pre_test_data_dir)
def fake_data_dir_in_a_vaccum(tmp_path): pre_test_data_dir = ytcfg["yt", "test_data_dir"] ytcfg.set("yt", "test_data_dir", "/does/not/exist") origin = os.getcwd() os.chdir(tmp_path) yield ytcfg.set("yt", "test_data_dir", pre_test_data_dir) os.chdir(origin)
def custom_ramses_fields_conf(): old_config = deepcopy(ytcfg.config_root.as_dict()) ytcfg.add_section("ramses-hydro") ytcfg.add_section("ramses-grav") ytcfg.set("ramses-hydro", "fields", custom_hydro) ytcfg.set("ramses-grav", "fields", custom_grav) yield ytcfg.remove_section("ramses-hydro") ytcfg.remove_section("ramses-grav") ytcfg.update(old_config)
import yt, sys, os yt.enable_parallelism() from yt.config import ytcfg from yt.analysis_modules.halo_finding.rockstar.api import \ RockstarHaloFinder from yt.data_objects.particle_filters import \ particle_filter from yt.data_objects.time_series import DatasetSeries import numpy as np from ramses_pp.modules import Simulation #ytcfg.set('yt', '__global_parallel_size', str(MPI.COMM_WORLD.Get_size())) #ncpu = 32 ncpu = 1 #ncpu = MPI.COMM_WORLD.Get_size() ytcfg.set('yt', '__global_parallel_size', str(ncpu)) # create a particle filter to remove star particles @yt.particle_filter("dark_matter", requires=[('particle_mass')]) def dark_matter(pfilter, data): if ('all', 'particle_age') in data.ds.field_list: return data[("all", "particle_age")] == 0.0 else: arr = np.zeros(len(data['particle_mass'])) return arr == 0.0 def setup_ds(ds): #Return only dark matter particles, and assert that the filter holds print 'Here'