pypet/storageservice.py
def _trj_load_trajectory(self, traj, as_new, load_parameters, load_derived_parameters,
                             load_results, load_other_data, recursive, max_depth,
                             with_run_information, with_meta_data, force):
        """Loads a single trajectory from a given file.


        :param traj: The trajectory

        :param as_new: Whether to load trajectory as new

        :param load_parameters: How to load parameters and config

        :param load_derived_parameters: How to load derived parameters

        :param load_results: How to load results

        :param load_other_data: How to load anything not within the four subbranches

        :param recursive: If data should be loaded recursively

        :param max_depth: Maximum depth of loading

        :param with_run_information:

            If run information should be loaded

        :param with_meta_data:

            If meta data infor should be loaded

        :param force: Force load in case there is a pypet version mismatch

        You can specify how to load the parameters, derived parameters and results
        as follows:

        :const:`pypet.pypetconstants.LOAD_NOTHING`: (0)

            Nothing is loaded

        :const:`pypet.pypetconstants.LOAD_SKELETON`: (1)

            The skeleton including annotations are loaded, i.e. the items are empty.
            Non-empty items in RAM are left untouched.

        :const:`pypet.pypetconstants.LOAD_DATA`: (2)

            The whole data is loaded.
            Only empty or in RAM non-existing instance are filled with the
            data found on disk.

        :const:`pypet.pypetconstants.OVERWRITE_DATA`: (3)

            The whole data is loaded.
            If items that are to be loaded are already in RAM and not empty,
            they are emptied and new data is loaded from disk.


        If `as_new=True` the old trajectory is loaded into the new one, only parameters can be
        loaded. If `as_new=False` the current trajectory is completely replaced by the one
        on disk, i.e. the name from disk, the timestamp, etc. are assigned to `traj`.

        """
        # Some validity checks, if `as_new` is used correctly
        if (as_new and (load_derived_parameters != pypetconstants.LOAD_NOTHING or
                                load_results != pypetconstants.LOAD_NOTHING or
                                load_other_data != pypetconstants.LOAD_NOTHING)):
            raise ValueError('You cannot load a trajectory as new and load the derived '
                             'parameters and results. Only parameters are allowed.')

        if as_new and load_parameters != pypetconstants.LOAD_DATA:
            raise ValueError('You cannot load the trajectory as new and not load the data of '
                             'the parameters.')

        loadconstants = (pypetconstants.LOAD_NOTHING, pypetconstants.LOAD_SKELETON,
                         pypetconstants.LOAD_DATA, pypetconstants.OVERWRITE_DATA)

        if not (load_parameters in loadconstants and load_derived_parameters in loadconstants and
                        load_results in loadconstants and load_other_data in loadconstants):
            raise ValueError('Please give a valid option on how to load data. Options for '
                             '`load_parameter`, `load_derived_parameters`, `load_results`, '
                             'and `load_other_data` are %s. See function documentation for '
                             'the semantics of the values.' % str(loadconstants))

        traj._stored = not as_new

        # Loads meta data like the name, timestamps etc.
        # load_data is only used here to determine how to load the annotations
        load_data = max(load_parameters, load_derived_parameters, load_results, load_other_data)
        if with_meta_data:
            self._trj_load_meta_data(traj, load_data, as_new, with_run_information, force)

        if (load_parameters != pypetconstants.LOAD_NOTHING or
                load_derived_parameters != pypetconstants.LOAD_NOTHING or
                load_results != pypetconstants.LOAD_NOTHING or
                load_other_data != pypetconstants.LOAD_NOTHING):
            self._logger.info('Loading trajectory `%s`.' % traj.v_name)
        else:
            self._logger.info('Checked meta data of trajectory `%s`.' % traj.v_name)
            return

        maximum_display_other = 10
        counter = 0

        for children in [self._trajectory_group._v_groups, self._trajectory_group._v_links]:
            for hdf5_group_name in children:
                hdf5_group = children[hdf5_group_name]
                child_name = hdf5_group._v_name

                load_subbranch = True
                if child_name == 'config':
                    if as_new:
                        loading = pypetconstants.LOAD_NOTHING
                    else:
                        # If the trajectory is loaded as new, we don't care about old config stuff
                        # and only load the parameters
                        loading = load_parameters
                elif child_name == 'parameters':
                    loading = load_parameters
                elif child_name == 'results':
                    loading = load_results
                elif child_name == 'derived_parameters':
                    loading = load_derived_parameters
                elif child_name == 'overview':
                    continue
                else:
                    loading = load_other_data
                    load_subbranch = False

                if loading == pypetconstants.LOAD_NOTHING:
                    continue

                if load_subbranch:
                    # Load the subbranches recursively
                    self._logger.info('Loading branch `%s` in mode `%s`.' %
                                          (child_name, str(loading)))
                else:
                    if counter < maximum_display_other:
                        self._logger.info(
                            'Loading branch/node `%s` in mode `%s`.' % (child_name, str(loading)))
                    elif counter == maximum_display_other:
                        self._logger.info('To many branchs or nodes at root for display. '
                                          'I will not inform you about loading anymore. '
                                          'Branches are loaded silently '
                                          'in the background. Do not worry, '
                                          'I will not freeze! Pinky promise!!!')
                    counter += 1

                self._tree_load_sub_branch(traj, child_name, load_data=loading, with_links=True,
                                     recursive=recursive,
                                     max_depth=max_depth,
                                     _trajectory=traj, _as_new=as_new,
                                     _hdf5_group=self._trajectory_group)
