:py:mod:`flip.gridding` ======================= .. py:module:: flip.gridding Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: flip.gridding._compute_grid_window flip.gridding.compute_grid_window flip.gridding.construct_grid_regular_sphere flip.gridding.construct_grid_regular_rectangular flip.gridding.ngp_weight flip.gridding.ngp_errw_weight flip.gridding.cic_weight flip.gridding.tsc_weight flip.gridding.pcs_weight flip.gridding.attribute_weight_density flip.gridding.define_randoms flip.gridding.grid_data_density flip.gridding.cut_grid flip.gridding.grid_data_density_pypower Attributes ~~~~~~~~~~ .. autoapisummary:: flip.gridding.log flip.gridding._GRID_KIND .. py:data:: log .. py:data:: _GRID_KIND :value: ['ngp', 'ngp_errw', 'cic', 'tsc', 'pcs'] .. py:function:: _compute_grid_window(grid_size, k, order, n) The _compute_grid_window function computes the window function for a given grid size. :param grid_size: Determine the size of the grid :param k: Compute the window function :param order: Determine the order of the sinc function :param n: Determine the number of points in the grid :returns: The window function for a given grid size, k, order and n .. py:function:: compute_grid_window(grid_size, kh, kind='ngp', n=1000) The compute_grid_window function computes the window function for a given grid size and kind. :param grid_size: Define the size of the grid :param kh: Compute the window function :param kind: Specify the type of grid :param n: Define the number of points used to compute the window function :returns: A window function .. py:function:: construct_grid_regular_sphere(grid_size, rcom_max) The construct_grid_regular_sphere function constructs a regular spherical grid. :param grid_size: Determine the number of grid voxels per axis :param rcom_max: Cut the grid with rcom_max :rtype: A dictionary with the following keys .. py:function:: construct_grid_regular_rectangular(grid_size, rcom_max) The construct_grid_regular_rectangular function constructs a regular rectangular grid. :param grid_size: Determine the number of grid voxels per axis :param rcom_max: Determine the size of the grid :returns: A dictionary with the grid coordinates .. py:function:: ngp_weight(ds) Nearest Grid Point. .. py:function:: ngp_errw_weight(ds) Nearest Grid Point with Weighted error. .. py:function:: cic_weight(ds) Clood In Cell. .. py:function:: tsc_weight(ds) Triangular Shaped Cloud. .. py:function:: pcs_weight(ds) Triangular Shaped Cloud. .. py:function:: attribute_weight_density(grid_size, xobj, yobj, zobj, xgrid, ygrid, zgrid, weight_fun) The attribute_weight_density function takes in the grid size, xobj, yobj, zobj (the coordinates of the objects), xgrid, ygrid and zgrid (the coordinates of the grid) and a weight function. It then calculates how many objects are in each cell by using a for loop to iterate through all of them. The dX is calculated by taking the difference between each object's x coordinate and each cell's x coordinate divided by grid_size. This is done for both dY and dZ as well. The w variable is calculated using this formula: w = weight_fun(dX) :param grid_size: Normalize the distances between objects and grid points :param xobj: Store the x coordinates of all objects in a galaxy :param yobj: Create a grid of y values :param zobj: Calculate the z-component of the distance between a grid point and an object :param xgrid: Define the x-coordinate of each grid cell :param ygrid: Calculate the distance between the object and grid :param zgrid: Determine the z-coordinate of the grid cell :param weight_fun: Determine the weight of each object :returns: A tuple of three arrays .. py:function:: define_randoms(random_method, xobj, yobj, zobj, raobj, decobj, rcomobj, Nrandom=None, coord_randoms=None, max_coordinates=None) .. py:function:: grid_data_density(grid, grid_size, ra, dec, rcom, kind='ngp', n_cut=None, weight_min=None, verbose=False, compute_density=True, Nrandom=10, random_method='cartesian', coord_randoms=None) The grid_data_density function takes in the data and grids it using a given grid size. It also computes the density of each voxel, as well as its error. :param grid: Store the grid properties :param grid_size: Define the size of each voxel in mpc/h :param ra: Define the right ascension of the object :param dec: Compute the cartesian coordinates of the objects :param rcom: Compute the comoving distance of each object :param kind: Select the method used to compute voxcell values :param n_cut: Cut the grid in cells with a minimum number of objects :param weight_min: Cut the grid :param verbose: Print the number of cells in the grid :param compute_density: Compute the density field :param Nrandom: Create random points in the grid_data_density function :param random_method: Choose the method to create random points :param : Define the grid size :rtype: A dictionary with the following keys .. py:function:: cut_grid(grid, remove_nan_density=True, n_cut=None, weight_min=None, rcom_max=None, xmax=None, ymax=None, zmax=None, remove_origin=False) The cut_grid function is used to remove grid cells from the catalog. :param grid: Pass the grid data to the function :param remove_nan_density: Remove any cells that have a density of nan :param n_cut: Remove grid cells with less than n_cut stars :param weight_min: Remove cells with too few stars :param rcom_max: Cut the grid by a maximum comoving distance :param xmax: Remove the cells that are too far away from the center of mass :param ymax: Cut the grid in y direction :param zmax: Cut the grid in z direction :param remove_origin: Remove the origin of the grid :returns: A dictionary with the same keys as grid, but where .. py:function:: grid_data_density_pypower(raobj, decobj, rcomobj, rcom_max, grid_size, grid_type, kind, Nrandom=10, random_method='cartesian', interlacing=2, compensate=False, coord_randoms=None, min_count_random=0, overhead=20) The grid_data_density_pypower function takes in the ra, dec, and rcom values of a galaxy catalog and returns a grid of density contrast values. The function uses pypower to create the grid. The function also has options for creating random points using different methods: choice, healpix, or cartesian. :param raobj: Pass the ra values of the data :param decobj: Calculate the z coordinate of the object in cartesian coordinates :param rcomobj: Calculate the comoving distance of each galaxy :param rcom_max: Cut the grid in a sphere of radius rcom_max :param grid_size: Determine the size of each cell in the grid :param grid_type: Determine whether to use a rectangular or spherical grid :param kind: Set the resampler in the catalogmesh function :param Nrandom: Determine the number of random points to be generated :param random_method: Choose the method used to generate random points :param interlacing: Reduce the variance of the density field :param compensate: Correct for the fact that we are using a finite number of random points :param : Remove the nan values from the grid :returns: A dictionary with the grid coordinates and density contrast values