def format_image_infos(self): self.input_folder = self.folder_ui.selected list_files = file_handler.retrieve_list_of_most_dominand_extension_from_folder( folder=self.input_folder) list_files = list_files[0] box = widgets.VBox( [widgets.Label("Retrieving Time Stamp .......... IN PROGRESS")]) display(box) progress_label = box.children[0] timestamp_array = [] list_base_file_name = [] for _index, _file in enumerate(list_files): time_stamp = os.path.getmtime(_file) timestamp_array.append(time_stamp) list_base_file_name.append(os.path.basename(_file)) progress_label.value = 'Retrieving Time Stamp .......... DONE!' data = list(zip(timestamp_array, list_base_file_name)) self.time_stamp_vs_file_name = pd.DataFrame( data, columns=['index', 'file_name']) self.timestamp_array = timestamp_array self.list_base_file_name = list_base_file_name
def _retrieve_list_of_files(self, folder_selected): [self.list_files, _ ] = file_handler.retrieve_list_of_most_dominand_extension_from_folder( folder=folder_selected) self.list_of_files_to_extract = self.list_files self.basename_list_files = [ os.path.basename(_file) for _file in self.list_files ] self.basename_list_of_files_that_will_be_extracted = [ os.path.basename(_file) for _file in self.list_files ] self.number_of_files = len(self.list_files) display( HTML('<span style="font-size: 15px; color:blue">' + str(self.number_of_files) + ' files will be used in the extraction.</span>'))
def _run(self): [list_files, ext ] = file_handler.retrieve_list_of_most_dominand_extension_from_folder( folder=self.folder, files=self.input_list_files) self.output_list_files = list_files if ext.lower() in ['.tiff', '.tif']: ext = 'tif' elif ext.lower() == '.fits': ext = 'fits' else: raise ValueError if self.__is_notebook: box = widgets.HBox([ widgets.Label("Retrieving Time Stamp", layout=widgets.Layout(width='20%')), widgets.IntProgress(min=0, max=len(list_files), value=0, layout=widgets.Layout(width='50%')) ]) progress_bar = box.children[1] display(box) list_time_stamp = [] list_time_stamp_user_format = [] for _index, _file in enumerate(list_files): _time_stamp = MetadataHandler.get_time_stamp(file_name=_file, ext=ext) list_time_stamp.append(_time_stamp) _user_format = MetadataHandler.convert_to_human_readable_format( _time_stamp) list_time_stamp_user_format.append(_user_format) if self.__is_notebook: progress_bar.value = _index + 1 self.list_time_stamp = list_time_stamp self.list_time_stamp_user_format = list_time_stamp_user_format if self.__is_notebook: box.close()
def __check_inputs(self): # images image_folder = self.folder_ui.selected list_images = file_handler.retrieve_list_of_most_dominand_extension_from_folder( folder=image_folder) list_images = list_images[0] self.nbr_images = len(list_images) # entry from file file_name_vs_metadata_name = self.metadata_file_ui.selected self.file_name_vs_metadata = pd.read_csv(file_name_vs_metadata_name) self.metadata_name = list(self.file_name_vs_metadata.columns.values)[2] nbr_metadata = len( self.file_name_vs_metadata[self.file_name_vs_metadata.columns[0]]) assert self.nbr_images == nbr_metadata self.list_images = list_images
def retrieve_time_stamp(self): self.image_folder = self.folder_ui.selected [list_files, ext ] = file_handler.retrieve_list_of_most_dominand_extension_from_folder( folder=self.image_folder) self.list_files = list_files if ext.lower() in ['.tiff', '.tif']: ext = 'tif' elif ext.lower() == '.fits': ext = 'fits' else: raise ValueError box = widgets.HBox([ widgets.Label("Retrieving Time Stamp", layout=widgets.Layout(width='20%')), widgets.IntProgress(min=0, max=len(list_files), value=0, layout=widgets.Layout(width='50%')) ]) progress_bar = box.children[1] display(box) list_time_stamp = [] for _index, _file in enumerate(list_files): _time_stamp = MetadataHandler.get_time_stamp(file_name=_file, ext=ext) list_time_stamp.append(_time_stamp) progress_bar.value = _index + 1 self.list_time_stamp = list_time_stamp self.list_time_offset = [ t - list_time_stamp[0] for t in list_time_stamp ]
def __retrieve_files(self): input_folder = self.input_folder_ui.selected list_files = file_handler.retrieve_list_of_most_dominand_extension_from_folder( folder=input_folder)[0] self.list_files = file_handler.remove_file_from_list( list_files=list_files, regular_expression='.*_SummedImg.fits')
def _retrieve_number_of_files(self, folder_selected): [self.list_files, _ ] = file_handler.retrieve_list_of_most_dominand_extension_from_folder( folder=folder_selected)