Exemple #1
0
    def process_single_buoy_sc(self, master):

        # Clear output windows and disable process button
        self.prepare_window(master)

        # Read the scene_id from the form
        scene_id = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_buoy_sc_frame'].input_values['scene_id'].get()

        if (scene_id != None):

            if (menu.is_valid_id(scene_id)):

                #  !!! Temporarily disabled due to multithreading issues with GTK+ !!!
                show_images = False  #self.ask_show_images()

                # Create a status logger instance
                self.path_dictionary['statusfile_name'] = str(
                    scene_id) + "_" + str(self.current_datetime) + ".status"

                # Create a output logger instance
                self.path_dictionary['outputfile_name'] = str(
                    scene_id) + "_" + str(self.current_datetime) + ".output"

                self.build_paths(master)

                # Create a progress bar to show activity
                self.progressbar = Progress_Bar(master,
                                                'Processing Scene ' + scene_id)
                self.progressbar.progressbar.config(mode='indeterminate')

                # Progressbar start and stop work with program loop, so manual loop is required for progression
                self.process_complete = False

                #                self.process_scene_id(master, scene_id, show_images)
                progressbar_thread = threading.Thread(
                    target=self.step_progressbar)
                progressbar_thread.start()

                # Launch single scene ID process job in own thread
                cis_tarca_thread = threading.Thread(
                    target=self.process_scene_id,
                    args=([
                        master,
                        scene_id,
                        show_images,
                    ]))

                cis_tarca_thread.start()

            else:

                messagebox.showwarning(
                    title="Invalid Input",
                    message=
                    "The scene id you entered is of an incorrect format.\n\n"
                    "Please try again")

                self.process_button.config(state='normal')
    def open_help(self, master):

        self.progressbar = Progress_Bar(master, 'Loading Help Page ... ')
        self.progressbar.progressbar.config(mode='indeterminate')

        self.progressbar.progressbar_window.deiconify()
        self.progressbar.progressbar.start()

        threading.Thread(target=self.open_webpage,
                         args=(self.GITHUB_PATH, )).start()
