[yt-users] Creating Derived Fields and Plotting Error

Madison Fitzgerald fitzg152 at msu.edu
Wed Jul 22 09:05:36 PDT 2015


Hi Hilary and other yt users,

It solved my convert_to_units problem! However, it does raise the error you said it would, the unit comparison problem, and even using your suggestion, I’m not able to resolve the issue. I’ve also tried using the suggestions from the FAQ (http://yt-project.org/docs/3.1/faq/index.html?highlight=convert%20units#how-do-i-get-the-convert-between-code-units-and-physical-units-for-my-dataset <http://yt-project.org/docs/3.1/faq/index.html?highlight=convert%20units#how-do-i-get-the-convert-between-code-units-and-physical-units-for-my-dataset>), but when I do that, it then reverses the order of the problem (saying code_velocity and then cm/s in my error output).

Updated code (http://paste.yt-project.org/show/5736/ <http://paste.yt-project.org/show/5736/>) and updated error message (http://paste.yt-project.org/show/5735/ <http://paste.yt-project.org/show/5735/>).

Thank you,
Madison


Madison Fitzgerald

Astrophysics | Lyman Briggs College
Women’s & Gender Studies | College of Arts & Letters
LGBTQ and Sexuality Studies Specialization
Women in Science, President
Undergraduate Teaching Assistant
Undergraduate Research Assistant
Department of Physics and Astronomy
Honors College
Michigan State University

> On Jul 22, 2015, at 11:01 AM, Hilary Egan <hilaryye at gmail.com> wrote:
> 
> Hi Madison,
> 
> When using the data object within a derived field, you have to specify what field you want to access. So line 13 should look like 
> 
> new_field = np.maximum(data['radial_velocity'], 0.0)
> 
> Right now the field is trying to find the maximum of the YTSphere object rather than the radial velocity data contained within the YTSphere, which isn't well defined. 
> 
> One other quick comment, once that's fixed your script is going to try and compare data['radial_velocity'] which has units of velocity, and 0.0 which is unitless. In order for that to be a valid comparison, you should give 0.0 in the appropriate units by doing something like this:
> 
> zero_vel = data.ds.quan(0.0, 'km/s')
> new_field = np.maximum(data['radial_velocity'], zero_vel)
> 
> Hope that helps!
> -Hilary
> 
> On Wed, Jul 22, 2015 at 8:49 AM Madison Fitzgerald <fitzg152 at msu.edu <mailto:fitzg152 at msu.edu>> wrote:
> Hello,
> 
> I am trying to create two new derived fields and then make a simple phase plot using one of these fields, but I am running into a pretty consistent error involving “convert_to_units". I get basically the same error when using the ds.sphere object and a ds.all_data object, so if there’s something I’ve messed up on, it’s not obvious to me and I would appreciate any help figuring out what’s wrong.
> 
> I am running yt on a MacBook Pro with OS 10.10.4. I have the newest version of stable yt (3.1 and changeset 665e2b6cdf78), and you can find my script at this link (http://paste.yt-project.org/show/5733/ <http://paste.yt-project.org/show/5733/>) and my error output at this link (http://paste.yt-project.org/show/5734/ <http://paste.yt-project.org/show/5734/>).
> 
> Thank you very much,
> Madison Fitzgerald
> 
> 
> 
> Madison Fitzgerald
> 
> Astrophysics | Lyman Briggs College
> Women’s & Gender Studies | College of Arts & Letters
> LGBTQ and Sexuality Studies Specialization
> Women in Science, President
> Undergraduate Teaching Assistant
> Undergraduate Research Assistant
> Department of Physics and Astronomy
> Honors College
> Michigan State University
> 
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org <mailto:yt-users at lists.spacepope.org>
> http://lists.spacepope.org/listinfo.cgi/yt-users-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/20150722/c98f95ce/attachment.htm>


More information about the yt-users mailing list