How to use the treecorr.util.double_ptr function in TreeCorr

To help you get started, we’ve selected a few TreeCorr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rmjarvis / TreeCorr / treecorr / kgcorrelation.py View on Github external
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.xi),dp(self.xi_im), dp(None), dp(None),
                    dp(self.meanr),dp(self.meanlogr),dp(self.weight),dp(self.npairs));
        return self._corr
github rmjarvis / TreeCorr / treecorr / field.py View on Github external
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)
github rmjarvis / TreeCorr / treecorr / nncorrelation.py View on Github external
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(None), dp(None), dp(None), dp(None),
                    dp(self.meanr),dp(self.meanlogr),dp(self.weight),dp(self.npairs));
        return self._corr
github rmjarvis / TreeCorr / treecorr / nnncorrelation.py View on Github external
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(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));
        return self._corr
github rmjarvis / TreeCorr / treecorr / field.py View on Github external
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')
        self._d = 3  # GData
        self.coords = cat.coords
        self._coords = treecorr.util.coord_enum(self.coords)  # These are the C++-layer enums

        self.data = treecorr._lib.BuildGSimpleField(dp(cat.x), dp(cat.y), dp(cat.z),
                                                    dp(cat.g1), dp(cat.g2),
                                                    dp(cat.w), dp(cat.wpos), cat.ntot,
                                                    self._coords)
        if logger:
            logger.debug('Finished building KSimpleField (%s)',self.coords)
github rmjarvis / TreeCorr / treecorr / catalog.py View on Github external
# This is straightforward.  Just select the rows with patch == single_patch
            use = np.where(self._patch == single_patch)[0]
        elif self._centers is not None:
            self._generate_xyz()
            use = np.empty(self.ntot, dtype=int)
            from .util import double_ptr as dp
            from .util import long_ptr as lp
            npatch = self._centers.shape[0]
            centers = np.ascontiguousarray(self._centers)
            if self._z is None:
                assert centers.shape[1] == 2
            else:
                assert centers.shape[1] == 3
            treecorr.set_omp_threads(self.config.get('num_threads',None))
            treecorr._lib.SelectPatch(single_patch, dp(centers), npatch,
                                      dp(self._x), dp(self._y), dp(self._z),
                                      lp(use), self.ntot)
            use = np.where(use)[0]
        else:
            use = slice(None)  # Which ironically means use all. :)
        return use
github rmjarvis / TreeCorr / treecorr / kgcorrelation.py View on Github external
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.xi),dp(self.xi_im), dp(None), dp(None),
                    dp(self.meanr),dp(self.meanlogr),dp(self.weight),dp(self.npairs));
        return self._corr
github rmjarvis / TreeCorr / treecorr / kkkcorrelation.py View on Github external
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.zeta), 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));
        return self._corr
github rmjarvis / TreeCorr / treecorr / catalog.py View on Github external
def _assign_patches(self):
        # This is equivalent to the following:
        #   field = self.getNField()
        #   self._patch = field.kmeans_assign_patches(self._centers)
        # However, when the field is not already created, it's faster to just run through
        # all the points directly and assign which one is closest.
        from treecorr.util import double_ptr as dp
        from treecorr.util import long_ptr as lp
        self._patch = np.empty(self.ntot, dtype=int)
        self._npatch = self._centers.shape[0]
        centers = np.ascontiguousarray(self._centers)
        treecorr.set_omp_threads(self.config.get('num_threads',None))
        treecorr._lib.QuickAssign(dp(centers), self._npatch,
                                  dp(self.x), dp(self.y), dp(self.z), lp(self._patch), self.ntot)