Skip to content

Commit 1b9ec3a

Browse files
author
Andrew Hearin
committed
Removed obsolete modules from mock_observables
1 parent 91696d4 commit 1b9ec3a

39 files changed

+274
-8237
lines changed

docs/full_ref_api/halotools_full_api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Comprehensive Halotools Reference/API
1616

1717
.. automodapi:: halotools.mock_observables
1818
.. automodapi:: halotools.mock_observables.pair_counters
19-
.. automodapi:: halotools.mock_observables.pair_counters.cpairs
2019
.. automodapi:: halotools.mock_observables.pair_counters.marked_cpairs
2120

2221

halotools/empirical_models/factories/tests/test_hod_mock_factory.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
from astropy.config.paths import _find_home
77

88
import numpy as np
9-
from copy import copy, deepcopy
10-
from time import time
9+
from copy import deepcopy
1110

12-
from ....mock_observables import periodic_3d_distance
1311
from ....mock_observables import return_xyz_formatted_array, tpcf_one_two_halo_decomp
1412

1513
from ....sim_manager import FakeSim, CachedHaloCatalog
@@ -178,7 +176,13 @@ def test_satellite_positions1(self):
178176
x2 = gals['halo_x']
179177
y2 = gals['halo_y']
180178
z2 = gals['halo_z']
181-
d = periodic_3d_distance(x1, y1, z1, x2, y2, z2, self.model.mock.Lbox)
179+
dx = np.fabs(x1 - x2)
180+
dx = np.fmin(dx, self.model.mock.Lbox - dx)
181+
dy = np.fabs(y1 - y2)
182+
dy = np.fmin(dy, self.model.mock.Lbox - dy)
183+
dz = np.fabs(z1 - z2)
184+
dz = np.fmin(dz, self.model.mock.Lbox - dz)
185+
d = np.sqrt(dx*dx+dy*dy+dz*dz)
182186
assert np.all(d <= gals['halo_rvir'])
183187

184188
@pytest.mark.slow

halotools/mock_observables/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
from .isolation_criteria import *
2323
from .void_stats import *
2424
from .catalog_analysis_helpers import *
25-
from .distances import *
26-
from .pair_counters import (npairs_3d, npairs_projected, npairs_xy_z)
25+
from .pair_counters import (npairs_3d, npairs_projected, npairs_xy_z,
26+
marked_npairs_3d, marked_npairs_xy_z)

