Skip to content

Commit

Permalink
handle HDU lists correctly to access numpy image data array
Browse files Browse the repository at this point in the history
  • Loading branch information
phycodurus committed Sep 11, 2024
1 parent aa847b0 commit fcb2f5b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions datalab/datalab_session/tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,17 @@ def tearDown(self):
def test_operate(self, mock_create_jpgs, mock_save_fits_and_thumbnails, mock_get_fits, mock_named_tempfile):

# Create a negative images using numpy
negative_image = fits.open(self.test_fits_1_path)
negative_image_hdul = fits.open(self.test_fits_1_path)
negative_image = negative_image_hdul['SCI']
# Multiply the data by -1 to create a negative image
negative_image.data = np.multiply(negative_image.data, -1)
fits.writeto(self.temp_fits_1_negative_path, negative_image, overwrite=True)
fits.writeto(self.temp_fits_1_negative_path, negative_image.data, overwrite=True)

negative_image = fits.open(self.test_fits_2_path)
# do the same for the second image
negative_image_hdul = fits.open(self.test_fits_2_path)
negative_image = negative_image_hdul['SCI']
negative_image.data = np.multiply(negative_image.data, -1)
fits.writeto(self.temp_fits_2_negative_path, negative_image, overwrite=True)
fits.writeto(self.temp_fits_2_negative_path, negative_image.data, overwrite=True)

# return the test fits paths in order of the input_files instead of aws fetch
mock_get_fits.side_effect = [self.test_fits_1_path, self.test_fits_2_path,
Expand Down

0 comments on commit fcb2f5b

Please sign in to comment.