orpheus-npcf 0.2.1__cp310-cp310-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orpheus/__init__.py +9 -0
- orpheus/catalog.py +1216 -0
- orpheus/covariance.py +153 -0
- orpheus/direct.py +1091 -0
- orpheus/flat2dgrid.py +68 -0
- orpheus/npcf_base.py +766 -0
- orpheus/npcf_fourth.py +1716 -0
- orpheus/npcf_second.py +620 -0
- orpheus/npcf_third.py +1684 -0
- orpheus/orpheus_clib.cpython-310-x86_64-linux-gnu.so +0 -0
- orpheus/patchutils.py +369 -0
- orpheus/utils.py +198 -0
- orpheus_npcf-0.2.1.dist-info/METADATA +67 -0
- orpheus_npcf-0.2.1.dist-info/RECORD +19 -0
- orpheus_npcf-0.2.1.dist-info/WHEEL +5 -0
- orpheus_npcf-0.2.1.dist-info/licenses/LICENSE +674 -0
- orpheus_npcf-0.2.1.dist-info/sboms/auditwheel.cdx.json +1 -0
- orpheus_npcf-0.2.1.dist-info/top_level.txt +1 -0
- orpheus_npcf.libs/libgomp-8949ffbe.so.1.0.0 +0 -0
orpheus/flat2dgrid.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.interpolate import RegularGridInterpolator
|
|
3
|
+
|
|
4
|
+
__all__ = ["FlatPixelGrid_2D","FlatDataGrid_2D"]
|
|
5
|
+
|
|
6
|
+
class FlatPixelGrid_2D(object):
|
|
7
|
+
|
|
8
|
+
def __init__(self, start_1, start_2, npix_1, npix_2, dpix_1, dpix_2):
|
|
9
|
+
self.start_1 = start_1
|
|
10
|
+
self.start_2 = start_2
|
|
11
|
+
self.npix_1 = npix_1
|
|
12
|
+
self.npix_2 = npix_2
|
|
13
|
+
self.dpix_1 = dpix_1
|
|
14
|
+
self.dpix_2 = dpix_2
|
|
15
|
+
self.pix1_lbounds = self.start_1 + self.dpix_1*np.arange(self.npix_1)
|
|
16
|
+
self.pix2_lbounds = self.start_2 + self.dpix_2*np.arange(self.npix_2)
|
|
17
|
+
self.pix1_centers = self.pix1_lbounds + self.dpix_1/2.
|
|
18
|
+
self.pix2_centers = self.pix2_lbounds + self.dpix_2/2.
|
|
19
|
+
|
|
20
|
+
def todatagrid(self, data):
|
|
21
|
+
return FlatDataGrid_2D(data, self.start_1, self.start_2, self.dpix_1, self.dpix_2)
|
|
22
|
+
|
|
23
|
+
def _regrid(self, other, data):
|
|
24
|
+
assert(isinstance(other,FlatPixelGrid_2D))
|
|
25
|
+
assert(data.shape == (self.npix_2,self.npix_1))
|
|
26
|
+
data_int = RegularGridInterpolator((self.pix2_centers, self.pix1_centers), data,
|
|
27
|
+
method="linear", bounds_error=False, fill_value=0)
|
|
28
|
+
oc1, oc2 = np.meshgrid(other.pix2_centers,other.pix1_centers, indexing='ij')
|
|
29
|
+
centers_mapgrid = np.array([oc1,oc2]).reshape((2,oc1.shape[1]*oc1.shape[0])).transpose()
|
|
30
|
+
data_regridded = data_int(centers_mapgrid).reshape((oc1.shape[0],oc1.shape[1]))
|
|
31
|
+
return other.todatagrid(data_regridded)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class FlatDataGrid_2D(FlatPixelGrid_2D):
|
|
35
|
+
|
|
36
|
+
def __init__(self, data, start_1, start_2, dpix_1, dpix_2):
|
|
37
|
+
"""
|
|
38
|
+
Convention: O (unmasked) --> 1 (fully masked)
|
|
39
|
+
"""
|
|
40
|
+
super().__init__(start_1, start_2, data.shape[1], data.shape[0], dpix_1, dpix_2)
|
|
41
|
+
self.data = data
|
|
42
|
+
|
|
43
|
+
def regrid(self, other_grid):
|
|
44
|
+
return super()._regrid(other_grid, self.data)
|
|
45
|
+
|
|
46
|
+
def samplePoints(self, nbar, method='Poisson', rng=None):
|
|
47
|
+
""" Sample points within all pixels ==0 """
|
|
48
|
+
assert(method in ["Poisson"])
|
|
49
|
+
if rng is None:
|
|
50
|
+
rng = np.random.RandomState()
|
|
51
|
+
mask1_lo = self.start_1
|
|
52
|
+
mask1_hi = self.start_1 + self.npix_1*self.dpix_1
|
|
53
|
+
mask2_lo = self.start_2
|
|
54
|
+
mask2_hi = self.start_2 + self.npix_2*self.dpix_2
|
|
55
|
+
mask_ext_area = (mask1_hi-mask1_lo)*(mask2_hi-mask2_lo)
|
|
56
|
+
# Assumes .data is mask s.t. we only sample in unmasked region, indexed by zero.
|
|
57
|
+
if method=="Poisson":
|
|
58
|
+
ngal_rand = int(nbar*mask_ext_area)
|
|
59
|
+
rand_1 = mask1_lo + (mask1_hi-mask1_lo)*rng.rand(ngal_rand)
|
|
60
|
+
rand_2 = mask2_lo + (mask2_hi-mask2_lo)*rng.rand(ngal_rand)
|
|
61
|
+
rand_ipix = np.floor((rand_2-mask2_lo)/self.dpix_2).astype(int)*self.npix_1 + np.floor((rand_1-mask1_lo)/self.dpix_1).astype(int)
|
|
62
|
+
infoot = self.data.flatten()[rand_ipix]==0
|
|
63
|
+
rand_1 = rand_1[infoot]
|
|
64
|
+
rand_2 = rand_2[infoot]
|
|
65
|
+
# Assumes .data is density map
|
|
66
|
+
if method=="LinBias":
|
|
67
|
+
raise NotImplementedError
|
|
68
|
+
return rand_1, rand_2
|