diff --git a/datalab/datalab_session/data_operations/normalization.py b/datalab/datalab_session/data_operations/normalization.py index 70df52b..aff5752 100644 --- a/datalab/datalab_session/data_operations/normalization.py +++ b/datalab/datalab_session/data_operations/normalization.py @@ -20,7 +20,7 @@ def name(): def description(): return """The normalize operation takes in 1..n input images and calculates each image's median value and divides every pixel by that value. -The output is a normalized image for the n input images. This operation is commonly used as a precursor step for flat removal.""" +The output is a normalized image. This operation is commonly used as a precursor step for flat removal.""" @staticmethod def wizard_description(): @@ -43,23 +43,24 @@ def operate(self): input = self.input_data.get('input_files', []) - log.info(f'Executing normalization operation on {len(input)} file(s) {input}') + log.info(f'Executing normalization operation on {len(input)} file(s)') + + image_data_list = self.get_fits_npdata(input) + self.set_percent_completion(0.40) - image_data_list = self.get_fits_npdata(input, percent=0.4, cur_percent=0.0) - log.info(f'image data list: {image_data_list}') output_files = [] - for i, image in enumerate(image_data_list): + for index, image in enumerate(image_data_list): median = np.median(image) normalized_image = image / median + fits_file = create_fits(self.cache_key, normalized_image) - log.info(f'fits_file: {fits_file}') large_jpg_path, small_jpg_path = create_jpgs(self.cache_key, fits_file) - output_file = save_fits_and_thumbnails(self.cache_key, fits_file, large_jpg_path, small_jpg_path, index=i) + output_file = save_fits_and_thumbnails(self.cache_key, fits_file, large_jpg_path, small_jpg_path, index=index) output_files.append(output_file) - log.info(f'x: {output_files}') + + self.set_percent_completion(self.get_percent_completion() + .40 * (index + 1) / len(input)) output = {'output_files': output_files} - self.set_percent_completion(1.0) self.set_output(output) log.info(f'Normalization output: {self.get_output()}')