Hi Yuan,
I do something like this:
def _velocity_los(field, data):
vel_axis = data.get_field_parameter("axis")
if iterable(vel_axis):
ret = data[ftype, "velocity_x"]*vel_axis[0] + \
data[ftype, "velocity_y"]*vel_axis[1] + \
data[ftype, "velocity_z"]*vel_axis[2]
elif vel_axis > 2:
raise NeedsParameter(["axis"])
else:
ret = data[ftype, "velocity_%s" % ({0: "x", 1: "y", 2: "z"}[vel_axis])]
return ret
ds.add_field(("gas", "velocity_los"), function=_velocity_los, units="cm/s”)
and then you set a field parameter, e.g.:
sp = ds.sphere(“c”, (1.0, “Mpc”)
sp.set_field_parameter(“axis”, np.array([0.1, -0.2, 0.3]))
Thank you, Suoqing and Nathan!
While I am on it... is there a good way of getting weighted average off-axis velocity? I guess I can do x, y and z separately and then add them up, but that feels silly.
Yuan
Yes, that is the image you want in the end.
No need to report the issue, I guess we're overdue for a new yt release :)
This bug has already been fixed in the dev version by Bili:
https://github.com/yt-project/yt/pull/2239
Hi Nathan,
Thank you! I am using the latest version of yt.
Just want to confirm -- if I use off_axis_projection, e.g. if I have
>>> image=yt.off_axis_projection(data_source=ds........)
then is image basically the frb that I wanted to get from OffAxisProjectionPlot?
Thanks!
Yuan
Hi Yuan,
What yt version are you using? If it's something older than yt 3.5.1 can you try updating? If it is yt 3.5.1 then this is a bug and should be fixed. Please report it as such on GitHub so it doesn't get lost.
A workaround would be to use the off_axis_projection interface directly:
Hello,
I am trying to get an array out of an off axis projection with a chosen resolution.
This is what I have:
plot = yt.OffAxisProjectionPlot(ds, [1, 1, 1], 'density')
plot.set_buff_size(1600)
image = plot.frb[“gas”, “density”]
According to Nathan's email to Stephanie last year,
"image will be a 1600x1600 2D ndarray containing an image of the density field."
However, it is not working for me. image is still 800x800.
I do see this message:
yt : [INFO ] 2019-07-01 15:51:04,868 Making a fixed resolution buffer of (('gas', 'density')) 1600 by 1600
so it seems that yt is making a FRB with the desired resolution, but how do I get the array?
Thanks!
Yuan
_______________________________________________
yt-users mailing list --
yt-users@python.org
To unsubscribe send an email to
yt-users-leave@python.org
_______________________________________________
yt-users mailing list --
yt-users@python.org
To unsubscribe send an email to
yt-users-leave@python.org
_______________________________________________
yt-users mailing list --
yt-users@python.org
To unsubscribe send an email to
yt-users-leave@python.org
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________
yt-users mailing list --
yt-users@python.orgTo unsubscribe send an email to
yt-users-leave@python.org