From c2b50bcd7095255de4d04185e0e46ecfad187919 Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Fri, 1 Nov 2019 02:26:19 -0700 Subject: [PATCH 01/10] first look --- .../catalog_analysis_helpers.py | 10 +-- .../conditional_cylindrical_isolation.py | 6 +- .../spherical_isolation.py | 4 +- .../large_scale_density_spherical_annulus.py | 8 +-- .../large_scale_density_spherical_volume.py | 14 ++--- .../mock_observables_helpers.py | 1 + .../mock_observables/occupation_stats.py | 27 +++++--- .../pair_counters/marked_npairs_3d.py | 34 ++++++----- .../pair_counters/npairs_3d.py | 16 ++--- .../pair_counters/npairs_jackknife_3d.py | 61 +++++++++---------- .../pair_counters/npairs_per_object_3d.py | 7 +-- .../pair_counters/npairs_s_mu.py | 7 +-- .../pairwise_velocities/los_pvd_vs_rp.py | 38 ++++++------ .../mean_radial_velocity_vs_r.py | 4 +- .../pairwise_velocities/radial_pvd_vs_r.py | 4 +- .../velocity_marked_npairs_3d.py | 7 +-- .../tensor_calculations/inertia_tensor.py | 2 +- .../two_point_clustering/angular_tpcf.py | 5 +- 18 files changed, 129 insertions(+), 126 deletions(-) diff --git a/halotools/mock_observables/catalog_analysis_helpers.py b/halotools/mock_observables/catalog_analysis_helpers.py index 547383b01..497694b05 100644 --- a/halotools/mock_observables/catalog_analysis_helpers.py +++ b/halotools/mock_observables/catalog_analysis_helpers.py @@ -131,7 +131,7 @@ def return_xyz_formatted_array(x, y, z, period=np.inf, galaxy positions under the distant-observer approximation. Default is no distortions. - cosmology : object, optional + cosmology : astropy.cosmology.Cosmology, optional Cosmology to assume when applying redshift-space distortions, e.g., the cosmology of the simulation. Default is set in `sim_manager.sim_defaults`. @@ -264,7 +264,7 @@ def apply_zspace_distortion(true_pos, peculiar_velocity, redshift, cosmology, Lb redshift of the snapshot. If using a lightcone, this argument is the redshift of each point. - cosmology : object + cosmology : astropy.cosmology.Cosmology Cosmology to assume when applying redshift-space distortions, e.g., the cosmology of the simulation. @@ -308,9 +308,9 @@ def cuboid_subvolume_labels(sample, Nsub, Lbox): Nsub : array_like Length-3 numpy array of integers indicating how many times to split the volume - along each dimension. If single integer, N, is supplied, ``Nsub`` is set to + along each dimension. If a single integer, N, is supplied, ``Nsub`` is set to [N,N,N], and the volume is split along each dimension N times. The total number - of subvolumes is then given by numpy.prod(Nsub). + of subvolumes is given by numpy.prod(Nsub). Lbox : array_like Length-3 numpy array definging the lengths of the sides of the cubical volume @@ -320,7 +320,7 @@ def cuboid_subvolume_labels(sample, Nsub, Lbox): Returns ------- labels : numpy.array - numpy array with integer labels in the range [1,numpy.prod(Nsub)] indicating + (Npts, ) numpy array with integer labels in the range [1,numpy.prod(Nsub)] indicating the subvolume each point in ``sample`` occupies. N_sub_vol : int diff --git a/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py b/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py index a2b2a7724..c34361743 100644 --- a/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py +++ b/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py @@ -60,7 +60,7 @@ def conditional_cylindrical_isolation(sample1, sample2, rp_max, pi_max, If a single float is given, ``rp_max`` is assumed to be the same for each galaxy in ``sample1``. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. - pi_max : float + pi_max : array_like half the length of cylinders to search for neighbors around galaxies in ``sample1``. If a single float is given, ``pi_max`` is assumed to be the same for each galaxy in ``sample1``. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. @@ -105,7 +105,7 @@ def conditional_cylindrical_isolation(sample1, sample2, rp_max, pi_max, The optimum choice unavoidably depends on the specs of your machine. Default choice is to use ``rp_max``/10 in the xy-dimensions and ``pi_max``/10 in the z-dimension, - which will return reasonable result performance for most use-cases. + which will return reasonable performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. @@ -117,7 +117,7 @@ def conditional_cylindrical_isolation(sample1, sample2, rp_max, pi_max, Returns ------- is_isolated : numpy.array - array of booleans indicating if each point in `sample1` is isolated. + (Npts1, ) array of booleans indicating if each point in `sample1` is isolated. Notes ----- diff --git a/halotools/mock_observables/isolation_functions/spherical_isolation.py b/halotools/mock_observables/isolation_functions/spherical_isolation.py index 59488047b..357b3c3c0 100644 --- a/halotools/mock_observables/isolation_functions/spherical_isolation.py +++ b/halotools/mock_observables/isolation_functions/spherical_isolation.py @@ -76,7 +76,7 @@ def spherical_isolation(sample1, sample2, r_max, period=None, will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use ``r_max``/10 in each dimension, - which will return reasonable result performance for most use-cases. + which will return reasonable performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. @@ -88,7 +88,7 @@ def spherical_isolation(sample1, sample2, r_max, period=None, Returns ------- is_isolated : numpy.array - array of booleans indicating if each point in `sample1` is isolated. + (Npts1, ) array of booleans indicating if each point in `sample1` is isolated. Examples -------- diff --git a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py index cb3df9e70..7379788d6 100644 --- a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py +++ b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py @@ -75,7 +75,7 @@ def large_scale_density_spherical_annulus(sample, tracers, inner_radius, outer_r will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable result performance for most use-cases. + which will return reasonable performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. @@ -88,7 +88,7 @@ def large_scale_density_spherical_annulus(sample, tracers, inner_radius, outer_r Returns -------- number_density : array_like - Length-Npts array of number densities + Length-Npts1 array of number densities Examples --------- @@ -105,9 +105,9 @@ def large_scale_density_spherical_annulus(sample, tracers, inner_radius, outer_r period, sample_volume, num_threads, approx_cell1_size) ) - _ = npairs_per_object_3d(sample, tracers, rbins, period=period, + result = npairs_per_object_3d(sample, tracers, rbins, period=period, num_threads=num_threads, approx_cell1_size=approx_cell1_size) - result = np.diff(_, axis=1) + result = np.diff(result, axis=1) environment_volume = (4/3.)*np.pi*(outer_radius**3 - inner_radius**3) number_density = result/environment_volume diff --git a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py index 8c012a5a4..9b3ea135f 100644 --- a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py +++ b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py @@ -18,6 +18,7 @@ np.seterr(divide='ignore', invalid='ignore') # ignore divide by zero in e.g. DD/RR +# cbx: I think all the code here could pretty easily be replaced with that of `large_scale_density_spherical_annulus` def large_scale_density_spherical_volume(sample, tracers, radius, period=None, sample_volume=None, num_threads=1, approx_cell1_size=None, norm_by_mean_density=False): @@ -74,7 +75,7 @@ def large_scale_density_spherical_volume(sample, tracers, radius, will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable result performance for most use-cases. + which will return reasonable performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. @@ -87,7 +88,7 @@ def large_scale_density_spherical_volume(sample, tracers, radius, Returns -------- number_density : array_like - Length-Npts array of number densities + Length-Npts1 array of number densities Examples --------- @@ -103,9 +104,8 @@ def large_scale_density_spherical_volume(sample, tracers, radius, sample, tracers, radius, period, sample_volume, num_threads, approx_cell1_size) ) - _ = npairs_per_object_3d(sample, tracers, rbins, period=period, - num_threads=num_threads, approx_cell1_size=approx_cell1_size) - result = _[:, 0] + result = npairs_per_object_3d(sample, tracers, rbins, period=period, + num_threads=num_threads, approx_cell1_size=approx_cell1_size)[:, 0] environment_volume = (4/3.)*np.pi*radius**3 number_density = result/environment_volume @@ -123,8 +123,8 @@ def _large_scale_density_spherical_volume_process_args( """ sample = np.atleast_1d(sample) tracers = np.atleast_1d(tracers) - _ = np.atleast_1d(radius).astype(float) - rbins = np.append(_, _[0]+0.0001) + rbins = np.atleast_1d(radius).astype(float) + rbins = np.append(rbins, rbins[0]+0.0001) if period is None: if sample_volume is None: diff --git a/halotools/mock_observables/mock_observables_helpers.py b/halotools/mock_observables/mock_observables_helpers.py index 7e93a728c..34abaa77f 100644 --- a/halotools/mock_observables/mock_observables_helpers.py +++ b/halotools/mock_observables/mock_observables_helpers.py @@ -143,6 +143,7 @@ def get_separation_bins_array(separation_bins): try: assert separation_bins.ndim == 1 assert len(separation_bins) > 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..32da48d13 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_per_object_3d.py b/halotools/mock_observables/pair_counters/npairs_per_object_3d.py index 4abc8a355..b25a1fcbb 100644 --- a/halotools/mock_observables/pair_counters/npairs_per_object_3d.py +++ b/halotools/mock_observables/pair_counters/npairs_per_object_3d.py @@ -17,7 +17,7 @@ def npairs_per_object_3d(sample1, sample2, rbins, period=None, - verbose=False, num_threads=1, + num_threads=1, approx_cell1_size=None, approx_cell2_size=None): """ Function counts the number of points in ``sample2`` separated by a distance @@ -48,9 +48,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 +102,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_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/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..1d09fc0c3 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, None) sample1, velocities1, sample2, velocities2, max_rbins_absolute, period,\ num_threads, _sample1_is_sample2, PBCs, \ 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..2185df771 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, None) 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..058b567b5 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)`. @@ -68,9 +68,6 @@ def velocity_marked_npairs_3d(sample1, sample2, rbins, period=None, 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 diff --git a/halotools/mock_observables/tensor_calculations/inertia_tensor.py b/halotools/mock_observables/tensor_calculations/inertia_tensor.py index f0dd57c47..35cc65c5e 100644 --- a/halotools/mock_observables/tensor_calculations/inertia_tensor.py +++ b/halotools/mock_observables/tensor_calculations/inertia_tensor.py @@ -93,7 +93,7 @@ def inertia_tensor_per_object(sample1, sample2, weights2, smoothing_scale, The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable result performance for most use-cases. + which will return reasonable performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. diff --git a/halotools/mock_observables/two_point_clustering/angular_tpcf.py b/halotools/mock_observables/two_point_clustering/angular_tpcf.py index 41159dd89..5b7e1f165 100644 --- a/halotools/mock_observables/two_point_clustering/angular_tpcf.py +++ b/halotools/mock_observables/two_point_clustering/angular_tpcf.py @@ -188,6 +188,7 @@ def area_spherical_cap(chord): elif randoms is None: # set the number of randoms equal to the number of points in sample1 + # cbx: Why not use much more? Less noise at no cost right? NR = len(sample1) # do area calculations @@ -205,13 +206,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 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. """ @@ -241,6 +243,7 @@ def pair_counts(sample1, sample2, chord_bins, return D1D1, D1D2, D2D2 # What needs to be done? + # cbx: do_DD is never used do_DD, do_DR, do_RR = _TP_estimator_requirements(estimator) # How many points are there (for normalization purposes)? From d57974cac5b93b6e7dfaff05573b242a694f6c0d Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Fri, 1 Nov 2019 02:48:44 -0700 Subject: [PATCH 02/10] first draft at getting started docs --- docs/index.rst | 1 + .../development/getting_started.rst | 27 +++++++++++++++++++ .../development/index.rst | 1 + 3 files changed, 29 insertions(+) create mode 100644 docs/quickstart_and_tutorials/development/getting_started.rst 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..77c002787 --- /dev/null +++ b/docs/quickstart_and_tutorials/development/getting_started.rst @@ -0,0 +1,27 @@ +.. _getting_started: + +************************* +Contributing to Halotools +************************* + +All halotools development happens in the github repository. To contribute, first clone the repo. +Then install the dependencies listed on the *installation* page. + +Halotools contains a compiled component. To compile all `.pyx` files inplace run + +``` +python3 setup.py build_ext --inplace +``` + +Halotools also has comprehensive unit tests using pytest. From the base of the repository first cd +into the source tree, then run `pytest`. + +``` +cd halotools +pytest +``` + +If you have made a change and only want to run a subset of tests run +``` +pytest -k name_of_test_to_run +``` 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 From 82f2d2f62325e8e6c7b27f616ddf802966033127 Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Fri, 1 Nov 2019 12:21:13 -0700 Subject: [PATCH 03/10] more docs --- .../development/getting_started.rst | 53 +++++++++++++------ .../pair_counters/npairs_3d.py | 2 + .../pair_counters/weighted_npairs_s_mu.py | 7 +-- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/docs/quickstart_and_tutorials/development/getting_started.rst b/docs/quickstart_and_tutorials/development/getting_started.rst index 77c002787..ce1e5f883 100644 --- a/docs/quickstart_and_tutorials/development/getting_started.rst +++ b/docs/quickstart_and_tutorials/development/getting_started.rst @@ -5,23 +5,46 @@ Contributing to Halotools ************************* All halotools development happens in the github repository. To contribute, first clone the repo. -Then install the dependencies listed on the *installation* page. +Then install the dependencies listed on the :ref:`step_by_step_install` page. -Halotools contains a compiled component. To compile all `.pyx` files inplace run -``` -python3 setup.py build_ext --inplace -``` +Code +==== -Halotools also has comprehensive unit tests using pytest. From the base of the repository first cd -into the source tree, then run `pytest`. +Halotools contains a compiled component. To compile all cython (``.pyx``) files inplace run, :: -``` -cd halotools -pytest -``` + 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. In the built directory run, :: + + python3 -m http.server + +The docs should then be viewable at ``localhost:8000`` (the port will be logged when you start the server). -If you have made a change and only want to run a subset of tests run -``` -pytest -k name_of_test_to_run -``` diff --git a/halotools/mock_observables/pair_counters/npairs_3d.py b/halotools/mock_observables/pair_counters/npairs_3d.py index 6e440fff5..4b395fedf 100644 --- a/halotools/mock_observables/pair_counters/npairs_3d.py +++ b/halotools/mock_observables/pair_counters/npairs_3d.py @@ -152,6 +152,8 @@ def npairs_3d(sample1, sample2, rbins, period=None, def _npairs_3d_process_args(sample1, sample2, rbins, period, num_threads, approx_cell1_size, approx_cell2_size): + """ + """ if num_threads is not 1: if num_threads == 'max': num_threads = multiprocessing.cpu_count() 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..678fa43f7 100644 --- a/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py +++ b/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py @@ -18,7 +18,7 @@ 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 @@ -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 From 96a761c4eb526d5f2fc8f94d0d1fbf6aaf12e583 Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Sat, 2 Nov 2019 02:50:26 -0700 Subject: [PATCH 04/10] lots of unused verbose --- .../development/getting_started.rst | 1 - .../pair_counters/marked_npairs_xy_z.py | 7 ++----- .../pair_counters/npairs_jackknife_xy_z.py | 7 ++----- .../pair_counters/npairs_per_object_3d.py | 3 +-- .../pair_counters/npairs_projected.py | 10 +++------- .../mock_observables/pair_counters/npairs_xy_z.py | 10 +++------- .../velocity_marked_npairs_xy_z.py | 11 +++-------- .../surface_density/weighted_npairs_per_object_xy.py | 5 ++--- .../surface_density/weighted_npairs_xy.py | 7 +++---- 9 files changed, 19 insertions(+), 42 deletions(-) diff --git a/docs/quickstart_and_tutorials/development/getting_started.rst b/docs/quickstart_and_tutorials/development/getting_started.rst index ce1e5f883..5c2f4b279 100644 --- a/docs/quickstart_and_tutorials/development/getting_started.rst +++ b/docs/quickstart_and_tutorials/development/getting_started.rst @@ -47,4 +47,3 @@ You can see the built documentation in ``docs/_build/html/``. The easiest way to 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/halotools/mock_observables/pair_counters/marked_npairs_xy_z.py b/halotools/mock_observables/pair_counters/marked_npairs_xy_z.py index 26dc75272..f2a5b9e6a 100644 --- a/halotools/mock_observables/pair_counters/marked_npairs_xy_z.py +++ b/halotools/mock_observables/pair_counters/marked_npairs_xy_z.py @@ -21,7 +21,7 @@ def marked_npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, weights1=None, weights2=None, - weight_func_id=0, verbose=False, num_threads=1, + weight_func_id=0, num_threads=1, approx_cell1_size=None, approx_cell2_size=None): r""" Calculate the number of weighted pairs with separations greater than @@ -77,9 +77,6 @@ def marked_npairs_xy_z(sample1, sample2, rp_bins, pi_bins, 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 @@ -116,7 +113,7 @@ def marked_npairs_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 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..cc5c819d7 100644 --- a/halotools/mock_observables/pair_counters/npairs_jackknife_xy_z.py +++ b/halotools/mock_observables/pair_counters/npairs_jackknife_xy_z.py @@ -22,7 +22,7 @@ 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=None, jtags2=None, N_samples=0, 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 @@ -77,9 +77,6 @@ def npairs_jackknife_xy_z(sample1, sample2, rp_bins, pi_bins, 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. - 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_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 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 b25a1fcbb..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, - 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``. 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_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/pairwise_velocities/velocity_marked_npairs_xy_z.py b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_xy_z.py index 03b958a53..c822b670d 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 @@ -76,9 +74,6 @@ def velocity_marked_npairs_xy_z(sample1, sample2, rp_bins, pi_bins, period=None, 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..e25d91ae7 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 @@ -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..39cf13304 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 @@ -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: From 63db1c8d765f286c96a75c8dd74e3c78d6435292 Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Tue, 12 Nov 2019 12:28:00 -0800 Subject: [PATCH 05/10] some other stuff... --- .../pair_counters/npairs_jackknife_xy_z.py | 50 ++++++++----------- .../pair_counters/weighted_npairs_s_mu.py | 4 +- .../velocity_marked_npairs_3d_engine.pyx | 2 +- .../engines/velocity_marking_functions.pyx | 8 +-- .../velocity_marked_npairs_3d.py | 13 ++--- .../velocity_marked_npairs_xy_z.py | 10 ++-- .../weighted_npairs_per_object_xy.py | 4 +- .../surface_density/weighted_npairs_xy.py | 4 +- 8 files changed, 45 insertions(+), 50 deletions(-) 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 cc5c819d7..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, 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,31 +52,31 @@ 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]. + 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 using the python ``multiprocessing`` module. Default is 1 for a purely serial @@ -220,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/weighted_npairs_s_mu.py b/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py index 678fa43f7..cbfec481a 100644 --- a/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py +++ b/halotools/mock_observables/pair_counters/weighted_npairs_s_mu.py @@ -21,10 +21,10 @@ def weighted_npairs_s_mu(sample1, sample2, weights1, weights2, s_bins, mu_bins, 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 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/velocity_marked_npairs_3d.py b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py index 058b567b5..b5a190d85 100644 --- a/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py +++ b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py @@ -54,14 +54,14 @@ 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 @@ -200,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") @@ -241,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") @@ -289,6 +289,7 @@ def _func_signature_int_from_vel_weight_func_id(weight_func_id): msg = "\n weight_func_id parameter must be an integer ID of a weighting function." raise HalotoolsError(msg) + # cbx: seriousl you need 6 weights? elif weight_func_id == 1: return 6 elif weight_func_id == 2: 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 c822b670d..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 @@ -48,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. @@ -60,14 +60,14 @@ 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 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 e25d91ae7..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 @@ -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. diff --git a/halotools/mock_observables/surface_density/weighted_npairs_xy.py b/halotools/mock_observables/surface_density/weighted_npairs_xy.py index 39cf13304..d4a114614 100644 --- a/halotools/mock_observables/surface_density/weighted_npairs_xy.py +++ b/halotools/mock_observables/surface_density/weighted_npairs_xy.py @@ -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. From b74a1ecaaee1a80de15913b5e2db61d4733f1be4 Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Tue, 26 Nov 2019 23:25:51 -0800 Subject: [PATCH 06/10] more info in CAM docs --- .../development/getting_started.rst | 2 +- .../empirical_models/abunmatch/bin_free_cam.py | 18 ++++++++++-------- .../abunmatch/noisy_percentile.py | 2 +- .../pair_counters/pairwise_distance_3d.py | 2 +- .../pair_counters/pairwise_distance_xy_z.py | 2 +- .../two_point_clustering/angular_tpcf.py | 14 +++++--------- halotools/utils/probabilistic_binning.py | 4 +++- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/quickstart_and_tutorials/development/getting_started.rst b/docs/quickstart_and_tutorials/development/getting_started.rst index 5c2f4b279..40e8d3f3a 100644 --- a/docs/quickstart_and_tutorials/development/getting_started.rst +++ b/docs/quickstart_and_tutorials/development/getting_started.rst @@ -42,7 +42,7 @@ 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. In the built directory run, :: +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 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( 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" From d2b810b21fa916276c31f2fa9f2feb01c97a2d57 Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Tue, 26 Nov 2019 23:30:18 -0800 Subject: [PATCH 07/10] Remove changes to approx_cell1_size --- .../isolation_functions/conditional_cylindrical_isolation.py | 2 +- .../mock_observables/isolation_functions/spherical_isolation.py | 2 +- .../large_scale_density_spherical_annulus.py | 2 +- .../large_scale_density/large_scale_density_spherical_volume.py | 2 +- halotools/mock_observables/pair_counters/marked_npairs_3d.py | 2 +- halotools/mock_observables/pair_counters/npairs_3d.py | 2 +- .../mock_observables/tensor_calculations/inertia_tensor.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py b/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py index c34361743..d3088849f 100644 --- a/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py +++ b/halotools/mock_observables/isolation_functions/conditional_cylindrical_isolation.py @@ -105,7 +105,7 @@ def conditional_cylindrical_isolation(sample1, sample2, rp_max, pi_max, The optimum choice unavoidably depends on the specs of your machine. Default choice is to use ``rp_max``/10 in the xy-dimensions and ``pi_max``/10 in the z-dimension, - which will return reasonable performance for most use-cases. + which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. diff --git a/halotools/mock_observables/isolation_functions/spherical_isolation.py b/halotools/mock_observables/isolation_functions/spherical_isolation.py index 357b3c3c0..9e2034440 100644 --- a/halotools/mock_observables/isolation_functions/spherical_isolation.py +++ b/halotools/mock_observables/isolation_functions/spherical_isolation.py @@ -76,7 +76,7 @@ def spherical_isolation(sample1, sample2, r_max, period=None, will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use ``r_max``/10 in each dimension, - which will return reasonable performance for most use-cases. + which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. diff --git a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py index 7379788d6..c753000c4 100644 --- a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py +++ b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_annulus.py @@ -75,7 +75,7 @@ def large_scale_density_spherical_annulus(sample, tracers, inner_radius, outer_r will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable performance for most use-cases. + which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. diff --git a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py index 9b3ea135f..7557b77fc 100644 --- a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py +++ b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py @@ -75,7 +75,7 @@ def large_scale_density_spherical_volume(sample, tracers, radius, will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable performance for most use-cases. + which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. diff --git a/halotools/mock_observables/pair_counters/marked_npairs_3d.py b/halotools/mock_observables/pair_counters/marked_npairs_3d.py index 32da48d13..2d1320686 100644 --- a/halotools/mock_observables/pair_counters/marked_npairs_3d.py +++ b/halotools/mock_observables/pair_counters/marked_npairs_3d.py @@ -88,7 +88,7 @@ def marked_npairs_3d(sample1, sample2, rbins, weight_func_id, will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable performance for most use-cases. + which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. diff --git a/halotools/mock_observables/pair_counters/npairs_3d.py b/halotools/mock_observables/pair_counters/npairs_3d.py index 4b395fedf..3e7d6661d 100644 --- a/halotools/mock_observables/pair_counters/npairs_3d.py +++ b/halotools/mock_observables/pair_counters/npairs_3d.py @@ -67,7 +67,7 @@ def npairs_3d(sample1, sample2, rbins, period=None, will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable performance for most use-cases. + which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. diff --git a/halotools/mock_observables/tensor_calculations/inertia_tensor.py b/halotools/mock_observables/tensor_calculations/inertia_tensor.py index 35cc65c5e..f0dd57c47 100644 --- a/halotools/mock_observables/tensor_calculations/inertia_tensor.py +++ b/halotools/mock_observables/tensor_calculations/inertia_tensor.py @@ -93,7 +93,7 @@ def inertia_tensor_per_object(sample1, sample2, weights2, smoothing_scale, The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, - which will return reasonable performance for most use-cases. + which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. From 65bcb335b9530556b73ecf8e96ea43e934844187 Mon Sep 17 00:00:00 2001 From: Christopher Bradshaw Date: Wed, 27 Nov 2019 00:55:37 -0800 Subject: [PATCH 08/10] cleanup comments to self --- .../large_scale_density_spherical_volume.py | 1 - .../pairwise_velocities/mean_radial_velocity_vs_r.py | 4 ++-- .../mock_observables/pairwise_velocities/radial_pvd_vs_r.py | 2 +- .../pairwise_velocities/velocity_marked_npairs_3d.py | 1 - .../mock_observables/two_point_clustering/angular_tpcf.py | 5 ++--- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py index 7557b77fc..80860fe79 100644 --- a/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py +++ b/halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py @@ -18,7 +18,6 @@ np.seterr(divide='ignore', invalid='ignore') # ignore divide by zero in e.g. DD/RR -# cbx: I think all the code here could pretty easily be replaced with that of `large_scale_density_spherical_annulus` def large_scale_density_spherical_volume(sample, tracers, radius, period=None, sample_volume=None, num_threads=1, approx_cell1_size=None, norm_by_mean_density=False): 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 1d09fc0c3..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 @@ -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, None) + 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 2185df771..f23e14354 100644 --- a/halotools/mock_observables/pairwise_velocities/radial_pvd_vs_r.py +++ b/halotools/mock_observables/pairwise_velocities/radial_pvd_vs_r.py @@ -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, None) + 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 b5a190d85..26145e323 100644 --- a/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py +++ b/halotools/mock_observables/pairwise_velocities/velocity_marked_npairs_3d.py @@ -289,7 +289,6 @@ def _func_signature_int_from_vel_weight_func_id(weight_func_id): msg = "\n weight_func_id parameter must be an integer ID of a weighting function." raise HalotoolsError(msg) - # cbx: seriousl you need 6 weights? elif weight_func_id == 1: return 6 elif weight_func_id == 2: diff --git a/halotools/mock_observables/two_point_clustering/angular_tpcf.py b/halotools/mock_observables/two_point_clustering/angular_tpcf.py index 8a602e995..bdae7e154 100644 --- a/halotools/mock_observables/two_point_clustering/angular_tpcf.py +++ b/halotools/mock_observables/two_point_clustering/angular_tpcf.py @@ -184,7 +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: Why not use much more? Less noise at no cost right? + # cbx: Maybe stupid question but why not use much more? Less noise at no cost right? NR = len(sample1) # do area calculations @@ -202,7 +202,7 @@ 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 + # 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) @@ -239,7 +239,6 @@ def pair_counts(sample1, sample2, chord_bins, return D1D1, D1D2, D2D2 # What needs to be done? - # cbx: do_DD is never used do_DD, do_DR, do_RR = _TP_estimator_requirements(estimator) # How many points are there (for normalization purposes)? From c00a984e722435fb8e9f7bb5a004816fe29cfe35 Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 7 Jan 2020 12:11:16 -0600 Subject: [PATCH 09/10] Resolved duplicate getting_started label --- docs/quickstart_and_tutorials/development/getting_started.rst | 2 +- docs/quickstart_and_tutorials/development/index.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/quickstart_and_tutorials/development/getting_started.rst b/docs/quickstart_and_tutorials/development/getting_started.rst index 40e8d3f3a..af71fec83 100644 --- a/docs/quickstart_and_tutorials/development/getting_started.rst +++ b/docs/quickstart_and_tutorials/development/getting_started.rst @@ -1,4 +1,4 @@ -.. _getting_started: +.. _getting_started_developers: ************************* Contributing to Halotools diff --git a/docs/quickstart_and_tutorials/development/index.rst b/docs/quickstart_and_tutorials/development/index.rst index 60a39a33b..0194ab27e 100644 --- a/docs/quickstart_and_tutorials/development/index.rst +++ b/docs/quickstart_and_tutorials/development/index.rst @@ -15,5 +15,6 @@ contribute to the Halotools code base. staying_up_to_date bug_reports getting_started + getting_started_developers contributors ../../changelog From f8c7372ebf42150d52e885d150c5c02a6a288ffb Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 7 Jan 2020 12:38:28 -0600 Subject: [PATCH 10/10] Fixed sphinx reference bug --- docs/quickstart_and_tutorials/development/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/quickstart_and_tutorials/development/index.rst b/docs/quickstart_and_tutorials/development/index.rst index 0194ab27e..60a39a33b 100644 --- a/docs/quickstart_and_tutorials/development/index.rst +++ b/docs/quickstart_and_tutorials/development/index.rst @@ -15,6 +15,5 @@ contribute to the Halotools code base. staying_up_to_date bug_reports getting_started - getting_started_developers contributors ../../changelog