[yt-users] Accessing particle_density in a Castro pure nbody simulation

Steffen Klemer moh at gmx.org
Fri Jun 10 01:32:51 PDT 2011


Hey,

I'm trying to access die derived field "particle_density" via the
following script:

from yt.mods import *

pf = load('plt00000')
my_sphere = pf.h.sphere([0,0,0], 1000.0/pf['kpc'])
print my_sphere["particle_density"]


Result:
http://pastebin.com/Hukh7ahB


The data is from a pure nbody Castro run and contains no
"Density"-Field in the output.


Like this:

gurke: ~/castro/runs/test_my_ic > yt stats plt00000
yt : [WARNING  ] 2011-06-10 10:29:56,591 Setting 1.0 in code units to be 1.0 cm
yt : [WARNING  ] 2011-06-10 10:29:56,591 No time units.  Setting 1.0 = 1 second.
yt : [INFO     ] 2011-06-10 10:29:56,592 Parameters: current_time              = 0.0
yt : [INFO     ] 2011-06-10 10:29:56,592 Parameters: domain_dimensions         = [64, 64, 64]
yt : [INFO     ] 2011-06-10 10:29:56,592 Parameters: domain_left_edge          = [ 0.  0.  0.]
yt : [INFO     ] 2011-06-10 10:29:56,592 Parameters: domain_right_edge         = [ 90.  90.  90.]
yt : [INFO     ] 2011-06-10 10:29:56,593 Parameters: cosmological_simulation   = 0.0
yt : [INFO     ] 2011-06-10 10:29:56,598 Adding particle_count to list of fields
yt : [INFO     ] 2011-06-10 10:29:56,598 Adding particle_mass_density to list of fields
Warning: invalid value encountered in sqrt
Warning: divide by zero encountered in divide
Warning: divide by zero encountered in divide
Warning: invalid value encountered in sqrt
level   # grids     # cells
---------------------------
  0          8       262144
----------------------------
             8       262144


t = 0.00000000e+00 = 0.00000000e+00 s = 0.00000000e+00 years

Smallest Cell:
        Width: 4.557e-25 mpc
        Width: 4.557e-22 kpc
        Width: 4.557e-19 pc
        Width: 9.402e-14 au
        Width: 2.022e-11 rsun
        Width: 8.736e-06 miles
        Width: 1.562e-02 unitary
        Width: 1.406e+00 1
        Width: 1.406e+00 cm
Traceback (most recent call last):
  File "/home/sklemer/yt/yt-x86_64/bin/yt", line 9, in <module>
    load_entry_point('yt==2.1dev', 'console_scripts', 'yt')()
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/utilities/command_line.py", line 1061, in run_main
    sys.exit(YT.main())
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/utilities/cmdln.py", line 257, in main
    return self.cmd(args)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/utilities/cmdln.py", line 280, in cmd
    retval = self.onecmd(argv)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/utilities/cmdln.py", line 412, in onecmd
    return self._dispatch_cmd(handler, argv)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/utilities/cmdln.py", line 1100, in _dispatch_cmd
    return handler(argv[0], opts, *args)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/utilities/command_line.py", line 224, in arg_iterate
    func(self, subcmd, opts, arg)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/utilities/command_line.py", line 535, in do_stats
    v, c = pf.h.find_max("Density")
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/object_finding_mixin.py", line 55, in find_max
    mg, mc, mv, pos = self.find_max_cell_location(field, finest_levels)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/object_finding_mixin.py", line 68, in find_max_cell_location
    source.quantities["MaxLocation"]( field, lazy_reader=True)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 91, in __call__
    return self._call_func_lazy(args, kwargs)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 98, in _call_func_lazy
    rv = self.func(GridChildMaskWrapper(g, self._data_source), *args, **kwargs)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 603, in _MaxLocation
    if data[field].size > 0:
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py", line 60, in __getitem__
    data = self.data_source._get_data_from_grid(self.grid, item)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 73, in save_state
    tr = func(self, grid, field)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 2313, in _get_data_from_grid
    if grid[field].size == 1: # dx, dy, dz, cellvolume
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 147, in __getitem__
    self.get_data(key)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 190, in get_data
    self._generate_field(field)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 135, in _generate_field
    self[field] = self.pf.field_info[field](self)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/field_info_container.py", line 309, in __call__
    dd = self._function(self, data)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/frontends/castro/fields.py", line 84, in <lambda>
    add_field(theirs, function=lambda a, b: b[mine], take_log=True)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 147, in __getitem__
    self.get_data(key)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 190, in get_data
    self._generate_field(field)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.py", line 125, in _generate_field
    self.pf.field_info[field].check_available(self)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/field_info_container.py", line 276, in check_available
    validator(data)
  File "/home/sklemer/yt/yt-x86_64/src/yt-hg/yt/data_objects/field_info_container.py", line 374, in __call__
    raise NeedsDataField(doesnt_have)
yt.data_objects.field_info_container.NeedsDataField: (['density'])



Or here like this:


In [27]: pf.keys()
Out[27]: 
['miles',
 'rsun',
 'mpc',
 'cm',
 'unitary',
 '1',
 'pc',
 'kpc',
 'au',
 '1',
 'days',
 'years',
 'DualEnergyFormalism',
 'cosmology_calculator',
 'TopGridDimensions',
 'CosmologyHubbleConstantNow',
 'TopGridRank',
 'CosmologyOmegaLambdaNow',
 'Time',
 'HydroMethod',
 'CosmologyOmegaMatterNow',
 'EOSType',
 'particle_velocity_z',
 'particle_position_z',
 'particle_position_x',
 'particle_position_y',
 'particle_mass',
 'particle_velocity_x',
 'particle_velocity_y']




bye
/Steffen

PS: Sorry for not using the yt-pastebin script but the lodge_it script
seems to not work via the http proxy from my mashine.

-- 
 ()  ascii ribbon campaign - against html e-mail 
 /\  www.asciiribbon.org   - against proprietary attachments



More information about the yt-users mailing list