def _trj_load_trajectory(self, traj, as_new, load_parameters, load_derived_parameters,
                             load_results, load_other_data, recursive, max_depth,
                             with_run_information, with_meta_data, force):
        """Loads a single trajectory from a given file.


        :param traj: The trajectory

        :param as_new: Whether to load trajectory as new

        :param load_parameters: How to load parameters and config

        :param load_derived_parameters: How to load derived parameters

        :param load_results: How to load results

        :param load_other_data: How to load anything not within the four subbranches

        :param recursive: If data should be loaded recursively

        :param max_depth: Maximum depth of loading

        :param with_run_information:

            If run information should be loaded

        :param with_meta_data:

            If meta data infor should be loaded

        :param force: Force load in case there is a pypet version mismatch

        You can specify how to load the parameters, derived parameters and results
        as follows:

        :const:`pypet.pypetconstants.LOAD_NOTHING`: (0)

            Nothing is loaded

        :const:`pypet.pypetconstants.LOAD_SKELETON`: (1)

            The skeleton including annotations are loaded, i.e. the items are empty.
            Non-empty items in RAM are left untouched.

        :const:`pypet.pypetconstants.LOAD_DATA`: (2)

            The whole data is loaded.
            Only empty or in RAM non-existing instance are filled with the
            data found on disk.

        :const:`pypet.pypetconstants.OVERWRITE_DATA`: (3)

            The whole data is loaded.
            If items that are to be loaded are already in RAM and not empty,
            they are emptied and new data is loaded from disk.


        If `as_new=True` the old trajectory is loaded into the new one, only parameters can be
        loaded. If `as_new=False` the current trajectory is completely replaced by the one
        on disk, i.e. the name from disk, the timestamp, etc. are assigned to `traj`.

        """
        # Some validity checks, if `as_new` is used correctly
        if (as_new and (load_derived_parameters != pypetconstants.LOAD_NOTHING or
                                load_results != pypetconstants.LOAD_NOTHING or
                                load_other_data != pypetconstants.LOAD_NOTHING)):
            raise ValueError('You cannot load a trajectory as new and load the derived '
                             'parameters and results. Only parameters are allowed.')

        if as_new and load_parameters != pypetconstants.LOAD_DATA:
            raise ValueError('You cannot load the trajectory as new and not load the data of '
                             'the parameters.')

        loadconstants = (pypetconstants.LOAD_NOTHING, pypetconstants.LOAD_SKELETON,
                         pypetconstants.LOAD_DATA, pypetconstants.OVERWRITE_DATA)

        if not (load_parameters in loadconstants and load_derived_parameters in loadconstants and
                        load_results in loadconstants and load_other_data in loadconstants):
            raise ValueError('Please give a valid option on how to load data. Options for '
                             '`load_parameter`, `load_derived_parameters`, `load_results`, '
                             'and `load_other_data` are %s. See function documentation for '
                             'the semantics of the values.' % str(loadconstants))

        traj._stored = not as_new

        # Loads meta data like the name, timestamps etc.
        # load_data is only used here to determine how to load the annotations
        load_data = max(load_parameters, load_derived_parameters, load_results, load_other_data)
        if with_meta_data:
            self._trj_load_meta_data(traj, load_data, as_new, with_run_information, force)

        if (load_parameters != pypetconstants.LOAD_NOTHING or
                load_derived_parameters != pypetconstants.LOAD_NOTHING or
                load_results != pypetconstants.LOAD_NOTHING or
                load_other_data != pypetconstants.LOAD_NOTHING):
            self._logger.info('Loading trajectory `%s`.' % traj.v_name)
        else:
            self._logger.info('Checked meta data of trajectory `%s`.' % traj.v_name)
            return

        maximum_display_other = 10
        counter = 0

        for children in [self._trajectory_group._v_groups, self._trajectory_group._v_links]:
            for hdf5_group_name in children:
                hdf5_group = children[hdf5_group_name]
                child_name = hdf5_group._v_name

                load_subbranch = True
                if child_name == 'config':
                    if as_new:
                        loading = pypetconstants.LOAD_NOTHING
                    else:
                        # If the trajectory is loaded as new, we don't care about old config stuff
                        # and only load the parameters
                        loading = load_parameters
                elif child_name == 'parameters':
                    loading = load_parameters
                elif child_name == 'results':
                    loading = load_results
                elif child_name == 'derived_parameters':
                    loading = load_derived_parameters
                elif child_name == 'overview':
                    continue
                else:
                    loading = load_other_data
                    load_subbranch = False

                if loading == pypetconstants.LOAD_NOTHING:
                    continue

                if load_subbranch:
                    # Load the subbranches recursively
                    self._logger.info('Loading branch `%s` in mode `%s`.' %
                                          (child_name, str(loading)))
                else:
                    if counter < maximum_display_other:
                        self._logger.info(
                            'Loading branch/node `%s` in mode `%s`.' % (child_name, str(loading)))
                    elif counter == maximum_display_other:
                        self._logger.info('To many branchs or nodes at root for display. '
                                          'I will not inform you about loading anymore. '
                                          'Branches are loaded silently '
                                          'in the background. Do not worry, '
                                          'I will not freeze! Pinky promise!!!')
                    counter += 1

                self._tree_load_sub_branch(traj, child_name, load_data=loading, with_links=True,
                                     recursive=recursive,
                                     max_depth=max_depth,
                                     _trajectory=traj, _as_new=as_new,
                                     _hdf5_group=self._trajectory_group)
