Skip to content

Commit 73c5cdf

Browse files
committed
Minor cosmetic changes
1 parent b2a97da commit 73c5cdf

File tree

4 files changed

+7
-60
lines changed

4 files changed

+7
-60
lines changed

ICgen_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def delistify(in_list):
177177

178178
return in_list
179179

180-
def est_eps(smoothlength_file):
180+
def est_eps(smoothlength_file, nstar=1):
181181
"""
182182
Estimate gravitational softening length (eps) from a ChaNGa output .smoothlength
183183
file. eps is estimated as 1/2 the mean smoothing length
@@ -186,6 +186,8 @@ def est_eps(smoothlength_file):
186186
187187
smoothlength_file : str
188188
Filename of the .smoothlength file
189+
nstar : int
190+
Number of star particles present
189191
190192
**RETURNS**
191193
@@ -204,7 +206,7 @@ def est_eps(smoothlength_file):
204206
smoothlength[i] = float(line.strip())
205207

206208
# Calculate eps, ignoring star particle
207-
mean_smooth = (smoothlength.sum() - smoothlength[-1])/(nParticles-1)
209+
mean_smooth = (smoothlength.sum() - smoothlength[-nstar])/(nParticles-nstar)
208210
eps = mean_smooth/2
209211

210212
return eps

calc_rho.py

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ def erf_res(scale_size):
301301

302302
return SimArray(rho0,'Msol au**-3'), SimArray(z,'au')
303303

304+
304305
def cdfinv_z(z,rho):
305306
"""
306307
Calculates the inverse of the cumulative distribution function for
@@ -359,60 +360,3 @@ def finv(m):
359360

360361
return finv
361362

362-
#def cdfinv_z(z,rho):
363-
# """
364-
# Calculates the inverse of the cumulative distribution function for
365-
# probability as a function of z for a given r
366-
#
367-
# *** Arguments ***
368-
#
369-
# * z * z positions to calculate over. 1D array
370-
#
371-
# * rho * Density as a function of z. Treated as an un-normalized
372-
# probability. 1D array
373-
#
374-
# IF Z doesn't have units, units of 'au' are assumed
375-
#
376-
# *** Returns ***
377-
#
378-
# Returns the inverse normalized CDF as 1D spline interpolation
379-
# """
380-
# # Check for units
381-
# if pynbody.units.has_units(z):
382-
#
383-
# zunit = z.units
384-
#
385-
# else:
386-
#
387-
# zunit = pynbody.units.au
388-
#
389-
# # Calculate the CDF from prob
390-
# nz = len(z)
391-
# f = np.zeros(nz)
392-
# f[1:] = nInt.cumtrapz(rho,z)
393-
# if f.max() <= 0.0:
394-
# # The density (rho) is zero here for all z or neg or something.
395-
# # Make all particles go to z = 0.0
396-
# def finv(m_in):
397-
# return m_in*0.0
398-
# return finv
399-
# f /= f.max()
400-
# # Calculate the inverse CDF.
401-
# # Assume CDF is approximately monotonic and sort to force it to be
402-
# ind = f.argsort()
403-
# f = f[ind]
404-
# z = z[ind]
405-
# # Drop values where CDF is constant (ie, prob = 0)
406-
# mask = np.ones(nz,dtype='bool')
407-
# for n in range(1,nz):
408-
# if f[n] == f[n-1]:
409-
# mask[n] = False
410-
# f = f[mask]
411-
# z = z[mask]
412-
# finv_spline = interp1d(f,z,kind='linear')
413-
#
414-
# def finv(m):
415-
#
416-
# return SimArray(finv_spline(m), zunit)
417-
#
418-
# return finv

calc_rho_zr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def rho_zr(ICobj):
9595
# Calculate rho using multiprocessing
9696
pool = Pool(n_proc)
9797
results = pool.map(multirun_rho, arg_list)
98+
pool.close()
9899

99100
# Extract results
100101
for i in range(nr):

make_snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def snapshot_gen(ICobj):
8383
star_metals = metals
8484

8585
# -------------------------------------------------
86-
# Generate snapshot
86+
# Initialize snapshot
8787
# -------------------------------------------------
8888
# Note that empty pos, vel, and mass arrays are created in the snapshot
8989
snapshot = pynbody.new(star=1,gas=nParticles)

0 commit comments

Comments
 (0)