From b44b7ad23463d8bb230025070a9a3f6dd93d8451 Mon Sep 17 00:00:00 2001 From: Carl Christofferson Date: Wed, 19 Jul 2023 08:13:53 -0700 Subject: [PATCH] switched random cluster generator to astropy.coordinates.uniform_spherical_random_surface --- src/kbmod/regionsearch/utilities.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kbmod/regionsearch/utilities.py b/src/kbmod/regionsearch/utilities.py index e852010..176a0ab 100644 --- a/src/kbmod/regionsearch/utilities.py +++ b/src/kbmod/regionsearch/utilities.py @@ -10,6 +10,7 @@ EarthLocation, SkyCoord, solar_system_ephemeris, + uniform_spherical_random_surface, ) @@ -80,7 +81,7 @@ def __init__( The version is checked when reading the file. """ # See https://docs.astropy.org/en/stable/io/unified.html#table-serialization-methods - self.version = "1" + self.version = "2" # seed for random number generator self.seed = seed # number of clusters in test @@ -248,9 +249,11 @@ def _generate_data(self): self.clusterdistances = [2] self.clusterdistances.extend([random.randrange(2, 10000) for _ in range(self.clustercnt - 1)]) - clusters = [[random.uniform(0.0, 360.0), random.uniform(0, 180.0)] for _ in range(self.clustercnt)] - - self.clusters = [[i[0] - 180.0, i[1] - 90.0] for i in clusters] + _clusters = uniform_spherical_random_surface(self.clustercnt) + self.clusters = [ + [i.value - 180.0, j.value] for i, j in zip(_clusters.lon.to(u.deg), _clusters.lat.to(u.deg)) + ] + clusters = np.stack([_clusters.lon.to(u.deg).value, _clusters.lat.to(u.deg).value + 90.0], axis=1) # the number of rows in the test dataset self.rowcnt = self.clustercnt * self.samplespercluster