Dear yt-users, I was making a plot with "radial_velocity" and noticed that it is always positive, which is odd (there should be both inflow and outflow). The source code is:
print(ds.field_info["gas","radial_velocity"].get_source()) def _radial(field, data): return data[ftype, "%s_spherical_radius" % basename]
I find that quite confusing. It also looks the same as (‘gas’, ‘radial_magnetic_field’) according to http://yt-project.org/doc/ reference/field_list.html Thank you!
Hi Yuan,
It’s the radial component of the velocity vector, so it is indeed always
positive (since the radial component of a vector is always positive).
To get a signed radial velocity like you’re looking for I think you’d need
to start with the full velocity vector and find whether the dot product of
the vector with the local normal to a spherical surface centered on the
center of your coordinate system is net inward or outward.
Now, one might argue that it would be more useful for yt to compute the
sign and include it in the radial velocity field or add a
signed_radial_velocity field. That’s probably something we could do to make
your workflow a bit easier. If you’d like please feel free to file an issue.
Nathan
On Wed, Jun 13, 2018 at 1:24 PM Yuan Li
Dear yt-users,
I was making a plot with "radial_velocity" and noticed that it is always positive, which is odd (there should be both inflow and outflow). The source code is:
print(ds.field_info["gas","radial_velocity"].get_source()) def _radial(field, data): return data[ftype, "%s_spherical_radius" % basename]
I find that quite confusing. It also looks the same as (‘gas’, ‘radial_magnetic_field’) according to http://yt-project.org/doc/reference/field_list.html
Thank you! _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Hi Yuan and Nathan, It's odd that it's not giving negative values; I believe it should. For instance, using the test data: import yt ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity")) gives me: -75850789.70441215 cm/s 45764811.75058524 cm/s Yuan, any chance that you could tell more about how you made the plot? Is it a profile, a slice, a projection? Did you use a data object as its source (otherwise it may use the wrong "center" value) when creating it? Thanks, -Matt
Ah oops, that was my off-the-cuff response from my phone, I didn't actually
double check to see if it produces negative values.
On Wed, Jun 13, 2018 at 1:41 PM, Matthew Turk
Hi Yuan and Nathan,
It's odd that it's not giving negative values; I believe it should. For instance, using the test data:
import yt ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity"))
gives me:
-75850789.70441215 cm/s 45764811.75058524 cm/s
Yuan, any chance that you could tell more about how you made the plot? Is it a profile, a slice, a projection? Did you use a data object as its source (otherwise it may use the wrong "center" value) when creating it?
Thanks,
-Matt _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Hi Matt,
Hmm...How interesting! I tried your script
print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity"))
and also got negative velocities:
-341554446.13335466 cm/s 2489830606.1403117 cm/s
I was trying to make a simple phase plot:
yt.PhasePlot(sphere,("gas","radial_velocity"),"density","cell_mass",weight_field=None,
x_bins=512,
y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mass","Msun")
It does not matter whether or not I have .set_log("radial_velocity",False).
See plots attached below. Is it a phase plot thing (everything becomes
positive?)?
The sphere has the right center (which is the center of the simulation
domain), and all the other phaseplots look normal.
Yuan
On Wed, Jun 13, 2018 at 2:43 PM, Nathan Goldbaum
Ah oops, that was my off-the-cuff response from my phone, I didn't actually double check to see if it produces negative values.
On Wed, Jun 13, 2018 at 1:41 PM, Matthew Turk
wrote: Hi Yuan and Nathan,
It's odd that it's not giving negative values; I believe it should. For instance, using the test data:
import yt ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity"))
gives me:
-75850789.70441215 cm/s 45764811.75058524 cm/s
Yuan, any chance that you could tell more about how you made the plot? Is it a profile, a slice, a projection? Did you use a data object as its source (otherwise it may use the wrong "center" value) when creating it?
Thanks,
-Matt _______________________________________________ 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
Hi Yuan,
I *think* that if you specify log to be false in the construction of
PhasePlot it should work; I am guessing it's cutting the values off before
they get binned.
You can try doing this by taking most of your code and using it slightly
differently:
prof = sphere.profile( [("gas","radial_velocity"), ("gas", "density") ],
["cell_mass"], weight_field=None, x_bins=512, y_bins = 512, logs = {
('gas','radial_velocity') : False })
prof.plot()
,("gas","radial_velocity"),"density","cell_mass",weight_field=None,
x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_
mass","Msun")
On Wed, Jun 13, 2018 at 2:11 PM Yuan Li
Hi Matt,
Hmm...How interesting! I tried your script print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity")) and also got negative velocities: -341554446.13335466 cm/s 2489830606.1403117 cm/s
I was trying to make a simple phase plot: yt.PhasePlot(sphere,("gas","radial_velocity"),"density","cell_mass",weight_field=None, x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mass","Msun")
It does not matter whether or not I have .set_log("radial_velocity",False). See plots attached below. Is it a phase plot thing (everything becomes positive?)?
The sphere has the right center (which is the center of the simulation domain), and all the other phaseplots look normal.
Yuan
On Wed, Jun 13, 2018 at 2:43 PM, Nathan Goldbaum
wrote: Ah oops, that was my off-the-cuff response from my phone, I didn't actually double check to see if it produces negative values.
On Wed, Jun 13, 2018 at 1:41 PM, Matthew Turk
wrote: Hi Yuan and Nathan,
It's odd that it's not giving negative values; I believe it should. For instance, using the test data:
import yt ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity"))
gives me:
-75850789.70441215 cm/s 45764811.75058524 cm/s
Yuan, any chance that you could tell more about how you made the plot? Is it a profile, a slice, a projection? Did you use a data object as its source (otherwise it may use the wrong "center" value) when creating it?
Thanks,
-Matt _______________________________________________ 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
Although when I use the following script, I get negative values in my plot:
import yt
ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
plot =
yt.PhasePlot(ds.all_data(),("gas","radial_velocity"),"density","cell_mass",weight_field=None,
x_bins=512, y_bins=512)
plot.set_unit("density","g/cm**3")
plot.set_unit("cell_mass","Msun")
plot.set_log('radial_velocity', False)
plot.save()
https://i.imgur.com/Hlq7F00.png
Yuan, which yt version are you using?
On Wed, Jun 13, 2018 at 2:15 PM, Matthew Turk
Hi Yuan,
I *think* that if you specify log to be false in the construction of PhasePlot it should work; I am guessing it's cutting the values off before they get binned.
You can try doing this by taking most of your code and using it slightly differently:
prof = sphere.profile( [("gas","radial_velocity"), ("gas", "density") ], ["cell_mass"], weight_field=None, x_bins=512, y_bins = 512, logs = { ('gas','radial_velocity') : False }) prof.plot()
,("gas","radial_velocity"),"density","cell_mass",weight_field=None, x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mas s","Msun")
On Wed, Jun 13, 2018 at 2:11 PM Yuan Li
wrote: Hi Matt,
Hmm...How interesting! I tried your script print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity")) and also got negative velocities: -341554446.13335466 cm/s 2489830606.1403117 cm/s
I was trying to make a simple phase plot: yt.PhasePlot(sphere,("gas","radial_velocity"),"density","cell_mass",weight_field=None, x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_ mass","Msun")
It does not matter whether or not I have .set_log("radial_velocity",False). See plots attached below. Is it a phase plot thing (everything becomes positive?)?
The sphere has the right center (which is the center of the simulation domain), and all the other phaseplots look normal.
Yuan
On Wed, Jun 13, 2018 at 2:43 PM, Nathan Goldbaum
wrote: Ah oops, that was my off-the-cuff response from my phone, I didn't actually double check to see if it produces negative values.
On Wed, Jun 13, 2018 at 1:41 PM, Matthew Turk
wrote: Hi Yuan and Nathan,
It's odd that it's not giving negative values; I believe it should. For instance, using the test data:
import yt ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity"))
gives me:
-75850789.70441215 cm/s 45764811.75058524 cm/s
Yuan, any chance that you could tell more about how you made the plot? Is it a profile, a slice, a projection? Did you use a data object as its source (otherwise it may use the wrong "center" value) when creating it?
Thanks,
-Matt _______________________________________________ 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
Hi Matt, John, Nathan and all,
I first tried what Matt suggested:
prof = sphere.profile( [("gas","radial_velocity"), ("gas", "density") ],
["cell_mass"], weight_field=None, x_bins=512, y_bins = 512, logs = {
('gas','radial_velocity') : False })
and I got this error message:
AttributeError: 'YTSphere' object has no attribute 'profile'
Then I tried what John suggested and added the extrema (to my original
PhasePlot):
rho_v=yt.PhasePlot(sphere,("gas","radial_velocity"),"density","cell_mass",weight_field=None,
x_bins=512,
y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mass","Msun").set_log("radial_velocity",False)
rho_v.set_xlim(-6e8,1e9)
Now I can see the negative radial velocities:
https://i.imgur.com/MqmEZkZ.png
I do not know why PhasePlot automatically shows all velocities for Nathan
but not me. I am using the latest version of yt.
Here is another question: it does not show labels of the color bar for me
either. Why? This does not happen all the time. For some of my output
files, the labels show, and for some, there is no label. Again, adding
"set_zlim" helps in some cases, but some plots still do not have labels on
the color bar.
Thank you!
Yuan
On Wed, Jun 13, 2018 at 3:25 PM, Nathan Goldbaum
Although when I use the following script, I get negative values in my plot:
import yt ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030') plot = yt.PhasePlot(ds.all_data(),("gas","radial_velocity")," density","cell_mass",weight_field=None, x_bins=512, y_bins=512) plot.set_unit("density","g/cm**3") plot.set_unit("cell_mass","Msun") plot.set_log('radial_velocity', False) plot.save()
https://i.imgur.com/Hlq7F00.png
Yuan, which yt version are you using?
On Wed, Jun 13, 2018 at 2:15 PM, Matthew Turk
wrote: Hi Yuan,
I *think* that if you specify log to be false in the construction of PhasePlot it should work; I am guessing it's cutting the values off before they get binned.
You can try doing this by taking most of your code and using it slightly differently:
prof = sphere.profile( [("gas","radial_velocity"), ("gas", "density") ], ["cell_mass"], weight_field=None, x_bins=512, y_bins = 512, logs = { ('gas','radial_velocity') : False }) prof.plot()
,("gas","radial_velocity"),"density","cell_mass",weight_field=None, x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mas s","Msun")
On Wed, Jun 13, 2018 at 2:11 PM Yuan Li
wrote: Hi Matt,
Hmm...How interesting! I tried your script print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity")) and also got negative velocities: -341554446.13335466 cm/s 2489830606.1403117 cm/s
I was trying to make a simple phase plot: yt.PhasePlot(sphere,("gas","radial_velocity"),"density","cell_mass",weight_field=None, x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mas s","Msun")
It does not matter whether or not I have .set_log("radial_velocity",False). See plots attached below. Is it a phase plot thing (everything becomes positive?)?
The sphere has the right center (which is the center of the simulation domain), and all the other phaseplots look normal.
Yuan
On Wed, Jun 13, 2018 at 2:43 PM, Nathan Goldbaum
wrote: Ah oops, that was my off-the-cuff response from my phone, I didn't actually double check to see if it produces negative values.
On Wed, Jun 13, 2018 at 1:41 PM, Matthew Turk
wrote: Hi Yuan and Nathan,
It's odd that it's not giving negative values; I believe it should. For instance, using the test data:
import yt ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity"))
gives me:
-75850789.70441215 cm/s 45764811.75058524 cm/s
Yuan, any chance that you could tell more about how you made the plot? Is it a profile, a slice, a projection? Did you use a data object as its source (otherwise it may use the wrong "center" value) when creating it?
Thanks,
-Matt _______________________________________________ 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
Hi Yuan, Do your plots have more than 9 decades of dynamic range? If so I think labels issue is caused by a bug in matplotlib: https://github.com/matplotlib/matplotlib/issues/10051 We’re currently waiting on an upstream fix this. Nathan
Hi Nathan,
That must be it! I think the plot is trying to do a full range of 1e2 to
1e11 M_sun. Adding "set_zlim" fixed it this time.
Thanks!
Yuan
On Thu, Jun 14, 2018 at 2:52 PM, Nathan Goldbaum
Hi Yuan,
Do your plots have more than 9 decades of dynamic range? If so I think labels issue is caused by a bug in matplotlib:
https://github.com/matplotlib/matplotlib/issues/10051
We’re currently waiting on an upstream fix this.
Nathan
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
That bug in MPL has bit me in the butt many times in the last year. Just
keep the number of orders of magnitude to <=9 or >=14 and you should be OK.
:)
Cameron
On Thu, Jun 14, 2018 at 12:23 PM, Yuan Li
Hi Nathan,
That must be it! I think the plot is trying to do a full range of 1e2 to 1e11 M_sun. Adding "set_zlim" fixed it this time.
Thanks! Yuan
On Thu, Jun 14, 2018 at 2:52 PM, Nathan Goldbaum
wrote: Hi Yuan,
Do your plots have more than 9 decades of dynamic range? If so I think labels issue is caused by a bug in matplotlib:
https://github.com/matplotlib/matplotlib/issues/10051
We’re currently waiting on an upstream fix this.
Nathan
_______________________________________________ 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
-- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org
I’d also try explicitly setting the extrema in the call to sphere.profile, e.g.: prof = sphere.profile( [("gas","radial_velocity"), ("gas", "density") ], ["cell_mass"], weight_field=None, x_bins=512, y_bins = 512, logs = { ('gas','radial_velocity') : False }, extrema={{ ('gas','radial_velocity') : (-1.0e9,1.0e9})
On Jun 13, 2018, at 3:15 PM, Matthew Turk
wrote: Hi Yuan,
I *think* that if you specify log to be false in the construction of PhasePlot it should work; I am guessing it's cutting the values off before they get binned.
You can try doing this by taking most of your code and using it slightly differently:
prof = sphere.profile( [("gas","radial_velocity"), ("gas", "density") ], ["cell_mass"], weight_field=None, x_bins=512, y_bins = 512, logs = { ('gas','radial_velocity') : False }) prof.plot()
,("gas","radial_velocity"),"density","cell_mass",weight_field=None, x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mass","Msun")
On Wed, Jun 13, 2018 at 2:11 PM Yuan Li
mailto:yuan.astro@gmail.com> wrote: Hi Matt, Hmm...How interesting! I tried your script print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity")) and also got negative velocities: -341554446.13335466 cm/s 2489830606.1403117 cm/s
I was trying to make a simple phase plot: yt.PhasePlot(sphere,("gas","radial_velocity"),"density","cell_mass",weight_field=None, x_bins=512, y_bins=512).set_unit("density","g/cm**3").set_unit("cell_mass","Msun")
It does not matter whether or not I have .set_log("radial_velocity",False). See plots attached below. Is it a phase plot thing (everything becomes positive?)?
The sphere has the right center (which is the center of the simulation domain), and all the other phaseplots look normal.
Yuan
On Wed, Jun 13, 2018 at 2:43 PM, Nathan Goldbaum
mailto:nathan12343@gmail.com> wrote: Ah oops, that was my off-the-cuff response from my phone, I didn't actually double check to see if it produces negative values. On Wed, Jun 13, 2018 at 1:41 PM, Matthew Turk
mailto:matthewturk@gmail.com> wrote: Hi Yuan and Nathan, It's odd that it's not giving negative values; I believe it should. For instance, using the test data:
import yt ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") print(ds.r[:].min("radial_velocity"), ds.r[:].max("radial_velocity"))
gives me:
-75850789.70441215 cm/s 45764811.75058524 cm/s
Yuan, any chance that you could tell more about how you made the plot? Is it a profile, a slice, a projection? Did you use a data object as its source (otherwise it may use the wrong "center" value) when creating it?
Thanks,
-Matt _______________________________________________ yt-users mailing list -- yt-users@python.org mailto:yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org mailto:yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org mailto:yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org mailto:yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org mailto:yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org mailto:yt-users-leave@python.org _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (5)
-
Cameron Hummels
-
John Zuhone
-
Matthew Turk
-
Nathan Goldbaum
-
Yuan Li