<div dir="ltr"><div>Dear yt community,<br><br></div>I am analyzing some Tipsy data output from Gadget 3. I have three different particles, Gas, Star and Dark Matter. I want to derive a new field 'PhysicalMass', that will make a unit conversion of code_mass to some physical mass units. My code so far looks like this:<br><br><b>import yt<br>from yt import derived_field<br><br>@derived_field(name="PhysicalMass", units="g")<br>def _PhysicalMass(field, data):<br>    M = data['Gas','Mass']*((5995.*(1e10)*(1.98855e33))/(0.7))<br>    return M<br>ds = yt.load('snap_p6n36fof_031.bin', n_ref=64)<br>dd= ds.all_data</b><br><div><div class="gmail-prompt gmail-output_prompt" style="box-sizing:border-box;min-width:14ex;padding:0.4em;margin:0px;font-family:monospace;text-align:right;line-height:1.21429em;color:rgb(216,67,21)"><pre style="box-sizing:border-box;overflow:auto;font-family:monospace;font-size:inherit;display:block;padding:0px;margin:0px;line-height:inherit;word-break:break-all;color:black;background-color:transparent;border-width:0px;border-style:none;border-color:currentcolor;border-radius:0px;white-space:pre-wrap;vertical-align:baseline"><br></pre></div><div>My default ('Gas', 'Mass') array looks like this:</div><div><b>dd['Gas','Mass']</b></div><div><pre style="box-sizing:border-box;overflow:auto;font-family:monospace;font-size:14px;display:block;padding:0px;margin:0px;line-height:inherit;word-break:break-all;color:rgb(0,0,0);background-color:rgb(255,255,255);border-width:0px;border-style:none;border-color:currentcolor;border-radius:0px;white-space:pre-wrap;vertical-align:baseline;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">YTArray([  9.64448986e-07,   9.64448986e-07,   9.64448986e-07, ...,
         9.64448986e-07,   9.64448986e-07,   9.64448986e-07]) code_mass<br><br></pre><pre style="box-sizing:border-box;overflow:auto;font-family:monospace;font-size:14px;display:block;padding:0px;margin:0px;line-height:inherit;word-break:break-all;color:rgb(0,0,0);background-color:rgb(255,255,255);border-width:0px;border-style:none;border-color:currentcolor;border-radius:0px;white-space:pre-wrap;vertical-align:baseline;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">But when I call the new derived field, it takes some values which does not correspond to the conversion constants I have multiplied with:<br><br>dd['PhysicalMass']<br>YTArray([  3.26598467e+74,   3.26598467e+74,   3.26598467e+74, ...,
         3.26598467e+74,   3.26598467e+74,   3.26598467e+74]) g<br><br></pre><pre style="box-sizing:border-box;overflow:auto;font-family:monospace;font-size:14px;display:block;padding:0px;margin:0px;line-height:inherit;word-break:break-all;color:rgb(0,0,0);background-color:rgb(255,255,255);border-width:0px;border-style:none;border-color:currentcolor;border-radius:0px;white-space:pre-wrap;vertical-align:baseline;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">I can directly multiply the ('Gas', 'Mass') array with some conversion factors to get accurate values, but I need to define a new field for later calls:<br>dd['Gas','Mass']*((5995.*(1e10)*(1.98855e33))/(0.7))<br></pre></div><div><br><br></div><div>So my question is how do I get a new field which will only contain PhysicalMass from Gas particles. it seems dd['Gas', 'PhysicalMass'] does not exist.</div><div><br></div><div><br></div><div>Thanks very much for your time.</div><div><br></div><div>Best</div><div>Tazkera<br></div><div><br></div></div></div>