def new_project(self):
        """
        Get the file path to a new project
        """

        # dirpath will be None or a string
        msg, pth = RegistryHelpers.GetFilenameFromUserQT(
            self,
            RegistryKey='klusterintel',
            Title='Create a new Kluster project',
            AppName='klusterintel',
            fFilter="*.json",
            bSave=True,
            DefaultFile='kluster_project.json')
        if pth:
            # the project name is mandatory, just so that we can find it later, I ask for a file path for the project
            #    file and override the filename, kind of messy but works for now
            if os.path.exists(pth):
                os.remove(pth)
            directory, filename = os.path.split(pth)
            project_file = os.path.join(directory, 'kluster_project.json')

            self.fil_text.setText(project_file)
            self.project_file = project_file
            self.project = FqprProject(is_gui=True)
            self.project.new_project_from_directory(directory)
            if self.parent:
                self.parent.set_project(self.project)

            self._load_from_project()
Example #2
0
    def output_file_browse(self):
        curr_opts = self.export_opts.currentText().lower()
        if curr_opts == 'csv':
            titl = 'Select output csv file'
            ffilter = "csv file|*.csv"
        elif curr_opts == 'bag':
            titl = 'Select output bag file'
            ffilter = "bag file|*.bag"
        elif curr_opts == 'geotiff':
            titl = 'Select output geotiff file'
            ffilter = "geotiff file|*.tif"
        else:
            raise ValueError(
                'dialog_export_grid: unrecognized method: {}'.format(
                    curr_opts))

        # dirpath will be None or a string
        msg, self.output_pth = RegistryHelpers.GetFilenameFromUserQT(
            self,
            RegistryKey='Kluster',
            Title=titl,
            fFilter=ffilter,
            AppName='\\reghelp')
        if self.output_pth is not None:
            self.output_text.setText(self.output_pth)
    def export_variable(self):
        """
        Export the currently selected dataset/variable to csv
        """

        if self.datasets:
            ky = self.dataset_dropdown.currentText()
            plottype = self.plottype_dropdown.currentText()
            reduce_method = None
            zero_centered = False

            try:
                dvar = self.variable_reverse_lookup[
                    self.variable_dropdown.currentText()]
            except:
                dvar = self.variable_dropdown.currentText()
            defvalue = os.path.join(self.fqpr.output_folder,
                                    'export_{}_{}.csv'.format(ky, dvar))
            if plottype[0:4] == 'Line':
                zero_centered = self.zero_center_plot.isChecked()
                if plottype.find('Mean') != -1:
                    reduce_method = 'mean'
                    defvalue = os.path.splitext(defvalue)[0] + '_mean.csv'
                elif plottype.find('Nadir') != -1:
                    reduce_method = 'nadir'
                    defvalue = os.path.splitext(defvalue)[0] + '_nadir.csv'
                elif plottype.find('Port') != -1:
                    reduce_method = 'port_outer_beam'
                    defvalue = os.path.splitext(defvalue)[0] + '_portbeam.csv'
                elif plottype.find('Starboard') != -1:
                    reduce_method = 'starboard_outer_beam'
                    defvalue = os.path.splitext(defvalue)[0] + '_stbdbeam.csv'
            if zero_centered:
                defvalue = os.path.splitext(defvalue)[0] + '_zerocentered.csv'

            msg, output_pth = RegistryHelpers.GetFilenameFromUserQT(
                self,
                RegistryKey='Kluster',
                DefaultVal=self.fqpr.output_folder,
                fFilter="csv files|*.csv",
                DefaultFile=defvalue,
                Title='Output dataset path for csv export',
                AppName='\\reghelp')
            if output_pth:
                min_max = self.data_widget.return_trim_times()
                if min_max:
                    err = self.fqpr.subset_by_time(min_max[0], min_max[1])
                    if err:
                        self.data_widget.warning_message.setText(
                            'ERROR: no data in times {}-{}'.format(
                                min_max[0], min_max[1]))
                        return
                self.reload_datasets()
                self.fqpr.export_variable(ky,
                                          dvar,
                                          output_pth,
                                          reduce_method=reduce_method,
                                          zero_centered=zero_centered)
                if min_max:
                    self.fqpr.restore_subset()
 def export_source(self):
     """
     Export the currently selected dataset to csv
     """
     if self.datasets:
         ky = self.dataset_dropdown.currentText()
         defvalue = os.path.join(self.fqpr.output_folder,
                                 'export_{}.csv'.format(ky))
         msg, output_pth = RegistryHelpers.GetFilenameFromUserQT(
             self,
             RegistryKey='Kluster',
             DefaultVal=self.fqpr.output_folder,
             fFilter="csv files|*.csv",
             DefaultFile=defvalue,
             Title='Output dataset path for csv export',
             AppName='\\reghelp')
         if output_pth:
             min_max = self.data_widget.return_trim_times()
             if min_max:
                 err = self.fqpr.subset_by_time(min_max[0], min_max[1])
                 if err:
                     self.data_widget.warning_message.setText(
                         'ERROR: no data in times {}-{}'.format(
                             min_max[0], min_max[1]))
                     return
             self.reload_datasets()
             self.fqpr.export_dataset(ky, output_pth)
             if min_max:
                 self.fqpr.restore_subset()
