Hi Tomoyuki,

It looks like you might almost have it. The one error I spotted is that the Clump object needs to be given a data container (i.e., the disk object you call data_source) instead of a dataset. If you change it to something like below, I think it should work.

master_clump = Clump(data_sourece, ("grid", "all_density"))

Britton


On Thu, Dec 16, 2021 at 9:25 AM Tomoyuki Shiokawa <201s408s@stu.kobe-u.ac.jp> wrote:
Hi there,

As I received the advice the other day,
I converted the Gadget2 data to arbitrary_grid data by referring to the following URL,
https://yt-project.org/docs/dev/analyzing/objects.html
https://yt-project.org/docs/dev/analyzing/saving_data.html
and reloaded it.

As I received the advice the other day,
I converted the Gadget2 data to arbitrary_grid data by referring to the following URL, and reloaded it.
Then, probably because the converted data does not have the necessary data elements, an error is displayed and clamp finding is not possible.

What elements should be added to the arbitrary_grid data in order to perform the clamp finding introduced on the homepage?
We apologize for the inconvenience, but thank you for your reply.

Below are all the results of the execution.
It's very hard to see, but please forgive me.
=================================================================================

import numpy as np
import yt
from yt.data_objects.level_sets.api import *

fname = "Gadget2.0090"
bbox_lim = 70 # pc
bbox = [[-bbox_lim, bbox_lim], [-bbox_lim, bbox_lim], [-bbox_lim, bbox_lim]]

ds = yt.load(fname, bounding_box=bbox)
ds.index
sorted(ds.field_list)
print(ds.field_list)

obj = ds.arbitrary_grid([-10, -10, -10], [10, 10, 10], dims=[128, 128, 128])
print(obj)
ds2 = obj.save_as_dataset(fields=[("deposit", "all_density"), ("deposit", "all_mass")])
print(ds2)
-------------------------------------------------------------------------------------------------------------------------------------------
yt : [INFO     ] 2021-12-15 11:52:05,207 Omega Lambda is 0.0, so we are turning off Cosmology.
yt : [INFO     ] 2021-12-15 11:52:05,209 Assuming length units are in kpc (physical)
yt : [INFO     ] 2021-12-15 11:52:05,280 Parameters: current_time              = 10.68
yt : [INFO     ] 2021-12-15 11:52:05,282 Parameters: domain_dimensions         = [2 2 2]
yt : [INFO     ] 2021-12-15 11:52:05,284 Parameters: domain_left_edge          = [-70. -70. -70.]
yt : [INFO     ] 2021-12-15 11:52:05,286 Parameters: domain_right_edge         = [70. 70. 70.]
yt : [INFO     ] 2021-12-15 11:52:05,289 Parameters: cosmological_simulation   = 0
yt : [INFO     ] 2021-12-15 11:52:05,295 Allocating for 2.198e+06 particles (index particle type 'all')
yt : [INFO     ] 2021-12-15 11:52:05,780 Identified 1.478e+05 octs

[('Gas', 'Coordinates'), ('Gas', 'Density'), ('Gas', 'InternalEnergy'), ('Gas', 'Mass'), ('Gas', 'ParticleIDs'), ('Gas', 'SmoothingLength'), ('Gas', 'Velocities'), ('Stars', 'Coordinates'), ('Stars', 'Mass'), ('Stars', 'ParticleIDs'), ('Stars', 'Velocities'), ('all', 'Coordinates'), ('all', 'Mass'), ('all', 'ParticleIDs'), ('all', 'Velocities')]
YTArbitraryGrid (Gadget2): , left_edge=[-3.08567758e+22 -3.08567758e+22 -3.08567758e+22] cm, right_edge=[3.08567758e+22 3.08567758e+22 3.08567758e+22] cm, ActiveDimensions=[128 128 128]

yt : [INFO     ] 2021-12-15 11:52:09,509 Saving field data to yt dataset: Gadget2_arbitrary_grid.h5.
Gadget2_arbitrary_grid.h5

=================================================================================

import yt

fname2 = 'Gadget2_arbitrary_grid.h5'
sphere_ds = yt.load(fname2)
sphere_ds.index
sorted(sphere_ds.field_list)

-------------------------------------------------------------------------------------------------------------------------------------------
yt : [INFO     ] 2021-12-15 11:52:15,177 Parameters: current_time              = 10.68 code_time
yt : [INFO     ] 2021-12-15 11:52:15,179 Parameters: domain_dimensions         = [128 128 128]
yt : [INFO     ] 2021-12-15 11:52:15,181 Parameters: domain_left_edge          = [-10. -10. -10.] code_length
yt : [INFO     ] 2021-12-15 11:52:15,183 Parameters: domain_right_edge         = [10. 10. 10.] code_length
yt : [INFO     ] 2021-12-15 11:52:15,187 Parameters: cosmological_simulation   = 0

[('grid', 'all_density'),
 ('grid', 'all_mass'),
 ('grid', 'dx'),
 ('grid', 'dy'),
 ('grid', 'dz'),
 ('grid', 'x'),
 ('grid', 'y'),
 ('grid', 'z')]

=================================================================================

import numpy as np
import yt
from yt.data_objects.level_sets.api import *

fname2 = 'Gadget2_arbitrary_grid.h5'
ds = yt.load(fname2)

data_source = ds.disk([0.5, 0.5, 0.5], [0.0, 0.0, 1.0], (8, "pc"), (1, "pc"))
master_clump = Clump(ds, ("grid", "all_density"))

master_clump.add_validator("min_cells", 20)
master_clump.add_info_item("center_of_mass")

c_min = data_source["grid", "all_density"].min()
c_max = data_source["grid", "all_density"].max()
step = 2.0
print(c_min)
print(c_max)

find_clumps(master_clump, c_min, c_max, step)

-------------------------------------------------------------------------------------------------------------------------------------------
yt : [INFO     ] 2021-12-15 13:11:53,189 Parameters: current_time              = 10.68 code_time
yt : [INFO     ] 2021-12-15 13:11:53,191 Parameters: domain_dimensions         = [128 128 128]
yt : [INFO     ] 2021-12-15 13:11:53,193 Parameters: domain_left_edge          = [-10. -10. -10.] code_length
yt : [INFO     ] 2021-12-15 13:11:53,195 Parameters: domain_right_edge         = [10. 10. 10.] code_length
yt : [INFO     ] 2021-12-15 13:11:53,198 Parameters: cosmological_simulation   = 0

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-f88c4eeda40e> in <module>()
     17 #master_clump = Clump(data_source, ("gas", "cell_density"))
     18
---> 19 master_clump = Clump(ds, ("grid", "all_density"))
     20
     21 master_clump.add_validator("min_cells", 20)

/home/salty1840/anaconda3/envs/yt3/lib/python2.7/site-packages/yt/data_objects/level_sets/clump_handling.pyc in __init__(self, data, field, parent, clump_info, validators, base, contour_key, contour_id)
     61         self.field = field
     62         self.parent = parent
---> 63         self.quantities = data.quantities
     64         self.min_val = self.data[field].min()
     65         self.max_val = self.data[field].max()

AttributeError: 'YTGridDataset' object has no attribute 'quantities'
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
https://mail.python.org/mailman3/lists/yt-users.python.org/
Member address: brittonsmith@gmail.com