Hi, I want to test if a data set at particles. I thought: pf.has_key("particle_type") would work, but oddly it doesn't since: In [17]: pf.has_key("particle_type") Out[17]: False yet: In [4]: dd = pf.h.all_data() In [5]: dd["particle_type"] yt : [INFO ] 2013-02-23 17:00:43,826 Getting particle_type using ParticleIO Out[5]: array([11, 11, 11, ..., 11, 11, 11]) Shouldn't pf.has_key("particle_type") be true in this case? Elizabeth
Hi Elizabeth, 'particle type' is a particle field and I don't think it's ever a well-defined key for the pf object. For Enzo datasets, you can query for 'NumberOfParticles':
pf = load('IsolatedGalaxy/galaxy0030/galaxy0030)' pf['NumberOfParticles] 1124450
Of course that won't tell you if particles of a given type are in the dataset, to do that I think you need to load the particle type dataset into memory as you did in your example. -Nathan On Sat, Feb 23, 2013 at 12:07 AM, Elizabeth Tasker < tasker@astro1.sci.hokudai.ac.jp> wrote:
Hi,
I want to test if a data set at particles. I thought:
pf.has_key("particle_type")
would work, but oddly it doesn't since:
In [17]: pf.has_key("particle_type") Out[17]: False
yet:
In [4]: dd = pf.h.all_data() In [5]: dd["particle_type"] yt : [INFO ] 2013-02-23 17:00:43,826 Getting particle_type using ParticleIO Out[5]: array([11, 11, 11, ..., 11, 11, 11])
Shouldn't pf.has_key("particle_type") be true in this case?
Elizabeth
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Elizabeth, On Sat, Feb 23, 2013 at 3:07 AM, Elizabeth Tasker <tasker@astro1.sci.hokudai.ac.jp> wrote:
Hi,
I want to test if a data set at particles. I thought:
pf.has_key("particle_type")
would work, but oddly it doesn't since:
In [17]: pf.has_key("particle_type") Out[17]: False
yet:
In [4]: dd = pf.h.all_data() In [5]: dd["particle_type"] yt : [INFO ] 2013-02-23 17:00:43,826 Getting particle_type using ParticleIO Out[5]: array([11, 11, 11, ..., 11, 11, 11])
Shouldn't pf.has_key("particle_type") be true in this case?
pf has an ill-defined access pattern, so I think the most likely case is that that will test if it has a conversion factor. But! In all codes, all detected fields get added to pf.h.field_list , and all derived fields (and non-derived fields) that yt can conceivably create are in pf.h.derived_field_list . So you can do: "particle_type" in pf.h.field_list for testing this. -Matt
Elizabeth
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Matt and Nathan, Both of those are great tests - thank you! Elizabeth On Feb 23, 2013, at 5:48 AM, Matthew Turk <matthewturk@gmail.com> wrote:
Hi Elizabeth,
On Sat, Feb 23, 2013 at 3:07 AM, Elizabeth Tasker <tasker@astro1.sci.hokudai.ac.jp> wrote:
Hi,
I want to test if a data set at particles. I thought:
pf.has_key("particle_type")
would work, but oddly it doesn't since:
In [17]: pf.has_key("particle_type") Out[17]: False
yet:
In [4]: dd = pf.h.all_data() In [5]: dd["particle_type"] yt : [INFO ] 2013-02-23 17:00:43,826 Getting particle_type using ParticleIO Out[5]: array([11, 11, 11, ..., 11, 11, 11])
Shouldn't pf.has_key("particle_type") be true in this case?
pf has an ill-defined access pattern, so I think the most likely case is that that will test if it has a conversion factor.
But! In all codes, all detected fields get added to pf.h.field_list , and all derived fields (and non-derived fields) that yt can conceivably create are in pf.h.derived_field_list . So you can do:
"particle_type" in pf.h.field_list
for testing this.
-Matt
Elizabeth
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (3)
-
Elizabeth Tasker
-
Matthew Turk
-
Nathan Goldbaum