Example #5
0
 def file_browse(self):
     # dirpath will be None or a string
     msg, self.output_pth = RegistryHelpers.GetDirFromUserQT(self, RegistryKey='Kluster',
                                                             Title='Select output directory', AppName='\\reghelp')
     if self.output_pth is not None:
         self.fil_text.setText(self.output_pth)
     self.update_output_structure_view()
 def file_browse(self):
     # dirpath will be None or a string
     msg, self.log_file_path = RegistryHelpers.GetFilenameFromUserQT(self, RegistryKey='Kluster',
                                                                     Title='Select POSPac Export Log',
                                                                     AppName='\\reghelp', bSave=False,
                                                                     fFilter="Log Files|*.txt;*.log")
     if self.log_file_path is not None:
         self.log_file.setText(self.log_file_path)
 def output_browse(self):
     msg, out_path = RegistryHelpers.GetDirFromUserQT(
         self,
         RegistryKey='Kluster',
         Title='Select folder to store plot images',
         AppName='\\reghelp')
     if out_path:
         self.out_text.setText(out_path)
Example #8
0
 def grid_folder_browse(self):
     # dirpath will be None or a string
     msg, self.input_pth = RegistryHelpers.GetDirFromUserQT(
         self,
         RegistryKey='Kluster',
         Title='Select Grid directory',
         AppName='\\reghelp')
     if self.input_pth is not None:
         self.update_input_path(self.input_pth)
 def file_browse(self):
     """
     select a file and add it to the list.
     """
     fils = []
     if self.opts['mode'] == 'file':
         msg, fils = RegistryHelpers.GetFilenameFromUserQT(self, RegistryKey=self.opts['registry_key'],
                                                           Title=self.opts['filebrowse_title'],
                                                           AppName=self.opts['app_name'],
                                                           bMulti=self.opts['multiselect'], bSave=False,
                                                           fFilter=self.opts['filebrowse_filter'])
     elif self.opts['mode'] == 'directory':
         msg, fils = RegistryHelpers.GetDirFromUserQT(self, RegistryKey=self.opts['registry_key'],
                                                      Title=self.opts['filebrowse_title'],
                                                      AppName=self.opts['app_name'])
         fils = [fils]
     if fils:
         self.add_new_files(fils)
     self.files_changed()
Example #10
0
 def vdatum_browse(self):
     # dirpath will be None or a string
     msg, self.vdatum_pth = RegistryHelpers.GetDirFromUserQT(
         self,
         RegistryKey='Kluster',
         Title='Select Vdatum directory',
         AppName='\\reghelp')
     if self.vdatum_pth:
         self.vdatum_text.setText(self.vdatum_pth)
     self._refresh_error_message()
 def file_browse(self, e):
     msg, file_path = RegistryHelpers.GetFilenameFromUserQT(
         self,
         RegistryKey='Kluster',
         Title='Select a raw file to read',
         AppName='\\analyzer',
         bMulti=False,
         bSave=False,
         fFilter='all files (*.*)')
     if file_path:
         self.fil_text.setText(file_path)
         self.filename = file_path
         fext = os.path.splitext(self.filename)[1]
         self.functioncombobox.clear()
         if fext == '.all':
             self.filetype = 'kongsberg_all'
             self.fileobject = par3.AllRead(self.filename)
             self.functioncombobox.addItems([
                 'read_first_fifty_records', 'kluster_read_test',
                 'bscorr_generation'
             ])
         elif fext == '.kmall':
             self.filetype = 'kongsberg_kmall'
             self.fileobject = kmall.kmall(self.filename)
             self.functioncombobox.addItems(['read_first_fifty_records'])
         elif fext in ['.out', '.sbet', 'smrmsg']:
             if sbet.is_sbet(file_path):
                 self.filetype = 'applanix_sbet'
                 self.fileobject = sbet.read(file_path, numcolumns=17)
                 self.functioncombobox.addItems(
                     ['read_first_fifty_records'])
             elif sbet.is_smrmsg(file_path):
                 self.filetype = 'applanix_smrmsg'
                 self.fileobject = sbet.read(file_path, numcolumns=10)
                 self.functioncombobox.addItems(
                     ['read_first_fifty_records'])
             else:
                 print(
                     f'Not a recognized file type, tried sbet and smrmsg: {self.filename}'
                 )
                 self.filetype = ''
                 self.fileobject = None
         else:
             try:
                 poscheck = int(fext[1:])
                 self.filetype = 'posmv'
                 self.fileobject = PCSio.PCSFile(self.filename)
                 self.functioncombobox.addItems(
                     ['read_first_fifty_records'])
             except:
                 print(f'Not a recognized file type: {self.filename}')
                 self.filetype = ''
                 self.fileobject = None
     self.ftypelabel.setText(f'File Type: {self.filetype}')
 def surf_browse(self):
     msg, surf_path = RegistryHelpers.GetDirFromUserQT(
         self,
         RegistryKey='Kluster',
         Title='Select gridded data folder',
         AppName='\\reghelp')
     if surf_path:
         if os.path.isdir(surf_path):
             self.surf_text.setText(surf_path)
         else:
             print('{} is not an existing directory'.format(surf_path))
