<div dir="ltr">Nathan is right.  If you want to permanently add your field spec to the codebase in the same way that I added the group0000 field spec, then you (and your group) wouldn't need to define it in each script you're using.  To add it, you can put it in:<div><br></div><div>yt/frontends/gadget/definitions.py, and just name it group0001.  </div><div><br></div><div>Let us know if you have any problems!</div><div><br></div><div>Cameron</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 3:35 PM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Aug 18, 2015 at 5:28 PM, Jared Coughlin <span dir="ltr"><<a href="mailto:Jared.W.Coughlin.29@nd.edu" target="_blank">Jared.W.Coughlin.29@nd.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks! I'll give that a try.  Also, in my field_spec definition, for those fields that applied to more than one particle type, I edited it to have () around them, so it reads ("C", ("Gas", "Stars")).  Is that the right way to do that? </div></blockquote><div><br></div></span><div>Yes, I think that's correct. It seems to be used that way in the group0000 field spec we have already. I've never actually tried to do what you're doing, though.</div><div><br></div><div>By the way, if you *do* get this working, we'd love to include your field spec in yt itself so future users who have data that looks like yours won't have to deal with this. Unfortunately due to the proliferation of Gadget output types, someone at some point needs to add support for each custom type to yt so we can ascribe semantic meaning to all of the fields.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Also, here's the documentation page I was following:<div><div><a href="http://yt-project.org/doc/examining/loading_data.html?highlight=gadget_field_specs#gadget-data" target="_blank">http://yt-project.org/doc/examining/loading_data.html?highlight=gadget_field_specs#gadget-data</a></div></div></div></blockquote><div><br></div></span><div>I've issued a pull request to fix this here:</div><div><br></div><div><a href="https://bitbucket.org/yt_analysis/yt/pull-requests/1706/correcting-two-incorrect-paths-in-the/diff" target="_blank">https://bitbucket.org/yt_analysis/yt/pull-requests/1706/correcting-two-incorrect-paths-in-the/diff</a><br></div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><br></div><div><br></div><div>Thanks!</div><span><font color="#888888"><div>-Jared</div><div><br></div></font></span></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 5:51 PM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Tue, Aug 18, 2015 at 4:46 PM, Jared Coughlin <span dir="ltr"><<a href="mailto:Jared.W.Coughlin.29@nd.edu" target="_blank">Jared.W.Coughlin.29@nd.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello! I have two questions: the first is related to saving new field specs, and the second is related to reading in the file itself.  <div><br></div><div>I was following along with the documentation that describes saving new field specs, and I defined a new field spec as (it should be noted that my extra columns are for both gas and star particles, and I was unsure as to how to tell yt that it applied for both types, so I made a best guess):<div><br></div><div><div>my_field_def = ("Coordinates", </div><div>                  "Velocities", </div><div>                  "ParticleIDs", </div><div>                  "Mass", </div><div>                  ("InternalEnergy", "Gas"), </div><div>                  ("Density", "Gas"), </div><div>                  ("SmoothingLength", "Gas"), </div><div>                  ("RII", "Stars"), </div><div>                  ("RIa", "Stars"), </div><div>                  ("StellarAge", "Stars"),</div><div>                  ("C", "Gas", "Stars"),</div><div>                  ("O", "Gas", "Stars"),</div><div>                  ("Ca", "Gas", "Stars"),</div><div>                  ("Cr", "Gas", "Stars"),</div><div>                  ("Mn", "Gas", "Stars"),</div><div>                  ("Fe", "Gas", "Stars"),</div><div>               )</div></div><div>And a unit base:</div><div><br></div><div><div>unit_base = {'UnitLength_in_cm' : 3.085678e+21, </div><div>               'UnitMass_in_g' : 1.989e+43, </div><div>               'UnitVelocity_in_cm_per_s' : 1.0e+5}</div></div><div><br></div><div>Firstly, when I tried to add my custom field definition to the gadget_field_specs by doing:</div><div><br></div><div>from yt.frontends.sph.definitions import gadget_field_specs</div><div><br></div><div>I get the error: </div><div><div>Traceback (most recent call last):</div><div>  File "<stdin>", line 1, in <module></div><div>ImportError: No module named definitions</div></div><div><br></div><div>Just wondering what I was doing wrong?  Also, when I try to load in the snapshot, I am doing: </div></div></div></blockquote><div><br></div></div></div><div>It looks like you're reading some out of date documentation. The correct import is now "from yt.frontends.gadget.definitions import gadget_field_specs"</div><div><br></div><div>Can you paste the link to the page with the incorrect import? If it's still that way in the latest version of the docs, we can correct it.</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><br></div><div>fname = 'snapshot_000.0'</div><div>ds = yt.GadgetDataset(fname, unit_base=unit_base, field_spec=my_field_def)</div><div><br></div><div>ds.index</div><div><br></div><div>ad = ds.all_data()</div><div><br></div><div>pz = yt.ProjectionPlot(ds, 'z', ('gas', 'density'))</div><div>pz.show()</div><div><br></div><div>The output is:</div><div><div>yt : [INFO     ] 2015-08-18 17:24:45,103 Calculating time from 2.500e-01 to be 6.950e+16 seconds</div><div>yt : [INFO     ] 2015-08-18 17:24:45,144 Parameters: current_time              = 6.95032608578e+16 s</div><div>yt : [INFO     ] 2015-08-18 17:24:45,144 Parameters: domain_dimensions         = [2 2 2]</div><div>yt : [INFO     ] 2015-08-18 17:24:45,144 Parameters: domain_left_edge          = [ 0.  0.  0.]</div><div>yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: domain_right_edge         = [ 50000.  50000.  50000.]</div><div>yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: cosmological_simulation   = 1</div><div>yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: current_redshift          = 3.00000005201</div><div>yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: omega_lambda              = 0.726</div><div>yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: omega_matter              = 0.274</div><div>yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: hubble_constant           = 0.702</div><div>yt : [INFO     ] 2015-08-18 17:24:45,146 Allocating for 4.194e+06 particles</div><div>yt : [INFO     ] 2015-08-18 17:24:45,664 Identified 3.077e+05 octs</div><div>Traceback (most recent call last):</div><div>  File "yt_test_script.py", line 72, in <module></div><div>    ds.index</div><div>  File "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/data_objects/static_output.py", line 321, in index</div><div>    self, dataset_type=self.dataset_type)</div><div>  File "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/geometry/particle_geometry_handler.py", line 53, in __init__</div><div>    super(ParticleIndex, self).__init__(ds, dataset_type)</div><div>  File "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/geometry/geometry_handler.py", line 65, in __init__</div><div>    self._detect_output_fields()</div><div>  File "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/geometry/particle_geometry_handler.py", line 125, in _detect_output_fields</div><div>    fl, _units = self.io._identify_fields(dom)</div><div>  File "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/frontends/gadget/io.py", line 208, in _identify_fields</div><div>    field, req = field</div><div>ValueError: too many values to unpack</div></div></div></div></blockquote><div><br></div></div></div><div>This is probably related to not having the correct field spec when loading the data.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><div dir="ltr"><div><div><br></div><div><br></div><div>The snapshot I'm trying to load is a 128^3 50Mpc snapshot distributed onto 4 files and the error occurs on a call to ds.index, if that helps.  Thank you!</div></div><span><font color="#888888"><div>-Jared</div></font></span></div>
<br></span>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Cameron Hummels<div><span style="font-size:12.8000001907349px">NSF Postdoctoral Fellow</span></div><div><span style="font-size:12.8000001907349px">Department of Astronomy</span></div><div><span style="font-size:12.8000001907349px">California Institute of Technology</span><br></div><div><a href="http://chummels.org" style="font-size:12.8000001907349px" target="_blank">http://chummels.org</a><br></div></div></div></div>
</div>