[yt-dev] Issue #592: Fields that combine deposited particle quantities with gas do not work (yt_analysis/yt)

Nathan Goldbaum issues-reply at bitbucket.org
Wed Jun 12 18:51:10 PDT 2013


New issue 592: Fields that combine deposited particle quantities with gas do not work
https://bitbucket.org/yt_analysis/yt/issue/592/fields-that-combine-deposited-particle

Nathan Goldbaum:

This was exposed on an enzo-3.0 dataset, but I've reproduced it using IsolatedGalaxy.

One minor note: the yt-3.0 `TotalMass` field still depends on `Dark_Matter_Density`.  I can't remember if we merged from yt-2.6dev before that was patched so this might not be a merge error, but I suspect it is.  In any case, the `Matter_Density` correctly uses `particle_density`, so I've used it below:


```
#!python

$ yt plot -a 2 -w 25 -u kpc -f Matter_Density IsolatedGalaxy/galaxy0030/galaxy0030
yt : [INFO     ] 2013-06-12 18:42:33,994 Parameters: current_time              = 0.00600002000283
yt : [INFO     ] 2013-06-12 18:42:33,994 Parameters: domain_dimensions         = [32 32 32]
yt : [INFO     ] 2013-06-12 18:42:33,995 Parameters: domain_left_edge          = [ 0.  0.  0.]
yt : [INFO     ] 2013-06-12 18:42:33,995 Parameters: domain_right_edge         = [ 1.  1.  1.]
yt : [INFO     ] 2013-06-12 18:42:33,996 Parameters: cosmological_simulation   = 0.0
yt : [INFO     ] 2013-06-12 18:42:33,996 Adding plot for axis 2
Parsing Hierarchy100% |||||||||||||||||||||||||||||||||||||||||| Time: 00:00:00
yt : [INFO     ] 2013-06-12 18:42:34,018 Gathering a field list (this may take a moment.)
yt : [INFO     ] 2013-06-12 18:42:34,031 Adding unknown field SFR_Density to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,031 Adding unknown field Forming_Stellar_Mass_Density to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,031 Adding unknown field Galaxy1Colour to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,031 Adding unknown field kphHeI to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,031 Adding unknown field MBHColour to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,032 Adding unknown field Phi_pField to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,032 Adding unknown field Galaxy2Colour to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,032 Adding unknown field Average_creation_time to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,032 Adding unknown field gammaHI to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,032 Adding unknown field kphHI to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,032 Adding unknown field kphHeII to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,032 Adding unknown field Star_Particle_Density to list of fields
yt : [INFO     ] 2013-06-12 18:42:34,036 Adding unknown field PhiField to list of fields
Traceback (most recent call last):
  File "/usr/local/share/python/yt", line 9, in <module>
    load_entry_point('yt==3.0dev', 'console_scripts', 'yt')()
  File "/Users/goldbaum/Documents/yt-3.0/yt/utilities/command_line.py", line 1691, in run_main
    args.func(args)
  File "/Users/goldbaum/Documents/yt-3.0/yt/utilities/command_line.py", line 97, in run
    self(args)
  File "/Users/goldbaum/Documents/yt-3.0/yt/utilities/command_line.py", line 1319, in __call__
    width=width)
  File "/Users/goldbaum/Documents/yt-3.0/yt/visualization/plot_window.py", line 1246, in __init__
    slc.get_data(fields)
  File "/Users/goldbaum/Documents/yt-3.0/yt/data_objects/data_containers.py", line 521, in get_data
    self._generate_fields(fields_to_generate)
  File "/Users/goldbaum/Documents/yt-3.0/yt/data_objects/data_containers.py", line 537, in _generate_fields
    self.field_data[field] = self._generate_field(field)
  File "/Users/goldbaum/Documents/yt-3.0/yt/data_objects/data_containers.py", line 226, in _generate_field
    return self._generate_fluid_field(field)
  File "/Users/goldbaum/Documents/yt-3.0/yt/data_objects/data_containers.py", line 242, in _generate_fluid_field
    rv = finfo(gen_obj)
  File "/Users/goldbaum/Documents/yt-3.0/yt/data_objects/field_info_container.py", line 482, in __call__
    dd = self._function(self, data)
  File "/Users/goldbaum/Documents/yt-3.0/yt/data_objects/universal_fields.py", line 411, in _Matter_Density
    return (data['Density'] + data['particle_density'])
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'
```

I put a breakpoint inside `_Matter_Density` and It looks like an exception is raised when yt attempts to retrieve `particle_density` during field detection.  This exception is never raised to the user level (see #589) so execution proceeds normally.  When the field is finally called by the script, 'Density' is returned as `None`, I guess since the field detection didn't finish properly.

Responsible: MatthewTurk



More information about the yt-dev mailing list