diff --git a/docs/index.rst b/docs/index.rst index 734dedab9..3123316e9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -26,6 +26,7 @@ Getting Started quickstart_and_tutorials/index function_usage/index source_notes/index + quickstart_and_tutorials/development/index *********** What's New? diff --git a/docs/quickstart_and_tutorials/development/getting_started.rst b/docs/quickstart_and_tutorials/development/getting_started.rst new file mode 100644 index 000000000..af71fec83 --- /dev/null +++ b/docs/quickstart_and_tutorials/development/getting_started.rst @@ -0,0 +1,49 @@ +.. _getting_started_developers: + +************************* +Contributing to Halotools +************************* + +All halotools development happens in the github repository. To contribute, first clone the repo. +Then install the dependencies listed on the :ref:`step_by_step_install` page. + + +Code +==== + +Halotools contains a compiled component. To compile all cython (``.pyx``) files inplace run, :: + + python3 setup.py build_ext --inplace + +If you modify a ``.pyx`` file use the same command to recompile it. Subsequent runs will only compile files whose source has changed and so will be much quicker. + +Halotools also has comprehensive unit tests and uses pytest. To run all tests, assuming you are in the base of the repository, first change directory into ``halotools`` and then run ``pytest``. :: + + cd halotools + pytest + +If you have made a change and only want to run a subset of tests run, :: + + pytest -k tests_matching_this_string_will_run + +Run ``pytest --help`` for a full list of options. + + +Docs +==== + +First ensure that the halotools package and sphinx are installed. From the base of the repository run, :: + + pip3 install -e . + pip3 install sphinx==1.3.1 # see docs/conf.py for the sphinx version + +Then build documentation with, :: + + cd docs + make html + +You can see the built documentation in ``docs/_build/html/``. The easiest way to view it in your browser is to spin up a local server. One way to do this is to run, from the built directory, :: + + python3 -m http.server + +The docs should then be viewable at ``localhost:8000`` (the port will be logged when you start the server). diff --git a/docs/quickstart_and_tutorials/development/index.rst b/docs/quickstart_and_tutorials/development/index.rst index 7ce3fc7d1..60a39a33b 100644 --- a/docs/quickstart_and_tutorials/development/index.rst +++ b/docs/quickstart_and_tutorials/development/index.rst @@ -14,5 +14,6 @@ contribute to the Halotools code base. staying_up_to_date bug_reports + getting_started contributors ../../changelog diff --git a/halotools/empirical_models/abunmatch/bin_free_cam.py b/halotools/empirical_models/abunmatch/bin_free_cam.py index c80e0909a..1777e6424 100644 --- a/halotools/empirical_models/abunmatch/bin_free_cam.py +++ b/halotools/empirical_models/abunmatch/bin_free_cam.py @@ -11,9 +11,14 @@ def conditional_abunmatch(x, y, x2, y2, nwin, add_subgrid_noise=True, assume_x_is_sorted=False, assume_x2_is_sorted=False, return_indexes=False): r""" Given a set of input points with primary property `x` and secondary property `y`, - use conditional abundance matching to map new values `ynew` onto the input points - such that :math:`P( 1 + # cbx_aph: There are lots of places like this where we never check that the array is increasing if it has 2 elements. The reason for this is that array_is_monotonic requires 3 elements. This could easily be fixed because I think we could allow 2 elements arrays to array_is_monotonic - it would always be monotonic but we would know whether it was increasing or decreasing if len(separation_bins) > 2: assert array_is_monotonic(separation_bins, strict=True) == 1 assert np.all(separation_bins > 0) diff --git a/halotools/mock_observables/occupation_stats.py b/halotools/mock_observables/occupation_stats.py index 736799c26..e10882cdd 100644 --- a/halotools/mock_observables/occupation_stats.py +++ b/halotools/mock_observables/occupation_stats.py @@ -12,7 +12,9 @@ def hod_from_mock(haloprop_galaxies, haloprop_halos, haloprop_bins=None): r""" - Calculate the HOD of a mock galaxy sample. + Calculate the HOD of a mock galaxy sample. It returns the expected number + of galaxies per halo, in bins of whatever halo property + ``haloprop_galaxies`` and ``haloprop_halos`` are given in. Parameters ---------- @@ -27,10 +29,14 @@ def hod_from_mock(haloprop_galaxies, haloprop_halos, haloprop_bins=None): Array of shape (num_halos, ) used to bin the halos in the same manner as the galaxies so that the counts in each bin can be properly normalized. + Note that this property (e.g. halo mass) must be the same as used for + ``haloprop_halos``. + haloprop_bins : ndarray, optional - Array defining the bin edges. If this array is not passed, then you will probably - obtain better results if you pass in logarithmic quantities for the - ``haloprop_galaxies`` and ``haloprop_halos`` arrays. + Array defining the bin edges. If None, this defaults to 10 linearly + spaced bins and so you will probably obtain better results if you + pass in logarithmic quantities for the ``haloprop_galaxies`` + and ``haloprop_halos`` arrays. Returns ------- @@ -44,10 +50,12 @@ def hod_from_mock(haloprop_galaxies, haloprop_halos, haloprop_bins=None): Examples -------- In the following calculation, we'll populate a mock catalog and then manually - compute the central galaxy HOD from the ``galaxy_table``. + compute the central galaxy HOD (number of central galaxies above the mass + threshold as a function of halo mass) from the ``galaxy_table``. >>> from halotools.empirical_models import PrebuiltHodModelFactory >>> from halotools.sim_manager import FakeSim + >>> from halotools.mock_observables import hod_from_mock >>> model = PrebuiltHodModelFactory('leauthaud11', threshold=10.75) >>> halocat = FakeSim() >>> model.populate_mock(halocat) @@ -81,9 +89,9 @@ def hod_from_mock(haloprop_galaxies, haloprop_halos, haloprop_bins=None): def get_haloprop_of_galaxies(halo_id_galaxies, halo_id_halos, haloprop_halos): - """ Calculate the host halo property of every galaxy with a ``halo_id`` that - matches one of the input halos. This function can be used, for example, - to calculate the host halo mass of a galaxy. + """ Determine the halo property in ``haloprop_halos`` for each galaxy. + This crossmatches the galaxy catalog with the halo catalog using their + ``halo_id``. Return the halo property for galaxies with a match, else nan. Parameters ---------- @@ -99,7 +107,7 @@ def get_haloprop_of_galaxies(halo_id_galaxies, halo_id_halos, haloprop_halos): haloprop_halos : ndarray Array of shape (num_halos, ) storing the halo property of interest, - e.g., ``halo_mvir``. + e.g., ``halo_vpeak`` or ``halo_spin``. Returns ------- @@ -117,6 +125,7 @@ def get_haloprop_of_galaxies(halo_id_galaxies, halo_id_halos, haloprop_halos): >>> from halotools.empirical_models import PrebuiltHodModelFactory >>> from halotools.sim_manager import FakeSim + >>> from halotools.mock_observables import get_haloprop_of_galaxies >>> model = PrebuiltHodModelFactory('leauthaud11') >>> halocat = FakeSim() >>> model.populate_mock(halocat) diff --git a/halotools/mock_observables/pair_counters/marked_npairs_3d.py b/halotools/mock_observables/pair_counters/marked_npairs_3d.py index 7d4f424ef..2d1320686 100644 --- a/halotools/mock_observables/pair_counters/marked_npairs_3d.py +++ b/halotools/mock_observables/pair_counters/marked_npairs_3d.py @@ -20,12 +20,14 @@ __all__ = ('marked_npairs_3d', ) -def marked_npairs_3d(sample1, sample2, rbins, - period=None, weights1=None, weights2=None, - weight_func_id=0, verbose=False, num_threads=1, +# cbx_aph: weight_function_id is not optional. However moving it to be a +# required arg is a breaking change. +def marked_npairs_3d(sample1, sample2, rbins, weight_func_id, + period=None, weights1=None, weights2=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): """ - Calculate the number of weighted pairs with separations greater than or equal to r, :math:`W(>r)`. + Calculate the weighted number of pairs with separations less than or equal to + the input ``rbins``, :math:`W(= 1"` down below fails +# if you don't pass them. I don't think that they should be optional and should probably be +# brought before period. I've done this, but this is a breaking API change so just letting +# you know :) The other option is to keep them as kwargs and just remove the `optional` tag +# in the docs. +# Similarly N_samples isn't optional +def npairs_jackknife_3d(sample1, sample2, rbins, jtags1, jtags2, N_samples, + period=None, weights1=None, weights2=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Pair counter used to make jackknife error estimates of real-space pair counter @@ -46,33 +52,30 @@ def npairs_jackknife_3d(sample1, sample2, rbins, period=None, weights1=None, wei Boundaries defining the bins in which pairs are counted. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. - period : array_like, optional - Length-3 sequence defining the periodic boundary conditions - in each dimension. If you instead provide a single scalar, Lbox, - period is assumed to be the same in all Cartesian directions. - - weights1 : array_like, optional - Numpy array of shape (Npts1, ) containing weights used for weighted pair counts. - - weights2 : array_like, optional - Numpy array of shape (Npts2, ) containing weights used for weighted pair counts. - - jtags1 : array_like, optional + jtags1 : array_like Numpy array of shape (Npts1, ) containing integer tags used to define jackknife sample membership. Tags are in the range [1, N_samples]. The tag '0' is a reserved tag and should not be used. - jtags2 : array_like, optional + jtags2 : array_like Numpy array of shape (Npts2, ) containing integer tags used to define jackknife sample membership. Tags are in the range [1, N_samples]. The tag '0' is a reserved tag and should not be used. - N_samples : int, optional + N_samples : int Total number of jackknife samples. All values of ``jtags1`` and ``jtags2`` should be in the range [1, N_samples]. - verbose : Boolean, optional - If True, print out information and progress. + period : array_like, optional + Length-3 sequence defining the periodic boundary conditions + in each dimension. If you instead provide a single scalar, Lbox, + period is assumed to be the same in all Cartesian directions. + + weights1 : array_like, optional + Numpy array of shape (Npts1, ) containing weights used for weighted pair counts. + + weights2 : array_like, optional + Numpy array of shape (Npts2, ) containing weights used for weighted pair counts. num_threads : int, optional Number of threads to use in calculation, where parallelization is performed @@ -117,6 +120,7 @@ def npairs_jackknife_3d(sample1, sample2, rbins, period=None, weights1=None, wei For demonstration purposes we create randomly distributed sets of points within a periodic unit cube. + >>> from halotools.mock_observables.pair_counters import npairs_jackknife_3d >>> Npts1, Npts2, Lbox = 1000, 1000, 250. >>> period = [Lbox, Lbox, Lbox] >>> rbins = np.logspace(-1, 1.5, 15) @@ -148,7 +152,7 @@ def npairs_jackknife_3d(sample1, sample2, rbins, period=None, weights1=None, wei """ # Process the inputs with the helper function result = _npairs_3d_process_args(sample1, sample2, rbins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] rbins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period @@ -215,19 +219,14 @@ def _npairs_jackknife_3d_process_weights_jtags(sample1, sample2, raise HalotoolsError("weights2 should have same len as sample2") # Process jtags_1 entry and check for consistency. - if jtags1 is None: - jtags1 = np.array([0]*np.shape(sample1)[0], dtype=np.int) - else: - jtags1 = np.asarray(jtags1).astype("int") - if np.shape(jtags1)[0] != np.shape(sample1)[0]: - raise HalotoolsError("jtags1 should have same len as sample1") + jtags1 = np.asarray(jtags1).astype("int") + if np.shape(jtags1)[0] != np.shape(sample1)[0]: + raise HalotoolsError("jtags1 should have same len as sample1") + # Process jtags_2 entry and check for consistency. - if jtags2 is None: - jtags2 = np.array([0]*np.shape(sample2)[0], dtype=np.int) - else: - jtags2 = np.asarray(jtags2).astype("int") - if np.shape(jtags2)[0] != np.shape(sample2)[0]: - raise HalotoolsError("jtags2 should have same len as sample2") + jtags2 = np.asarray(jtags2).astype("int") + if np.shape(jtags2)[0] != np.shape(sample2)[0]: + raise HalotoolsError("jtags2 should have same len as sample2") # Check bounds of jackknife tags if np.min(jtags1) < 1: diff --git a/halotools/mock_observables/pair_counters/npairs_jackknife_xy_z.py b/halotools/mock_observables/pair_counters/npairs_jackknife_xy_z.py index 4efe2309e..df8a219a3 100644 --- a/halotools/mock_observables/pair_counters/npairs_jackknife_xy_z.py +++ b/halotools/mock_observables/pair_counters/npairs_jackknife_xy_z.py @@ -21,8 +21,8 @@ def npairs_jackknife_xy_z(sample1, sample2, rp_bins, pi_bins, - period=None, weights1=None, weights2=None, - jtags1=None, jtags2=None, N_samples=0, verbose=False, num_threads=1, + jtags1, jtags2, N_samples, + period=None, weights1=None, weights2=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Pair counter used to make jackknife error estimates of redshift-space pair counter @@ -52,33 +52,30 @@ def npairs_jackknife_xy_z(sample1, sample2, rp_bins, pi_bins, maximum LOS distance defining the projection integral length-scale in the z-dimension. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. - period : array_like, optional - Length-3 sequence defining the periodic boundary conditions - in each dimension. If you instead provide a single scalar, Lbox, - period is assumed to be the same in all Cartesian directions. - - weights1 : array_like, optional - Numpy array of shape (Npts1, ) containing weights used for weighted pair counts. - - weights2 : array_like, optional - Numpy array of shape (Npts2, ) containing weights used for weighted pair counts. - - jtags1 : array_like, optional + jtags1 : array_like Numpy array of shape (Npts1, ) containing integer tags used to define jackknife sample membership. Tags are in the range [1, N_samples]. The tag '0' is a reserved tag and should not be used. - jtags2 : array_like, optional + jtags2 : array_like Numpy array of shape (Npts2, ) containing integer tags used to define jackknife sample membership. Tags are in the range [1, N_samples]. The tag '0' is a reserved tag and should not be used. - N_samples : int, optional + N_samples : int Total number of jackknife samples. All values of ``jtags1`` and ``jtags2`` should be in the range [1, N_samples]. - verbose : Boolean, optional - If True, print out information and progress. + period : array_like, optional + Length-3 sequence defining the periodic boundary conditions + in each dimension. If you instead provide a single scalar, Lbox, + period is assumed to be the same in all Cartesian directions. + + weights1 : array_like, optional + Numpy array of shape (Npts1, ) containing weights used for weighted pair counts. + + weights2 : array_like, optional + Numpy array of shape (Npts2, ) containing weights used for weighted pair counts. num_threads : int, optional Number of threads to use in calculation, where parallelization is performed @@ -155,7 +152,7 @@ def npairs_jackknife_xy_z(sample1, sample2, rp_bins, pi_bins, """ # Process the inputs with the helper function result = _npairs_xy_z_process_args(sample1, sample2, rp_bins, pi_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] rp_bins, pi_bins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period @@ -223,19 +220,13 @@ def _npairs_jackknife_xy_z_process_weights_jtags(sample1, sample2, raise HalotoolsError("weights2 should have same len as sample2") # Process jtags_1 entry and check for consistency. - if jtags1 is None: - jtags1 = np.array([0]*np.shape(sample1)[0], dtype=np.int) - else: - jtags1 = np.asarray(jtags1).astype("int") - if np.shape(jtags1)[0] != np.shape(sample1)[0]: - raise HalotoolsError("jtags1 should have same len as sample1") + jtags1 = np.asarray(jtags1).astype("int") + if np.shape(jtags1)[0] != np.shape(sample1)[0]: + raise HalotoolsError("jtags1 should have same len as sample1") # Process jtags_2 entry and check for consistency. - if jtags2 is None: - jtags2 = np.array([0]*np.shape(sample2)[0], dtype=np.int) - else: - jtags2 = np.asarray(jtags2).astype("int") - if np.shape(jtags2)[0] != np.shape(sample2)[0]: - raise HalotoolsError("jtags2 should have same len as sample2") + jtags2 = np.asarray(jtags2).astype("int") + if np.shape(jtags2)[0] != np.shape(sample2)[0]: + raise HalotoolsError("jtags2 should have same len as sample2") # Check bounds of jackknife tags if np.min(jtags1) < 1: diff --git a/halotools/mock_observables/pair_counters/npairs_per_object_3d.py b/halotools/mock_observables/pair_counters/npairs_per_object_3d.py index 4abc8a355..1261ec732 100644 --- a/halotools/mock_observables/pair_counters/npairs_per_object_3d.py +++ b/halotools/mock_observables/pair_counters/npairs_per_object_3d.py @@ -17,8 +17,7 @@ def npairs_per_object_3d(sample1, sample2, rbins, period=None, - verbose=False, num_threads=1, - approx_cell1_size=None, approx_cell2_size=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): """ Function counts the number of points in ``sample2`` separated by a distance ``r`` from each point in ``sample1``, where ``r`` is defined by the input ``rbins``. @@ -48,9 +47,6 @@ def npairs_per_object_3d(sample1, sample2, rbins, period=None, If period is set to None, the default option, PBCs are set to infinity. - verbose : Boolean, optional - If True, print out information and progress. - num_threads : int, optional Number of threads to use in calculation, where parallelization is performed using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -105,7 +101,7 @@ def npairs_per_object_3d(sample1, sample2, rbins, period=None, # Process the inputs with the helper function result = _npairs_3d_process_args(sample1, sample2, rbins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] rbins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period diff --git a/halotools/mock_observables/pair_counters/npairs_projected.py b/halotools/mock_observables/pair_counters/npairs_projected.py index 83b1606ed..f4f9fc0cc 100644 --- a/halotools/mock_observables/pair_counters/npairs_projected.py +++ b/halotools/mock_observables/pair_counters/npairs_projected.py @@ -18,8 +18,7 @@ def npairs_projected(sample1, sample2, rp_bins, pi_max, period=None, - verbose=False, num_threads=1, - approx_cell1_size=None, approx_cell2_size=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): """ Function counts the number of pairs of points with separation in the xy-plane less than the input ``rp_bins`` and separation in the z-dimension less than @@ -62,9 +61,6 @@ def npairs_projected(sample1, sample2, rp_bins, pi_max, period=None, in each dimension. If you instead provide a single scalar, Lbox, period is assumed to be the same in all Cartesian directions. - verbose : Boolean, optional - If True, print out information and progress. - num_threads : int, optional Number of threads to use in calculation, where parallelization is performed using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -121,7 +117,7 @@ def npairs_projected(sample1, sample2, rp_bins, pi_max, period=None, # Process the inputs with the helper function result = _npairs_projected_process_args(sample1, sample2, rp_bins, pi_max, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] rp_bins, pi_max, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period @@ -162,7 +158,7 @@ def npairs_projected(sample1, sample2, rp_bins, pi_max, period=None, def _npairs_projected_process_args(sample1, sample2, rp_bins, pi_max, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size): + num_threads, approx_cell1_size, approx_cell2_size): """ """ if num_threads is not 1: diff --git a/halotools/mock_observables/pair_counters/npairs_s_mu.py b/halotools/mock_observables/pair_counters/npairs_s_mu.py index d49bb77f6..313bd9773 100644 --- a/halotools/mock_observables/pair_counters/npairs_s_mu.py +++ b/halotools/mock_observables/pair_counters/npairs_s_mu.py @@ -18,7 +18,7 @@ def npairs_s_mu(sample1, sample2, s_bins, mu_bins, period=None, - verbose=False, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Function counts the number of pairs of points separated by less than radial separation, :math:`s`, given by ``s_bins`` and @@ -68,9 +68,6 @@ def npairs_s_mu(sample1, sample2, s_bins, mu_bins, period=None, period is assumed to be the same in all Cartesian directions. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. - verbose : Boolean, optional - If True, print out information and progress. - num_threads : int, optional Number of threads to use in calculation, where parallelization is performed using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -155,7 +152,7 @@ def npairs_s_mu(sample1, sample2, s_bins, mu_bins, period=None, # Process the inputs with the helper function result = _npairs_3d_process_args(sample1, sample2, s_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] s_bins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period diff --git a/halotools/mock_observables/pair_counters/npairs_xy_z.py b/halotools/mock_observables/pair_counters/npairs_xy_z.py index 4edff1442..012af4bf4 100644 --- a/halotools/mock_observables/pair_counters/npairs_xy_z.py +++ b/halotools/mock_observables/pair_counters/npairs_xy_z.py @@ -18,8 +18,7 @@ def npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, - verbose=False, num_threads=1, - approx_cell1_size=None, approx_cell2_size=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): """ Function counts the number of pairs of points with separation in the xy-plane less than the input ``rp_bins`` and separation in the z-dimension less than @@ -67,9 +66,6 @@ def npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, If set to None (the default option), PBCs are set to infinity. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. - verbose : Boolean, optional - If True, print out information and progress. - num_threads : int, optional Number of threads to use in calculation, where parallelization is performed using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -126,7 +122,7 @@ def npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, # Process the inputs with the helper function result = _npairs_xy_z_process_args(sample1, sample2, rp_bins, pi_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] rp_bins, pi_bins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period @@ -168,7 +164,7 @@ def npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, def _npairs_xy_z_process_args(sample1, sample2, rp_bins, pi_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size): + num_threads, approx_cell1_size, approx_cell2_size): """ """ if num_threads is not 1: diff --git a/halotools/mock_observables/pair_counters/pairwise_distance_3d.py b/halotools/mock_observables/pair_counters/pairwise_distance_3d.py index 58b1b2fe9..cdbc50803 100644 --- a/halotools/mock_observables/pair_counters/pairwise_distance_3d.py +++ b/halotools/mock_observables/pair_counters/pairwise_distance_3d.py @@ -25,7 +25,7 @@ def pairwise_distance_3d(data1, data2, r_max, period=None, approx_cell1_size=None, approx_cell2_size=None): """ Function returns pairs of points separated by - a three-dimensional distance smaller than or eqaul to the input ``r_max``. + a three-dimensional distance smaller than or equal to the input ``r_max``. Note that if data1 == data2 that the `~halotools.mock_observables.pairwise_distance_3d` function double-counts pairs. diff --git a/halotools/mock_observables/pair_counters/pairwise_distance_xy_z.py b/halotools/mock_observables/pair_counters/pairwise_distance_xy_z.py index e6801aa44..54ad883ef 100644 --- a/halotools/mock_observables/pair_counters/pairwise_distance_xy_z.py +++ b/halotools/mock_observables/pair_counters/pairwise_distance_xy_z.py @@ -24,7 +24,7 @@ def pairwise_distance_xy_z(data1, data2, rp_max, pi_max, period=None, approx_cell1_size=None, approx_cell2_size=None): """ Function returns pairs of points separated by - a xy-projected distance smaller than or eqaul to the input ``rp_max`` and z distance ``pi_max``. + a xy-projected distance smaller than or equal to the input ``rp_max`` and z distance ``pi_max``. Note that if data1 == data2 that the `~halotools.mock_observables.pairwise_distance_xy_z` function double-counts pairs. diff --git a/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py b/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py index 1e1607260..cbfec481a 100644 --- a/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py +++ b/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py @@ -18,13 +18,13 @@ def weighted_npairs_s_mu(sample1, sample2, weights1, weights2, s_bins, mu_bins, period=None, - verbose=False, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Function performs a *weighted* count of the number of pairs of points separated by less than - radial separation, :math:`s`, given by ``s_bins`` and + distance r:math:`s`, given by ``s_bins`` along the line-of-sight (LOS), and angular distance, :math:`\mu\equiv\cos(\theta_{\rm los})`, given by ``mu_bins``, where :math:`\theta_{\rm los}` is the angle between :math:`\vec{s}` and - the line-of-sight (LOS). + the (LOS). The first two dimensions (x, y) define the plane for perpendicular distances. The third dimension (z) defines the LOS. i.e. x,y positions are on @@ -74,9 +74,6 @@ def weighted_npairs_s_mu(sample1, sample2, weights1, weights2, s_bins, mu_bins, period is assumed to be the same in all Cartesian directions. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. - verbose : Boolean, optional - If True, print out information and progress. - num_threads : int, optional Number of threads to use in calculation, where parallelization is performed using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -167,7 +164,7 @@ def weighted_npairs_s_mu(sample1, sample2, weights1, weights2, s_bins, mu_bins, # Process the inputs with the helper function result = _npairs_3d_process_args(sample1, sample2, s_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] s_bins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period diff --git a/halotools/mock_observables/pairwise_velocities/engines/velocity_marked_npairs_3d_engine.pyx b/halotools/mock_observables/pairwise_velocities/engines/velocity_marked_npairs_3d_engine.pyx index 77040f53b..4276387fe 100644 --- a/halotools/mock_observables/pairwise_velocities/engines/velocity_marked_npairs_3d_engine.pyx +++ b/halotools/mock_observables/pairwise_velocities/engines/velocity_marked_npairs_3d_engine.pyx @@ -33,7 +33,7 @@ def velocity_marked_npairs_3d_engine(double_mesh, x1in, y1in, z1in, x2in, y2in, x2in, y2in, z2in : arrays Numpy arrays storing Cartesian coordinates of points in sample 2 - weight_func_id : int, optional + weight_func_id : int weighting function integer ID. weights1in : array diff --git a/halotools/mock_observables/pairwise_velocities/engines/velocity_marking_functions.pyx b/halotools/mock_observables/pairwise_velocities/engines/velocity_marking_functions.pyx index 48e682ee0..a584b8d8a 100644 --- a/halotools/mock_observables/pairwise_velocities/engines/velocity_marking_functions.pyx +++ b/halotools/mock_observables/pairwise_velocities/engines/velocity_marking_functions.pyx @@ -31,12 +31,12 @@ cdef void relative_radial_velocity_weights(cnp.float64_t* w1, ---------- w1 : pointer to an array weights array associated with data1. - w1[0:2] x,y,z positions + w1[0:3] x,y,z positions w1[3:6] vx, vy, vz velocities w2 : pointer to an array weights array associated with data2 - w2[0:2] x,y,z positions + w2[0:3] x,y,z positions w2[3:6] vx, vy, vz velocities shift : pointer to an array @@ -102,13 +102,13 @@ cdef void radial_velocity_variance_counter_weights(cnp.float64_t* w1, ---------- w1 : pointer to an array weights array associated with data1. - w1[0:2] x,y,z positions + w1[0:3] x,y,z positions w1[3:6] vx, vy, vz velocities w1[6] offset w2 : pointer to an array weights array associated with data2 - w2[0:2] x,y,z positions + w2[0:3] x,y,z positions w2[3:6] vx, vy, vz velocities w2[6] offset diff --git a/halotools/mock_observables/pairwise_velocities/los_pvd_vs_rp.py b/halotools/mock_observables/pairwise_velocities/los_pvd_vs_rp.py index 7309d10b3..7376855f7 100644 --- a/halotools/mock_observables/pairwise_velocities/los_pvd_vs_rp.py +++ b/halotools/mock_observables/pairwise_velocities/los_pvd_vs_rp.py @@ -21,57 +21,60 @@ def los_pvd_vs_rp(sample1, velocities1, rp_bins, pi_max, sample2=None, velocities2=None, period=None, do_auto=True, do_cross=True, - num_threads=1, - approx_cell1_size=None, approx_cell2_size=None, seed=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" - Calculate the pairwise line-of-sight (LOS) velocity dispersion (PVD), :math:`\sigma_{z12}(r_p)`. + Calculate the pairwise line-of-sight (LOS) velocity dispersion (PVD), + as a function of radial distance from ``sample1`` :math:`\sigma_{z12}(r_p)`. Example calls to this function appear in the documentation below. Parameters ---------- sample1 : array_like - Npts x 3 numpy array containing 3-D positions of points. + Npts1 x 3 numpy array containing 3-D positions of points. velocities1 : array_like - N1pts x 3 array containing the 3-D components of the velocities. + Npts1 x 3 array containing the 3-D components of the velocities. rp_bins : array_like array of boundaries defining the radial bins perpendicular to the LOS in which pairs are counted. + Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. pi_max : float maximum LOS separation + Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. sample2 : array_like, optional - Npts x 3 array containing 3-D positions of points. + Npts2 x 3 array containing 3-D positions of points. velocities2 : array_like, optional - N1pts x 3 array containing the 3-D components of the velocities. + Npts2 x 3 array containing the 3-D components of the velocities. period : array_like, optional length 3 array defining periodic boundary conditions. If only one number, Lbox, is specified, period is assumed to be [Lbox, Lbox, Lbox]. do_auto : boolean, optional - caclulate the auto-pairwise velocities? + calculate the auto-pairwise velocities? do_cross : boolean, optional - caclulate the cross-pairwise velocities? + calculate the cross-pairwise velocities? num_threads : int, optional number of threads to use in calculation. Default is 1. A string 'max' may be used to indicate that the pair counters should use all available cores on the machine. - seed : int, optional - Random number seed used to randomly downsample data, if applicable. - Default is None, in which case downsampling will be stochastic. - Returns ------- - sigma_12 : numpy.array - *len(rbins)-1* length array containing the dispersion of the pairwise velocity, - :math:`\sigma_{12}(r)`, computed in each of the bins defined by ``rbins``. + sigma : numpy.array or tuple(numpy.arrays) + Each numpy.array is a *len(rbins)-1* length array containing the dispersion + of the pairwise velocity, :math:`\sigma_{12}(r)`, computed in each of the bins + defined by ``rbins``. + If sample2 is None, returns :math:`\sigma_{11}(r)` + If ``do_auto`` and ``do_cross`` are True, returns (:math:`\sigma_{11}(r)`, :math:`\sigma_{12}(r)`, :math:`\sigma_{22}(r)`) + If only ``do_auto`` is True, returns (:math:`\sigma_{11}(r)`, :math:`\sigma_{22}(r)`) + If only ``do_cross`` is True, returns :math:`\sigma_{12}(r)` Notes ----- @@ -94,6 +97,7 @@ def los_pvd_vs_rp(sample1, velocities1, rp_bins, pi_max, sample2=None, For demonstration purposes we create a randomly distributed set of points within a periodic unit cube. + >>> from halotools.mock_observables import los_pvd_vs_rp >>> Npts = 1000 >>> Lbox = 1.0 >>> period = np.array([Lbox,Lbox,Lbox]) @@ -138,7 +142,7 @@ def los_pvd_vs_rp(sample1, velocities1, rp_bins, pi_max, sample2=None, # process input arguments function_args = (sample1, velocities1, sample2, velocities2, period, do_auto, do_cross, num_threads, - approx_cell1_size, approx_cell2_size, seed) + approx_cell1_size, approx_cell2_size, None) sample1, velocities1, sample2, velocities2,\ period, do_auto, do_cross,\ num_threads, _sample1_is_sample2, PBCs =\ diff --git a/halotools/mock_observables/pairwise_velocities/mean_radial_velocity_vs_r.py b/halotools/mock_observables/pairwise_velocities/mean_radial_velocity_vs_r.py index 47aeaf11e..4f2a83df6 100644 --- a/halotools/mock_observables/pairwise_velocities/mean_radial_velocity_vs_r.py +++ b/halotools/mock_observables/pairwise_velocities/mean_radial_velocity_vs_r.py @@ -28,7 +28,7 @@ def mean_radial_velocity_vs_r(sample1, velocities1, rbins_absolute=None, rbins_normalized=None, normalize_rbins_by=None, sample2=None, velocities2=None, period=None, - num_threads=1, approx_cell1_size=None, approx_cell2_size=None, seed=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Calculate the mean pairwise velocity, :math:`\bar{v}_{12}(r)`. @@ -169,7 +169,7 @@ def mean_radial_velocity_vs_r(sample1, velocities1, """ result = _process_args(sample1, velocities1, sample2, velocities2, rbins_absolute, rbins_normalized, normalize_rbins_by, - period, num_threads, approx_cell1_size, approx_cell2_size, seed) + period, num_threads, approx_cell1_size, approx_cell2_size) sample1, velocities1, sample2, velocities2, max_rbins_absolute, period,\ num_threads, _sample1_is_sample2, PBCs, \ @@ -230,7 +230,7 @@ def mean_radial_velocity_vs_r(sample1, velocities1, def _process_args(sample1, velocities1, sample2, velocities2, rbins_absolute, rbins_normalized, normalize_rbins_by, - period, num_threads, approx_cell1_size, approx_cell2_size, seed): + period, num_threads, approx_cell1_size, approx_cell2_size): """ Private method to do bounds-checking on the arguments passed to `~halotools.mock_observables.pairwise_velocity_stats`. diff --git a/halotools/mock_observables/pairwise_velocities/radial_pvd_vs_r.py b/halotools/mock_observables/pairwise_velocities/radial_pvd_vs_r.py index 996b83c44..f23e14354 100644 --- a/halotools/mock_observables/pairwise_velocities/radial_pvd_vs_r.py +++ b/halotools/mock_observables/pairwise_velocities/radial_pvd_vs_r.py @@ -25,7 +25,7 @@ def radial_pvd_vs_r(sample1, velocities1, rbins_absolute=None, rbins_normalized=None, normalize_rbins_by=None, sample2=None, velocities2=None, period=None, - num_threads=1, approx_cell1_size=None, approx_cell2_size=None, seed=None): + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Calculate the pairwise radial velocity dispersion as a function of absolute distance, or as a function of :math:`s = r / R_{\rm vir}`. @@ -167,7 +167,7 @@ def radial_pvd_vs_r(sample1, velocities1, """ result = _process_args(sample1, velocities1, sample2, velocities2, rbins_absolute, rbins_normalized, normalize_rbins_by, - period, num_threads, approx_cell1_size, approx_cell2_size, seed) + period, num_threads, approx_cell1_size, approx_cell2_size) sample1, velocities1, sample2, velocities2, max_rbins_absolute, period,\ num_threads, _sample1_is_sample2, PBCs, \ diff --git a/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py index 8441705b9..26145e323 100644 --- a/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py +++ b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py @@ -19,7 +19,7 @@ def velocity_marked_npairs_3d(sample1, sample2, rbins, period=None, weights1=None, weights2=None, - weight_func_id=1, verbose=False, num_threads=1, + weight_func_id=1, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): """ Calculate the number of velocity weighted pairs with separations greater than or equal to r, :math:`W(>r)`. @@ -54,23 +54,20 @@ def velocity_marked_npairs_3d(sample1, sample2, rbins, period=None, Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. weights1 : array_like, optional - Either a 1-D array of length *N1*, or a 2-D array of length *N1* x *N_weights*, + Either a 1-D array of length *Npts1*, or a 2-D array of length *Npts1* x *N_weights*, containing the weights used for the weighted pair counts. If this parameter is - None, the weights are set to np.ones(*(N1,N_weights)*). + None, the weights are set to np.ones(*(Npts1,N_weights)*). weights2 : array_like, optional - Either a 1-D array of length *N1*, or a 2-D array of length *N1* x *N_weights*, + Either a 1-D array of length *Npts2*, or a 2-D array of length *Npts2* x *N_weights*, containing the weights used for the weighted pair counts. If this parameter is - None, the weights are set to np.ones(*(N1,N_weights)*). + None, the weights are set to np.ones(*(Npts2,N_weights)*). weight_func_id : int, optional velocity weighting function integer ID. Each weighting function requires a specific number of weights per point, *N_weights*. See the Notes for a description of available weighting functions. - verbose : Boolean, optional - If True, print out information and progress. - num_threads : int, optional Number of threads to use in calculation, where parallelization is performed using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -140,7 +137,7 @@ def velocity_marked_npairs_3d(sample1, sample2, rbins, period=None, """ result = _npairs_3d_process_args(sample1, sample2, rbins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] rbins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period @@ -203,7 +200,7 @@ def _velocity_marked_npairs_3d_process_weights(sample1, sample2, weights1, weigh _converted_to_2d_from_1d = False # First convert weights1 into a 2-d ndarray if weights1 is None: - weights1 = np.ones((npts_sample1, 1), dtype=np.float64) + weights1 = np.ones(correct_shape1, dtype=np.float64) else: weights1 = np.atleast_1d(weights1) weights1 = weights1.astype("float64") @@ -244,7 +241,7 @@ def _velocity_marked_npairs_3d_process_weights(sample1, sample2, weights1, weigh _converted_to_2d_from_1d = False # Now convert weights2 into a 2-d ndarray if weights2 is None: - weights2 = np.ones((npts_sample2, 1), dtype=np.float64) + weights2 = np.ones(correct_shape2, dtype=np.float64) else: weights2 = np.atleast_1d(weights2) weights2 = weights2.astype("float64") diff --git a/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_xy_z.py b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_xy_z.py index 03b958a53..d4abc0375 100644 --- a/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_xy_z.py +++ b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_xy_z.py @@ -6,8 +6,7 @@ from ..pair_counters.npairs_xy_z import _npairs_xy_z_process_args from ..pair_counters.mesh_helpers import _set_approximate_cell_sizes, _cell1_parallelization_indices from ..pair_counters.rectangular_mesh import RectangularDoubleMesh -from .velocity_marked_npairs_3d import ( - _func_signature_int_from_vel_weight_func_id, _velocity_marked_npairs_3d_process_weights) +from .velocity_marked_npairs_3d import _velocity_marked_npairs_3d_process_weights from .engines import velocity_marked_npairs_xy_z_engine __author__ = ('Duncan Campbell', 'Andrew Hearin') @@ -17,8 +16,7 @@ def velocity_marked_npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, - weights1=None, weights2=None, - weight_func_id=1, verbose=False, num_threads=1, + weights1=None, weights2=None, weight_func_id=1, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Calculate the number of velocity weighted pairs @@ -50,7 +48,7 @@ def velocity_marked_npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. pi_bins : array_like - array of boundaries defining the p radial bins parallel to the LOS in which + array of boundaries defining the bins parallel to the LOS in which pairs are counted. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. @@ -62,23 +60,20 @@ def velocity_marked_npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. weights1 : array_like, optional - Either a 1-D array of length *N1*, or a 2-D array of length *N1* x *N_weights*, + Either a 1-D array of length *Npts1*, or a 2-D array of length *Npts1* x *N_weights*, containing the weights used for the weighted pair counts. If this parameter is - None, the weights are set to np.ones(*(N1,N_weights)*). + None, the weights are set to np.ones(*(Npts1,N_weights)*). weights2 : array_like, optional - Either a 1-D array of length *N1*, or a 2-D array of length *N1* x *N_weights*, + Either a 1-D array of length *Npts2*, or a 2-D array of length *Npts2* x *N_weights*, containing the weights used for the weighted pair counts. If this parameter is - None, the weights are set to np.ones(*(N1,N_weights)*). + None, the weights are set to np.ones(*(Npts2,N_weights)*). weight_func_id : int, optional velocity weighting function integer ID. Each weighting function requires a specific number of weights per point, *N_weights*. See the Notes for a description of available weighting functions. - verbose : Boolean, optional - If True, print out information and progress. - num_threads : int, optional Number of threads to use in calculation, where parallelization is performed using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -148,7 +143,7 @@ def velocity_marked_npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, """ result = _npairs_xy_z_process_args(sample1, sample2, rp_bins, pi_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, z1in, x2in, y2in, z2in = result[0:6] rp_bins, pi_bins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[6:] xperiod, yperiod, zperiod = period diff --git a/halotools/mock_observables/surface_density/weighted_npairs_per_object_xy.py b/halotools/mock_observables/surface_density/weighted_npairs_per_object_xy.py index b58184350..9b80d5537 100644 --- a/halotools/mock_observables/surface_density/weighted_npairs_per_object_xy.py +++ b/halotools/mock_observables/surface_density/weighted_npairs_per_object_xy.py @@ -20,7 +20,7 @@ def weighted_npairs_per_object_xy(sample1, sample2, sample2_mass, rp_bins, - period=None, verbose=False, num_threads=1, + period=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Function counts the total mass of ``sample2`` enclosed within @@ -29,7 +29,7 @@ def weighted_npairs_per_object_xy(sample1, sample2, sample2_mass, rp_bins, Parameters ---------- sample1 : array_like - Array of shape (Npts1, 2) containing 3-D positions of points. + Array of shape (Npts1, 2) containing the XY positions of points. See the :ref:`mock_obs_pos_formatting` documentation page, or the Examples section below, for instructions on how to transform @@ -38,7 +38,7 @@ def weighted_npairs_per_object_xy(sample1, sample2, sample2_mass, rp_bins, Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. sample2 : array_like - Array of shape (Npts2, 2) containing 3-D positions of particles. + Array of shape (Npts2, 2) containing XY positions of particles. sample2_mass : array_like Array of shape (Npts2, ) containing the masses of the ``sample2`` particles. @@ -112,8 +112,7 @@ def weighted_npairs_per_object_xy(sample1, sample2, sample2_mass, rp_bins, """ # Process the inputs with the helper function result = _weighted_npairs_xy_process_args(sample1, sample2, sample2_mass, - rp_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + rp_bins, period, num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, x2in, y2in, w2in = result[0:5] rp_bins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[5:] xperiod, yperiod = period diff --git a/halotools/mock_observables/surface_density/weighted_npairs_xy.py b/halotools/mock_observables/surface_density/weighted_npairs_xy.py index e420514fb..d4a114614 100644 --- a/halotools/mock_observables/surface_density/weighted_npairs_xy.py +++ b/halotools/mock_observables/surface_density/weighted_npairs_xy.py @@ -21,7 +21,7 @@ def weighted_npairs_xy(sample1, sample2, sample2_mass, rp_bins, - period=None, verbose=False, num_threads=1, + period=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Function counts the total mass of ``sample2`` enclosed within @@ -30,7 +30,7 @@ def weighted_npairs_xy(sample1, sample2, sample2_mass, rp_bins, Parameters ---------- sample1 : array_like - Array of shape (Npts1, 2) containing 3-D positions of points. + Array of shape (Npts1, 2) containing XY positions of points. See the :ref:`mock_obs_pos_formatting` documentation page, or the Examples section below, for instructions on how to transform your coordinate position arrays into the @@ -38,7 +38,7 @@ def weighted_npairs_xy(sample1, sample2, sample2_mass, rp_bins, Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. sample2 : array_like - Array of shape (Npts2, 2) containing 3-D positions of points. + Array of shape (Npts2, 2) containing XY positions of points. sample2_mass : array_like Array of shape (Npts2, ) containing the masses of the ``sample2`` points. @@ -111,8 +111,7 @@ def weighted_npairs_xy(sample1, sample2, sample2_mass, rp_bins, """ # Process the inputs with the helper function result = _weighted_npairs_xy_process_args(sample1, sample2, sample2_mass, - rp_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size) + rp_bins, period, num_threads, approx_cell1_size, approx_cell2_size) x1in, y1in, x2in, y2in, w2in = result[0:5] rp_bins, period, num_threads, PBCs, approx_cell1_size, approx_cell2_size = result[5:] xperiod, yperiod = period @@ -153,7 +152,7 @@ def weighted_npairs_xy(sample1, sample2, sample2_mass, rp_bins, def _weighted_npairs_xy_process_args(sample1, sample2, w2, rp_bins, period, - verbose, num_threads, approx_cell1_size, approx_cell2_size): + num_threads, approx_cell1_size, approx_cell2_size): """ """ if num_threads is not 1: diff --git a/halotools/mock_observables/two_point_clustering/angular_tpcf.py b/halotools/mock_observables/two_point_clustering/angular_tpcf.py index 41159dd89..bdae7e154 100644 --- a/halotools/mock_observables/two_point_clustering/angular_tpcf.py +++ b/halotools/mock_observables/two_point_clustering/angular_tpcf.py @@ -24,7 +24,7 @@ def angular_tpcf(sample1, theta_bins, sample2=None, randoms=None, - do_auto=True, do_cross=True, estimator='Natural', num_threads=1, seed=None): + do_auto=True, do_cross=True, estimator='Natural', num_threads=1): r""" Calculate the angular two-point correlation function, :math:`w(\theta)`. @@ -49,8 +49,8 @@ def angular_tpcf(sample1, theta_bins, sample2=None, randoms=None, randoms : array_like, optional Nran x 2 array containing ra,dec positions of points in degrees. If no randoms - are provided analytic randoms are used (only valid for for continious all-sky - converage). + are provided analytic randoms are used (only valid for for continuous all-sky + coverage). do_auto : boolean, optional Boolean determines whether the auto-correlation function will @@ -73,10 +73,6 @@ def angular_tpcf(sample1, theta_bins, sample2=None, randoms=None, never be instantiated. A string 'max' may be used to indicate that the pair counters should use all available cores on the machine. - seed : int, optional - Random number seed used to randomly downsample data, if applicable. - Default is None, in which case downsampling will be stochastic. - Returns ------- correlation_function(s) : numpy.array @@ -128,7 +124,7 @@ def angular_tpcf(sample1, theta_bins, sample2=None, randoms=None, # check input arguments using clustering helper functions function_args = (sample1, theta_bins, sample2, randoms, do_auto, do_cross, - estimator, num_threads, seed) + estimator, num_threads) # pass arguments in, and get out processed arguments, plus some control flow variables sample1, theta_bins, sample2, randoms, do_auto, do_cross, num_threads,\ @@ -188,6 +184,7 @@ def area_spherical_cap(chord): elif randoms is None: # set the number of randoms equal to the number of points in sample1 + # cbx: Maybe stupid question but why not use much more? Less noise at no cost right? NR = len(sample1) # do area calculations @@ -205,13 +202,14 @@ def area_spherical_cap(chord): D2R = N2*(da*rho2) # calculate the random-random pairs. + # cbx: This should be NR(NR-1) if we are doing an autocorr I think? Maybe it doesn't matter. rhor = NR**2/global_area RR = (da*rhor) return D1R, D2R, RR def pair_counts(sample1, sample2, chord_bins, - N_thread, do_auto, do_cross, _sample1_is_sample2): + num_threads, do_auto, do_cross, _sample1_is_sample2): """ Count data-data pairs. """ @@ -280,7 +278,7 @@ def pair_counts(sample1, sample2, chord_bins, def _angular_tpcf_process_args(sample1, theta_bins, sample2, randoms, - do_auto, do_cross, estimator, num_threads, seed): + do_auto, do_cross, estimator, num_threads): """ Private method to do bounds-checking on the arguments passed to `~halotools.mock_observables.angular_tpcf`. diff --git a/halotools/utils/probabilistic_binning.py b/halotools/utils/probabilistic_binning.py index 8fa58e913..39fc3cc96 100644 --- a/halotools/utils/probabilistic_binning.py +++ b/halotools/utils/probabilistic_binning.py @@ -26,7 +26,8 @@ def fuzzy_digitize(x, centroids, min_counts=2, seed=43): centroids : ndarray Numpy array of shape (num_centroids, ). The values of ``centroids`` must - strictly encompass the range of values spanned by ``x``. + strictly encompass the range of values spanned by ``x`` and must also be + monotonically increasing. min_counts : int, optional Minimum required number of elements assigned to each centroid. @@ -56,6 +57,7 @@ def fuzzy_digitize(x, centroids, min_counts=2, seed=43): .. image:: /_static/fuzzy_binning_example.png """ + assert np.all(np.diff(centroids) > 0), "centroids must be monotonically increasing" assert centroids[0] < x.min(), "smallest bin must be less than smallest element in x" assert centroids[-1] > x.max(), "largest bin must be less than largest element in x"