[yt-users] cannot SlicePlot() using cut_region() filter on data from yt.load_uniform_grid()
Dale Braden
genghis17 at comcast.net
Sat Dec 9 16:23:21 PST 2017
Hello,
I have some density data in an unsupported format which I read into yt
by means of the yt.load_uniform_grid() function. I want to filter this
data by creating a cut_region and then do a SlicePlot on the filtered
data. What I find is that no matter how I define the cut_region, the
dynamic range of the resulting plot is said to be 0.0, even though the
cut region has no values in it which are actually 0.0.
I do not have this problem if I use data in a supported format. For
example, I can follow the yt tutorial which creates a SlicePlot from a
cut_region on the Enzo_64 example dataset. So I wonder if maybe the
problem I'm having is due to the fact that when one creates a dataset
using load_uniform_grid(), one ends up with a StreamDataset object
instead of an object representing a supported format.
Here is some relevant output from my session (omitting the code to read
in my data from disk):
In [8]: data2 = np.array(griddata)
In [9]: arr = data2.reshape((41,56,47))
In [10]: data = dict(density = (arr,"g/cm**3"))
In [11]: bbox = np.array([[-4.0,4.2],[-5.5,5.7],[-4.175872,5.22413]])
In [12]: ds = yt.load_uniform_grid(data, arr.shape, length_unit="cm",
bbox=bbox)
yt : [INFO ] 2017-12-09 15:41:20,781 Parameters:
current_time = 0.0
yt : [INFO ] 2017-12-09 15:41:20,781 Parameters:
domain_dimensions = [41 56 47]
yt : [INFO ] 2017-12-09 15:41:20,782 Parameters:
domain_left_edge = [-4. -5.5 -4.175872]
yt : [INFO ] 2017-12-09 15:41:20,782 Parameters:
domain_right_edge = [ 4.2 5.7 5.22413]
yt : [INFO ] 2017-12-09 15:41:20,783 Parameters:
cosmological_simulation = 0.0
In [13]: ds.find_max('density')
yt : [INFO ] 2017-12-09 15:48:16,640 Max Value is 5.14618e+01 at
0.0999999999999996 -0.0000000000000009 -0.0758711276595738
Out[13]: (51.4618 g/cm**3, YTArray([ 1.00000000e-01, -8.88178420e-16,
-7.58711277e-02]) code_length)
In [14]: ds.find_min('density')
yt : [INFO ] 2017-12-09 15:48:53,392 Min Value is 8.71255e-12 at
-3.8999999999999999 -5.4000000000000004 -4.0758719787234039
Out[14]: (8.71255e-12 g/cm**3, YTArray([-3.9 , -5.4 ,
-4.07587198]) code_length)
So you can see from find_min() that all data values are > 0.0. I should
mention that if I do a SlicePlot on ds.all_data(), it looks fine. But
if I try a SlicePlot on a cut_region, even one that essentially
duplicates the entire dataset, then there's nothing to plot even though
the cut_region does have valid data in it:
In [20]: ad = ds.all_data()
In [23]: den = ad.cut_region(['obj["density"] > 0.0'])
In [24]: print den.quantities.extrema([('gas','density')])
[ 8.71255000e-12 5.14618000e+01] g/cm**3
In [25]: p2 = yt.SlicePlot(ds, 'x','density', center="m", data_source=den)
yt : [INFO ] 2017-12-09 15:55:58,155 Max Value is 5.14618e+01 at
0.0999999999999996 -0.0000000000000009 -0.0758711276595738
yt : [INFO ] 2017-12-09 15:55:58,585 xlim = -5.600000 5.600000
yt : [INFO ] 2017-12-09 15:55:58,585 ylim = -4.775872 4.624130
yt : [INFO ] 2017-12-09 15:55:58,586 xlim = -5.600000 5.600000
yt : [INFO ] 2017-12-09 15:55:58,586 ylim = -4.775872 4.624130
yt : [INFO ] 2017-12-09 15:55:58,587 Making a fixed resolution
buffer of (('gas', 'density')) 800 by 800
yt : [WARNING ] 2017-12-09 15:55:58,606 Plot image for field ('gas',
'density') has zero dynamic range. Min = Max = 0.000000.
yt : [WARNING ] 2017-12-09 15:55:58,606 Switching to linear colorbar
scaling.
That first warning message is the problem: zero dynamic range. What's
going wrong?
best wishes,
Dale
More information about the yt-users
mailing list