Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/cfis/config_tile_PiViVi_canfar_sx.ini
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ POSITION_PARAMS = XWIN_WORLD,YWIN_WORLD
GET_SHAPES = True

# Number of stars threshold
STAR_THRESH = 20
STAR_THRESH = 22

# chi^2 threshold
CHI2_THRESH = 2
Expand Down
2 changes: 1 addition & 1 deletion example/cfis/config_tile_PiViVi_canfar_uc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ POSITION_PARAMS = XWIN_WORLD,YWIN_WORLD
GET_SHAPES = True

# Number of stars threshold
STAR_THRESH = 20
STAR_THRESH = 22

# chi^2 threshold
CHI2_THRESH = 2
Expand Down
19 changes: 12 additions & 7 deletions src/shapepipe/modules/setools_package/setools.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,18 @@ def _make_rand_split(self):

cat_size = len(np.where(mask)[0])
n_keep = int(np.ceil(cat_size * ratio))
mask_ratio = []
mask_left = list(range(0, cat_size))
while len(mask_ratio) != n_keep:
idx = np.random.randint(0, len(mask_left))
mask_ratio.append(mask_left.pop(idx))
mask_ratio = np.array(mask_ratio)
mask_left = np.array(mask_left)
# Deterministic split, seeded from the unit's file number: the
# train/validation assignment is a pure function of the input
# catalogue, so the PSF star sample (and everything downstream
# of the PSF model) is reproducible run-to-run. An unseeded
# np.random here made the shear catalogue non-reproducible
# upstream of ngmix's own position seeding.
seed = int(
re.sub(r"\D", "", self._file_number_string) or 0
) % (2 ** 32)
perm = np.random.RandomState(seed).permutation(cat_size)
mask_ratio = perm[:n_keep]
mask_left = np.sort(perm[n_keep:])
self.rand_split[key]["mask"] = mask
self.rand_split[key][f"ratio_{int(ratio * 100)}"] = mask_ratio
self.rand_split[key][f"ratio_{100 - int(ratio * 100)}"] = mask_left
Expand Down
Loading