[yt-users] Creating Derived Fields and Plotting Error

Hilary Egan hilaryye at gmail.com
Wed Jul 22 08:01:29 PDT 2015


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> 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/) and my error
> output at this link (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
> 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/28006d9d/attachment.htm>


More information about the yt-users mailing list