27 """A Config class that holds some of the parameters supported by treecorr.
29 The fields in this class correspond to the parameters that can be passed to
30 any calls to `treecorr` methods, including catalog creation and two-point
31 correlation function calculations. The default values set for the fields
32 are identical to the default values set in v4.3 of `treecorr`.
34 A separate config class is used instead
35 of constructing a `~lsst.pex.config.DictField` so that mixed types can be
36 supported and the config can be validated at the beginning of the
41 This is intended to be used with correlations of PSF residuals. It only supports
42 some of the fields that are relevant for rho-statistics calculations and the likes
48 "How many bins to use. "
49 "(Exactly three of nbins, bin_size, min_sep, max_sep "
50 "are required. If nbins is not given, it will be "
51 "calculated from the values of the other three, "
52 "rounding up to the next highest integer. "
53 "In this case, bin_size will be readjusted to account "
54 "for this rounding up."
57 check=
lambda x: x > 0,
60 bin_size = Field[float](
62 "The width of the bins in log(separation). "
63 "Exactly three of nbins, bin_size, min_sep, max_sep are required. "
64 "If bin_size is not given, it will be calculated from the values "
70 min_sep = Field[float](
72 "The minimum separation in units of sep_units, if relevant. "
73 "Exactly three of nbins, bin_size, min_sep, max_sep are required. "
74 "If min_sep is not given, it will be calculated from the values "
80 max_sep = Field[float](
82 "The maximum separation in units of sep_units, if relevant. "
83 "Exactly three of nbins, bin_size, min_sep, max_sep are required. "
84 "If max_sep is not given, it will be calculated from the values "
90 sep_units = ChoiceField[str](
92 "The units to use for the separation values, given as a string. "
93 "This includes both min_sep and max_sep above, as well as the "
94 "units of the output distance values."
99 units: units
for units
in [
"arcsec",
"arcmin",
"degree",
"hour",
"radian"]
103 bin_slop = Field[float](
105 "How much slop to allow in the placement of pairs in the bins. "
106 "If bin_slop = 1, then the bin into which a particular pair is "
107 "placed may be incorrect by at most 1.0 bin widths. "
108 r"If None, use a bin_slop that gives a maximum error of 10% on "
109 "any bin, which has been found to yield good results for most "
116 precision = Field[int](
118 "The precision to use for the output values. This specifies how many digits to write."
122 check=
lambda x: x > 0,
125 metric = ChoiceField[str](
127 "Which metric to use for distance measurements. For details, see "
128 "https://rmjarvis.github.io/TreeCorr/_build/html/metric.html"
133 "Euclidean":
"straight-line Euclidean distance between two points",
135 "the perpendicular component of the distance, "
136 "following the definitions in "
137 "Fisher et al, 1994 (MNRAS, 267, 927)"
140 "the perpendicular component of the distance using the "
141 "definition of Rperp from TreeCorr v3.x."
144 "Distance from the first object (taken to be a lens) to "
145 "the line connecting Earth and the second object "
146 "(taken to be a lensed source)."
148 "Arc":
"the true great circle distance for spherical coordinates.",
149 "Periodic":
"Like ``Euclidean``, but with periodic boundaries.",
153 bin_type = ChoiceField[str](
154 doc=
"What type of binning should be used?",
159 "Logarithmic binning in the distance. The bin steps will "
160 "be uniform in log(r) from log(min_sep) .. log(max_sep)."
163 "Linear binning in the distance. The bin steps will be "
164 "uniform in r from min_sep .. max_sep."
167 "2-dimensional binning from x = (-max_sep .. max_sep) "
168 "and y = (-max_sep .. max_sep). The bin steps will be "
169 "uniform in both x and y. (i.e. linear in x,y)"
174 var_method = ChoiceField[str](
175 doc=
"Which method to use for estimating the variance",
191 doc=
"How many patches to split the catalog into for the purpose of "
192 "jackknife variance or other options that involve running via "
193 "patches (boostrap, marked_boostrap etc.)",
198 num_bootstrap = Field[int](
200 "How many bootstrap samples to use for the 'bootstrap' and 'marked_bootstrap' var methods."
206 rng_seed = Field[int](
207 doc=
"Value to seed the treecorr random number generator with. Used to generate patches.",
215 num_req_params = sum(param
is not None for param
in req_params)
216 if num_req_params != 3:
218 "You must specify exactly three of ``nbins``, ``bin_size``, ``min_sep`` and ``max_sep``"
219 f
" in treecorr_config. {num_req_params} parameters were set instead."
221 raise FieldValidationError(self.__class__.bin_size, self, msg)
225 raise FieldValidationError(
226 self.__class__.min_sep, self,
"min_sep must be <= max_sep"