Tickets/DM-54855#1324
Conversation
Create a series of tasks that mimic the rgb2hips code which make hips trees in parallel. Unlike the rgb code, this produces fits files that are not compressed or processed other that what is needed to create tiles.
c6e1670 to
7bb76f9
Compare
fred3m
left a comment
There was a problem hiding this comment.
A few bugs the need to be corrected. Maybe add a few unit tests to check that everything works correctly, they likely would have caught at least the indexing issue.
|
|
||
| image = handle.get() | ||
| mosaic_maker.add_to_image(new_array, image.image.array, tmp_new_box, tmpBox, reverse=False) | ||
| boxes.append((new_array, skyWcs, new_box)) |
There was a problem hiding this comment.
Comparing to rgb2hips and looking at the logic, I think that this line is indented one too many times and should be outside of the above loop
| for j in range(binned_array.shape[1] // 512): | ||
| pixel_id = int(hpx_id_array[i, j]) | ||
| sub_pixel = binned_array[i * 512 : i * 512 + 512, j * 512 : j * 512 + 512] | ||
| self.log.info(f"writing sub_pixel {pixel_id}") |
There was a problem hiding this comment.
This should use lazy formatting, as you used above
| - "float": 32-bit floating-point numbers | ||
| tile_wcs : `~lsst.afw.geom.SkyWcs` or `None` | ||
| If supplied, this wcs is written to fits images. | ||
| Raises |
| allsky_image = np.zeros( | ||
| (n_tiles_wide * tile_size, n_tiles_high * tile_size), | ||
| ) |
There was a problem hiding this comment.
I think that you need to switch the first two shape dimensions. The above worked in rgb2hips because it was a PIL Image, but here it is an ndarray.
| (column + 1) * tile_size, | ||
| (row + 1) * tile_size, | ||
| ) | ||
| tile_image_shrunk = tile_image.resize((tile_size, tile_size)) |
There was a problem hiding this comment.
I think that ndarray.resize is in place (see docs.) You probably need to use tile_image_shrunk = np.resize(tile_image, (tile_size, tile_size))
| bitpix = 32 | ||
| hbitpix = 32 |
There was a problem hiding this comment.
Per FITS guidelines BITPIX should be negative for floating point data: https://archive.stsci.edu/fits/fits_standard/node39.html#s:man
| if band in properties_config.spectral_ranges: | ||
| em_min = properties_config.spectral_ranges[band].lambda_min / 1e9 | ||
| else: | ||
| self.log.warning("blue band %s not in self.config.spectral_ranges.", band) | ||
| em_min = 3e-7 | ||
| if band in properties_config.spectral_ranges: | ||
| em_max = properties_config.spectral_ranges[band].lambda_max / 1e9 | ||
| else: | ||
| self.log.warning("red band %s not in self.config.spectral_ranges.", band) | ||
| em_max = 1e-6 |
There was a problem hiding this comment.
You have two duplicate checks, since for a single band fits there is a single band config property as opposed to bluest_band and reddest_band in rgb2hips. You should set em_min and em_max in the same block and if the band isn't contained, you should probably raise, right?
No description provided.