
Hi all, Is there a simple way I can combine two data objects to create a new data object? For example, if I created two sphere objects, is there a way I can combine them to create an object that contains the data of both of them? Thanks Christine

Hi Christine, You can do this with Extracted regions using the .join() method. Right now it doesn't work for regular data objects. However, one could make up a new data object that does this. You could create a new data object: http://yt-project.org/docs/2.2/advanced/creating_datatypes.html and have it calculate joins for each of the sub objects it represents for _get_list_of_grids, return a logical or of _get_fully_enclosed called on each sub-object, and a logical or for _get_cut_mask called on each sub-object. If you do this, it would be awesome if you'd fork: https://bitbucket.org/yt_analysis/yt/fork and issue a pull request with the new object! There may be some subtleties with passing field parameters down, but we can deal with that later. -Matt On Tue, Sep 6, 2011 at 3:31 PM, Christine Simpson <csimpson@astro.columbia.edu> wrote:
Hi all,
Is there a simple way I can combine two data objects to create a new data object? For example, if I created two sphere objects, is there a way I can combine them to create an object that contains the data of both of them?
Thanks Christine
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Christine, Depending on what you want to do, it could be a simple as something like this: sp1 = pf.h.sphere([0.2]*3, 0.1) sp2 = pf.h.sphere([0.7]*3, 0.2) def spboth(field): one = sp1[field] two = sp2[field] return na.concatenate((one, two)) and then you could do things like spboth('Density') Many things will not work with spboth, like quantities. Matt's suggestion would probably be a better long-term solution. -- Stephen Skory s@skory.us http://stephenskory.com/ 510.621.3687 (google voice)

[slaps forehead] Yes, of course. This will definitely work if the objects are disjoint, but use care if they overlap, as it will return double points. Thank you, Stephen. On Tue, Sep 6, 2011 at 3:54 PM, Stephen Skory <s@skory.us> wrote:
Christine,
Depending on what you want to do, it could be a simple as something like this:
sp1 = pf.h.sphere([0.2]*3, 0.1) sp2 = pf.h.sphere([0.7]*3, 0.2)
def spboth(field): one = sp1[field] two = sp2[field] return na.concatenate((one, two))
and then you could do things like
spboth('Density')
Many things will not work with spboth, like quantities. Matt's suggestion would probably be a better long-term solution.
-- Stephen Skory s@skory.us http://stephenskory.com/ 510.621.3687 (google voice) _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Hmmm... I actually wanted to feed this new object to the star analysis module so I don't think this will work for me. But it's very useful to know for future reference. Maybe I'll try what Matt suggested or come up with another solution. On Tue, 2011-09-06 at 13:54 -0600, Stephen Skory wrote:
Christine,
Depending on what you want to do, it could be a simple as something like this:
sp1 = pf.h.sphere([0.2]*3, 0.1) sp2 = pf.h.sphere([0.7]*3, 0.2)
def spboth(field): one = sp1[field] two = sp2[field] return na.concatenate((one, two))
and then you could do things like
spboth('Density')
Many things will not work with spboth, like quantities. Matt's suggestion would probably be a better long-term solution.

Christine,
Hmmm... I actually wanted to feed this new object to the star analysis module so I don't think this will work for me. But it's very useful to know for future reference. Maybe I'll try what Matt suggested or come up with another solution.
I think you should still be able to use the Star stuff. Just pass the data as arrays to the modules. Let me know if the examples aren't clear enough: http://yt-project.org/doc/analysis_modules/star_analysis.html -- Stephen Skory s@skory.us http://stephenskory.com/ 510.621.3687 (google voice)
participants (3)
-
Christine Simpson
-
Matthew Turk
-
Stephen Skory