def _trj_load_trajectory ( self , traj , as_new , load_parameters , load_derived_parameters , load_results , load_other_data , recursive , max_depth , with_run_information , with_meta_data , force ) : # Some validity checks, if `as_new` is used correctly if ( as_new and ( load_derived_parameters != pypetconstants . LOAD_NOTHING or load_results != pypetconstants . LOAD_NOTHING or load_other_data != pypetconstants . LOAD_NOTHING ) ) : raise ValueError ( 'You cannot load a trajectory as new and load the derived ' 'parameters and results. Only parameters are allowed.' ) if as_new and load_parameters != pypetconstants . LOAD_DATA : raise ValueError ( 'You cannot load the trajectory as new and not load the data of ' 'the parameters.' ) loadconstants = ( pypetconstants . LOAD_NOTHING , pypetconstants . LOAD_SKELETON , pypetconstants . LOAD_DATA , pypetconstants . OVERWRITE_DATA ) if not ( load_parameters in loadconstants and load_derived_parameters in loadconstants and load_results in loadconstants and load_other_data in loadconstants ) : raise ValueError ( 'Please give a valid option on how to load data. Options for ' '`load_parameter`, `load_derived_parameters`, `load_results`, ' 'and `load_other_data` are %s. See function documentation for ' 'the semantics of the values.' % str ( loadconstants ) ) traj . _stored = not as_new # Loads meta data like the name, timestamps etc. # load_data is only used here to determine how to load the annotations load_data = max ( load_parameters , load_derived_parameters , load_results , load_other_data ) if with_meta_data : self . _trj_load_meta_data ( traj , load_data , as_new , with_run_information , force ) if ( load_parameters != pypetconstants . LOAD_NOTHING or load_derived_parameters != pypetconstants . LOAD_NOTHING or load_results != pypetconstants . LOAD_NOTHING or load_other_data != pypetconstants . LOAD_NOTHING ) : self . _logger . info ( 'Loading trajectory `%s`.' % traj . v_name ) else : self . _logger . info ( 'Checked meta data of trajectory `%s`.' % traj . v_name ) return maximum_display_other = 10 counter = 0 for children in [ self . _trajectory_group . _v_groups , self . _trajectory_group . _v_links ] : for hdf5_group_name in children : hdf5_group = children [ hdf5_group_name ] child_name = hdf5_group . _v_name load_subbranch = True if child_name == 'config' : if as_new : loading = pypetconstants . LOAD_NOTHING else : # If the trajectory is loaded as new, we don't care about old config stuff # and only load the parameters loading = load_parameters elif child_name == 'parameters' : loading = load_parameters elif child_name == 'results' : loading = load_results elif child_name == 'derived_parameters' : loading = load_derived_parameters elif child_name == 'overview' : continue else : loading = load_other_data load_subbranch = False if loading == pypetconstants . LOAD_NOTHING : continue if load_subbranch : # Load the subbranches recursively self . _logger . info ( 'Loading branch `%s` in mode `%s`.' % ( child_name , str ( loading ) ) ) else : if counter < maximum_display_other : self . _logger . info ( 'Loading branch/node `%s` in mode `%s`.' % ( child_name , str ( loading ) ) ) elif counter == maximum_display_other : self . _logger . info ( 'To many branchs or nodes at root for display. ' 'I will not inform you about loading anymore. ' 'Branches are loaded silently ' 'in the background. Do not worry, ' 'I will not freeze! Pinky promise!!!' ) counter += 1 self . _tree_load_sub_branch ( traj , child_name , load_data = loading , with_links = True , recursive = recursive , max_depth = max_depth , _trajectory = traj , _as_new = as_new , _hdf5_group = self . _trajectory_group )
Loads a single trajectory from a given file.


        :param traj: The trajectory

        :param as_new: Whether to load trajectory as new

        :param load_parameters: How to load parameters and config

        :param load_derived_parameters: How to load derived parameters

        :param load_results: How to load results

        :param load_other_data: How to load anything not within the four subbranches

        :param recursive: If data should be loaded recursively

        :param max_depth: Maximum depth of loading

        :param with_run_information:

            If run information should be loaded

        :param with_meta_data:

            If meta data infor should be loaded

        :param force: Force load in case there is a pypet version mismatch

        You can specify how to load the parameters, derived parameters and results
        as follows:

        :const:`pypet.pypetconstants.LOAD_NOTHING`: (0)

            Nothing is loaded

        :const:`pypet.pypetconstants.LOAD_SKELETON`: (1)

            The skeleton including annotations are loaded, i.e. the items are empty.
            Non-empty items in RAM are left untouched.

        :const:`pypet.pypetconstants.LOAD_DATA`: (2)

            The whole data is loaded.
            Only empty or in RAM non-existing instance are filled with the
            data found on disk.

        :const:`pypet.pypetconstants.OVERWRITE_DATA`: (3)

            The whole data is loaded.
            If items that are to be loaded are already in RAM and not empty,
            they are emptied and new data is loaded from disk.


        If `as_new=True` the old trajectory is loaded into the new one, only parameters can be
        loaded. If `as_new=False` the current trajectory is completely replaced by the one
        on disk, i.e. the name from disk, the timestamp, etc. are assigned to `traj`.
Loads a single trajectory from a given file .