<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19328">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Calibri>Hi Matt,</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>Thanks for the help! I'll keep looking into the code and
reply and question I have.</FONT></DIV>
<DIV><FONT face=Calibri>Also, I'll be more than willing to share the image once
I have the implementation done!</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>Sincerely,</FONT></DIV>
<DIV><FONT face=Calibri>Hsi-Yu</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt 新細明體">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt 新細明體; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=matthewturk@gmail.com href="mailto:matthewturk@gmail.com">Matthew
Turk</A> </DIV>
<DIV style="FONT: 10pt 新細明體"><B>To:</B> <A title=yt-dev@lists.spacepope.org
href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</A> </DIV>
<DIV style="FONT: 10pt 新細明體"><B>Sent:</B> Tuesday, October 30, 2012 8:29
PM</DIV>
<DIV style="FONT: 10pt 新細明體"><B>Subject:</B> Re: [yt-dev] Question: adding new
fields for GAMER</DIV>
<DIV><BR></DIV>Hi Hsi-Yu,<BR><BR>On Tue, Oct 30, 2012 at 3:26 AM, Hsi-Yu
Schive <<A href="mailto:hyschive@ntu.edu.tw">hyschive@ntu.edu.tw</A>>
wrote:<BR>> Hi Matt,<BR>><BR>> Thanks for the explanation! Now it's
clearer to me.<BR>><BR>> Let me describe what I understand so far, and
please correct me if there is<BR>> anything wrong.<BR>><BR>> When I
use "add_gamer_field" to add a build-in field in GAMER,<BR>> in principle I
DON'T need to set the "function" parameter since the field<BR>> values
can<BR>> be set directly to the loaded values, but I DO need to provide
the<BR>> "convert_function"<BR>> parameter to properly convert unit to
cgs.<BR><BR>Yup, that's right. But it's probably a good idea to set the
function<BR>to NullFunc, as there may be places where the code checks to see
if a<BR>field has a "real" function or not. So to be on the safe
side:<BR><BR>add_gamer_field("SomeFieldInYourOutput",
function=NullFunc,<BR>convert_function = ...)<BR><BR>><BR>> On the other
hand, when I use "add_field" to define a derived field, I DO<BR>> need to
set<BR>> the "function" parameter to describe how to get the new derived
field from<BR>> the<BR>> existing fields, but in principle I DON'T need
to provide the<BR>> "convert_function" again<BR>> since all existing
fields are already in cgs units. Is that correct?<BR><BR>In principle,
yes. I think in practice there are one or two fields<BR>that are derived
fields that also specify a conversion factor, but<BR>most are because of
things like converting to Msun and Mpc.<BR><BR>><BR>> One more question.
In the field.py file of flash, I saw the following
lines.<BR>><BR>> def
_get_convert(fname):<BR>> def
_conv(data):<BR>>
return data.convert(fname)<BR>> return
_conv<BR>> add_flash_field("divb",
function=NullFunc,
take_log=False,<BR>>
convert_function=_get_convert("divb"),<BR>>
units = r"\mathrm{Gau\ss}\/\rm{cm}")<BR>><BR>> My question is:<BR>>
1. Where can I explicitly set the operations performed by<BR>>
data.convert("divb")?<BR><BR>data.convert(key) will look in the StaticOutput
instance affiliated<BR>with the data, specifically in its conversion_factors
dictionary, and<BR>find "key" in it. So if you want data.convert(key) to
work, set<BR>self.conversion_factors[key] to be a floating point value inside
the<BR>StaticOutput instantiation -- you can see this in the FLASH and
Enzo<BR>frontends where it sets up units.<BR><BR>><BR>> 2. What "field"
variables can be put into data["field"] (may all the fields<BR>> that have
been added by add_field and gamer_add_field)?<BR>><BR><BR>Yup! Any
real or derived field can be requested.<BR><BR>><BR>> Thank you very
much for the help. The YT group is so active and I<BR>> will be more than
willing to have GAMER supported in YT ASAP !!<BR>><BR><BR>That's great to
hear! And once you do have it supported, send an<BR>image from a recent
simulation and we'll put it on the home page. :)<BR>Please feel free to
ask any other questions you might have.<BR><BR>-Matt<BR><BR>>
Sincerely,<BR>> Hsi-Yu<BR>><BR>><BR>><BR>> ----- Original
Message -----<BR>> From: Matthew Turk<BR>> To: <A
href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</A><BR>>
Sent: Monday, October 29, 2012 10:42 PM<BR>> Subject: Re: [yt-dev]
Question: adding new fields for GAMER<BR>><BR>> Hi
Hsi-Yu,<BR>><BR>> On Mon, Oct 29, 2012 at 9:54 AM, Hsi-Yu Schive <<A
href="mailto:hyschive@ntu.edu.tw">hyschive@ntu.edu.tw</A>>
wrote:<BR>>> Dear all,<BR>>><BR>>> I'm trying to add new
fields used in GAMER by editing the file "field.py",<BR>>> but I'm
confused about the following
declarations.<BR>>><BR>>> KnownGAMERFields =
FieldInfoContainer()<BR>>> add_gamer_field =
KnownGAMERFields.add_field<BR>>><BR>>>
GAMERFieldInfo =
FieldInfoContainer.create_with_fallback(FieldInfo)<BR>>>
add_field = GAMERFieldInfo.add_field<BR>>><BR>>> What is the
difference between "KnownGAMERField" and "GAMERFieldInfo"?<BR>>> To me,
it seems that they are both instantiations of the class<BR>>>
FieldInfoContainer,<BR>>> except that GAMERFieldInfo has a fallback
function "FieldInfo".<BR>>> Similarly, what's the difference between
"add_gamer_field" and<BR>>> "add_field"?<BR>><BR>> Ah, this is
something that should be made a bit clearer in the<BR>>
documentation. The distinction is somewhat subtle, and relies on<BR>>
whether a field is something that could reasonably be expected to<BR>>
exist in a file, or<BR>><BR>> A "known" field would be one that can
exist in an output file. The<BR>> others are fields that could be
derived from output from the<BR>> particular code. It's a bit of a
semantic difference, but it helps<BR>> with how derived fields are
detected. So if you know a field is going<BR>> to (potentially) exist
inside a data dump, it gets added with<BR>> add_gamer_field. As an
example, FLASH has the field "dens". We want<BR>> to be able to
access this field with either "dens" or "Density", so we<BR>>
do:<BR>><BR>> add_flash_field("dens", function=NullFunc,
...)<BR>><BR>> and then we add a translation (i.e., a *flash-specific*
derived field) with:<BR>><BR>> add_field("Density",
function=TranslationFunc("dens"))<BR>><BR>> I hope that
helps!<BR>><BR>> Also, thanks for adding support for
GAMER!<BR>><BR>> -Matt<BR>><BR>>><BR>>> Thanks in advance
for the help!!<BR>>><BR>>> Sincerely,<BR>>>
Hsi-Yu<BR>>><BR>>><BR>>><BR>>>
_______________________________________________<BR>>> yt-dev mailing
list<BR>>> <A
href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</A><BR>>>
<A
href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</A><BR>>><BR>>
_______________________________________________<BR>> yt-dev mailing
list<BR>> <A
href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</A><BR>>
<A
href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</A><BR>><BR>><BR>>
_______________________________________________<BR>> yt-dev mailing
list<BR>> <A
href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</A><BR>>
<A
href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</A><BR>><BR>_______________________________________________<BR>yt-dev
mailing list<BR><A
href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</A><BR><A
href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</A></BLOCKQUOTE></BODY></HTML>