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

Feature/coaddmask #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
15 changes: 12 additions & 3 deletions hips/draw/paint.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ def _make_empty_sky_image(self):
def draw_all_tiles(self):
"""Make an empty sky image and draw all the tiles."""
image = self._make_empty_sky_image()
"""Make a coadd mask"""
coadds = self._make_empty_sky_image()
if self.progress_bar:
from tqdm import tqdm
tiles = tqdm(self.draw_tiles, desc='Drawing tiles')
Expand All @@ -198,12 +200,19 @@ def draw_all_tiles(self):

for tile in tiles:
tile_image = self.warp_image(tile)
# TODO: put better algorithm here instead of summing pixels
# this can lead to pixels that are painted twice and become to bright
image += tile_image
# The mask has a value of 1 wherever there is positive flux
# mask = image > 0.0
mask = np.where(tile_image > 0.0, 1, 0)
coadds += mask

# import matplotlib.pyplot as plt
# plt.imshow(coadds)

# TODO: use the mask to interpolate across the healpix seams rather than divide

# Store the result
self.float_image = image
self.float_image = np.divide(image, coadds, where=coadds != 0)

def plot_mpl_hips_tile_grid(self) -> None:
"""Plot output image and HiPS grid with matplotlib.
Expand Down
4 changes: 2 additions & 2 deletions hips/draw/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ def write_image(self, filename: str, overwrite: bool = False) -> None:

if self.tile_format == 'fits':
hdu = fits.PrimaryHDU(data=self.image, header=self.geometry.fits_header)
hdu.writeto(filename)
hdu.writeto(filename, overwrite=overwrite)
else:
image = Image.fromarray(self.image)
image.save(filename)
image.save(filename,j, overwrite=overwrite)

def plot(self, show_grid: bool = False) -> None:
"""Plot the all sky image and overlay HiPS tile outlines.
Expand Down