forked from yt-project/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.yaml
133 lines (133 loc) · 4.5 KB
/
examples.yaml
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
- category: Data
entries:
- name: Quick calculations
id: quick_calc
content: |
import yt
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
ds.r[0.45:0.55,:,:].sum("cell_mass").in_units("Mjup")
output: |
9.98537989593e+12 Mjup
- name: Derived fields
id: derived_fields
content: |
import yt
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
def thermal_energy_dens(field, data):
return (3/2)*data['gas', 'number_density'] * data['gas', 'kT']
ds.add_field(("gas", "thermal_energy_density"), units="erg/cm**3",
function=thermal_energy_dens)
ad = ds.all_data()
ad.mean("thermal_energy_density", "z", weight="density").plot()
image: galaxy0030_Projection_z_thermal_energy_density_density.png
- name: Unit systems
id: unit_systems
content: |
import yt
ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150",
unit_system="imperial")
slc = yt.SlicePlot(ds, 'z', "temperature", width=(600,"kpc"))
image: sloshing_nomag2_hdf5_plt_cnt_0150_Slice_z_temperature.png
- name: Data Portability
id: data_portability
content: |
import yt
ds = yt.load("galaxy0030/galaxy0030")
sp = ds.sphere([0.5, 0.5, 0.5], (8, "kpc"))
sp.save_as_dataset("my_sphere.h5", ["density", "particle_mass"])
ds2 = yt.load("my_sphere.h5")
print (ds2.data["particle_mass"].to("Msun"))
output: |
[ 213975.58440381
213975.58440381
213975.58440381
...,
102714.05991054
102857.70970906
102981.94762343] Msun
- category: Viz
entries:
- name: Slicing
id: slicing
content: |
import yt
ds = yt.load("snapshot_033/snap_033.0.hdf5")
ds.r[(12.4, 'Mpc'),:,:].plot("density")
image: snap_033_Slice_x_density.png
- name: Projecting
id: projecting
content: |
import yt
ds = yt.load("D9p_500/10MpcBox_HartGal_csf_a0.500.d")
p = yt.ProjectionPlot(ds, "y", "density")
image: 10MpcBox_HartGal_csf_a0.500.d_Projection_y_density.png
- name: Interaction
id: interaction
content: |
import yt
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
yt.interactive_render(ds)
image: interactive.png
- name: Profile
id: profile
content: |
import yt
ds = yt.load("snipshot_399_z000p000/snip_399_z000p000.0.hdf5")
ad = ds.all_data()
yt.ProfilePlot(ad, ("PartType0", "density"),
("PartType0", "temperature"),
weight_field = ("PartType0", "particle_mass")).save()
image: snip_399_z000p000_1d-Profile_density_temperature.png
- name: Phase Plot
id: phase
content: |
import yt
ds = yt.load("HiresIsolatedGalaxy/DD0044/DD0044")
ad = ds.all_data()
yt.PhasePlot(ad, "density", "temperature", "cell_mass",
weight_field=None).save()
image: DD0044_2d-Profile_density_temperature_cell_mass.png
- category: Analysis
entries:
- name: Extrema
id: extrema
content: |
import yt
ds = yt.load("Enzo_64/DD0043/data0043")
ds.r[:].min(), ds.r[:].max()
output: |
(3.81289338015e-32 g/cm**3,
6.27892369905e-27 g/cm**3)
- name: Averages
id: averages
content: |
import yt
ds = yt.load("output_00080/info_00080.txt")
ds.r[(10.0, "Mpc"):(20.0, "Mpc"),
(30.0, "Mpc"):(40.0, "Mpc"),
(50.0, "Mpc"):(60.0, "Mpc")].mean("temperature", weight="density")
output: |
296317.62046 K
- name: Line query
id: line_query
content: |
import yt
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
loc1 = ds.r[:].argmax("temperature")
loc2 = ds.r[:].argmax("density")
ray = ds.ray(loc1, loc2)
ray["velocity_magnitude"].in_units("cm/s")
output: |
YTArray([ 22921344.10593038,
24626806.46165072,
24759784.32406003,
26583519.63858156,
27331481.53657745,
27728742.61474814,
28734604.40420894,
30188600.75890669,
30989266.0493723 ,
31197303.98155414,
...
10846216.93678336,
12222078.64819527]) cm/s