How to use the plonk.units.Units function in plonk

To help you get started, we’ve selected a few plonk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dmentipl / plonk / plonk / header.py View on Github external
def _read_hdf5_file(self):

        f = h5py.File(self.filename, 'r')

        headerGroup = f['header']

        parameters = dict()
        for key in headerGroup.keys():
            parameters[key] = headerGroup[key].value

        f.close()

        self.parameters = parameters

        units = Units(parameters['udist'], parameters['umass'], parameters['utime'])
        self.units = units.units

        warning = '''
Warning: hdf5 header read cannot determine if full/small dump or if the dump
contains dust. For now assume full dump and no dust.
        '''
        print(warning)

        self.dumpType = 'full'
        self.containsDust = False
github dmentipl / plonk / plonk / PhantomDump.py View on Github external
headerFileName = filePrefix + '.' + fileExtension

        exists = os.path.isfile(headerFileName)
        if not exists:
            raise FileNotFoundError('Cannot find header file: ' +
                                    headerFileName)

        if dumpFileFormat == 'HDF5':
            header, isFullDump = _read_header_from_hdf5(headerFileName)

        elif dumpFileFormat == 'ASCII':
            header, isFullDump = _read_header_from_showheader(headerFileName)

        self.Parameters = header

        self.Units = Units(header['udist'], header['umass'],
                           header['utime']).units

        return isFullDump
github dmentipl / plonk / plonk / parameters.py View on Github external
numerical['hfact'] = 1.2
        numerical['tolh'] = 0.0001
        numerical['C_cour'] = 0.3
        numerical['C_force'] = 0.25
        numerical['alpha'] = 0.1

        sinks = dict()

        sinks['nSinks'] = 0

        self.particles = particles
        self.dust      = dust
        self.eos       = eos
        self.numerical = numerical
        self.sinks     = sinks
        self.units     = Units()
github dmentipl / plonk / plonk / header.py View on Github external
firstMultipleKey = True
                idxj += 1
                newKeys.append(key)
                newValues.append(values[idxi])

            prevKey = key

        parameters = dict(zip(newKeys, newValues))

        for key in parameters:
            if isinstance(parameters[key], list):
                parameters[key] = np.array(parameters[key])

        self.parameters = parameters

        units = Units(parameters['udist'], parameters['umass'], parameters['utime'])
        self.units = units.units