Skip to content

Commit

Permalink
starformation
Browse files Browse the repository at this point in the history
added precise statement
  • Loading branch information
healther committed Apr 4, 2013
1 parent b80f742 commit 60c1b83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def main():
for av in np.linspace(5.0, 50.0, 10):
for apera in np.linspace(15000, 50000, 11):
for age in np.linspace(500000, 2000000, 11):
starformation.main(av, .001, apera, age, "%s_%s_%s" % (av,apera,age), True)
starformation.main(av, .001, apera, age, "%s_%s_%s" % (av,apera,age), quiet=True)
print av, apera, age, k/10./11./11.
k = k+1
parameters.append([av,apera,age])
Expand All @@ -28,6 +28,6 @@ def main():
f.write( ','.join(head)+'\n' )
np.savetxt(f, parameters)
f.close()
analysis.main('out', True)
analysis.main('out', quiet=True)


24 changes: 16 additions & 8 deletions starformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@



def main(A_v = 10.0, sfr = .001, apera = 24000, maxage = 2000000., appendix='default', quiet=0):
def main(A_v = 10.0, sfr = .001, apera = 24000, maxage = 2000000., appendix='default', quiet=0, precise=0):
'''Creates a sample of stars
input:
Expand Down Expand Up @@ -72,16 +72,24 @@ def g(x):

t1 = time() # startup completed

if precise == True:
while cumass < exmass:
mass, age = mf.sample(1)[0], sf.sample(1)[0]
cumass = cumass + mass
stars.append([n, age, mass])
if n % 10000 == 0:
print (n, cumass, file=output_stream) #reporting progress
n = n+1
else:
n = int(exmass/.49)
mass, age = mf.sample(n), sf.sample(n)
cumass = np.sum(mass)
stars = [[i, age[i], mass[i]] for i in range(n)]

while cumass < exmass:
mass, age = mf.sample(1)[0], sf.sample(1)[0]
cumass = cumass + mass
stars.append([n, age, mass])
if n % 10000 == 0:
print (n, cumass, file=output_stream) #reporting progress
n = n+1
print ('number of sampled stars: %s' %n , file=output_stream)
print ('mass of sampled stars: %s' % cumass , file=output_stream)
print ('mean mass: %s' % (cumass/n), file=output_stream)
print ('expected mass of stars: %s' % exmass , file=output_stream)
t2 = time() # sampleing completed


Expand Down

0 comments on commit 60c1b83

Please sign in to comment.