Exemple #3
0
    def process_single_lst_sw(self, master):

        # Keep track of all the invalid entries
        error_message_list = {
            'scene_id':
            ' is not a valid Scene ID',
            'lat':
            ' does not fall within the range of -90 to 90 degrees for a valid latitude',
            'lon':
            ' does not fall within the range of -180 to 180 degrees for a valid longitude',
            'emis_b10':
            ' does not fall within the range of 0.8 to 1.0 for a valid emissivity',
            'emis_b11':
            ' does not fall within the range of 0.8 to 1.0 for a valid emissivity'
        }

        error_list = {}

        # Clear output windows and disable process button
        self.prepare_window(master)

        # Define dictionary for required values
        partial_data = {}

        # Read the scene_id from the form
        scene_id = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_lst_sw_frame'].input_values['scene_id'].get()
        partial_data['lat'] = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_lst_sw_frame'].input_values['lat'].get()
        partial_data['lon'] = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_lst_sw_frame'].input_values['lon'].get()
        partial_data['emis_b10'] = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_lst_sw_frame'].input_values['emissivity_b10'].get()
        partial_data['emis_b11'] = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_lst_sw_frame'].input_values['emissivity_b11'].get()

        # There is no .get() method for the ttk.Checkbutton object, therefore an even listener is added to the element
        # and the value in the variable changed based on the "change" event from the checkbutton
        partial_data['add_gain_bias'] = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_lst_sw_frame'].input_values['add_gain_bias']

        # Convert all entered data to float values
        partial_data['lat'] = self.convert_to_float(partial_data['lat'])
        partial_data['lon'] = self.convert_to_float(partial_data['lon'])
        partial_data['emis_b10'] = self.convert_to_float(
            partial_data['emis_b10'])
        partial_data['emis_b11'] = self.convert_to_float(
            partial_data['emis_b11'])

        if partial_data['add_gain_bias']:
            partial_data['gain_b10'] = master.frames[
                self.frame_name].notebooks['input_notebook'].frames[
                    'input_lst_sw_frame'].frames[
                        'input_lst_sw_gb_frame'].input_values['gain_b10'].get(
                        )
            partial_data['bias_b10'] = master.frames[
                self.frame_name].notebooks['input_notebook'].frames[
                    'input_lst_sw_frame'].frames[
                        'input_lst_sw_gb_frame'].input_values['bias_b10'].get(
                        )
            partial_data['gain_b11'] = master.frames[
                self.frame_name].notebooks['input_notebook'].frames[
                    'input_lst_sw_frame'].frames[
                        'input_lst_sw_gb_frame'].input_values['gain_b11'].get(
                        )
            partial_data['bias_b11'] = master.frames[
                self.frame_name].notebooks['input_notebook'].frames[
                    'input_lst_sw_frame'].frames[
                        'input_lst_sw_gb_frame'].input_values['bias_b11'].get(
                        )

            partial_data['gain_b10'] = self.convert_to_float(
                partial_data['gain_b10'])
            partial_data['bias_b10'] = self.convert_to_float(
                partial_data['bias_b10'])
            partial_data['gain_b11'] = self.convert_to_float(
                partial_data['gain_b11'])
            partial_data['bias_b11'] = self.convert_to_float(
                partial_data['bias_b11'])
        else:
            partial_data['gain_b10'] = 0
            partial_data['bias_b10'] = 0
            partial_data['gain_b11'] = 0
            partial_data['bias_b11'] = 0

        # Check if the scene id is valid
        if (scene_id != None):
            if not menu.is_valid_id(scene_id):

                error_list['scene_id'] = scene_id

        # Check if the latitude is valid
        if (partial_data['lat'] != None):
            if not menu.is_valid_latitude(partial_data['lat']):

                error_list['lat'] = partial_data['lat']

        # Check if the longitude is valid
        if (partial_data['lon'] != None):
            if not menu.is_valid_longitude(partial_data['lon']):

                error_list['lon'] = partial_data['lon']

        # Check if the emissivity for band 10 is valid
        if (partial_data['emis_b10'] != None):
            if False:
                error_list['emis_b10'] = partial_data['emis_b10']

        # Check if the emissivity for band 11 is valid
        if (partial_data['emis_b11'] != None):
            if False:
                error_list['emis_b11'] = partial_data['emis_b11']

        if len(error_list) == 0:

            # Create a status logger instance
            self.path_dictionary['statusfile_name'] = "Split_Window_" + str(
                self.current_datetime) + ".status"

            # Create a output logger instance
            self.path_dictionary['outputfile_name'] = "Split_Window_" + str(
                self.current_datetime) + ".output"

            self.build_paths(master)

            # Create a progress bar to show activity
            self.progressbar = Progress_Bar(master, 'Processing... ')
            self.progressbar.progressbar.config(mode='indeterminate')

            # Progressbar start and stop work with program loop, so manual loop is required for progression
            self.process_complete = False

            progressbar_thread = threading.Thread(target=self.step_progressbar)
            progressbar_thread.start()

            # Launch single process job in own thread
            cis_tarca_thread = threading.Thread(target=self.process_lst_sw,
                                                args=([
                                                    master,
                                                    scene_id,
                                                    False,
                                                    partial_data,
                                                ]))

            cis_tarca_thread.start()

        else:

            asterisk = '*'
            nr_asterisks = 65

            space = ' '
            nr_spaces = 5

            header1 = ''.join([char * nr_asterisks for char in asterisk])
            header1 += '\n'
            header2 = ''.join([char * nr_spaces for char in space])
            header2 += '!!!   The following data you entered is incorrect.   !!!'
            header2 += ''.join([char * nr_spaces for char in space])
            header2 += '\n'
            header3 = ''.join([char * nr_asterisks for char in asterisk])

            message_header = header1 + header2 + header3

            message_body = ""

            for error in error_list:

                if error_list[error] == '':
                    message_body += "You did not enter a value for %s\n" % error
                else:
                    message_body += "%s %s\n" % (error_list[error],
                                                 error_message_list[error])

            Error_Window(master, "partial_single_error_window",
                         "Data Input Errors", message_header, message_body)

            self.process_button.config(state='normal')
