- class RIFT.misc.amrlib.Cell(boundaries, center=None)
Bases:
object- area()
- divide()
Subdivide once along each dimension, recursively.
- divide_if(testfunc, depth=1)
Subdivide once along each dimension, recursively.
- intersects(other)
- static make_cell_from_boundaries(inpt_pt, pts, symmetric=True)
Construct a ‘virtual cell’ from the extent of the points, centered on inpt_pt. If symmetric is True, the boundaries will be symmetric about the input point, if False, the cell will follow the extent of the points on either side.
- refine()
Refine each cell such that 2*dim new cells are created. In contrast to divide, refine will place the center of each new cell at the midpoint along the boundary of the mother cell. Its dimensions will be the half width from the center to the edge on each side, except for the dimension along the splitting axis, where the dimension will be twice the half width of the original cell in that dimension (and on that side).
- refine_full(return_cntr=True)
Refine each cell such that new cells are created along all permutations of a displacement vector with unit vectors in each dimension and the 0 vector.
- translate(offset)
Translate this cell’s position and extent by offset.
- exception RIFT.misc.amrlib.GriddingException(*args, **kwargs)
Bases:
Exception
- RIFT.misc.amrlib.apply_inv_transform(pts, intr_prms, mass_transform=None, spin_transform=None)
- RIFT.misc.amrlib.apply_transform(pts, intr_prms, mass_transform=None, spin_transform=None)
- RIFT.misc.amrlib.check_grid(grid, intr_prms, distance_coordinates, mass_lower_bound=1)
Check the validity of points in various coordinate spaces to ensure they are physical.
- RIFT.misc.amrlib.check_mchirpeta(mchirp, eta)
- RIFT.misc.amrlib.check_q(q)
- RIFT.misc.amrlib.check_spins(spin)
- RIFT.misc.amrlib.check_tau0tau3(tau0, tau3, flow=40)
- RIFT.misc.amrlib.create_new_grid(cell, pts, max_level=6)
Subdivide until all cells are self contained - e.g. every cell contains no more than one pt from pts. If the number of divisions exceeds max_level, stop dividing.
- RIFT.misc.amrlib.create_regular_grid_from_cell(cell, side_pts=5, return_cells=False)
Given a region (amrlib.Cell), grid it with side_pts to a dimension. If return_cells is given, the divided cells will be returned rather than the grid points. >>> import numpy >>> region = Cell(numpy.array([(-1., 1.), (-2., 2.)])) >>> grid, spacing = create_regular_grid_from_cell(region, side_pts=2) >>> print(grid) [[-1. -2.]
[-1. 2.] [ 1. -2.] [ 1. 2.]]
>>> print(spacing) [ 2. 4.]
- RIFT.misc.amrlib.deserialize_grid_cells(fname)
Unpacks a numpy file of level grid points and returns a cell collection. FIXME: This can’t yet distinguish the level of refinement. Need to teach it to pay attention to the resolution.
- RIFT.misc.amrlib.grid_to_cells(grid, grid_spacing)
- RIFT.misc.amrlib.grid_to_indices(pts, region, grid_spacing, check=True)
Convert points in a grid to their 1-D indices according to the grid extent in region, and grid spacing. If ‘check’ is True, ensure that all points exist within the expanded region before indexing — this tends to avoid more cryptic errors about indexing later on.
- RIFT.misc.amrlib.init_grid_hdf(init_region, h5file, overlap_thresh, crd_sys, intr_prms=None, base_grp='rapidpe_grids')
Set up a new HDF5 file (h5file), truncating any existing file with this name. A new ‘folder’ called ‘base_grp’ is set up and the initial region with attribute ‘overlap_thresh’ is set up under it.
- RIFT.misc.amrlib.load_grid_level(h5file, level, return_labels=False, base_grp='rapidpe_grids')
Load a set grid points (in the form of cells) from h5file. If level is None, return the base_grp, if level is -1, return the highest resolution available, otherwise an ArgumentError is raised if ‘level’ is not represented in the attributes of one of the levels stored under base_grp/’grids’
- RIFT.misc.amrlib.load_init_region(h5file, get_labels=False, base_grp='rapidpe_grids')
Load the initial region for a set grid points (in the form of cells) from h5file.
- RIFT.misc.amrlib.midpoint(pt1, pt2)
- RIFT.misc.amrlib.ndim_offsets(ndim)
- RIFT.misc.amrlib.pack_grid_cells(cells, resolution)
Pack the cell centers (grid points) into a convienient numpy array. The resolution of the grid is prepended for later use.
- RIFT.misc.amrlib.prune_duplicate_pts(pts, region, grid_spacing)
Remove identical points from list.
- RIFT.misc.amrlib.refine_regular_grid(grid, grid_spacing, return_cntr=False)
Given a regular grid in N dimensions with spacing given by grid_spacing, refine the grid by bisection along all dimensions. Returns the new grid and new spacing. The grid will not contain the center point by default (since it is assumed the point already exists in the unrefined grid, but this behavior can be changed by setting return_cntr to True. >>> region = Cell(numpy.array([(-1., 1.), (-2., 2.)])) >>> grid, spacing = create_regular_grid_from_cell(region, side_pts=2) >>> grid, spacing = refine_regular_grid(grid, spacing) >>> print(grid) [array([-2., -4.]), array([-2., -2.]), array([-1., -4.]), array([-1., -2.]), array([-2., 0.]), array([-2., 2.]), array([-1., 0.]), array([-1., 2.]), array([ 0., -4.]), array([ 0., -2.]), array([ 1., -4.]), array([ 1., -2.]), array([ 0., 0.]), array([ 0., 2.]), array([ 1., 0.]), array([ 1., 2.])] >>> print(spacing) [ 1. 2.]
- RIFT.misc.amrlib.save_grid_cells_hdf(base_grp, cells, crd_sys, intr_prms=None, check=True)
Under the base_grp, a new level of grid points is saved. It will create a subgroup called “grids” if it does not already exist. Under this subgroup, levels are created sequentially, the function looks for the last level (e.g. the subsubgroup with the largest “level” attribute, and appends a new level with +1 to that number. If check is enabled (that is the default), a safety check against the new level versus the last level is made to ensure the resolution is a factor of two smaller.
- RIFT.misc.amrlib.serialize_grid_cells(level_dict, fname)
Given a dictionary of refinement levels, pack it up and save it to a numpy file. FIXME: This can’t yet distinguish the level of refinement. Need to teach it to pay attention to the resolution.
- RIFT.misc.amrlib.transform_chi_eff_chi_a_s1zs2z(mass1, mass2, chi_eff, chi_a)
Returns spin1z.
- RIFT.misc.amrlib.transform_m1m2_mcdelta(m1, m2)
- RIFT.misc.amrlib.transform_m1m2_mceta(m1, m2)
- RIFT.misc.amrlib.transform_m1m2_mcq(m1, m2)
- RIFT.misc.amrlib.transform_m1m2_tau0tau3(m1, m2, flow=40.0)
- RIFT.misc.amrlib.transform_mcdelta_m1m2(mc, delta)
- RIFT.misc.amrlib.transform_mceta_m1m2(mc, eta)
- RIFT.misc.amrlib.transform_mcq_m1m2(mc, q)
- RIFT.misc.amrlib.transform_s1zs2z_chi(m1, m2, s1z, s2z)
- RIFT.misc.amrlib.transform_s1zs2z_chi_eff_chi_a(mass1, mass2, spin1z, spin2z)
Returns the aligned mass-weighted spin difference from mass1, mass2, spin1z, and spin2z.
- RIFT.misc.amrlib.transform_tau0tau3_m1m2(tau0, tau3, flow=40.0)
- RIFT.misc.amrlib.unpack_grid_cells(npy_cells)
Unpack the cell centers (grid points), the cell collection is returned.