-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_dataset_dm_fields.py
More file actions
30 lines (24 loc) · 998 Bytes
/
create_dataset_dm_fields.py
File metadata and controls
30 lines (24 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
import os
import sys
import yt
import ytree
from yt.extensions.p2p import \
add_p2p_particle_filters
# load data
root_dir = "/disk12/brs/pop2-prime/firstpop2_L2-Seed3_large/cc_512_no_dust_continue"
a = ytree.load(os.path.join(root_dir, 'merger_trees/p2p_nd/p2p_nd.h5'))
ds = yt.load("DD0560_sphere.h5")
output_file = os.path.join("dm", "{ds.basename}.h5")
# if os.path.exists(output_file):
#add_p2p_particle_filters(ds)
region = ds.box(ds.parameters["RefineRegionLeftEdge"],
ds.parameters["RefineRegionRightEdge"])
fields = [('nbody', 'particle_index'), ('nbody', 'particle_type'), ('gas', 'temperature'), ('gas', 'density'),
("all", "particle_position_x"), ("all", "particle_position_y"), ("all", "particle_position_z"),
("all", "particle_position")]
data = dict((field, region[field]) for field in fields)
ftypes = dict(field for field in fields)
yt.save_as_dataset(
ds, filename=output_file,
data=data, field_types=ftypes)