Пример #1
0
    def __init__(self, cat, min_size=0, max_size=None, split_method='mean', brute=False,
                 min_top=3, max_top=10, coords=None, logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building NField from cat %s',cat.name)
            else:
                logger.info('Building NField')

        self._cat = weakref.ref(cat)
        self.ntot = cat.ntot
        self.min_size = float(min_size) if not brute else 0.
        self.max_size = float(max_size) if max_size is not None else np.inf
        self.split_method = split_method
        self._sm = _parse_split_method(split_method)
        self._d = 1  # NData
        self.brute = bool(brute)
        self.min_top = int(min_top)
        self.max_top = int(max_top)
        self.coords = coords if coords is not None else cat.coords
        self._coords = treecorr.util.coord_enum(self.coords)  # These are the C++-layer enums

        self.data = treecorr._lib.BuildNField(dp(cat.x), dp(cat.y), dp(cat.z),
                                              dp(cat.w), dp(cat.wpos), cat.ntot,
                                              self.min_size, self.max_size, self._sm,
                                              self.brute, self.min_top, self.max_top, self._coords)
        if logger:
            logger.debug('Finished building NField (%s)',self.coords)
Пример #2
0
    def __init__(self, cat, min_size=0, max_size=None, split_method='mean', brute=False,
                 min_top=3, max_top=10, coords=None, logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building NField from cat %s',cat.name)
            else:
                logger.info('Building NField')

        self._cat = weakref.ref(cat)
        self.min_size = float(min_size) if not brute else 0.
        self.max_size = float(max_size) if max_size is not None else np.inf
        self.split_method = split_method
        self._sm = _parse_split_method(split_method)
        self._d = 1  # NData
        self.brute = bool(brute)
        self.min_top = int(min_top)
        self.max_top = int(max_top)
        self.coords = coords if coords is not None else cat.coords
        self._coords = treecorr.util.coord_enum(self.coords)  # These are the C++-layer enums

        self.data = treecorr._lib.BuildNField(dp(cat.x), dp(cat.y), dp(cat.z),
                                              dp(cat.w), dp(cat.wpos), cat.ntot,
                                              self.min_size, self.max_size, self._sm,
                                              self.brute, self.min_top, self.max_top, self._coords)
        if logger:
            logger.debug('Finished building NField (%s)',self.coords)
Пример #3
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildNKCorr(
             self._min_sep,self._max_sep,self.nbins,self.bin_size,self.b,
             self.min_rpar, self.max_rpar,
             dp(self.xi),
             dp(self.meanr),dp(self.meanlogr),dp(self.weight),dp(self.npairs));
Пример #4
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr.lib.BuildNNNCorr(
             self.min_sep,self.max_sep,self.nbins,self.bin_size,self.b,
             self.min_u,self.max_u,self.nubins,self.ubin_size,self.bu,
             self.min_v,self.max_v,self.nvbins,self.vbin_size,self.bv,
             dp(self.meand1), dp(self.meanlogd1), dp(self.meand2), dp(self.meanlogd2),
             dp(self.meand3), dp(self.meanlogd3), dp(self.meanu), dp(self.meanv), 
             dp(self.weight), dp(self.ntri));
Пример #5
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr.lib.BuildNNNCorr(
         self.min_sep, self.max_sep, self.nbins, self.bin_size, self.b,
         self.min_u, self.max_u, self.nubins, self.ubin_size, self.bu,
         self.min_v, self.max_v, self.nvbins, self.vbin_size, self.bv,
         dp(self.meand1), dp(self.meanlogd1), dp(self.meand2),
         dp(self.meanlogd2), dp(self.meand3), dp(self.meanlogd3),
         dp(self.meanu), dp(self.meanv), dp(self.weight), dp(self.ntri))
Пример #6
0
    def kmeans_initialize_centers(self, npatch, init='tree'):
        """Use the field's tree structure to assign good initial centers for a K-Means run.

        The classic K-Means algorithm involves starting with random points as the initial
        centers of the patches.  This has a tendency to result in rather poor results in
        terms of having similar sized patches at the end.  Specifically, the rms inertia
        of the local minimum that the K-Means algorithm settles into tends to be fairly high
        for typical geometries.

        A better approach is to use the existing tree structure to star out with centers that
        are fairly evenly spread out through the field.  This algorithm traverses the tree
        until we get to a level that has enough cells for the requested number of patches.
        Then it uses the centroids of these cells as the initial patch centers.

        Parameters:
            npatch (int):       How many patches to generate initial centers for
            init (str):         Initialization method. Options are::

                                    - 'tree' (default) Use the normal tree structure of the field,
                                      traversing down to a level where there are npatch cells,
                                      and use the centroids of these cells as the initial centers.
                                      This is almost always the best choice.
                                    - 'random' Use npatch random points as the intial centers.
                                    - 'kmeans++' Use the k-means++ algorithm.
                                      cf. https://en.wikipedia.org/wiki/K-means%2B%2B

        Returns:
            centers (array):    An array of center coordinates.
                                Shape is (npatch, 2) for flat geometries or (npatch, 3) for 3d or
                                spherical geometries.  In the latter case, the centers represent
                                (x,y,z) coordinates on the unit sphere.
        """
        from treecorr.util import double_ptr as dp
        if npatch > self.ntot:
            raise ValueError(
                "Invalid npatch.  Cannot be greater than self.ntot.")
        if npatch < 1:
            raise ValueError("Invalid npatch.  Cannot be less than 1.")
        if self._coords == treecorr._lib.Flat:
            centers = np.empty((npatch, 2))
        else:
            centers = np.empty((npatch, 3))
        if init == 'tree':
            treecorr._lib.KMeansInitTree(self.data, dp(centers), int(npatch),
                                         self._d, self._coords)
        elif init == 'random':
            treecorr._lib.KMeansInitRand(self.data, dp(centers), int(npatch),
                                         self._d, self._coords)
        elif init == 'kmeans++':
            treecorr._lib.KMeansInitKMPP(self.data, dp(centers), int(npatch),
                                         self._d, self._coords)
        else:
            raise ValueError("Invalid init: %s. " % init +
                             "Must be one of 'tree', 'random', or 'kmeans++.'")

        return centers
Пример #7
0
    def kmeans_initialize_centers(self, npatch, init='tree'):
        """Use the field's tree structure to assign good initial centers for a K-Means run.

        The classic K-Means algorithm involves starting with random points as the initial
        centers of the patches.  This has a tendency to result in rather poor results in
        terms of having similar sized patches at the end.  Specifically, the rms inertia
        of the local minimum that the K-Means algorithm settles into tends to be fairly high
        for typical geometries.

        A better approach is to use the existing tree structure to star out with centers that
        are fairly evenly spread out through the field.  This algorithm traverses the tree
        until we get to a level that has enough cells for the requested number of patches.
        Then it uses the centroids of these cells as the initial patch centers.

        Parameters:
            npatch (int):       How many patches to generate initial centers for
            init (str):         Initialization method. Options are::

                                    - 'tree' (default) Use the normal tree structure of the field,
                                      traversing down to a level where there are npatch cells,
                                      and use the centroids of these cells as the initial centers.
                                      This is almost always the best choice.
                                    - 'random' Use npatch random points as the intial centers.
                                    - 'kmeans++' Use the k-means++ algorithm.
                                      cf. https://en.wikipedia.org/wiki/K-means%2B%2B

        Returns:
            centers (array):    An array of center coordinates.
                                Shape is (npatch, 2) for flat geometries or (npatch, 3) for 3d or
                                spherical geometries.  In the latter case, the centers represent
                                (x,y,z) coordinates on the unit sphere.
        """
        from treecorr.util import double_ptr as dp
        if npatch > self.ntot:
            raise ValueError("Invalid npatch.  Cannot be greater than self.ntot.")
        if npatch < 1:
            raise ValueError("Invalid npatch.  Cannot be less than 1.")
        if self._coords == treecorr._lib.Flat:
            centers = np.empty((npatch, 2))
        else:
            centers = np.empty((npatch, 3))
        if init == 'tree':
            treecorr._lib.KMeansInitTree(self.data, dp(centers), int(npatch), self._d, self._coords)
        elif init == 'random':
            treecorr._lib.KMeansInitRand(self.data, dp(centers), int(npatch), self._d, self._coords)
        elif init == 'kmeans++':
            treecorr._lib.KMeansInitKMPP(self.data, dp(centers), int(npatch), self._d, self._coords)
        else:
            raise ValueError("Invalid init: %s. "%init +
                             "Must be one of 'tree', 'random', or 'kmeans++.'")

        return centers
Пример #8
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildCorr2(
             self._d1, self._d2, self._bintype,
             self._min_sep,self._max_sep,self._nbins,self._bin_size,self.b,
             self.min_rpar, self.max_rpar, self.xperiod, self.yperiod, self.zperiod,
             dp(self.xi),dp(self.xi_im), dp(None), dp(None),
             dp(self.meanr),dp(self.meanlogr),dp(self.weight),dp(self.npairs));
Пример #9
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr.lib.BuildGGCorr(self.min_sep, self.max_sep,
                                          self.nbins, self.bin_size, self.b,
                                          dp(self.xip), dp(self.xip_im),
                                          dp(self.xim), dp(self.xim_im),
                                          dp(self.meanr), dp(self.meanlogr),
                                          dp(self.weight), dp(self.npairs))
Пример #10
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildCorr2(
         self._d1, self._d2, self._bintype, self._min_sep, self._max_sep,
         self._nbins, self._bin_size, self.b, self.min_rpar, self.max_rpar,
         self.xperiod, self.yperiod, self.zperiod, dp(self.xi), dp(None),
         dp(None), dp(None), dp(self.meanr), dp(self.meanlogr),
         dp(self.weight), dp(self.npairs))
Пример #11
0
    def __init__(self, cat, logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building NSimpleField from cat %s',cat.name)
            else:
                logger.info('Building NSimpleField')
        self._d = 1  # NData
        self.coords = cat.coords
        self._coords = treecorr.util.coord_enum(self.coords)  # These are the C++-layer enums

        self.data = treecorr._lib.BuildNSimpleField(dp(cat.x), dp(cat.y), dp(cat.z),
                                                    dp(cat.w), dp(cat.wpos), cat.ntot,
                                                    self._coords)
        if logger:
            logger.debug('Finished building NSimpleField (%s)',self.coords)
Пример #12
0
    def __init__(self, cat, logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building NSimpleField from cat %s',cat.name)
            else:
                logger.info('Building NSimpleField')
        self._d = 1  # NData
        self.coords = cat.coords
        self._coords = treecorr.util.coord_enum(self.coords)  # These are the C++-layer enums

        self.data = treecorr._lib.BuildNSimpleField(dp(cat.x), dp(cat.y), dp(cat.z),
                                                    dp(cat.w), dp(cat.wpos), cat.ntot,
                                                    self._coords)
        if logger:
            logger.debug('Finished building NSimpleField (%s)',self.coords)
Пример #13
0
 def corr(self):
     if not hasattr(self, '_corr'):
         from treecorr.util import double_ptr as dp
         self._corr = treecorr._lib.BuildCorr2(
                 self._d1, self._d2, self._bintype,
                 self._min_sep,self._max_sep,self._nbins,self._bin_size,self.b,
                 self.min_rpar, self.max_rpar, self.xperiod, self.yperiod, self.zperiod,
                 dp(self.raw_xi),dp(self.raw_xi_im), dp(None), dp(None),
                 dp(self.meanr),dp(self.meanlogr),dp(self.weight),dp(self.npairs))
     return self._corr
Пример #14
0
    def kmeans_refine_centers(self,
                              centers,
                              max_iter=200,
                              tol=1.e-5,
                              alt=False):
        """Fast implementation of the K-Means algorithm

        The standard K-Means algorithm is as follows
        (cf. https://en.wikipedia.org/wiki/K-means_clustering):

        1. Choose centers somehow.  Traditionally, this is done by just selecting npatch random
           points from the full set, but we do this more smartly in `kmeans_initialize_centers`.
        2. For each point, measure the distance to each current patch center, and assign it to the
           patch that has the closest center.
        3. Update all the centers to be the centroid of the points assigned to each patch.
        4. Repeat 2, 3 until the rms shift in the centers is less than some tolerance or the
           maximum number of iterations is reached.
        5. Assign the corresponding patch label to each point (`kmeans_assign_patches`).

        In TreeCorr, we use the tree structure to massively increase the speed of steps 2 and 3.
        For a given cell, we know both its center and its size, so we can quickly check whether
        all the points in the cell are closer to one center than another.  This lets us quickly
        cull centers from consideration as we traverse the tree.  Once we get to a cell where only
        one center can be closest for any of the points in it, we stop traversing and assign the
        whole cell to that patch.

        Further, it is also fast to update the new centroid, since the sum of all the positions
        for a cell is just N times the cell's centroid.

        As a result, this algorithm typically takes a fraction of a second for ~a million points.
        Indeed most of the time spent in the full kmeans calculation is in building the tree
        in the first place, rather than actually running the kmeans code.  With the alternate
        algorithm (``alt=True``), the time is only slightly slower from having to calculate
        the sizes at each step.

        Parameters:
            centers (array):    An array of center coordinates. (modified by this function)
                                Shape is (npatch, 2) for flat geometries or (npatch, 3) for 3d or
                                spherical geometries.  In the latter case, the centers represent
                                (x,y,z) coordinates on the unit sphere.
            max_iter (int):     How many iterations at most to run. (default: 200)
            tol (float):        Tolerance in the rms centroid shift to consider as converged
                                as a fraction of the total field size. (default: 1.e-5)
            alt (bool):         Use the alternate assignment algorithm to minimize the standard
                                deviation of the inertia rather than the total inertia (aka WCSS).
                                (default: False)
        """
        from treecorr.util import double_ptr as dp
        npatch = centers.shape[0]
        treecorr._lib.KMeansRun(self.data, dp(centers), npatch, int(max_iter),
                                float(tol), bool(alt), self._d, self._coords)
Пример #15
0
    def kmeans_refine_centers(self, centers, max_iter=200, tol=1.e-5, alt=False):
        """Fast implementation of the K-Means algorithm

        The standard K-Means algorithm is as follows:
        (cf. https://en.wikipedia.org/wiki/K-means_clustering)
        1. Choose centers somehow.  Traditionally, this is done by just selecting npatch random
           points from the full set, but we do this more smartly in `kmeans_initialize_centers`.
        2. For each point, measure the distance to each current patch center, and assign it to the
           patch that has the closest center.
        3. Update all the centers to be the centroid of the points assigned to each patch.
        4. Repeat 2, 3 until the rms shift in the centers is less than some tolerance or the
           maximum number of iterations is reached.
        5. Assign the corresponding patch label to each point (`kmeans_assign_patches`).

        In TreeCorr, we use the tree structure to massively increase the speed of steps 2 and 3.
        For a given cell, we know both its center and its size, so we can quickly check whether
        all the points in the cell are closer to one center than another.  This lets us quickly
        cull centers from consideration as we traverse the tree.  Once we get to a cell where only
        one center can be closest for any of the points in it, we stop traversing and assign the
        whole cell to that patch.

        Further, it is also fast to update the new centroid, since the sum of all the positions
        for a cell is just N times the cell's centroid.

        As a result, this algorithm typically takes a fraction of a second for ~a million points.
        Indeed most of the time spent in the full kmeans calculation is in building the tree
        in the first place, rather than actually running the kmeans code.  With the alternate
        algorithm (**alt=True**), the time is only slightly slower from having to calculate
        the sizes at each step.

        Parameters:
            centers (array):    An array of center coordinates. (modified by this function)
                                Shape is (npatch, 2) for flat geometries or (npatch, 3) for 3d or
                                spherical geometries.  In the latter case, the centers represent
                                (x,y,z) coordinates on the unit sphere.
            max_iter (int):     How many iterations at most to run. (default: 200)
            tol (float):        Tolerance in the rms centroid shift to consider as converged
                                as a fraction of the total field size. (default: 1.e-5)
            alt (bool):         Use the alternate assignment algorithm to minimize the rms size
                                rather than the total inertia (aka WCSS). (default: False)
        """
        from treecorr.util import double_ptr as dp
        npatch = centers.shape[0]
        treecorr._lib.KMeansRun(self.data, dp(centers), npatch, int(max_iter), float(tol),
                                bool(alt), self._d, self._coords)
Пример #16
0
    def kmeans_assign_patches(self, centers):
        """Assign patch numbers to each point according to the given centers.

        This is final step in the full K-Means algorithm.  It assignes patch numbers to each
        point in the field according to which center is closest.

        Parameters:
            centers (array):    An array of center coordinates.
                                Shape is (npatch, 2) for flat geometries or (npatch, 3) for 3d or
                                spherical geometries.  In the latter case, the centers represent
                                (x,y,z) coordinates on the unit sphere.

        Returns:
            patches (array):    An array of patch labels, all integers from 0..npatch-1.
                                Size is self.ntot.
        """
        from treecorr.util import double_ptr as dp
        from treecorr.util import long_ptr as lp
        patches = np.empty(self.ntot, dtype=int)
        npatch = centers.shape[0]
        treecorr._lib.KMeansAssign(self.data, dp(centers), npatch,
                                   lp(patches), self.ntot, self._d, self._coords)
        return patches
Пример #17
0
    def kmeans_assign_patches(self, centers):
        """Assign patch numbers to each point according to the given centers.

        This is final step in the full K-Means algorithm.  It assignes patch numbers to each
        point in the field according to which center is closest.

        Parameters:
            centers (array):    An array of center coordinates.
                                Shape is (npatch, 2) for flat geometries or (npatch, 3) for 3d or
                                spherical geometries.  In the latter case, the centers represent
                                (x,y,z) coordinates on the unit sphere.

        Returns:
            patches (array):    An array of patch labels, all integers from 0..npatch-1.
                                Size is self.ntot.
        """
        from treecorr.util import double_ptr as dp
        from treecorr.util import long_ptr as lp
        patches = np.empty(self.ntot, dtype=int)
        npatch = centers.shape[0]
        treecorr._lib.KMeansAssign(self.data, dp(centers), npatch, lp(patches),
                                   self.ntot, self._d, self._coords)
        return patches
Пример #18
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildGGGCorr(
         self._min_sep, self._max_sep, self.nbins, self.bin_size, self.b,
         self.min_u, self.max_u, self.nubins, self.ubin_size, self.bu,
         self.min_v, self.max_v, self.nvbins,
         self.vbin_size, self.bv, self.min_rpar, self.max_rpar,
         dp(self.gam0r), dp(self.gam0i), dp(self.gam1r), dp(self.gam1i),
         dp(self.gam2r), dp(self.gam2i), dp(self.gam3r), dp(self.gam3i),
         dp(self.meand1), dp(self.meanlogd1), dp(self.meand2),
         dp(self.meanlogd2), dp(self.meand3), dp(self.meanlogd3),
         dp(self.meanu), dp(self.meanv), dp(self.weight), dp(self.ntri))
    def __init__(self, cat, min_size, max_size, split_method='mean', max_top=10, logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building NField from cat %s',cat.name)
            else:
                logger.info('Building NField')

        self.min_size = min_size
        self.max_size = max_size
        self.split_method = split_method
        sm = _parse_split_method(split_method)

        if cat.coords == 'flat':
            self.flat = True
            self.data = treecorr._lib.BuildNFieldFlat(dp(cat.x),dp(cat.y),
                                                      dp(cat.w),dp(cat.wpos),cat.ntot,
                                                      min_size,max_size,sm,max_top)
            if logger:
                logger.debug('Finished building NField 2D')
        else:
            self.flat = False
            if cat.coords == 'spherical':
                self.data = treecorr._lib.BuildNFieldSphere(dp(cat.x),dp(cat.y),dp(cat.z),
                                                            dp(cat.w),dp(cat.wpos),cat.ntot,
                                                            min_size,max_size,sm,max_top)
                self.spher = True
                if logger:
                    logger.debug('Finished building NField Sphere')
            else:
                self.data = treecorr._lib.BuildNField3D(dp(cat.x),dp(cat.y),dp(cat.z),
                                                        dp(cat.w),dp(cat.wpos),cat.ntot,
                                                        min_size,max_size,sm,max_top)
                self.spher = False
                if logger:
                    logger.debug('Finished building NField 3D')
    def __init__(self, cat, logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building GSimpleField from cat %s',cat.name)
            else:
                logger.info('Building GSimpleField')

        if cat.coords == 'flat':
            self.flat = True
            self.data = treecorr._lib.BuildGSimpleFieldFlat(dp(cat.x),dp(cat.y),
                                                            dp(cat.g1),dp(cat.g2),
                                                            dp(cat.w),dp(cat.wpos),cat.ntot)
            if logger:
                logger.debug('Finished building GSimpleField Flat')
        else:
            self.flat = False
            if cat.coords == 'spherical':
                self.data = treecorr._lib.BuildGSimpleFieldSphere(dp(cat.x),dp(cat.y),dp(cat.z),
                                                                  dp(cat.g1),dp(cat.g2),
                                                                  dp(cat.w),dp(cat.wpos),cat.ntot)
                self.spher = True
                if logger:
                    logger.debug('Finished building GSimpleField Sphere')
            else:
                self.data = treecorr._lib.BuildGSimpleField3D(dp(cat.x),dp(cat.y),dp(cat.z),
                                                              dp(cat.g1),dp(cat.g2),
                                                              dp(cat.w),dp(cat.wpos),cat.ntot)
                self.spher = False
                if logger:
                    logger.debug('Finished building GSimpleField 3D')
Пример #21
0
 def corr(self):
     if not hasattr(self, '_corr'):
         from treecorr.util import double_ptr as dp
         self._corr = treecorr._lib.BuildCorr3(
             self._d1, self._d2, self._d3, self._bintype, self._min_sep,
             self._max_sep, self.nbins, self._bin_size, self.b, self.min_u,
             self.max_u, self.nubins, self.ubin_size, self.bu, self.min_v,
             self.max_v, self.nvbins, self.vbin_size, self.bv,
             self.min_rpar, self.max_rpar, self.xperiod, self.yperiod,
             self.zperiod, dp(self.gam0r), dp(self.gam0i), dp(self.gam1r),
             dp(self.gam1i), dp(self.gam2r), dp(self.gam2i), dp(self.gam3r),
             dp(self.gam3i), dp(self.meand1), dp(self.meanlogd1),
             dp(self.meand2), dp(self.meanlogd2), dp(self.meand3),
             dp(self.meanlogd3), dp(self.meanu), dp(self.meanv),
             dp(self.weight), dp(self.ntri))
     return self._corr
Пример #22
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildCorr3(
             self._d1, self._d2, self._d3, self._bintype,
             self._min_sep,self._max_sep,self.nbins,self._bin_size,self.b,
             self.min_u,self.max_u,self.nubins,self.ubin_size,self.bu,
             self.min_v,self.max_v,self.nvbins,self.vbin_size,self.bv,
             self.min_rpar, self.max_rpar, self.xperiod, self.yperiod, self.zperiod,
             dp(None), dp(None), dp(None), dp(None),
             dp(None), dp(None), dp(None), dp(None),
             dp(self.meand1), dp(self.meanlogd1), dp(self.meand2), dp(self.meanlogd2),
             dp(self.meand3), dp(self.meanlogd3), dp(self.meanu), dp(self.meanv),
             dp(self.weight), dp(self.ntri));
Пример #23
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildKKKCorr(
         self._bintype, self._min_sep, self._max_sep, self.nbins,
         self.bin_size, self.b, self.min_u, self.max_u, self.nubins,
         self.ubin_size, self.bu, self.min_v, self.max_v,
         self.nvbins, self.vbin_size, self.bv, self.min_rpar, self.max_rpar,
         dp(self.zeta),
         dp(self.meand1), dp(self.meanlogd1), dp(self.meand2),
         dp(self.meanlogd2), dp(self.meand3), dp(self.meanlogd3),
         dp(self.meanu), dp(self.meanv), dp(self.weight), dp(self.ntri))
Пример #24
0
    def __init__(self, cat, logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building GSimpleField from cat %s', cat.name)
            else:
                logger.info('Building GSimpleField')

        if cat.coords == 'flat':
            self.flat = True
            self.data = treecorr._lib.BuildGSimpleFieldFlat(
                dp(cat.x), dp(cat.y), dp(cat.g1), dp(cat.g2), dp(cat.w),
                dp(cat.wpos), cat.ntot)
            if logger:
                logger.debug('Finished building GSimpleField Flat')
        else:
            self.flat = False
            if cat.coords == 'spherical':
                self.data = treecorr._lib.BuildGSimpleFieldSphere(
                    dp(cat.x), dp(cat.y), dp(cat.z), dp(cat.g1), dp(cat.g2),
                    dp(cat.w), dp(cat.wpos), cat.ntot)
                self.spher = True
                if logger:
                    logger.debug('Finished building GSimpleField Sphere')
            else:
                self.data = treecorr._lib.BuildGSimpleField3D(
                    dp(cat.x), dp(cat.y), dp(cat.z), dp(cat.g1), dp(cat.g2),
                    dp(cat.w), dp(cat.wpos), cat.ntot)
                self.spher = False
                if logger:
                    logger.debug('Finished building GSimpleField 3D')
Пример #25
0
    def __init__(self,
                 cat,
                 min_size,
                 max_size,
                 split_method='mean',
                 max_top=10,
                 logger=None):
        from treecorr.util import double_ptr as dp
        if logger:
            if cat.name != '':
                logger.info('Building NField from cat %s', cat.name)
            else:
                logger.info('Building NField')

        self.min_size = min_size
        self.max_size = max_size
        self.split_method = split_method
        sm = _parse_split_method(split_method)

        if cat.coords == 'flat':
            self.flat = True
            self.data = treecorr._lib.BuildNFieldFlat(dp(cat.x), dp(cat.y),
                                                      dp(cat.w), dp(cat.wpos),
                                                      cat.ntot, min_size,
                                                      max_size, sm, max_top)
            if logger:
                logger.debug('Finished building NField 2D')
        else:
            self.flat = False
            if cat.coords == 'spherical':
                self.data = treecorr._lib.BuildNFieldSphere(
                    dp(cat.x), dp(cat.y), dp(cat.z), dp(cat.w), dp(cat.wpos),
                    cat.ntot, min_size, max_size, sm, max_top)
                self.spher = True
                if logger:
                    logger.debug('Finished building NField Sphere')
            else:
                self.data = treecorr._lib.BuildNField3D(
                    dp(cat.x), dp(cat.y), dp(cat.z), dp(cat.w), dp(cat.wpos),
                    cat.ntot, min_size, max_size, sm, max_top)
                self.spher = False
                if logger:
                    logger.debug('Finished building NField 3D')
Пример #26
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr.lib.BuildGGCorr(
             self.min_sep,self.max_sep,self.nbins,self.bin_size,self.b,
             dp(self.xip),dp(self.xip_im),dp(self.xim),dp(self.xim_im),
             dp(self.meanr),dp(self.meanlogr),dp(self.weight),dp(self.npairs));
Пример #27
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildGGGCorr(
             self._min_sep,self._max_sep,self.nbins,self.bin_size,self.b,
             self.min_u,self.max_u,self.nubins,self.ubin_size,self.bu,
             self.min_v,self.max_v,self.nvbins,self.vbin_size,self.bv,
             self.min_rpar, self.max_rpar,
             dp(self.gam0r), dp(self.gam0i), dp(self.gam1r), dp(self.gam1i),
             dp(self.gam2r), dp(self.gam2i), dp(self.gam3r), dp(self.gam3i),
             dp(self.meand1), dp(self.meanlogd1), dp(self.meand2), dp(self.meanlogd2),
             dp(self.meand3), dp(self.meanlogd3), dp(self.meanu), dp(self.meanv), 
             dp(self.weight), dp(self.ntri));
Пример #28
0
 def _build_corr(self):
     from treecorr.util import double_ptr as dp
     self.corr = treecorr._lib.BuildCorr3(
         self._d1, self._d2, self._d3, self._bintype, self._min_sep,
         self._max_sep, self.nbins, self._bin_size, self.b, self.min_u,
         self.max_u, self.nubins, self.ubin_size, self.bu, self.min_v,
         self.max_v, self.nvbins, self.vbin_size, self.bv, self.min_rpar,
         self.max_rpar, self.xperiod, self.yperiod, self.zperiod, dp(None),
         dp(None), dp(None), dp(None), dp(None), dp(None), dp(None),
         dp(None), dp(self.meand1), dp(self.meanlogd1), dp(self.meand2),
         dp(self.meanlogd2), dp(self.meand3), dp(self.meanlogd3),
         dp(self.meanu), dp(self.meanv), dp(self.weight), dp(self.ntri))