<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hello,</div><div><br></div><div>I’m new to yt so this maybe solved easily, though it puzzled me for quite some time and I still don’t understand what is going on. </div><div><br></div><div>I try to create derived fields to analyze a simulation using AMR, from an output from CHOMBO. I define the following derived fields: </div><div><br></div><div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;"><span style="color: #d03cff">def</span> <span style="color: #5e34ff">_VRA</span>(field,data):</div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;">    <span style="color: #d03cff">return</span>  data[<span style="color: #c59c9c">'Cylsin'</span>]*data[<span style="color: #c59c9c">'Vx2'</span>]</div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;"><span style="color: #d03cff">def</span> <span style="color: #5e34ff">_VRB</span>(field,data):</div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;">    <span style="color: #d03cff">return</span>  data[<span style="color: #c59c9c">'Cylcos'</span>]*data[<span style="color: #c59c9c">'Vx1'</span>]</div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;"><span style="color: #d03cff">def</span> <span style="color: #5e34ff">_VVR</span>(field,data):</div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;">    <span style="color: #d03cff">return</span>  data[<span style="color: #c59c9c">'VRA'</span>]+data[<span style="color: #c59c9c">'VRB'</span>]</div></div><div><br></div><div>Then I add them to my yt object:</div><div><br></div><div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;">    ds=yt.load(file)</div><p style="margin: 0px; font-size: 14px; font-family: Inconsolata; min-height: 15px;">    ds.index</p><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;">    ds.add_field((<span style="color: #c59c9c">'chombo'</span>,<span style="color: #c59c9c">'VRA'</span>),function=_VRA,units=<span style="color: #c59c9c">'cm/s'</span>,take_log=<span style="color: #d03cff">False</span>)</div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;">    ds.add_field((<span style="color: #c59c9c">'chombo'</span>,<span style="color: #c59c9c">'VRB'</span>),function=_VRB,units=<span style="color: #c59c9c">'cm/s'</span>,take_log=<span style="color: #d03cff">False</span>)</div><div style="margin: 0px; font-size: 14px; font-family: Inconsolata;">    ds.add_field((<span style="color: #c59c9c">'chombo'</span>,<span style="color: #c59c9c">'VVR'</span>),function=_VVR,units=<span style="color: #c59c9c">'cm/s'</span>,take_log=<span style="color: #d03cff">False</span>)</div><p style="margin: 0px; font-size: 14px; font-family: Inconsolata; min-height: 15px;"><br class="webkit-block-placeholder"></p></div><div>and everything goes on smoothly (they are the only variables named this way). Now, If I try to slice VRA and VRB I obtain the (correct) attached plots. Both VRA and VRB are strictly positive. If I try to slice VVR which is the sum VRA+VRB, I obtained the third attached plot which does not correspond to the expected sum (there are even negative values)! I suspect something went odd in the slice function, but I used the exact same lines of code to generate the three plots.</div><div><br></div><div>I must be missing something here but I really don’t get it. Many thanks in advance for your help!</div><div><br></div><div>Antoine</div><div><br></div><div><img apple-inline="yes" id="BA5D4346-A719-4BD5-A556-0B8D48E79016" height="860" width="1014" apple-width="yes" apple-height="yes" src="cid:08F759AE-454F-41C6-B4C4-23EC20E99B8B@umontreal.ca"><img apple-inline="yes" id="4A1DE2A8-B2B6-466A-B97F-EA96709887EC" height="860" width="1014" apple-width="yes" apple-height="yes" src="cid:F60EFB68-F6FD-4546-93C6-9E70D3C6B641@umontreal.ca"><img apple-inline="yes" id="FCC1AA6A-0FD2-41F6-B27F-9D7C05D83B3F" height="860" width="1014" apple-width="yes" apple-height="yes" src="cid:F1A11AF9-C0C2-4CFF-9B37-9320D30F80A1@umontreal.ca"></div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Antoine STRUGAREK</div>-------------------------------------------------------------------<br><a href="https://googledrive.com/host/0BxBaqwiaesNkcDBWcUFCdmMxSUU/strugarek.html">Webpage</a> <br><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Département de physique, Université de Montréal<br><a href="mailto:strugarek@astro.umontreal.ca">strugarek@astro.umontreal.ca</a><br>(+1) 514 343 7077<br>--------------------------------------------------------------------<br>DSM/IRFU/SAp/LDEE CEA Saclay<br>DSM/IRFM/SCCP CEA Cadarache<br>antoine.strugarek@cea.fr<br>--------------------------------------------------------------------<br><br><br><br><br><br><br></div></div></div></div></div></div></div>
</div>
<br></body></html>