[yt-users] Plotting differences of two datasets
dcollins4096 at gmail.com
Wed Mar 12 06:20:45 PDT 2014
What I typically do for such a task is to get the data form yt, then plot
the difference with matplotlib directly. For instance,
>>> import matplotlib.pyplot as plt
>>> DifferenceCube = cube1['Density']-cube2['Density']
>>> plt.imshow( np.sum(DifferenceCube,axis=2), interpolation='nearest',
To my knowlege, there's no way to feed a covering grid back into yt's
projection tools, so this is the best way that I've found. (And you're
definitely right, a covering_grid is necessary for this task)
In general, if you want to make a new field you can't just assign it the
way you did, since there isn't a set method on the covering grid. In
general, look at the add_field tool in the docs for making new fields.
On Tue, Mar 11, 2014 at 5:27 PM, Aaron Lee <a.t.lee at berkeley.edu> wrote:
> Hopefully this is a simple question and is giving me trouble only because
> of my ignorance of how data is stored in YT structures.
> I have two data files of data tabulated over the same unigrid. Each side
> of the domain ranges from 0 to 1. I am interested in plotting a cell by
> cell difference of some quantity. For simplicity, let's just say it's the
> So what I have tried is this:
> (1) Load the files:
> pf1 = load("file1")
> pf2 = load("file2")
> (2) Following some YT cookbook pages, I extract the data :
> cube1 =
> cube2 =
> If I then type something like
> the output is a 3d array of data. Similarly for cube2["Density"]. OK.
> (3) Now the part I'm more iffy on. To create a new data cube, I first
> instigate it as a copy of cube1 and then manipulate the data (at least, I
> thought I was... see below):
> test = cube1
> test["Density"] = cube1["Density"]-cube2["Density"]
> If I then type
> the outputted array is an array of the differences, which is what I want
> to plot.
> However, when I then plot the data by doing:
> The Test.pdf is a plot of just the cube1 density. So the data does not
> appear to be manipulated at all. If I do not instigate 'test' first as a
> copy of cube1, yt complains because cube1["Density"]-cube2["Density"] is
> only an array of data.
> Another idea could be to create a new user-defined field that within the
> field definition loads another data file and does the difference for me. It
> would probably be clunky, but seems possible in theory. But you would know
> better than I.
> Thanks in advance for any notes and tips,
> yt-users mailing list
> yt-users at lists.spacepope.org
-- Sent from a computer.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the yt-users