Exemple #4
0
    def process_batch_buoy_sc(self, master):

        # Clear output windows and disable process button
        self.prepare_window(master)

        # Get the batch file from the form
        source_file = master.frames[
            self.frame_name].notebooks['input_notebook'].frames[
                'input_batch_frame'].input_values['batch_file'].get()
        source_file_name = source_file[(source_file.rfind('/') + 1):]

        if (source_file == ''):
            messagebox.showwarning(
                title="Invalid Input",
                message="No file specified, please select a file and try again."
            )

            self.process_button.config(state='normal')

        else:
            # Read in the file
            scenes = open(source_file).readlines()

            counter = 0
            error_list = {"errors": []}

            for scene in scenes:

                counter += 1

                if not menu.is_valid_id(scene):

                    error = {}
                    error["idx"] = counter
                    error["scene"] = scene

                    error_list["errors"].append(error)

            if (len(error_list['errors']) > 0):

                asterisk = '*'
                nr_asterisks = 65

                space = ' '
                nr_spaces = 5

                header1 = ''.join([char * nr_asterisks for char in asterisk])
                header1 += '\n'
                header2 = ''.join([char * nr_spaces for char in space])
                header2 += '!!!   The following errors were found in your batch file   !!!'
                header2 += ''.join([char * nr_spaces for char in space])
                header2 += '\n'
                header3 = ''.join([char * nr_asterisks for char in asterisk])

                message_header = header1 + header2 + header3

                message_body = ""

                for error in error_list['errors']:
                    message_body = message_body + "  line : %5s         scene : %40s\n" % (
                        error['idx'], error['scene'])

                message_body = message_body[:-2]

                Error_Window(master, "batch_error_window", "Batch File Errors",
                             message_header, message_body)

                self.process_button.config(state='normal')

            else:

                if (len(scenes) > 0):

                    # Ask user if they want to display each image during processing
                    #  !!! Temporarily disabled due to multithreading issues with GTK+ !!!
                    show_images = False  #self.ask_show_images()

                    # Define a status logger file
                    self.path_dictionary['statusfile_name'] = source_file[
                        source_file.rfind('/') +
                        1:source_file.rfind('.')] + "_" + str(
                            self.current_datetime) + ".status"

                    # Define a output logger file
                    self.path_dictionary['outputfile_name'] = source_file[
                        source_file.rfind('/') +
                        1:source_file.rfind('.')] + "_" + str(
                            self.current_datetime) + ".output"

                    # Define all logger paths
                    self.build_paths(master)

                    # Create a progress bar to show activity
                    self.progressbar = Progress_Bar(
                        master, 'Processing Batch: ' + source_file_name)
                    self.progressbar.progressbar.config(mode='indeterminate')

                    # Progressbar start and stop work with program loop, so manual loop is required for progression
                    self.process_complete = False

                    progressbar_thread = threading.Thread(
                        target=self.step_progressbar)
                    progressbar_thread.start()

                    # Launch single scene ID process job in own thread
                    cis_tarca_thread = threading.Thread(
                        target=self.process_batch_buoy_sc_ids,
                        args=([
                            master,
                            source_file,
                            show_images,
                        ]))

                    cis_tarca_thread.start()

                else:

                    messagebox.showwarning(
                        title="Invalid Input",
                        message=
                        "The file you specified is empty, please select a non-empty file."
                    )

                    self.process_button.config(state='normal')