Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for hex and grid layout for DeblendedGalaxy #191

Merged
merged 16 commits into from
Dec 5, 2023
Merged
Changes from 3 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
24 changes: 16 additions & 8 deletions descwl_shear_sims/galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,14 +599,19 @@ def __init__(self, *, rng, coadd_dim, buff=0, layout='random'):
# one square degree catalog, convert to arcmin
gal_dens = self._wldeblend_cat.size / (60 * 60)
if layout == 'random':
# need to calculate number of objects first
# this layout is random in a square
if (coadd_dim - 2*buff) < 2:
warnings.warn("dim - 2*buff <= 2, force it to 2.")
area = (2**SCALE/60)**2.
else:
area = ((coadd_dim - 2*buff)*SCALE/60)**2

print("The area is of the simulation is %.2f arcmin2" % area)
mr-superonion marked this conversation as resolved.
Show resolved Hide resolved
# a least 1 expected galaxy (used for simple tests)
nobj_mean = max(area * gal_dens, 1)
nobj = rng.poisson(nobj_mean)
elif layout == 'random_disk':
# need to calculate number of objects first
# this layout is random in a circle
if (coadd_dim - 2*buff) < 2:
warnings.warn("dim - 2*buff <= 2, force it to 2.")
Expand All @@ -616,14 +621,17 @@ def __init__(self, *, rng, coadd_dim, buff=0, layout='random'):
radius = (coadd_dim/2. - buff)*SCALE/60
area = np.pi*radius**2
del radius
print("The area is of the simulation is %.2f arcmin2" % area)
mr-superonion marked this conversation as resolved.
Show resolved Hide resolved
# a least 1 expected galaxy (used for simple tests)
nobj_mean = max(area * gal_dens, 1)
nobj = rng.poisson(nobj_mean)
elif layout == "hex":
nobj = None
elif layout == "grid":
nobj = None
else:
raise ValueError("layout can only be 'random' or 'random_disk' \
for wldeblend")

# a least 1 expected galaxy (used for simple tests)
nobj_mean = max(area * gal_dens, 1)

nobj = rng.poisson(nobj_mean)
raise ValueError("layout can only be 'random', 'random_disk' \
'hex' or 'grid 'for wldeblend")

self.shifts_array = get_shifts(
rng=rng,
Expand Down