[yt-users] Column density plot

Stephanie Tonnesen stonnes at gmail.com
Tue Nov 4 21:16:33 PST 2014


Dear Nathan,

Looks great!  Thanks so much!

So once it is officially commited, I should be able to just type hg update
and it will update?  What folder do I need to be in for that to happen (it
keeps on saying no .hg file is not in the folder).

-Stephanie

--
Dr. Stephanie Tonnesen
Alvin E. Nashman Postdoctoral Fellow
Carnegie Observatories, Pasadena, CA
stonnes at gmail.com

On Tue, Nov 4, 2014 at 5:05 PM, Stephanie Tonnesen <stonnes at gmail.com>
wrote:

> Definitely will!  Must wait a couple hrs until little one asleep.  Will
> let you know when done
>
>
> On Tuesday, November 4, 2014, Nathan Goldbaum <nathan12343 at gmail.com>
> wrote:
>
>> I've updated the pull request I created earlier for John Regan's issue to
>> include a fix for this, since they're related:
>> https://bitbucket.org/yt_analysis/yt/pull-request/1292/ensure-profiled-data-are-in-the-correct/diff
>>
>> Would you mind giving it a test drive?
>>
>> On Tue, Nov 4, 2014 at 1:39 PM, Nathan Goldbaum <nathan12343 at gmail.com>
>> wrote:
>>
>>>
>>>
>>> On Tue, Nov 4, 2014 at 1:37 PM, Stephanie Tonnesen <stonnes at gmail.com>
>>> wrote:
>>>
>>>> I want the cylindrical_r bins to be in linear space.  When I do just
>>>> the first line, I still get everything in log space.  When I include
>>>> "logs=logs" in the profile call, it crashes.
>>>>
>>>> alld = ds.all_data()
>>>> gal = alld.cut_region("obj['density'] > 1.01e-28")
>>>> logs = {('index', 'cylindrical_r'): False}
>>>> #logs = {('gas', 'cell_mass'): False}
>>>> profile = yt.create_profile(gal,
>>>>                             [('index', 'cylindrical_r')],          #
>>>> the bin field
>>>>                             [('gas', 'cell_mass')],  # profile field
>>>>                             weight_field=None, n_bins=17,logs=logs)
>>>> coldens = profile["gas","cell_mass"]/1.6733e-24
>>>> coldens[0] = coldens[0]/(3.14159*profile.x[0]*profile.x[0])
>>>> i = 1
>>>> while i < len(coldens):
>>>>     coldens[i] = coldens[i]/((3.14159*profile.x[i]*profile.x[i]) -
>>>> (3.14159*profile.x[i-1]*profile.x[i-1]))
>>>>     i = i+1
>>>> mp.plot(profile.x/3.086e21,coldens)
>>>> mp.show()
>>>> print profile.x
>>>>
>>>> ---------------------------------------------------------------------------KeyError                                  Traceback (most recent call last)<ipython-input-23-a4ffd8615abf> in <module>()      6                             [('index', 'cylindrical_r')],          # the bin field      7                             [('gas', 'cell_mass')],  # profile field----> 8                             weight_field=None, n_bins=17,logs=logs)      9 coldens = profile["gas","cell_mass"]/1.6733e-24     10 coldens[0] = coldens[0]/(3.14159*profile.x[0]*profile.x[0])
>>>> /Users/stephanietonnesen/yt-x86_64/src/yt-hg/yt/data_objects/profiles.pyc in create_profile(data_source, bin_fields, fields, n_bins, extrema, logs, units, weight_field, accumulation, fractional)   1326                 for f in bin_fields]   1327     else:-> 1328         logs = [logs[bin_field[-1]] for bin_field in bin_fields]   1329     if extrema is None:   1330         ex = [data_source.quantities["Extrema"](f, non_zero=l)
>>>> KeyError: 'cylindrical_r'
>>>>
>>>>
>>> This looks like a bug.  Can you file an issue?  It would be great if you
>>> included a script exhibiting the behavior that makes use of one of the
>>> public datasets on yt-project.org/data
>>>
>>>
>>>>
>>>> --
>>>> Dr. Stephanie Tonnesen
>>>> Alvin E. Nashman Postdoctoral Fellow
>>>> Carnegie Observatories, Pasadena, CA
>>>> stonnes at gmail.com
>>>>
>>>> On Tue, Nov 4, 2014 at 1:31 PM, Nathan Goldbaum <nathan12343 at gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Tue, Nov 4, 2014 at 1:29 PM, Stephanie Tonnesen <stonnes at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Okay, I think I must be missing something because right now I am
>>>>>> still getting log-spaced bins:
>>>>>>
>>>>>> alld = ds.all_data()
>>>>>> gal = alld.cut_region("obj['density'] > 1.01e-28")
>>>>>> logs = {('index', 'cylindrical_r'): False}
>>>>>> logs = {('gas', 'cell_mass'): False}
>>>>>>
>>>>>
>>>>> Do you want both of these to be linearly spaced?  Right now you're
>>>>> overwriting the first one when you redeclare "logs".
>>>>>
>>>>>
>>>>>> profile = yt.create_profile(gal,
>>>>>>                             [('index', 'cylindrical_r')],          #
>>>>>> the bin field
>>>>>>                             [('gas', 'cell_mass')],  # profile field
>>>>>>                             weight_field=None, n_bins=17)
>>>>>>
>>>>>
>>>>> Did you forget to pass logs in here?
>>>>>
>>>>>
>>>>>> coldens = profile["gas","cell_mass"]/1.6733e-24
>>>>>> coldens[0] = coldens[0]/(3.14159*profile.x[0]*profile.x[0])
>>>>>> i = 1
>>>>>> while i < len(coldens):
>>>>>>     coldens[i] = coldens[i]/((3.14159*profile.x[i]*profile.x[i]) -
>>>>>> (3.14159*profile.x[i-1]*profile.x[i-1]))
>>>>>>     i = i+1
>>>>>> mp.plot(profile.x/3.086e21,coldens)
>>>>>> mp.show()
>>>>>> print profile.x
>>>>>>
>>>>>> [  2.59949407e+20   3.49922639e+20   4.71037249e+20   6.34071835e+20
>>>>>>    8.53535665e+20   1.14895993e+21   1.54663592e+21   2.08195484e+21
>>>>>>    2.80255739e+21   3.77257363e+21   5.07833019e+21   6.83603292e+21
>>>>>>    9.20210863e+21   1.23871263e+22   1.66745367e+22   2.24458981e+22
>>>>>>    3.02148330e+22] cm
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dr. Stephanie Tonnesen
>>>>>> Alvin E. Nashman Postdoctoral Fellow
>>>>>> Carnegie Observatories, Pasadena, CA
>>>>>> stonnes at gmail.com
>>>>>>
>>>>>> On Tue, Nov 4, 2014 at 12:32 PM, Nathan Goldbaum <
>>>>>> nathan12343 at gmail.com> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Nov 4, 2014 at 12:26 PM, Stephanie Tonnesen <
>>>>>>> stonnes at gmail.com> wrote:
>>>>>>>
>>>>>>>> Okay, I've got that, but does that mean that I can't set something
>>>>>>>> in the parenthesis to force the bins to be in linear space?  and I need to
>>>>>>>> do the take_log setting earlier in the code?
>>>>>>>>
>>>>>>>
>>>>>>> You can, you would need to have something like:
>>>>>>>
>>>>>>> logs = {('gas', 'cell_mass'): False}
>>>>>>>
>>>>>>> profile = yt.create_profile(gal,
>>>>>>>                             [('index', 'cylindrical_r')],          #
>>>>>>> the bin field
>>>>>>>                             [('gas', 'cell_mass')],  # profile field
>>>>>>>                             weight_field=None, logs=logs)
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Stephanie
>>>>>>>>
>>>>>>>> --
>>>>>>>> Dr. Stephanie Tonnesen
>>>>>>>> Alvin E. Nashman Postdoctoral Fellow
>>>>>>>> Carnegie Observatories, Pasadena, CA
>>>>>>>> stonnes at gmail.com
>>>>>>>>
>>>>>>>> On Tue, Nov 4, 2014 at 11:10 AM, Nathan Goldbaum <
>>>>>>>> nathan12343 at gmail.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Nov 4, 2014 at 10:59 AM, Stephanie Tonnesen <
>>>>>>>>> stonnes at gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Thank you both!  I ended up generally following Suoqing's method,
>>>>>>>>>> but tried to use create_profile.  I want my radial spacing to be linear,
>>>>>>>>>> and when I look at the help page:
>>>>>>>>>>
>>>>>>>>>> http://yt-project.org/docs/dev/reference/api/generated/yt.data_objects.profiles.create_profile.html#yt.data_objects.profiles.create_profile
>>>>>>>>>>
>>>>>>>>>> I read that I should set logs=False
>>>>>>>>>>
>>>>>>>>>> So I type in:
>>>>>>>>>>
>>>>>>>>>> profile = yt.create_profile(gal,
>>>>>>>>>>                             [('index',
>>>>>>>>>> 'cylindrical_r')],          # the bin field
>>>>>>>>>>                             [('gas', 'cell_mass')],  # profile
>>>>>>>>>> field
>>>>>>>>>>                             weight_field=None, logs=False)
>>>>>>>>>>
>>>>>>>>>> and yt does not like that.  Nor does it like take_log or
>>>>>>>>>> log_space.  Can someone tell me what I should be setting there?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> In this case, logs is a dictionary that maps field names to
>>>>>>>>> logging selection.  From the docstrings for create_profile:
>>>>>>>>>
>>>>>>>>> logs : dict of boolean values
>>>>>>>>>
>>>>>>>>>         Whether or not to log the bin_fields for the profiles.
>>>>>>>>>
>>>>>>>>>         The keys correspond to the field names. Defaults to the
>>>>>>>>> take_log
>>>>>>>>>         attribute of the field.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Thanks again!
>>>>>>>>>>
>>>>>>>>>> Stephanie
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Dr. Stephanie Tonnesen
>>>>>>>>>> Alvin E. Nashman Postdoctoral Fellow
>>>>>>>>>> Carnegie Observatories, Pasadena, CA
>>>>>>>>>> stonnes at gmail.com
>>>>>>>>>>
>>>>>>>>>> On Mon, Nov 3, 2014 at 9:45 PM, Suoqing JI <
>>>>>>>>>> suoqing at physics.ucsb.edu> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Stephanie,
>>>>>>>>>>>
>>>>>>>>>>> profile.add_fields(‘cell_mass’, weight=None)
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Sorry I’ve missed the later part of my old script — after
>>>>>>>>>>> getting the profile[‘cell_mass’] it should be divided by the unit surface
>>>>>>>>>>> area. The following is the full code and it has been tested with AMR data:
>>>>>>>>>>>
>>>>>>>>>>> profile = BinnedProfile1D(mydisk, Nbin, 'cylindrical_r', rmin,
>>>>>>>>>>> rmax, log_space=True, lazy_reader=True, end_collect=False)
>>>>>>>>>>> profile.add_fields('cell_mass', weight=None)
>>>>>>>>>>>
>>>>>>>>>>> R = profile['cylindrical_r’]
>>>>>>>>>>> Sigma = profile[‘cell_mass']
>>>>>>>>>>>
>>>>>>>>>>> R_edge = np.logspace(np.log10(rmin), np.log10(rmax), num=Nbin+1)
>>>>>>>>>>> for i in range(0, Nbin): Sigma[i] = Sigma[i] /
>>>>>>>>>>> (np.pi*(R_edge[i+1]**2 - R_edge[i]**2.))
>>>>>>>>>>>
>>>>>>>>>>> And Nathan’s approach which takes the advantage of image buffer
>>>>>>>>>>> should also work.
>>>>>>>>>>>
>>>>>>>>>>> Best wishes,
>>>>>>>>>>> --
>>>>>>>>>>> Suoqing JI
>>>>>>>>>>> Ph.D Student
>>>>>>>>>>> Department of Physics
>>>>>>>>>>> University of California, Santa Barbara
>>>>>>>>>>> CA 93106, USA
>>>>>>>>>>>
>>>>>>>>>>> On Nov 3, 2014, at 8:40 PM, Nathan Goldbaum <
>>>>>>>>>>> nathan12343 at gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Nov 3, 2014 at 5:29 PM, Suoqing JI <
>>>>>>>>>>> suoqing at physics.ucsb.edu> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi Stephanie,
>>>>>>>>>>>>
>>>>>>>>>>>> Maybe you could specify a disk, use BinnedProfile1D to create
>>>>>>>>>>>> bins along cylindrical radial ('cylindrical_r'), and do
>>>>>>>>>>>>
>>>>>>>>>>>> profile.add_fields(‘cell_mass’, weight=None)
>>>>>>>>>>>>
>>>>>>>>>>>> then you could plot profile[‘cell_mass’] vs.
>>>>>>>>>>>> profile['cylindrical_r’] and get the 1-D plot the surface density.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> This will be a profile of the gas mass as a function of radius,
>>>>>>>>>>> but it's not quite a surface density profile.  That said, for an unweighted
>>>>>>>>>>> projection, I think it's the same up to a constant scaling factor.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Best wishes,
>>>>>>>>>>>> --
>>>>>>>>>>>> Suoqing JI
>>>>>>>>>>>> Ph.D Student
>>>>>>>>>>>> Department of Physics
>>>>>>>>>>>> University of California, Santa Barbara
>>>>>>>>>>>> CA 93106, USA
>>>>>>>>>>>>
>>>>>>>>>>>> On Nov 3, 2014, at 5:17 PM, Stephanie Tonnesen <
>>>>>>>>>>>> stonnes at gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi yt-users,
>>>>>>>>>>>>
>>>>>>>>>>>> I would like to make a 1D plot of column density vs radius for
>>>>>>>>>>>> a disk (to compare with observations).  I can make a projectionplot, but
>>>>>>>>>>>> want something a bit more simple to look at.  I am using yt3.0.1--is there
>>>>>>>>>>>> a nice way to to this?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> The key is to use the numpy.digitize and numpy.bincount
>>>>>>>>>>> functions to find the histogram of the surface density as a function of
>>>>>>>>>>> radius.  Here's an example:
>>>>>>>>>>>
>>>>>>>>>>> http://nbviewer.ipython.org/gist/ngoldbaum/af8e7f317efe8f115e8b
>>>>>>>>>>>
>>>>>>>>>>> This is a simplified version of what I've done for a project I'm
>>>>>>>>>>> working on right now, which involves making a ton of radial plots of
>>>>>>>>>>> projected quantities:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> https://bitbucket.org/ngoldbaum/galaxy_analysis/src/910f5a7e278247a36f25d62bdc478a7b5a7fe8ce/galanyl/galaxy_analyzer.py?at=default#cl-338
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>
>>>>>>>>>>>> Stephanie
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Dr. Stephanie Tonnesen
>>>>>>>>>>>> Alvin E. Nashman Postdoctoral Fellow
>>>>>>>>>>>> Carnegie Observatories, Pasadena, CA
>>>>>>>>>>>> stonnes at gmail.com
>>>>>>>>>>>>  _______________________________________________
>>>>>>>>>>>> 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
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>>
>>>>
>>>
>>
>
> --
> --
> Dr. Stephanie Tonnesen
> Alvin E. Nashman Postdoctoral Fellow
> Carnegie Observatories, Pasadena, CA
> stonnes at gmail.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141104/5c3915cc/attachment.htm>


More information about the yt-users mailing list