Sure, using a derived field would work as well. On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen <stonnes@gmail.com> wrote:
In your particular example, I feel like you can get around this without needing to use cut region. Nathan and Vadlamani, it looks like what one could do is set all the cells with density below 600 to have a density = 0, then the projection would only actually add up the dense cells. Of course, I don't know off the top of my head how to do this.
Maybe define a new variable:
def _only_dens(field,data): onlydens = data['gas','density'] if data['gas','density'] < 600: onlydens = 0.0 return onlydens
And then make a projectionplot of that?
Best, Stephanie -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com
On Tue, Oct 9, 2018 at 12:07 PM Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi,
I have a feeling you're running into a known bug:
https://github.com/yt-project/yt/issues/1646
Unfortunately I don't have a workaround and fixing that bug is nontrivial.
Sorry to not have an easy answer.
-Nathan
On Tue, Oct 9, 2018 at 10:57 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi,
I am trying to make a projection plot of a cut region with the following script:
import yt
from yt.units import kpc
import matplotlib.pyplot as plt
import numpy as np
import yt.visualization.eps_writer as eps
filename= "/lunarc/nobackup/users/samvad/BIG-12-new/output/output_00044/info_00044.txt"
ds = yt.load(filename)
ds.define_unit("hpc", (1.674*10**(-24), "g/cm**3"))
ad=ds.all_data()
dens=ad.cut_region(["obj['density'].in_units('hpc') > 600"])
a=dens.quantities.extrema("density").in_units('hpc')
plot = yt.ProjectionPlot(ds, 'z', "density", weight_field="density",
data_source=dens) plot.set_unit("density", "hpc") plot.set_zlim("density", 1e-7, 1e8)
plot.save("density.png")
I find that my cut region is not empty and has some values, however, when I look at the plot, it is empty. I get the following error in the output:
/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_window.py:785: RuntimeWarning: All-NaN axis encountered
elif np.nanmax(image) == np.nanmin(image):
/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_window.py:788: RuntimeWarning: All-NaN axis encountered
elif np.nanmax(image) <= 0:
yt : [WARNING ] 2018-10-09 17:56:15,001 Plot image for field ('gas', 'density') is filled with NaNs.
yt : [WARNING ] 2018-10-09 17:56:15,001 Switching to linear colorbar scaling.
yt : [INFO ] 2018-10-09 17:56:15,513 Saving plot density.png
_______________________________________________ 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