[yt-users] error with derived field: operands could not be broadcast together with shapes
Jean-Claude Passy
jcpassy at gmail.com
Tue May 1 09:27:58 PDT 2012
Hi all,
I am trying to compare the energy between two datasets. I execute the
following script that uses the derived field 'RelativeEnergy':
--------------------------------------------------------------------------------------------------------------------------------------------------
def _RelativeEnergy(field, data):
return
(data["TotalEnergy"]-data.pf.parameters["TotalEnergy_ref"])/data.pf.parameters["TotalEnergy_ref"]
add_field("RelativeEnergy", function=_RelativeEnergy)
filen1 = 'helix/DD0000/CE0000'
pf1 = load(filen1)
region1 = pf1.h.region([0.5, 0.5, 0.5], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0])
energy1 = region1["TotalEnergy"]
filen2 = 'parallel/DD0000/CE0000'
pf2 = load(filen2)
region2 = pf2.h.region([0.5, 0.5, 0.5], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0])
energy2 = region2["TotalEnergy"]
# Adding reference energy into pf2
pf2.parameters["TotalEnergy_ref"] = energy1
delta_energy = region2["RelativeEnergy"]
pc = PlotCollection(pf2)
pc.add_slice("RelativeEnergy",2,center=[0.5, 0.5, 0.5])
pc.set_lim((0.4, 0.6, 0.4, 0.6))
pc.save('DeltaEnergy')
--------------------------------------------------------------------------------------------------------------------------------------------------
I get the error pasted here:
http://paste.yt-project.org/show/DPgMjV44JktpXExCljUj/
The variable delta_energy looks good (same type and size and energy1),
but the problem arises when I try to take a slice of it.
Any help much appreciated.
Thanks a lot,
JC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20120501/70fcc108/attachment.htm>
More information about the yt-users
mailing list