ISSUE WITH CUT REGION PROJECTION PLOT
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
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
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
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
Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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
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
Thanks for the workaround. Could you please let me know the exact way to do
this? I’ve been tweaking with the code from documentation for derived
fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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
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
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Here's a worked example: https://gist.github.com/ngoldbaum/7d788c91a140a2eb89d4d355e5c1479a On Tue, Oct 9, 2018 at 3:47 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the workaround. Could you please let me know the exact way to do this? I’ve been tweaking with the code from documentation for derived fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
wrote: Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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
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
_______________________________________________ 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
Can you send us where you are at now? And if you are getting an error message? On Tue, Oct 9, 2018 at 4:49 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the workaround. Could you please let me know the exact way to do this? I’ve been tweaking with the code from documentation for derived fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
wrote: Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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
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
_______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com
def _dens(field, data):
dens=data["density"]
if data["density"].any() < 1e-21:
dens=0.0
return dens
filename=
"/lunarc/nobackup/users/samvad/BIG-12-new/output/output_00044/info_00044.txt"
ds = yt.load(filename) dd=ds.all_data()
b=dd.quantities.extrema("density") print(b.value[0],b.value[1]) ds.add_field(("gas", "dens"), function=_dens, units="auto", dimensions=dimensions.density) ad=ds.all_data() c=ad.quantities.extrema("dens")
print(c.value[0], c.value[1]) plot = yt.ProjectionPlot(ds, 'z', 'dens', weight_field="density")
plot.save("density.png")
(change from 600 to 1e-21 is just unit conversion)
I'm not sure if this is how the derived field has to be used in this case,
as this doesn't seem to be doing the pruning I want (the entire density map
without the cut is being displayed). Furthermore, the two print values
display the same extrema (so, I think the mask isn't being applied as
expected)
On Tue, Oct 9, 2018 at 11:03 PM Stephanie Tonnesen
Can you send us where you are at now? And if you are getting an error message?
On Tue, Oct 9, 2018 at 4:49 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the workaround. Could you please let me know the exact way to do this? I’ve been tweaking with the code from documentation for derived fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
wrote: Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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
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
_______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Thanks Nathan, the solution you have suggested works. However, I get an error with setting z limits. When I use:
plot.set_unit("density","hpc")
plot.set_zlim("density", 1e2, 1e7)
I end up with:
plot.set_zlim("density", 1e2, 1e7)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 766, in set_zlim
self.plots[field].zmin = myzmin
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 182, in __getitem__
self, self.data_source._determine_fields(item)[0])
KeyError: ('gas', 'density')
On Tue, Oct 9, 2018 at 11:21 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
def _dens(field, data):
dens=data["density"]
if data["density"].any() < 1e-21:
dens=0.0
return dens
filename=
"/lunarc/nobackup/users/samvad/BIG-12-new/output/output_00044/info_00044.txt"
ds = yt.load(filename)
dd=ds.all_data()
b=dd.quantities.extrema("density") print(b.value[0],b.value[1]) ds.add_field(("gas", "dens"), function=_dens, units="auto", dimensions=dimensions.density) ad=ds.all_data() c=ad.quantities.extrema("dens")
print(c.value[0], c.value[1])
plot = yt.ProjectionPlot(ds, 'z', 'dens', weight_field="density")
plot.save("density.png")
(change from 600 to 1e-21 is just unit conversion) I'm not sure if this is how the derived field has to be used in this case, as this doesn't seem to be doing the pruning I want (the entire density map without the cut is being displayed). Furthermore, the two print values display the same extrema (so, I think the mask isn't being applied as expected)
On Tue, Oct 9, 2018 at 11:03 PM Stephanie Tonnesen
wrote: Can you send us where you are at now? And if you are getting an error message?
On Tue, Oct 9, 2018 at 4:49 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the workaround. Could you please let me know the exact way to do this? I’ve been tweaking with the code from documentation for derived fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
wrote: Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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
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
_______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Pass (“gas”, “density”) instead of “density” and it shoukd work. On Tue, Oct 9, 2018 at 5:11 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks Nathan, the solution you have suggested works. However, I get an error with setting z limits.
When I use:
plot.set_unit("density","hpc")
plot.set_zlim("density", 1e2, 1e7)
I end up with:
plot.set_zlim("density", 1e2, 1e7)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 766, in set_zlim
self.plots[field].zmin = myzmin
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 182, in __getitem__
self, self.data_source._determine_fields(item)[0])
KeyError: ('gas', 'density')
On Tue, Oct 9, 2018 at 11:21 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
def _dens(field, data):
dens=data["density"]
if data["density"].any() < 1e-21:
dens=0.0
return dens
filename=
"/lunarc/nobackup/users/samvad/BIG-12-new/output/output_00044/info_00044.txt"
ds = yt.load(filename)
dd=ds.all_data()
b=dd.quantities.extrema("density") print(b.value[0],b.value[1]) ds.add_field(("gas", "dens"), function=_dens, units="auto", dimensions=dimensions.density) ad=ds.all_data() c=ad.quantities.extrema("dens")
print(c.value[0], c.value[1])
plot = yt.ProjectionPlot(ds, 'z', 'dens', weight_field="density")
plot.save("density.png")
(change from 600 to 1e-21 is just unit conversion) I'm not sure if this is how the derived field has to be used in this case, as this doesn't seem to be doing the pruning I want (the entire density map without the cut is being displayed). Furthermore, the two print values display the same extrema (so, I think the mask isn't being applied as expected)
On Tue, Oct 9, 2018 at 11:03 PM Stephanie Tonnesen
wrote: Can you send us where you are at now? And if you are getting an error message?
On Tue, Oct 9, 2018 at 4:49 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the workaround. Could you please let me know the exact way to do this? I’ve been tweaking with the code from documentation for derived fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
wrote: Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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
_______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ 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, Sorry for interrupting the discussion. According to the previous discussion, possibly *Vadlamani* derived a new field named "dens" and making a projection plot of the derived field (if I am not wrong) instead of "density" field. So, Instead of passing "density", you should pass the "dens" field, it will work. i.e.,
plot.set_unit("dens","hpc")
plot.set_zlim("dens", 1e2, 1e7)
Regards
-Prateek Gupta
On Wed, Oct 10, 2018 at 4:19 AM Nathan Goldbaum
Pass (“gas”, “density”) instead of “density” and it shoukd work.
On Tue, Oct 9, 2018 at 5:11 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks Nathan, the solution you have suggested works. However, I get an error with setting z limits.
When I use:
plot.set_unit("density","hpc")
plot.set_zlim("density", 1e2, 1e7)
I end up with:
plot.set_zlim("density", 1e2, 1e7)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 766, in set_zlim
self.plots[field].zmin = myzmin
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 182, in __getitem__
self, self.data_source._determine_fields(item)[0])
KeyError: ('gas', 'density')
On Tue, Oct 9, 2018 at 11:21 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
def _dens(field, data):
dens=data["density"]
if data["density"].any() < 1e-21:
dens=0.0
return dens
filename=
"/lunarc/nobackup/users/samvad/BIG-12-new/output/output_00044/info_00044.txt"
ds = yt.load(filename)
dd=ds.all_data()
b=dd.quantities.extrema("density") print(b.value[0],b.value[1]) ds.add_field(("gas", "dens"), function=_dens, units="auto", dimensions=dimensions.density) ad=ds.all_data() c=ad.quantities.extrema("dens")
print(c.value[0], c.value[1])
plot = yt.ProjectionPlot(ds, 'z', 'dens', weight_field="density")
plot.save("density.png")
(change from 600 to 1e-21 is just unit conversion) I'm not sure if this is how the derived field has to be used in this case, as this doesn't seem to be doing the pruning I want (the entire density map without the cut is being displayed). Furthermore, the two print values display the same extrema (so, I think the mask isn't being applied as expected)
On Tue, Oct 9, 2018 at 11:03 PM Stephanie Tonnesen
wrote: Can you send us where you are at now? And if you are getting an error message?
On Tue, Oct 9, 2018 at 4:49 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the workaround. Could you please let me know the exact way to do this? I’ve been tweaking with the code from documentation for derived fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
wrote: Sure, using a derived field would work as well.
On Tue, Oct 9, 2018 at 11:21 AM Stephanie Tonnesen
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 > _______________________________________________ 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ 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
Thanks Nathan and Prateek. @Nathan Goldbaum
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 766, in set_zlim
self.plots[field].zmin = myzmin
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 182, in __getitem__
self, self.data_source._determine_fields(item)[0])
KeyError: ('gas', 'density')
and @Prateek, doing what you suggested gives me:
File "dens.py", line 22, in <module>
plot.set_unit("dens","hpc")
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_window.py", line 387, in set_unit
field = self.data_source._determine_fields(field)[0]
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/data_objects/data_containers.py", line 1127, in _determine_fields
finfo = self.ds._get_field_info("unknown", fname)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/data_objects/static_output.py", line 753, in _get_field_info
raise YTFieldNotFound((ftype, fname), self)
yt.utilities.exceptions.YTFieldNotFound: Could not find field '('all', 'dens')' in info_00044.
Neither does ("gas","dens") seems to work
On Wed, Oct 10, 2018 at 1:33 AM Prateek Gupta
Hi, Sorry for interrupting the discussion.
According to the previous discussion, possibly *Vadlamani* derived a new field named "dens" and making a projection plot of the derived field (if I am not wrong) instead of "density" field.
So, Instead of passing "density", you should pass the "dens" field, it will work. i.e.,
plot.set_unit("dens","hpc")
plot.set_zlim("dens", 1e2, 1e7)
Regards -Prateek Gupta
On Wed, Oct 10, 2018 at 4:19 AM Nathan Goldbaum
wrote: Pass (“gas”, “density”) instead of “density” and it shoukd work.
On Tue, Oct 9, 2018 at 5:11 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks Nathan, the solution you have suggested works. However, I get an error with setting z limits.
When I use:
plot.set_unit("density","hpc")
plot.set_zlim("density", 1e2, 1e7)
I end up with:
plot.set_zlim("density", 1e2, 1e7)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 766, in set_zlim
self.plots[field].zmin = myzmin
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 182, in __getitem__
self, self.data_source._determine_fields(item)[0])
KeyError: ('gas', 'density')
On Tue, Oct 9, 2018 at 11:21 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
def _dens(field, data):
dens=data["density"]
if data["density"].any() < 1e-21:
dens=0.0
return dens
filename=
"/lunarc/nobackup/users/samvad/BIG-12-new/output/output_00044/info_00044.txt"
ds = yt.load(filename)
dd=ds.all_data()
b=dd.quantities.extrema("density") print(b.value[0],b.value[1]) ds.add_field(("gas", "dens"), function=_dens, units="auto", dimensions=dimensions.density) ad=ds.all_data() c=ad.quantities.extrema("dens")
print(c.value[0], c.value[1])
plot = yt.ProjectionPlot(ds, 'z', 'dens', weight_field="density")
plot.save("density.png")
(change from 600 to 1e-21 is just unit conversion) I'm not sure if this is how the derived field has to be used in this case, as this doesn't seem to be doing the pruning I want (the entire density map without the cut is being displayed). Furthermore, the two print values display the same extrema (so, I think the mask isn't being applied as expected)
On Tue, Oct 9, 2018 at 11:03 PM Stephanie Tonnesen
wrote: Can you send us where you are at now? And if you are getting an error message?
On Tue, Oct 9, 2018 at 4:49 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the workaround. Could you please let me know the exact way to do this? I’ve been tweaking with the code from documentation for derived fields but unable to do this.
On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum
wrote: > 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 >> > _______________________________________________ > 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
-- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ 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
Sorry for the confusion, you should be using consistent field names, if you’re using the ones in my notebook, you should use the ones I use there. On Tue, Oct 9, 2018 at 7:14 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks Nathan and Prateek. @Nathan Goldbaum
replacing plot.set_zlim("density", 1e2, 1e7) with plot.set_zlim(("gas","density"), 1e2, 1e7) is giving a similar error. plot.set_zlim(("gas","density"), 1e2, 1e7)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 766, in set_zlim
self.plots[field].zmin = myzmin
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 182, in __getitem__
self, self.data_source._determine_fields(item)[0])
KeyError: ('gas', 'density')
and @Prateek, doing what you suggested gives me:
File "dens.py", line 22, in <module>
plot.set_unit("dens","hpc")
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_window.py", line 387, in set_unit
field = self.data_source._determine_fields(field)[0]
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/data_objects/data_containers.py", line 1127, in _determine_fields
finfo = self.ds._get_field_info("unknown", fname)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/data_objects/static_output.py", line 753, in _get_field_info
raise YTFieldNotFound((ftype, fname), self)
yt.utilities.exceptions.YTFieldNotFound: Could not find field '('all', 'dens')' in info_00044.
Neither does ("gas","dens") seems to work
On Wed, Oct 10, 2018 at 1:33 AM Prateek Gupta
wrote: Hi, Sorry for interrupting the discussion.
According to the previous discussion, possibly *Vadlamani* derived a new field named "dens" and making a projection plot of the derived field (if I am not wrong) instead of "density" field.
So, Instead of passing "density", you should pass the "dens" field, it will work. i.e.,
plot.set_unit("dens","hpc")
plot.set_zlim("dens", 1e2, 1e7)
Regards -Prateek Gupta
On Wed, Oct 10, 2018 at 4:19 AM Nathan Goldbaum
wrote: Pass (“gas”, “density”) instead of “density” and it shoukd work.
On Tue, Oct 9, 2018 at 5:11 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks Nathan, the solution you have suggested works. However, I get an error with setting z limits.
When I use:
plot.set_unit("density","hpc")
plot.set_zlim("density", 1e2, 1e7)
I end up with:
plot.set_zlim("density", 1e2, 1e7)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 77, in newfunc
rv = f(*args, **kwargs)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 766, in set_zlim
self.plots[field].zmin = myzmin
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/plot_container.py", line 182, in __getitem__
self, self.data_source._determine_fields(item)[0])
KeyError: ('gas', 'density')
On Tue, Oct 9, 2018 at 11:21 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
def _dens(field, data):
dens=data["density"]
if data["density"].any() < 1e-21:
dens=0.0
return dens
filename=
"/lunarc/nobackup/users/samvad/BIG-12-new/output/output_00044/info_00044.txt"
ds = yt.load(filename)
dd=ds.all_data()
b=dd.quantities.extrema("density") print(b.value[0],b.value[1]) ds.add_field(("gas", "dens"), function=_dens, units="auto", dimensions=dimensions.density) ad=ds.all_data() c=ad.quantities.extrema("dens")
print(c.value[0], c.value[1])
plot = yt.ProjectionPlot(ds, 'z', 'dens', weight_field="density")
plot.save("density.png")
(change from 600 to 1e-21 is just unit conversion) I'm not sure if this is how the derived field has to be used in this case, as this doesn't seem to be doing the pruning I want (the entire density map without the cut is being displayed). Furthermore, the two print values display the same extrema (so, I think the mask isn't being applied as expected)
On Tue, Oct 9, 2018 at 11:03 PM Stephanie Tonnesen
wrote: Can you send us where you are at now? And if you are getting an error message?
On Tue, Oct 9, 2018 at 4:49 PM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
> Thanks for the workaround. Could you please let me know the exact > way to do this? I’ve been tweaking with the code from documentation for > derived fields but unable to do this. > > On Tue, 9 Oct 2018 at 6:24 PM, Nathan Goldbaum < > nathan12343@gmail.com> wrote: > >> 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 >>> >> _______________________________________________ >> 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 > -- -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ 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
participants (4)
-
Nathan Goldbaum
-
Prateek Gupta
-
Stephanie Tonnesen
-
Vadlamani Samhitha