Example #13
0
 def file_browse(self):
     msg, self.output_pth = RegistryHelpers.GetFilenameFromUserQT(
         self,
         RegistryKey='Kluster',
         Title='Select output surface path',
         AppName='kluster',
         bMulti=False,
         bSave=True,
         fFilter='numpy npz (*.npz)')
     if self.output_pth is not None:
         self.fil_text.setText(self.output_pth)
Example #14
0
    def dir_browse(self):
        """
        As long as you aren't currently running the monitoring, this will get the directory you want to monitor
        """

        if not self.is_running():
            # dirpath will be None or a string
            msg, pth = RegistryHelpers.GetDirFromUserQT(self, RegistryKey='klusterintel',
                                                        Title='Select directory to monitor', AppName='klusterintel')
            if pth is not None:
                self.fil_text.setText(pth)
        else:
            print('You have to stop monitoring before you can change the path')
    def open_project(self):
        """
        Get the file path to a new project
        """

        # dirpath will be None or a string
        msg, pth = RegistryHelpers.GetFilenameFromUserQT(
            self,
            RegistryKey='klusterintel',
            Title='Open an existing Kluster project',
            AppName='klusterintel',
            fFilter="*.json",
            bSave=False)
        if pth:
            self.fil_text.setText(pth)
            self.build_from_project(pth)
    def file_browse(self):
        """
        Browse to a Kluster converted data folder.  Structure should look something like:

        C:\collab\dasktest\data_dir\kmall_test\mbes\converted
        C:\collab\dasktest\data_dir\kmall_test\mbes\converted\attitude.zarr
        C:\collab\dasktest\data_dir\kmall_test\mbes\converted\ping_53011.zarr

        You would point at the converted folder using this browse button.
        """
        # dirpath will be None or a string
        msg, fqpr_path = RegistryHelpers.GetDirFromUserQT(self, RegistryKey='Kluster',
                                                          Title='Select converted data directory',
                                                          AppName='\\reghelp')
        if fqpr_path:
            self.new_fqpr_path(fqpr_path)
            self.initialize_controls()
 def file_browse_two(self, e):
     msg, file_path = RegistryHelpers.GetFilenameFromUserQT(
         self,
         RegistryKey='Kluster',
         Title='Select a raw file to read',
         AppName='\\analyzer',
         bMulti=False,
         bSave=False,
         fFilter='all files (*.*)')
     if file_path:
         fext = os.path.splitext(file_path)[1]
         if self.filetype == 'kongsberg_all' and fext != '.all':
             print('Expected .all file, got {}'.format(file_path))
         elif self.filetype == 'kongsberg_kmall' and fext != '.kmall':
             print('Expected .kmall file, got {}'.format(file_path))
         elif self.filetype in [
                 'applanix_sbet', 'applanix_smrmsg'
         ] and fext not in ['.out', '.sbet', 'smrmsg']:
             print('Expected .kmall file, got {}'.format(file_path))
         else:
             self.fil_two_text.setText(file_path)
             self.filenametwo = file_path
             if fext == '.all':
                 self.fileobjecttwo = par3.AllRead(file_path)
             elif fext == '.kmall':
                 self.fileobjecttwo = kmall.kmall(file_path)
             elif fext in ['.out', '.sbet', 'smrmsg']:
                 if sbet.is_sbet(file_path):
                     self.fileobjecttwo = sbet.read(file_path,
                                                    numcolumns=17)
                 elif sbet.is_smrmsg(file_path):
                     self.fileobjecttwo = sbet.read(file_path,
                                                    numcolumns=10)
                 else:
                     print(
                         f'Not a recognized file type, tried sbet and smrmsg: {file_path}'
                     )
                     self.fileobjecttwo = None
             else:
                 try:
                     poscheck = int(fext[1:])
                     self.fileobjecttwo = PCSio.PCSFile(self.filename)
                 except:
                     print(f'Not a recognized file type: {self.filename}')
                     self.fileobjecttwo = None
    def output_file_browse(self):
        curr_opts = self.export_opts.currentText().lower()
        if curr_opts == 'geopackage':
            titl = 'Select output geopackage file'
            ffilter = "gpkg file|*.gpkg"
        else:
            raise ValueError(
                'dialog_export_tracklines: unrecognized method: {}'.format(
                    curr_opts))

        # dirpath will be None or a string
        msg, outpth = RegistryHelpers.GetFilenameFromUserQT(
            self,
            RegistryKey='Kluster',
            DefaultFile=self.output_text.text(),
            Title=titl,
            fFilter=ffilter,
            AppName='\\reghelp')
        if outpth:
            self.output_text.setText(outpth)
 def filter_browse(self):
     # dirpath will be None or a string
     msg, filter_pth = RegistryHelpers.GetDirFromUserQT(self, RegistryKey='Kluster',
                                                        Title='Select filter directory', AppName='\\reghelp')
     if filter_pth:
         self.filter_text.setText(filter_pth)