Skip to content
Snippets Groups Projects
Commit 1291fec3 authored by Bert Vandenbroucke's avatar Bert Vandenbroucke
Browse files

Made all python scripts numpy 1.8.2 compatible, and fixed some bugs while doing it.

parent 26ecd35b
Branches
Tags
1 merge request!319Made all python scripts numpy 1.8.2 compatible, and fixed some bugs while doing it.
......@@ -107,7 +107,7 @@ if n_copy > 1:
for i in range(n_copy):
for j in range(n_copy):
for k in range(n_copy):
coords = np.append(coords, coords_tile + np.array([ i * boxSize, j * boxSize, k * boxSize ]), axis=0)
coords = np.append(coords, coords_tile + np.array([ i * boxSize[0], j * boxSize[1], k * boxSize[2] ]), axis=0)
v = np.append(v, v_tile, axis=0)
m = np.append(m, m_tile)
h = np.append(h, h_tile)
......
......@@ -227,7 +227,7 @@ ds[()] = u
u = np.zeros(1)
# Particle IDs
ids = 1 + np.linspace(0, N, N, endpoint=False, dtype='L')
ids = 1 + np.linspace(0, N, N, endpoint=False)
ds = grp.create_dataset('ParticleIDs', (N, ), 'L')
ds[()] = ids
......
......@@ -233,7 +233,7 @@ ds[()] = u
u = np.zeros(1)
# Particle IDs
ids = 1 + np.linspace(0, N, N, endpoint=False, dtype='L')
ids = 1 + np.linspace(0, N, N, endpoint=False)
ds = grp.create_dataset('ParticleIDs', (N, ), 'L')
ds[()] = ids
......
......@@ -150,7 +150,7 @@ ds[()] = m
m = numpy.zeros(1)
ids = 1 + numpy.linspace(0, numPart, numPart, endpoint=False, dtype='L')
ids = 1 + numpy.linspace(0, numPart, numPart, endpoint=False)
ds = grp1.create_dataset('ParticleIDs', (numPart, ), 'L')
ds[()] = ids
......
......@@ -205,7 +205,7 @@ if (entropy_flag == 1):
else:
ds[()] = u
ids = 1 + numpy.linspace(0, numGas, numGas, endpoint=False, dtype='L')
ids = 1 + numpy.linspace(0, numGas, numGas, endpoint=False)
ds = grp0.create_dataset('ParticleIDs', (numGas, ), 'L')
ds[()] = ids
......
......@@ -28,7 +28,7 @@ unit_mass_cgs = float(params.attrs["InternalUnitSystem:UnitMass_in_cgs"])
unit_length_cgs = float(params.attrs["InternalUnitSystem:UnitLength_in_cgs"])
unit_velocity_cgs = float(params.attrs["InternalUnitSystem:UnitVelocity_in_cgs"])
unit_time_cgs = unit_length_cgs / unit_velocity_cgs
v_c = float(params.attrs["SoftenedIsothermalPotential:vrot"])
v_c = float(params.attrs["IsothermalPotential:vrot"])
v_c_cgs = v_c * unit_velocity_cgs
#lambda_cgs = float(params.attrs["LambdaCooling:lambda_cgs"])
#X_H = float(params.attrs["LambdaCooling:hydrogen_mass_abundance"])
......
......@@ -46,7 +46,7 @@ unit_mass_cgs = float(params.attrs["InternalUnitSystem:UnitMass_in_cgs"])
unit_length_cgs = float(params.attrs["InternalUnitSystem:UnitLength_in_cgs"])
unit_velocity_cgs = float(params.attrs["InternalUnitSystem:UnitVelocity_in_cgs"])
unit_time_cgs = unit_length_cgs / unit_velocity_cgs
v_c = float(params.attrs["SoftenedIsothermalPotential:vrot"])
v_c = float(params.attrs["IsothermalPotential:vrot"])
v_c_cgs = v_c * unit_velocity_cgs
#lambda_cgs = float(params.attrs["LambdaCooling:lambda_cgs"])
#X_H = float(params.attrs["LambdaCooling:hydrogen_mass_abundance"])
......
......@@ -227,7 +227,7 @@ ds[()] = u
u = np.zeros(1)
# Particle IDs
ids = 1 + np.linspace(0, N, N, endpoint=False, dtype='L')
ids = 1 + np.linspace(0, N, N, endpoint=False)
ds = grp.create_dataset('ParticleIDs', (N, ), 'L')
ds[()] = ids
......
......@@ -46,7 +46,7 @@ unit_mass_cgs = float(params.attrs["InternalUnitSystem:UnitMass_in_cgs"])
unit_length_cgs = float(params.attrs["InternalUnitSystem:UnitLength_in_cgs"])
unit_velocity_cgs = float(params.attrs["InternalUnitSystem:UnitVelocity_in_cgs"])
unit_time_cgs = unit_length_cgs / unit_velocity_cgs
v_c = float(params.attrs["SoftenedIsothermalPotential:vrot"])
v_c = float(params.attrs["IsothermalPotential:vrot"])
v_c_cgs = v_c * unit_velocity_cgs
header = f["Header"]
N = header.attrs["NumPart_Total"][0]
......
......@@ -138,7 +138,7 @@ ds = grp1.create_dataset('Masses', (numPart,), 'f')
ds[()] = m
m = numpy.zeros(1)
ids = 1 + numpy.linspace(0, numPart, numPart, endpoint=False, dtype='L')
ids = 1 + numpy.linspace(0, numPart, numPart, endpoint=False)
ds = grp1.create_dataset('ParticleIDs', (numPart, ), 'L')
ds[()] = ids
......
......@@ -35,8 +35,8 @@ glass = h5py.File("glassCube_64.hdf5", "r")
vol = 8.
pos = glass["/PartType0/Coordinates"][:,:] * cbrt(vol)
h = glass["/PartType0/SmoothingLength"][:] * cbrt(vol)
pos = glass["/PartType0/Coordinates"][:,:] * vol**(1./3.)
h = glass["/PartType0/SmoothingLength"][:] * vol**(1./3.)
numPart = size(h)
# Generate extra arrays
......@@ -65,7 +65,7 @@ file = h5py.File(fileName, 'w')
# Header
grp = file.create_group("/Header")
grp.attrs["BoxSize"] = [cbrt(vol), cbrt(vol), cbrt(vol)]
grp.attrs["BoxSize"] = [vol**(1./3.), vol**(1./3.), vol**(1./3.)]
grp.attrs["NumPart_Total"] = [numPart, 0, 0, 0, 0, 0]
grp.attrs["NumPart_Total_HighWord"] = [0, 0, 0, 0, 0, 0]
grp.attrs["NumPart_ThisFile"] = [numPart, 0, 0, 0, 0, 0]
......
......@@ -55,7 +55,7 @@ rho_x = 1000.*np.exp(-0.5*A/np.pi/cs2*np.cos(2.*np.pi*x))
P = cs2*rho
n1D = int(np.cbrt(len(P)))
n1D = np.ceil(len(P)**(1./3.))
gradP = np.zeros(P.shape)
for i in range(len(P)):
iself = int(ids[i]/n1D/n1D)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment