[yt-users] error in the field SoundSpeed?

Luigi Iapichino luigi at ita.uni-heidelberg.de
Tue May 24 07:39:02 PDT 2011


Hi Matt,

it looks like it is getting a bit complicated...
Let's refer only to GasEnergy, for simplicity. Following your suggestion, I 
added to the file ~/.yt/my_plugins.py the lines

def _convertEnergy(data):
    return data.convert("x-velocity")**2.0
 
def _GasEnergy(field, data):
    return data["Gas_Energy"] / _convertEnergy(data)
add_enzo_field("GasEnergy", function=_GasEnergy,
           units=r"\rm{ergs}/\rm{g}", convert_function=_convertEnergy)

(note the add_enzo_field, as you suggested). In this way, slicing GasEnergy 
finally worked, but >not< projecting it. I attach a simple script reproducing 
my error (assuming you have a test Enzo dataset with the field Gas_Energy in 
it).
I hope that tracking this issue is useful for your development; you mentioned 
that future, major changes will address this problem anyway. If you prefer, I 
can simply go back to the stable branch for a quick fix, until some more 
efficient and general solution is found.  

Cheers,

  Luigi

On Tuesday 24 May 2011, Matthew Turk wrote:
> Hi Luigi,
>
> What I think might be happening is that your field ("ThermalEnergy" is
> the one that you can't access, right?) is being added to the universal
> container, which is less specific than the Enzo-specific container;
> ThermalEnergy is nominally defined in the Enzo-specific container, so
> it wins.  Try changing add_field to add_enzo_field and see if that
> helps out.  If you want to redefine a field that is *in* the data
> output, that is trickier, as it requires also removing the item from
> the list of 'in the data' fields with
> "pf.h.field_list.pop(pf.h.field_list.index('whatever'))".
>
> The field stuff has grown to the point where it no longer scales in
> the human dimension.  I think this will be a target of a cleanup in
> the near future.  Britton and I have been working to expand testing
> coverage and to move to a new scheme of binary-diff testing of
> results; this will help us to refactor things like the field
> containers.
>
> -Matt
>
> On Tue, May 24, 2011 at 5:36 AM, Luigi Iapichino
>
> <luigi at ita.uni-heidelberg.de> wrote:
> > Hi Matt,
> >
> > thanks for the suggestions. I added to my file ~/.yt/my_plugins.py the
> > following lines:
> >
> > def _ThermalEnergy(field, data):
> >    if data.pf["HydroMethod"] == 2:
> >        return data["Total_Energy"]
> >    else:
> >        if data.pf["DualEnergyFormalism"]:
> >            return data["GasEnergy"]
> >        else:
> >            return data["Total_Energy"] - 0.5*(
> >                   data["x-velocity"]**2.0
> >                 + data["y-velocity"]**2.0
> >                 + data["z-velocity"]**2.0 )
> > add_field("ThermalEnergy", function=_ThermalEnergy,
> >          units=r"\rm{ergs}/\rm{cm^3}")
> >
> > def _convertEnergy(data):
> >    return data.convert("x-velocity")**2.0
> >
> > def _GasEnergy(field, data):
> >     return data["Gas_Energy"] / _convertEnergy(data)
> > add_field("GasEnergy", function=_GasEnergy,
> >           units=r"\rm{ergs}/\rm{g}", convert_function=_convertEnergy)
> >
> >
> > def _TotalEnergy(field, data):
> >    return data["Total_Energy"] / _convertEnergy(data)
> > add_field("TotalEnergy", function=_TotalEnergy,
> >          display_name = "\mathrm{Total}\/\mathrm{Energy}",
> >          units=r"\rm{ergs}/\rm{g}", convert_function=_convertEnergy)
> >
> > and I switched back to the unstable branch. Still, I have a problem (that
> > I noticed also other times): what I put in my_plugins.py is added to yt,
> > but it does not override the existing definitions. In my case, I get
> > again an error, because yt takes the definition of ThermalEnergy from
> > yt-unstable/src/yt-hg/yt/frontends/enzo/fields.py , rather than from
> > my_plugins.py (I can even copy the definitions in my yt script, but it
> > doesn't change the problem). Is there a way to arrange my script in such
> > a way to give priority to the definitions in my_plugins.py?
> >
> > Cheers,
> >
> >  Luigi
> >
> > On Monday 23 May 2011, Matthew Turk wrote:
> >> Hi Luigi,
> >>
> >> Yes -- in the past we mutually aliased the fields "GasEnergy" and
> >> "Gas_Energy" to each other, so that if one was not found the other was
> >> looked for.  Unfortunately, this aliasing caused infinite recursion
> >> loops:
> >>
> >> https://bitbucket.org/yt_analysis/yt/changeset/258083307f14
> >>
> >> so we had to remove this dual-aliasing.  I had hoped it wouldn't cause
> >> problems; I tried very hard with Sam to come up with a way around
> >> this, so that we could leave the aliasing in.  Unfortunately without
> >> reworking the field container, we could not.  I am hoping that by the
> >> end of the calendar year we will be able to rework the field container
> >> to be more flexible.  However, for now, it should suffice to add into
> >> your plugins file the lines that were removed in the linked commit.
> >> This also took place while we standardized in Enzo on GasEnergy rather
> >> than Gas_Energy (although I personally preferred the hyphen :):
> >>
> >> https://groups.google.com/d/topic/enzo-dev/64j9OZEAzcU/discussion
> >>
> >> Sorry for the inconvenience -- let me know if the plugins fix doesn't
> >> work and we'll figure something else out.
> >>
> >> -Matt
> >>
> >> On Mon, May 23, 2011 at 3:49 PM,  <luigi at ita.uni-heidelberg.de> wrote:
> >> > Dear all,
> >> >
> >> > I want to point out that, in the unstable branch, any attempt of using
> >> > the field SoundSpeed returns an error. I have the impression that yt
> >> > looks for GasEnergy, but in my dataset I have Gas_Energy defined. In
> >> > the stable branch everything works well. I hope it does not depend on
> >> > the data I'm analysing (some old Enzo 1.0 output)...
> >> > Cheers,
> >> >
> >> >  Luigi
> >
> > --
> >
> > ---------------------------------------------------------------
> >
> > Luigi Iapichino
> > Zentrum fuer Astronomie der Universitaet Heidelberg
> > Institut fuer Theoretische Astrophysik
> > Albert-Ueberle-Str. 2, D-69120 Heidelberg, Germany
> > Tel: +49 6221 548983, Fax: +49 6221 544221
> > e-mail: luigi at ita.uni-heidelberg.de
> > URL: http://www.ita.uni-heidelberg.de/~luigi/
> > _______________________________________________
> > yt-users mailing list
> > yt-users at lists.spacepope.org
> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org



-- 

---------------------------------------------------------------

Luigi Iapichino
Zentrum fuer Astronomie der Universitaet Heidelberg
Institut fuer Theoretische Astrophysik
Albert-Ueberle-Str. 2, D-69120 Heidelberg, Germany
Tel: +49 6221 548983, Fax: +49 6221 544221
e-mail: luigi at ita.uni-heidelberg.de
URL: http://www.ita.uni-heidelberg.de/~luigi/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-script.py
Type: application/x-python
Size: 1097 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20110524/2215df92/attachment-0001.bin>


More information about the yt-users mailing list