Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not os.path.exists(groupfinder):
raise RuntimeError("Path to AHF (%s) is invalid" % groupfinder)
if (os.path.basename(groupfinder) == 'AHFstep'):
isAHFstep = True
else:
isAHFstep = False
# build units file
if isAHFstep:
f = open('tipsy.info', 'w')
f.write(str(sim.properties['omegaM0']) + "\n")
f.write(str(sim.properties['omegaL0']) + "\n")
f.write(str(sim['pos'].units.ratio(
units.kpc, a=1) / 1000.0 * sim.properties['h']) + "\n")
f.write(
str(sim['vel'].units.ratio(units.km / units.s, a=1)) + "\n")
f.write(str(sim['mass'].units.ratio(units.Msol)) + "\n")
f.close()
# make input file
f = open('AHF.in', 'w')
f.write(sim._filename + " " + str(typecode) + " 1\n")
f.write(sim._filename + "\n256\n5\n5\n0\n0\n0\n0\n")
f.close()
else:
# make input file
f = open('AHF.in', 'w')
lgmax = np.min([int(2 ** np.floor(np.log2(
1.0 / np.min(sim['eps'])))), 131072])
# hardcoded maximum 131072 might not be necessary
print >>f, config_parser.get('AHFCatalogue', 'Config', vars={
raise RuntimeError("Path to AHF (%s) is invalid" % groupfinder)
if (os.path.basename(groupfinder) == 'AHFstep'):
isAHFstep = True
else:
isAHFstep = False
# build units file
if isAHFstep:
f = open('tipsy.info', 'w')
f.write(str(sim.properties['omegaM0']) + "\n")
f.write(str(sim.properties['omegaL0']) + "\n")
f.write(str(sim['pos'].units.ratio(
units.kpc, a=1) / 1000.0 * sim.properties['h']) + "\n")
f.write(
str(sim['vel'].units.ratio(units.km / units.s, a=1)) + "\n")
f.write(str(sim['mass'].units.ratio(units.Msol)) + "\n")
f.close()
# make input file
f = open('AHF.in', 'w')
f.write(sim._filename + " " + str(typecode) + " 1\n")
f.write(sim._filename + "\n256\n5\n5\n0\n0\n0\n0\n")
f.close()
else:
# make input file
f = open('AHF.in', 'w')
lgmax = np.min([int(2 ** np.floor(np.log2(
1.0 / np.min(sim['eps'])))), 131072])
# hardcoded maximum 131072 might not be necessary
print >>f, config_parser.get('AHFCatalogue', 'Config', vars={
'filename': sim._filename,
lgmax = np.min([int(2 ** np.floor(np.log2(
1.0 / np.min(sim['eps'])))), 131072])
# hardcoded maximum 131072 might not be necessary
print >>f, config_parser.get('AHFCatalogue', 'Config', vars={
'filename': sim._filename,
'typecode': typecode,
'gridmax': lgmax
})
print >>f, config_parser.get('AHFCatalogue', 'ConfigTipsy', vars={
'omega0': sim.properties['omegaM0'],
'lambda0': sim.properties['omegaL0'],
'boxsize': sim['pos'].units.ratio('Mpc a h^-1', **sim.conversion_context()),
'vunit': sim['vel'].units.ratio('km s^-1 a', **sim.conversion_context()),
'munit': sim['mass'].units.ratio('Msol h^-1', **sim.conversion_context()),
'eunit': 0.03 # surely this can't be right?
})
f.close()
if (not os.path.exists(sim._filename)):
os.system("gunzip " + sim._filename + ".gz")
# determine parallel possibilities
if os.path.exists(groupfinder):
# run it
os.system(groupfinder + " AHF.in")
return
groupfinder = ahf
break
if not os.path.exists(groupfinder):
raise RuntimeError("Path to AHF (%s) is invalid" % groupfinder)
if (os.path.basename(groupfinder) == 'AHFstep'):
isAHFstep = True
else:
isAHFstep = False
# build units file
if isAHFstep:
f = open('tipsy.info', 'w')
f.write(str(sim.properties['omegaM0']) + "\n")
f.write(str(sim.properties['omegaL0']) + "\n")
f.write(str(sim['pos'].units.ratio(
units.kpc, a=1) / 1000.0 * sim.properties['h']) + "\n")
f.write(
str(sim['vel'].units.ratio(units.km / units.s, a=1)) + "\n")
f.write(str(sim['mass'].units.ratio(units.Msol)) + "\n")
f.close()
# make input file
f = open('AHF.in', 'w')
f.write(sim._filename + " " + str(typecode) + " 1\n")
f.write(sim._filename + "\n256\n5\n5\n0\n0\n0\n0\n")
f.close()
else:
# make input file
f = open('AHF.in', 'w')
lgmax = np.min([int(2 ** np.floor(np.log2(
1.0 / np.min(sim['eps'])))), 131072])
groupfinder = ahf
break
if not os.path.exists(groupfinder):
raise RuntimeError("Path to AHF (%s) is invalid" % groupfinder)
if (os.path.basename(groupfinder) == 'AHFstep'):
isAHFstep = True
else:
isAHFstep = False
# build units file
if isAHFstep:
f = open('tipsy.info', 'w')
f.write(str(sim.properties['omegaM0']) + "\n")
f.write(str(sim.properties['omegaL0']) + "\n")
f.write(str(sim['pos'].units.ratio(
units.kpc, a=1) / 1000.0 * sim.properties['h']) + "\n")
f.write(
str(sim['vel'].units.ratio(units.km / units.s, a=1)) + "\n")
f.write(str(sim['mass'].units.ratio(units.Msol)) + "\n")
f.close()
# make input file
f = open('AHF.in', 'w')
f.write(sim._filename + " " + str(typecode) + " 1\n")
f.write(sim._filename + "\n256\n5\n5\n0\n0\n0\n0\n")
f.close()
else:
# make input file
f = open('AHF.in', 'w')
lgmax = np.min([int(2 ** np.floor(np.log2(
1.0 / np.min(sim['eps'])))), 131072])
raise RuntimeError("Path to AHF (%s) is invalid" % groupfinder)
if (os.path.basename(groupfinder) == 'AHFstep'):
isAHFstep = True
else:
isAHFstep = False
# build units file
if isAHFstep:
f = open('tipsy.info', 'w')
f.write(str(sim.properties['omegaM0']) + "\n")
f.write(str(sim.properties['omegaL0']) + "\n")
f.write(str(sim['pos'].units.ratio(
units.kpc, a=1) / 1000.0 * sim.properties['h']) + "\n")
f.write(
str(sim['vel'].units.ratio(units.km / units.s, a=1)) + "\n")
f.write(str(sim['mass'].units.ratio(units.Msol)) + "\n")
f.close()
# make input file
f = open('AHF.in', 'w')
f.write(sim._filename + " " + str(typecode) + " 1\n")
f.write(sim._filename + "\n256\n5\n5\n0\n0\n0\n0\n")
f.close()
else:
# make input file
f = open('AHF.in', 'w')
lgmax = np.min([int(2 ** np.floor(np.log2(
1.0 / np.min(sim['eps'])))), 131072])
# hardcoded maximum 131072 might not be necessary
print >>f, config_parser.get('AHFCatalogue', 'Config', vars={
'filename': sim._filename,
lgmax = np.min([int(2 ** np.floor(np.log2(
1.0 / np.min(sim['eps'])))), 131072])
# hardcoded maximum 131072 might not be necessary
print >>f, config_parser.get('AHFCatalogue', 'Config', vars={
'filename': sim._filename,
'typecode': typecode,
'gridmax': lgmax
})
print >>f, config_parser.get('AHFCatalogue', 'ConfigTipsy', vars={
'omega0': sim.properties['omegaM0'],
'lambda0': sim.properties['omegaL0'],
'boxsize': sim['pos'].units.ratio('Mpc a h^-1', **sim.conversion_context()),
'vunit': sim['vel'].units.ratio('km s^-1 a', **sim.conversion_context()),
'munit': sim['mass'].units.ratio('Msol h^-1', **sim.conversion_context()),
'eunit': 0.03 # surely this can't be right?
})
f.close()
if (not os.path.exists(sim._filename)):
os.system("gunzip " + sim._filename + ".gz")
# determine parallel possibilities
if os.path.exists(groupfinder):
# run it
os.system(groupfinder + " AHF.in")
return