[yt-users] Gadget snapshot read Problem

Jared Coughlin Jared.W.Coughlin.29 at nd.edu
Wed Aug 19 11:21:23 PDT 2015


That works! Thanks!
-Jared

On Wed, Aug 19, 2015 at 12:35 PM, Matthew Turk <matthewturk at gmail.com>
wrote:

> Hi Jared,
>
> I think "show" will only work in the notebook.  You'll have to call
> pz.save() to save it to a file to view it if you're on the terminal.
>
> -Matt
>
> On Wed, Aug 19, 2015 at 11:34 AM, Jared Coughlin <
> Jared.W.Coughlin.29 at nd.edu> wrote:
>
>> Awesome, thanks, that worked like a charm! Just another quick question,
>> if you wouldn't mind? I'm trying to make a simple projection plot from
>> within ipython (terminal version, not the ipython notebook). I have all of
>> my commands in a script that I run via: %run yt_script.py
>>
>> The script imports yt, numpy as np, pylab, and yt.units as units.  It
>> then loads the snapshot using ds = yt.GadgetDataset(fname,
>> unit_base=unit_base, field_spec=my_field_def), does the indexing as
>> ds.index, and then sets up a projection plot as: pz = yt.ProjectionPlot(ds,
>> 'z', ('gas', 'density')).  However, when I call pz.show(), I get this in my
>> terminal:
>>
>> yt : [INFO     ] 2015-08-19 12:26:28,544 Projection completed
>> yt : [INFO     ] 2015-08-19 12:26:28,544 xlim = 0.000000 50000.000000
>> yt : [INFO     ] 2015-08-19 12:26:28,544 ylim = 0.000000 50000.000000
>> yt : [INFO     ] 2015-08-19 12:26:28,546 xlim = 0.000000 50000.000000
>> yt : [INFO     ] 2015-08-19 12:26:28,546 ylim = 0.000000 50000.000000
>> yt : [INFO     ] 2015-08-19 12:26:28,552 Making a fixed resolution buffer
>> of (('gas', 'density')) 800 by 800
>> <yt.visualization.plot_window.ProjectionPlot at 0x7f01c5170850>
>>
>> And the plot does not actually show up anywhere.  Do I have to manually
>> set a graphics device/window or some such thing like you do in gnuplot, or
>> am I missing a needed library that's causing the plot to not actually show
>> up?  Thanks, and sorry for the bother!
>> -Jared
>>
>> On Tue, Aug 18, 2015 at 6:39 PM, Cameron Hummels <chummels at gmail.com>
>> wrote:
>>
>>> 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:
>>>
>>> yt/frontends/gadget/definitions.py, and just name it group0001.
>>>
>>> Let us know if you have any problems!
>>>
>>> Cameron
>>>
>>> On Tue, Aug 18, 2015 at 3:35 PM, Nathan Goldbaum <nathan12343 at gmail.com>
>>> wrote:
>>>
>>>>
>>>>
>>>> On Tue, Aug 18, 2015 at 5:28 PM, Jared Coughlin <
>>>> Jared.W.Coughlin.29 at nd.edu> wrote:
>>>>
>>>>> 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?
>>>>>
>>>>
>>>> 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.
>>>>
>>>> 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.
>>>>
>>>>
>>>>> Also, here's the documentation page I was following:
>>>>>
>>>>> http://yt-project.org/doc/examining/loading_data.html?highlight=gadget_field_specs#gadget-data
>>>>>
>>>>
>>>> I've issued a pull request to fix this here:
>>>>
>>>>
>>>> https://bitbucket.org/yt_analysis/yt/pull-requests/1706/correcting-two-incorrect-paths-in-the/diff
>>>>
>>>>
>>>>>
>>>>>
>>>>> Thanks!
>>>>> -Jared
>>>>>
>>>>>
>>>>> On Tue, Aug 18, 2015 at 5:51 PM, Nathan Goldbaum <
>>>>> nathan12343 at gmail.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Aug 18, 2015 at 4:46 PM, Jared Coughlin <
>>>>>> Jared.W.Coughlin.29 at nd.edu> wrote:
>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>> 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):
>>>>>>>
>>>>>>> my_field_def = ("Coordinates",
>>>>>>>                   "Velocities",
>>>>>>>                   "ParticleIDs",
>>>>>>>                   "Mass",
>>>>>>>                   ("InternalEnergy", "Gas"),
>>>>>>>                   ("Density", "Gas"),
>>>>>>>                   ("SmoothingLength", "Gas"),
>>>>>>>                   ("RII", "Stars"),
>>>>>>>                   ("RIa", "Stars"),
>>>>>>>                   ("StellarAge", "Stars"),
>>>>>>>                   ("C", "Gas", "Stars"),
>>>>>>>                   ("O", "Gas", "Stars"),
>>>>>>>                   ("Ca", "Gas", "Stars"),
>>>>>>>                   ("Cr", "Gas", "Stars"),
>>>>>>>                   ("Mn", "Gas", "Stars"),
>>>>>>>                   ("Fe", "Gas", "Stars"),
>>>>>>>                )
>>>>>>> And a unit base:
>>>>>>>
>>>>>>> unit_base = {'UnitLength_in_cm' : 3.085678e+21,
>>>>>>>                'UnitMass_in_g' : 1.989e+43,
>>>>>>>                'UnitVelocity_in_cm_per_s' : 1.0e+5}
>>>>>>>
>>>>>>> Firstly, when I tried to add my custom field definition to the
>>>>>>> gadget_field_specs by doing:
>>>>>>>
>>>>>>> from yt.frontends.sph.definitions import gadget_field_specs
>>>>>>>
>>>>>>> I get the error:
>>>>>>> Traceback (most recent call last):
>>>>>>>   File "<stdin>", line 1, in <module>
>>>>>>> ImportError: No module named definitions
>>>>>>>
>>>>>>> Just wondering what I was doing wrong?  Also, when I try to load in
>>>>>>> the snapshot, I am doing:
>>>>>>>
>>>>>>
>>>>>> 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"
>>>>>>
>>>>>> 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.
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> fname = 'snapshot_000.0'
>>>>>>> ds = yt.GadgetDataset(fname, unit_base=unit_base,
>>>>>>> field_spec=my_field_def)
>>>>>>>
>>>>>>> ds.index
>>>>>>>
>>>>>>> ad = ds.all_data()
>>>>>>>
>>>>>>> pz = yt.ProjectionPlot(ds, 'z', ('gas', 'density'))
>>>>>>> pz.show()
>>>>>>>
>>>>>>> The output is:
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,103 Calculating time from
>>>>>>> 2.500e-01 to be 6.950e+16 seconds
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,144 Parameters: current_time
>>>>>>>            = 6.95032608578e+16 s
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,144 Parameters:
>>>>>>> domain_dimensions         = [2 2 2]
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,144 Parameters:
>>>>>>> domain_left_edge          = [ 0.  0.  0.]
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters:
>>>>>>> domain_right_edge         = [ 50000.  50000.  50000.]
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters:
>>>>>>> cosmological_simulation   = 1
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters:
>>>>>>> current_redshift          = 3.00000005201
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: omega_lambda
>>>>>>>            = 0.726
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: omega_matter
>>>>>>>            = 0.274
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,145 Parameters: hubble_constant
>>>>>>>           = 0.702
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,146 Allocating for 4.194e+06
>>>>>>> particles
>>>>>>> yt : [INFO     ] 2015-08-18 17:24:45,664 Identified 3.077e+05 octs
>>>>>>> Traceback (most recent call last):
>>>>>>>   File "yt_test_script.py", line 72, in <module>
>>>>>>>     ds.index
>>>>>>>   File
>>>>>>> "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/data_objects/static_output.py",
>>>>>>> line 321, in index
>>>>>>>     self, dataset_type=self.dataset_type)
>>>>>>>   File
>>>>>>> "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/geometry/particle_geometry_handler.py",
>>>>>>> line 53, in __init__
>>>>>>>     super(ParticleIndex, self).__init__(ds, dataset_type)
>>>>>>>   File
>>>>>>> "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/geometry/geometry_handler.py",
>>>>>>> line 65, in __init__
>>>>>>>     self._detect_output_fields()
>>>>>>>   File
>>>>>>> "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/geometry/particle_geometry_handler.py",
>>>>>>> line 125, in _detect_output_fields
>>>>>>>     fl, _units = self.io._identify_fields(dom)
>>>>>>>   File
>>>>>>> "/home/user/Research/Tools/yt/yt-x86_64/src/yt-hg/yt/frontends/gadget/io.py",
>>>>>>> line 208, in _identify_fields
>>>>>>>     field, req = field
>>>>>>> ValueError: too many values to unpack
>>>>>>>
>>>>>>
>>>>>> This is probably related to not having the correct field spec when
>>>>>> loading the data.
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 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!
>>>>>>> -Jared
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> 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
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>>
>>>
>>>
>>> --
>>> Cameron Hummels
>>> NSF Postdoctoral Fellow
>>> Department of Astronomy
>>> California Institute of Technology
>>> http://chummels.org
>>>
>>> _______________________________________________
>>> 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
>>
>>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150819/29dc9bfe/attachment.htm>


More information about the yt-users mailing list