halotools/mock_observables/clustering_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def _s_mu_tpcf_process_args(sample1, s_bins, mu_bins, sample2, randoms,
517517

518518
#work with the sine of the angle between s and the LOS. Only using cosine as the
519519
#input because of convention. sin(theta_los) increases as theta_los increases, which
520-
#is required in order to get the pair counter to work. see note in cpairs s_mu_pairs.
520+
#is required in order to get the pair counter to work.
521521
theta = np.arccos(mu_bins)
522522
mu_bins = np.sin(theta)[::-1] #must be increasing, remember to reverse result.
523523

halotools/mock_observables/distances.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

halotools/mock_observables/error_estimation_tools.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""
4-
functions to assist in error estimation of mock observations.
2+
Functions to assist in error estimation of mock observations.
53
"""
64

7-
from __future__ import (absolute_import, division, print_function, unicode_literals)
5+
from __future__ import absolute_import, division, print_function, unicode_literals
86

9-
__all__=['jackknife_covariance_matrix','cuboid_subvolume_labels']
7+
__all__ = ['jackknife_covariance_matrix','cuboid_subvolume_labels']
108
__author__ = ('Duncan Campbell', )
119

1210
import numpy as np
13-
from ..utils.array_utils import convert_to_ndarray
14-
from ..custom_exceptions import HalotoolsError
1511
from warnings import warn
1612

13+
from ..utils.array_utils import convert_to_ndarray
14+
from ..custom_exceptions import HalotoolsError
1715

1816
def cuboid_subvolume_labels(sample, Nsub, Lbox):
1917
"""
20-
return integer labels indicating which cuboid subvolume of a larger cuboid volume a
21-
set of pionts occupy.
18+
Return integer labels indicating which cubical subvolume of a larger cubical volume a
19+
set of points occupy.
2220
2321
Parameters
2422
----------
@@ -32,9 +30,9 @@ def cuboid_subvolume_labels(sample, Nsub, Lbox):
3230
of subvolumes is then given by `numpy.prod(Nsub)`.
3331
3432
Lbox : array_like
35-
Lenght-3 numpy array definging the legnths of the sides of the cuboid volume
36-
that ``sample`` occupies. If only one number is specified, the volume is assumed
37-
to cubic with sides given by np.array([Lbox]*3).
33+
Lenght-3 numpy array definging the lengths of the sides of the cubical volume
34+
that ``sample`` occupies. If only a single scalar is specified, the volume is assumed
35+
to be a cube with side-length Lbox
3836
3937
Returns
4038
-------
@@ -124,7 +122,7 @@ def jackknife_covariance_matrix(observations):
124122
Examples
125123
--------
126124
For demonstration purposes we create some random data. Let's say we have jackknife
127-
samples and to estimate the errors on 15 measurements. e.g. the two point
125+
100 samples and to estimate the errors on 15 measurements, e.g. the two point
128126
correlation function in 15 radial bins.
129127
130128
>>> observations = np.random.random((100,15))
@@ -144,7 +142,7 @@ def jackknife_covariance_matrix(observations):
144142

145143
# raise a warning if N_samples < Nr
146144
if N_samples < Nr:
147-
msg = ("\n the nubumber of samples is smaller than the number of \n"
145+
msg = ("\n the number of samples is smaller than the number of \n"
148146
"observations. It is recommended to increase the number \n"
149147
"of samples or decrease the number of observations.")
150148
warn(msg)

halotools/mock_observables/groups.py

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""
4-
galaxy group classes
2+
Module containing the `~halotools.mock_observables.FoFGroups` class used to
3+
identify friends-of-friends groups of points.
54
"""
65

7-
from __future__ import (absolute_import, division, print_function,
8-
unicode_literals)
6+
from __future__ import absolute_import, division, print_function, unicode_literals
97

108
import numpy as np
119
from scipy.sparse import csgraph, csr_matrix
10+
11+
from .pair_counters.pairwise_distance_xy_z import pairwise_distance_xy_z
12+
1213
from ..custom_exceptions import HalotoolsError
13-
from .pair_counters.double_tree_pair_matrix import xy_z_pair_matrix
1414

1515
igraph_available=True
16-
try: import igraph
16+
try:
17+
import igraph
1718
except ImportError:
1819
igraph_available=False
1920
if igraph_available is True: #there is another package called igraph--need to distinguish.
2021
if not hasattr(igraph,'Graph'):
2122
igraph_available is False
2223
no_igraph_msg = ("igraph package not installed. Some functions will not be available. \n"
23-
"See http://igraph.org/ and note that there are two packages called \n"
24-
"'igraph'.")
24+
"See http://igraph.org/ and note that there are two packages called 'igraph'.")
2525

26-
__all__=['FoFGroups']
26+
__all__ = ['FoFGroups']
2727
__author__ = ['Duncan Campbell']
2828

2929
class FoFGroups(object):
@@ -37,34 +37,42 @@ def __init__(self, positions, b_perp, b_para, period=None, Lbox=None, num_thread
3737
3838
The first two dimensions (x, y) define the plane for perpendicular distances.
3939
The third dimension (z) is used for line-of-sight distances.
40+
4041
See the :ref:`mock_obs_pos_formatting` documentation page for
4142
instructions on how to transform your coordinate position arrays into the
4243
format accepted by the ``positions`` argument.
43-
See also :ref:`galaxy_catalog_analysis_tutorial5`.
4444
45+
See also :ref:`galaxy_catalog_analysis_tutorial5`.
46+
4547
Parameters
4648
----------
4749
positions : array_like
4850
Npts x 3 numpy array containing 3-D positions of galaxies.
49-
51+
Length units assumed to be in Mpc/h, here and throughout Halotools.
52+
5053
b_perp : float
51-
Normalized maximum linking length in the perpendicular direction.
52-
Normalized to the mean separation between galaxies.
54+
Maximum linking length in the perpendicular direction,
55+
normalized to the mean separation between galaxies.
5356
5457
b_para : float
55-
Normalized maximum linking length in the parallel direction.
56-
Normalized to the mean separation between galaxies.
58+
Maximum linking length in the parallel direction,
59+
normalized to the mean separation between galaxies.
5760
5861
period : array_like, optional
59-
length 3 array defining periodic boundary conditions.
60-
62+
Length-3 sequence defining the periodic boundary conditions
63+
in each dimension. If you instead provide a single scalar, Lbox,
64+
period is assumed to be the same in all Cartesian directions.
65+
Length units assumed to be in Mpc/h, here and throughout Halotools.
66+
6167
Lbox : array_like, optional
6268
length 3 array defining boundaries of the simulation box.
6369
6470
num_threads : int, optional
65-
number of threads to use in calculation. Default is 1. A string 'max' may be
66-
used to indicate that the pair counters should use all available cores on
67-
the machine.
71+
Number of threads to use in calculation, where parallelization is performed
72+
using the python ``multiprocessing`` module. Default is 1 for a purely serial
73+
calculation, in which case a multiprocessing Pool object will
74+
never be instantiated. A string 'max' may be used to indicate that
75+
the pair counters should use all available cores on the machine.
6876
6977
Examples
7078
--------
@@ -73,7 +81,7 @@ def __init__(self, positions, b_perp, b_para, period=None, Lbox=None, num_thread
7381
7482
>>> Npts = 1000
7583
>>> Lbox = 1.0
76-
>>> period = np.array([Lbox,Lbox,Lbox])
84+
>>> period = Lbox
7785
7886
>>> x = np.random.random(Npts)
7987
>>> y = np.random.random(Npts)
@@ -103,11 +111,11 @@ def __init__(self, positions, b_perp, b_para, period=None, Lbox=None, num_thread
103111
raise ValueError("Lbox and Period cannot be both be None.")
104112
elif (Lbox is None) & (period is not None):
105113
Lbox = period
106-
elif np.shape(Lbox)==():
107-
Lbox = np.array([Lbox]*3)
108-
elif np.shape(Lbox)==(1,):
109-
Lbox = np.array([Lbox[0]]*3)
110-
else: Lbox = np.array(Lbox)
114+
115+
Lbox = np.atleast_1d(Lbox)
116+
if len(Lbox) == 1:
117+
Lbox = np.array([period, period, period])
118+
111119
if np.shape(Lbox) != (3,):
112120
raise ValueError("Lbox must be an array of length 3, or number indicating the\
113121
length of one side of a cube")
@@ -123,7 +131,7 @@ def __init__(self, positions, b_perp, b_para, period=None, Lbox=None, num_thread
123131
self.d_perp = self.b_perp/(self.n_gal**(1.0/3.0))
124132
self.d_para = self.b_para/(self.n_gal**(1.0/3.0))
125133

126-
self.m_perp, self.m_para = xy_z_pair_matrix(
134+
self.m_perp, self.m_para = pairwise_distance_xy_z(
127135
self.positions, self.positions, self.d_perp, self.d_para,
128136
period=self.period,num_threads=num_threads)
129137

@@ -171,7 +179,8 @@ def create_graph(self):
171179
"""
172180
if igraph_available is True:
173181
self.g = _scipy_to_igraph(self.m, self.positions, directed=False)
174-
else: raise HalotoolsError(no_igraph_msg)
182+
else:
183+
raise HalotoolsError(no_igraph_msg)
175184

176185
def get_degree(self):
177186
"""
@@ -186,7 +195,8 @@ def get_degree(self):
186195
if igraph_available is True:
187196
self.degree = self.g.degree()
188197
return self.degree
189-
else: raise HalotoolsError(no_igraph_msg)
198+
else:
199+
raise HalotoolsError(no_igraph_msg)
190200

191201
def get_betweenness(self):
192202
"""
@@ -200,7 +210,8 @@ def get_betweenness(self):
200210
if igraph_available is True:
201211
self.betweenness = self.g.betweenness()
202212
return self.betweenness
203-
else: raise HalotoolsError(no_igraph_msg)
213+
else:
214+
raise HalotoolsError(no_igraph_msg)
204215

205216
def get_multiplicity(self):
206217
"""
@@ -211,7 +222,8 @@ def get_multiplicity(self):
211222
mltp = np.array(clusters.sizes())
212223
self.multiplicity = mltp[self.group_ids]
213224
return self.multiplicity
214-
else: raise HalotoolsError(no_igraph_msg)
225+
else:
226+
raise HalotoolsError(no_igraph_msg)
215227

216228
def get_edges(self):
217229
"""

halotools/mock_observables/pair_counters/__init__.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@
22

33
from __future__ import (absolute_import, division, print_function, unicode_literals)
44

5-
from .double_tree_pairs import *
6-
from .double_tree_per_object_pairs import *
7-
from .marked_double_tree_pairs import *
8-
from .double_tree import *
9-
from .double_tree_pair_matrix import *
10-
from .npairs_3d import npairs_3d
115
from .rectangular_mesh import RectangularDoubleMesh
12-
from .npairs_xy_z import npairs_xy_z
6+
from .npairs_3d import npairs_3d
137
from .npairs_projected import npairs_projected
14-
from .npairs_s_mu import npairs_s_mu
15-
from .npairs_jackknife_3d import npairs_jackknife_3d
8+
from .npairs_xy_z import npairs_xy_z
169
from .marked_npairs_3d import marked_npairs_3d
1710
from .marked_npairs_xy_z import marked_npairs_xy_z
11+
from .npairs_jackknife_3d import npairs_jackknife_3d
12+
from .npairs_s_mu import npairs_s_mu
1813
from .npairs_per_object_3d import npairs_per_object_3d
1914
from .velocity_marked_npairs_3d import velocity_marked_npairs_3d
20-
from .velocity_marked_npairs_xy_z import velocity_marked_npairs_xy_z
2115
from .pairwise_distance_3d import pairwise_distance_3d
2216
from .pairwise_distance_xy_z import pairwise_distance_xy_z
23-
17+
from .velocity_marked_npairs_3d import velocity_marked_npairs_3d
18+
from .velocity_marked_npairs_xy_z import velocity_marked_npairs_xy_z

halotools/mock_observables/pair_counters/cpairs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ All actual distance caclualtions are done using "cdef" functions defined in "dis
2424

2525
Available functions are:
2626

27-
* cpairs : pair counts in bins
27+
* pair_counting_engines : pair counts in bins
2828
* pairwise_distances : a matrix of distances between points
29-
* per_object_cpairs : pair counts in bins per object
29+
* per_object_npairs : pair counts in bins per object
3030

3131
There are usually two version of these functions, one assuming non-periodic distances, and another that presumes periodic boundary conditions. However, the functions that assume non-periodic distances can be used for the periodic case if the points have been shifted to account for the periodic boundaries--this is the current approach of the halotools higher level pair counting modules.
3232

halotools/mock_observables/pair_counters/cpairs/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import (absolute_import, division, print_function, unicode_literals)
44

5-
from .cpairs import *
6-
from .per_object_cpairs import *
75
from .pairwise_distances import *
86
from .npairs_3d_engine import npairs_3d_engine
97
from .npairs_projected_engine import npairs_projected_engine
@@ -15,4 +13,3 @@
1513
from .cylindrical_isolation_engine import cylindrical_isolation_engine
1614
from .pairwise_distance_3d_engine import pairwise_distance_3d_engine
1715
from .pairwise_distance_xy_z_engine import pairwise_distance_xy_z_engine
18-

0 commit comments

Comments
 (0)