<div dir="ltr"><div>I'm not able to reproduce the behavior you're seeing. If you can trigger it using one of the example datasets on <a href="http://yt-project.org/data" target="_blank">yt-project.org/data</a> that would help to narrow down the issue. Here's a modified version of your script using one of those datasets:</div><div><br></div><div><a href="http://paste.yt-project.org/show/7262/" target="_blank">http://paste.yt-project.org/<wbr>show/7262/</a></div><div><a href="http://paste.yt-project.org/show/7262/" target="_blank"><br></a></div><div>(this script runs without error on my laptop)<br></div><div><br></div><div>It would also help to know what yt version you're using.<br></div><div><br></div><div>If I had to guess what the issue was, it might be that you aren't using the full field names in your field definition. Rather than defining as you have it in your script, why not try:<br></div><div><br></div><div><div>    def my_cell_mass(field, data):</div><div>        return (data['gas', 'density']*data['index', 'cell_volume'])</div><div><br></div><div><br></div><div>That's just a guess though.<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 17, 2017 at 2:41 PM, tyuta <span dir="ltr"><<a href="mailto:y0u1t1a5.t@gmail.com" target="_blank">y0u1t1a5.t@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Dear yt users,</div><div><br></div><div>Hi, I have a question on derived field. I want to define "Dark Matter cell mass", which can be defined by (Dark matter density) * (cell_volume). To check that "Dark Matter cell mass" defined well, I also tried to define "my_cell_mass", which should give the same value as the default  'cell_mass', but it gave me an error, and I don't have any idea what the problem is. Could you help me with the problem?</div><div><br></div><div>I'm working on Enzo data.</div><div><br></div><div>Here is my python code (I'm sorry that it's lengthy):</div><div><br></div><div>import yt</div><div>from yt.data_objects.particle_filte<wbr>rs import add_particle_filter</div><div><br></div><div><div>def stars(pfilter, data):</div><div>    filter = data[(pfilter.filtered_type, "particle_type")] == 2</div><div>    return filter</div><div>def DMparticles(pfilter, data):</div><div>    filter = data[(pfilter.filtered_type, "particle_type")] == 1</div><div>    return filter</div></div><div><br></div><div><div>add_particle_filter("stars", function=stars, filtered_type='io',</div><div>                  requires=["particle_type"])</div><div>add_particle_filter("DMparticl<wbr>es", function=DMparticles, filtered_type='io', requires=["particle_type"])</div></div><div><br></div><div><div>def only_DM(field, data):</div><div>    return data['deposit','DMparticles_de<wbr>nsity']</div><div>def DM_in_cell_mass(field, data):</div><div>    return (data['only_DM_Density']*data[<wbr>'cell_volume'])</div><div>def my_cell_mass(field, data):</div><div>    return (data['density']*data['cell_vo<wbr>lume'])</div></div><div><br></div><div>ds_all=yt.load("/.../redshift0<wbr>0??")<br></div><div><br></div><div><div>ds_all.add_particle_filter('st<wbr>ars')</div><div>ds_all.add_particle_filter('DM<wbr>particles')</div></div><div><br></div><div><div>ds_all.add_field(("gas", "only_DM_Density"), units="g/cm**3", function=only_DM)</div><div>ds_all.add_field(("gas", "DM_in_cell_mass"), units="g", function=DM_in_cell_mass)</div><div>ds_all.add_field(("gas", "my_cell_mass"), units="g", function=my_cell_mass)</div></div><div><br></div><div>sp = ds_all.sphere([centerx, centery, centerz], ((somevalue), "kpc"))<br></div><div><br></div><div>sp['cell_volume']<br></div><div><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline">YTArray([  4.44089210e-16,   4.44089210e-16,   4.44089210e-16, ...,
           6.93889390e-18,   6.93889390e-18,   6.93889390e-18]) code_length**3</pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline"><br></pre></div><div>sp[('gas', 'my_cell_mass')]<br></div><div><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline"><span class="m_7687114561721018220m_-2453237892518126219gmail-ansi-red-fg" style="box-sizing:border-box;color:rgb(231,92,88)">YTFieldNotFound</span>: Could not find field '('gas', 'my_cell_mass')' in redshift00??.</pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline"><br></pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal">Best,</span><br></pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal">Y.T.</span></pre></div></div>
<br>______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a><br>
<br></blockquote></div><br></div></div>