Skip to content

Commit

Permalink
made output_density_shell_maps optional
Browse files Browse the repository at this point in the history
  • Loading branch information
elvinpoole committed Mar 25, 2024
1 parent 9ce41fb commit 7b8b465
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions txpipe/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TXLogNormalGlass(PipelineStage):
("lens_tomography_catalog_unweighted", TomographyCatalog),
("glass_cl_shells", HDFFile),
("glass_cl_binned", HDFFile),
("density_shell_maps", HDFFile),
("density_shells", HDFFile),
# TO DO: add shear maps
]

Expand All @@ -59,6 +59,7 @@ class TXLogNormalGlass(PipelineStage):
"ell_binned_min": 0.1,
"ell_binned_max": 5.0e5,
"ell_binned_nbins": 100,
"output_density_shell_maps":False,
}

def run(self):
Expand Down Expand Up @@ -432,13 +433,14 @@ def setup_output(self):
group.create_dataset("counts_2d", (1,), dtype="i")
self.tomo_output = tomo_output

density_shell_output = self.open_output("density_shell_maps")
group = density_shell_output.create_group("density_shell_maps")
fullsky_npix = hp.nside2npix(self.nside)
for ishell in range(self.nshells):
group.create_dataset(
f"shell{ishell}", (fullsky_npix,), dtype="f"
)
density_shell_output = self.open_output("density_shells")
if self.config["output_density_shell_maps"]:
group = density_shell_output.create_group("density_shell_maps")
fullsky_npix = hp.nside2npix(self.nside)
for ishell in range(self.nshells):
group.create_dataset(
f"shell{ishell}", (fullsky_npix,), dtype="f"
)
group = density_shell_output.create_group("num_dens_shell")
group.create_dataset(
f"num_dens_shell", (self.nbin_lens, self.nshells), dtype="f"
Expand All @@ -452,8 +454,9 @@ def write_shell_output(self, ishell, delta_i, ngal_in_shell, zeff_shell):
"""
write a single density shell to output
"""
group = self.density_shell_output['density_shell_maps']
group[f"shell{ishell}"][:] = delta_i
if self.config["output_density_shell_maps"]:
group = self.density_shell_output['density_shell_maps']
group[f"shell{ishell}"][:] = delta_i

group = self.density_shell_output['num_dens_shell']
group["num_dens_shell"][:,ishell] = ngal_in_shell
Expand Down

0 comments on commit 7b8b465

Please sign in to comment.