def use_quantities(self, filename, quantities=['density', 'specific_energy'],
                       use_minimum_specific_energy=True, use_dust=True, copy=True,
                       only_initial=False):

        from .helpers import find_last_iteration

        # Open existing file
        f = h5py.File(filename, 'r')

        # Find path to file for link. For now, use absolute links.
        # In Model.write() we can always replace the links with
        # relative links if desired.
        file_path = os.path.abspath(filename)

        logger.info("Retrieving quantities from %s" % filename)

        quantities_path = {}

        if 'Input' in f:

            # Find last iteration
            max_iteration = find_last_iteration(f)

            if only_initial:
                logger.info("Reading input quantities")
            elif max_iteration == 0:
                logger.warn("No iterations found in file - only the input quantities will be used")
                last_iteration = None
            else:
                logger.info("Retrieving quantities from iteration %i" % max_iteration)
                last_iteration = 'iteration_{0:05d}'.format(max_iteration)

            if 'density' in quantities:
                if only_initial or last_iteration is None or 'density' not in f[last_iteration]:
                    quantities_path['density'] = '/Input/Grid/Quantities'
                else:
                    quantities_path['density'] = last_iteration

            if 'specific_energy' in quantities:
                if only_initial or last_iteration is None:
                    if 'specific_energy' in f['/Input/Grid/Quantities']:
                        quantities_path['specific_energy'] = '/Input/Grid/Quantities'
                else:
                    quantities_path['specific_energy'] = last_iteration

            # Minimum specific energy
            if use_minimum_specific_energy:
                minimum_specific_energy_path = '/Input/Grid/Quantities'

            if use_dust:
                dust_path = '/Input/Dust'

        else:

            if 'density' in quantities:
                quantities_path['density'] = '/Grid/Quantities'

            if 'specific_energy' in quantities:
                if 'specific_energy' in f['/Grid/Quantities']:
                    quantities_path['specific_energy'] = '/Grid/Quantities'

            # Minimum specific energy
            if use_minimum_specific_energy:
                minimum_specific_energy_path = '/Grid/Quantities'

            if use_dust:
                dust_path = '/Dust'

        # Now extract the quantities
        for quantity in quantities_path:

            logger.info("Using {quantity} from {path} in {filename}".format(quantity=quantity, path=quantities_path[quantity], filename=filename))

            # Add quantity to grid
            if copy:
                self.grid.read_quantities(f[quantities_path[quantity]], quantities=[quantity])
            else:
                self.grid[quantity] = h5py.ExternalLink(file_path, quantities_path[quantity] + '/' + quantity)

        # Minimum specific energy
        if use_minimum_specific_energy and 'minimum_specific_energy' in f[minimum_specific_energy_path].attrs:
            logger.info("Using minimum_specific_energy from {filename}".format(filename=filename))
            self.set_minimum_specific_energy([float(x) for x in f[minimum_specific_energy_path].attrs['minimum_specific_energy']])

        # Dust properties
        if use_dust:
            logger.info("Using dust properties from {filename}".format(filename=filename))
            if copy:
                self.dust = [SphericalDust(f[dust_path][name]) for name in f[dust_path]]
            else:
                self.dust = h5py.ExternalLink(file_path, dust_path)

        # Close the file
        f.close()
Decorator for Flask view functions.
dataset/ETHPy150Open hyperion-rt/hyperion/hyperion/model/model.py/Model.use_quantities--crossover with--dataset/ETHPy150Open peterhudec/authomatic/authomatic/extras/flask.py/FlaskAuthomatic.login