Repository: spacetelescope/jwql

Issue:
Missing NIRCam preview images due to mosaics
Currently, the web app shows many missing preview images for NIRCam data. This is because the preview image generator currently creates its own quick mosaics of preview images of NIRCam SW exposures. It creates these mosaic preview images, and skips the creation of preview images for individual detectors. However, in the web app pages for individual exposures, we have a separate page for each detector, and each of those pages is looking for a detector-specific preview image, rather than the mosaic.

We had originally thought that having these mosaic images would be a nice way to look at an entire exposure at once. However, with a separate page for each detector, combined with the fact that it will be hard to see small features/sources in a mosaic preview image, perhaps it makes more sense to go back to having detector-specific preview images for everything.

Maybe down the road we could add a link or a page that will show a full mosaic preview image if desired. But I'm thinking for the purposes of actual quick look, detector-specific might be better. 

@bourque @bsunnquist what do you think?


Discussion:
Yeah that definitely makes sense to me

Resolving patch:
diff --git a/jwql/jwql_monitors/generate_preview_images.py b/jwql/jwql_monitors/generate_preview_images.py
--- a/jwql/jwql_monitors/generate_preview_images.py
+++ b/jwql/jwql_monitors/generate_preview_images.py
@@ -644,16 +644,12 @@ def process_program(program):
 
     # Ignore "original" files
     filenames = [filename for filename in filenames if os.path.splitext(filename.split('_')[-1]) not in IGNORED_SUFFIXES]
-
-    # Group together common exposures
-    grouped_filenames = group_filenames(filenames)
     logging.info('Found {} filenames'.format(len(filenames)))
     logging.info('')
 
-    for file_list in grouped_filenames:
+    for filename in filenames:
 
         # Determine the save location
-        filename = file_list[0]
         try:
             identifier = 'jw{}'.format(filename_parser(filename)['program_id'])
         except ValueError:
@@ -662,7 +658,7 @@ def process_program(program):
         thumbnail_output_directory = os.path.join(get_config()['thumbnail_filesystem'], identifier)
 
         # Check to see if the preview images already exist and skip if they do
-        file_exists = check_existence(file_list, preview_output_directory)
+        file_exists = check_existence([filename], preview_output_directory)
         if file_exists:
             logging.info("\tJPG already exists for {}, skipping.".format(filename))
             continue
@@ -677,25 +673,6 @@ def process_program(program):
             permissions.set_permissions(thumbnail_output_directory)
             logging.info('\tCreated directory {}'.format(thumbnail_output_directory))
 
-        # If the exposure contains more than one file (because more
-        # than one detector was used), then create a mosaic
-        max_size = 8
-        numfiles = len(file_list)
-        if numfiles > 1:
-            try:
-                mosaic_image, mosaic_dq = create_mosaic(file_list)
-                logging.info('\tCreated mosiac for:')
-                for item in file_list:
-                    logging.info('\t{}'.format(item))
-            except (ValueError, FileNotFoundError) as error:
-                mosaic_image, mosaic_dq = None, None
-                logging.error(error)
-            dummy_file = create_dummy_filename(file_list)
-            if numfiles in [2, 4]:
-                max_size = 16
-            elif numfiles in [8]:
-                max_size = 32
-
         # Create the nominal preview image and thumbnail
         try:
             im = PreviewImage(filename, "SCI")
@@ -705,17 +682,7 @@ def process_program(program):
             im.output_format = 'jpg'
             im.preview_output_directory = preview_output_directory
             im.thumbnail_output_directory = thumbnail_output_directory
-
-            # If a mosaic was made from more than one file
-            # insert it and it's associated DQ array into the
-            # instance of PreviewImage. Also set the input
-            # filename to indicate that we have mosaicked data
-            if numfiles > 1 and mosaic_image is not None:
-                im.data = mosaic_image
-                im.dq = mosaic_dq
-                im.file = dummy_file
-
-            im.make_image(max_img_size=max_size)
+            im.make_image(max_img_size=8)
             logging.info('\tCreated preview image and thumbnail for: {}'.format(filename))
         except (ValueError, AttributeError) as error:
             logging.warning(error)


Test patch: