#
# Build (or retrieve) the initial region
#
if opts.refine or opts.prerefine:
    init_region, region_labels = amrlib.load_init_region(opts.refine or opts.prerefine, get_labels=True)
else:
    ####### BEGIN INITIAL GRID CODE #########
    init_region, idx = determine_region(pt, pts, ovrlp, opts.overlap_threshold, expand_prms)
    region_labels = intr_prms
    # FIXME: To be reimplemented in a different way
    #if opts.expand_param is not None:
        #expand_param(init_region, opts.expand_param)

    # TODO: Alternatively, check density of points in the region to determine
    # the points to a side
    grid, spacing = amrlib.create_regular_grid_from_cell(init_region, side_pts=5, return_cells=True)

    # "Deactivate" cells not close to template points
    # FIXME: This gets more and more dangerous in higher dimensions
    # FIXME: Move to function
    tree = BallTree(grid)
    if opts.deactivate:
        get_idx = set()
        for pt in pts[idx:]:
            get_idx.add(tree.query(pt, k=1, return_distance=False)[0][0])
        selected = grid[numpy.array(list(get_idx))]
    else:
        selected = grid

# Make sure all our dimensions line up
# FIXME: We just need to be consistent from the beginning
Example #2
0
                                            opts.overlap_threshold,
                                            expand_prms)
        region_labels = intr_prms
        # FIXME: To be reimplemented in a different way
        #if opts.expand_param is not None:
        #expand_param(init_region, opts.expand_param)
    else:
        # Override initial region -- use with care
        _, init_region = common_cl.parse_param(opts.initial_region)
        region_labels = init_region.keys()
        init_region = amrlib.Cell(
            numpy.vstack(init_region[k] for k in region_labels))

    # TODO: Alternatively, check density of points in the region to determine
    # the points to a side
    grid, spacing = amrlib.create_regular_grid_from_cell(
        init_region, side_pts=opts.points_per_side / 2, return_cells=True)

    # "Deactivate" cells not close to template points
    # FIXME: This gets more and more dangerous in higher dimensions
    # FIXME: Move to function
    tree = BallTree(grid)
    if opts.deactivate:
        get_idx = set()
        for pt in pts[idx:]:
            get_idx.add(
                tree.query(numpy.atleast_2d(pt), k=1,
                           return_distance=False)[0][0])
        selected = grid[numpy.array(list(get_idx))]
    else:
        selected = grid
    init_region, region_labels = amrlib.load_init_region(opts.refine
                                                         or opts.prerefine,
                                                         get_labels=True)
else:
    ####### BEGIN INITIAL GRID CODE #########
    init_region, idx = determine_region(pt, pts, ovrlp, opts.overlap_threshold,
                                        expand_prms)
    region_labels = intr_prms
    # FIXME: To be reimplemented in a different way
    #if opts.expand_param is not None:
    #expand_param(init_region, opts.expand_param)

    # TODO: Alternatively, check density of points in the region to determine
    # the points to a side
    grid, spacing = amrlib.create_regular_grid_from_cell(init_region,
                                                         side_pts=5,
                                                         return_cells=True)

    # "Deactivate" cells not close to template points
    # FIXME: This gets more and more dangerous in higher dimensions
    # FIXME: Move to function
    tree = BallTree(grid)
    if opts.deactivate:
        get_idx = set()
        for pt in pts[idx:]:
            get_idx.add(tree.query(pt, k=1, return_distance=False)[0][0])
        selected = grid[numpy.array(list(get_idx))]
    else:
        selected = grid

# Make sure all our dimensions line up
    ####### BEGIN INITIAL GRID CODE #########
    if opts.initial_region is None:
        init_region, idx = determine_region(pt, pts, ovrlp, opts.overlap_threshold, expand_prms)
        region_labels = intr_prms
        # FIXME: To be reimplemented in a different way
        #if opts.expand_param is not None:
            #expand_param(init_region, opts.expand_param)
    else:
        # Override initial region -- use with care
        _, init_region = common_cl.parse_param(opts.initial_region)
        region_labels = init_region.keys()
        init_region = amrlib.Cell(numpy.vstack(init_region[k] for k in region_labels))

    # TODO: Alternatively, check density of points in the region to determine
    # the points to a side
    grid, spacing = amrlib.create_regular_grid_from_cell(init_region, side_pts=opts.points_per_side / 2, return_cells=True)

    # "Deactivate" cells not close to template points
    # FIXME: This gets more and more dangerous in higher dimensions
    # FIXME: Move to function
    tree = BallTree(grid)
    if opts.deactivate:
        get_idx = set()
        for pt in pts[idx:]:
            get_idx.add(tree.query(numpy.atleast_2d(pt), k=1, return_distance=False)[0][0])
        selected = grid[numpy.array(list(get_idx))]
    else:
        selected = grid

# Make sure all our dimensions line up
# FIXME: We just need to be consistent from the beginning