Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: missing values for minimum value of the data #171

Open
chrishavlin opened this issue Feb 11, 2025 · 0 comments · May be fixed by #172
Open

BUG: missing values for minimum value of the data #171

chrishavlin opened this issue Feb 11, 2025 · 0 comments · May be fixed by #172
Labels
bug Something isn't working

Comments

@chrishavlin
Copy link
Contributor

chrishavlin commented Feb 11, 2025

Elements where the data value is equal to the minimum are not being rendered. Here's an example that builds some refined grids:

import yt
import numpy as np
import yt
import yt_idv

bbox = np.array([
    [0., 1.],
    [0., 1.],
    [0., 1.]
])
bbox_wid = bbox[:,1] - bbox[:,0]
bbox_c = np.mean(bbox,axis=1)
sz_0 = np.array((64, 64, 64))
refine_factor = 2
max_lev = 5

# divide grid by 2 every time


dd0 = bbox_wid / sz_0
sz_i = sz_0.copy()
grids = []
for lev in range(max_lev):

    box_wid_factor = 2. * int(lev > 0) + int(lev==0) * 1.
    bbox_wid = bbox_wid / box_wid_factor
    le_i = bbox_c - bbox_wid/2.
    re_i = bbox_c + bbox_wid/2.

    # find closest start/end index in lev 0 grid
    start_i = np.round(le_i / dd0).astype(int)
    end_i = np.round(re_i / dd0).astype(int)
    #print(start_i, end_i)
    sz_0 = end_i - start_i

    # recompute for rounding errors
    le_i = start_i * dd0
    re_i = le_i + sz_0 * dd0

    sz_i = sz_0 * 2 ** lev

    levp1 = np.full(sz_i, lev+1.0)
    if lev==0:
        levp1[32:,32:,32:] = 1.5
    grid = {'left_edge': le_i,
            'right_edge': re_i,
            'dimensions': sz_i,
            'level': lev,
            ('gas', 'density'): np.random.random(sz_i) * (lev+1),
            ('stream', 'lev_p1'): levp1,
           }
    grids.append(grid)


ds = yt.load_amr_grids(
        grids,
        sz_0,
        bbox=bbox,    
        length_unit=1,
    ) 

fld = ('stream', 'lev_p1')
slc = yt.SlicePlot(ds, 'x', fld)
slc.set_log(fld, False)
slc.annotate_grids()
slc.save()

rc = yt_idv.render_context(height=800, width=800, gui=True)
sg = rc.add_scene(ds, fld, no_ghost=True)
rc.scene.components[0].sample_factor = 50.0
rc.scene.components[0].cmap_log = False
rc.scene.components[0]._reset_cmap_bounds()

rc.run()

Results in the following yt slice plot

Image

and the following in yt_idv

Image

The outermost level 0 grid is missing.

@chrishavlin chrishavlin added the bug Something isn't working label Feb 11, 2025
@chrishavlin chrishavlin linked a pull request Feb 12, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant