Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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()
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