[Yt-svn] yt: 1. Bug fixes and upgrades to the StarAnalysis stuff.
hg at spacepope.org
hg at spacepope.org
Sun Mar 21 16:18:59 PDT 2010
hg Repository: yt
details: yt/rev/4f3965faa48c
changeset: 1465:4f3965faa48c
user: Stephen Skory <stephenskory at yahoo.com>
date:
Sun Mar 21 16:18:08 2010 -0700
description:
1. Bug fixes and upgrades to the StarAnalysis stuff.
2. The python-native kd tree really sucks. I've effectively turned it
into a brute-force search with this change. But for some reason it
isn't finding the correct nearest neighbors. I think slow but correct
is preferable to fast(ish) and wrong.
3. Small changes to the parallel HOP code for mpi_get_size/rank().
diffstat:
yt/extensions/StarAnalysis.py | 15 ++++++++++++---
yt/lagos/HaloFinding.py | 4 ++--
yt/lagos/kd.py | 2 +-
yt/lagos/parallelHOP/parallelHOP.py | 5 +----
4 files changed, 16 insertions(+), 10 deletions(-)
diffs (102 lines):
diff -r 1aa6eb842a66 -r 4f3965faa48c yt/extensions/StarAnalysis.py
--- a/yt/extensions/StarAnalysis.py Sun Mar 21 14:58:21 2010 -0700
+++ b/yt/extensions/StarAnalysis.py Sun Mar 21 16:18:08 2010 -0700
@@ -215,7 +215,7 @@
def calculate_spectrum(self, data_source=None, star_mass=None,
star_creation_time=None, star_metallicity_fraction=None,
- star_metallicity_constant=None):
+ star_metallicity_constant=None, min_age=0.):
"""
For the set of stars, calculate the collective spectrum.
Attached to the output are several useful objects:
@@ -233,6 +233,8 @@
metallicity fractions, in code units (which is not Z/Zsun).
:param star_metallicity_constant (float): If desired, override the star
metallicity fraction of all the stars to the given value.
+ :param min_age (float): Removes young stars below this number (in years
+ from the spectrum. Default: 0 (all stars).
"""
# Initialize values
self.final_spec = na.zeros(self.wavelength.size, dtype='float64')
@@ -240,6 +242,7 @@
self.star_mass = star_mass
self.star_creation_time = star_creation_time
self.star_metal = star_metallicity_fraction
+ self.min_age = min_age
# Check to make sure we have the right set of data.
if data_source is None:
@@ -273,8 +276,13 @@
self.star_metal /= Zsun
# Age of star in years.
dt = (self.time_now - self.star_creation_time * self._pf['Time']) / YEAR
+ # Remove young stars
+ sub = dt > self.min_age
+ self.star_metal = self.star_metal[sub]
+ dt = dt[sub]
+ self.star_creation_time = self.star_creation_time[sub]
# Figure out which METALS bin the star goes into.
- Mindex = na.digitize(dt, METALS)
+ Mindex = na.digitize(self.star_metal, METALS)
# Replace the indices with strings.
Mname = MtoD[Mindex]
# Figure out which age bin this star goes into.
@@ -284,7 +292,8 @@
ratio2 = (self.age[Aindex] - dt) / (self.age[Aindex] - self.age[Aindex-1])
# Sort the stars by metallicity and then by age, which should reduce
# memory access time by a little bit in the loop.
- sort = na.lexsort((Aindex, Mname))
+ indexes = na.arange(self.star_metal.size)
+ sort = na.asarray([indexes[i] for i in na.lexsort([indexes, Aindex, Mname])])
Mname = Mname[sort]
Aindex = Aindex[sort]
ratio1 = ratio1[sort]
diff -r 1aa6eb842a66 -r 4f3965faa48c yt/lagos/HaloFinding.py
--- a/yt/lagos/HaloFinding.py Sun Mar 21 14:58:21 2010 -0700
+++ b/yt/lagos/HaloFinding.py Sun Mar 21 16:18:08 2010 -0700
@@ -1144,7 +1144,7 @@
# Adaptive subregions by bisection.
ds_names = ["particle_position_x","particle_position_y","particle_position_z"]
if ytcfg.getboolean("yt","inline") == False and \
- resize and self._mpi_get_size() is not None:
+ resize and self._mpi_get_size() != 1:
cut_list = self._partition_hierarchy_3d_bisection_list()
for i,cut in enumerate(cut_list):
dim = cut[0]
@@ -1180,7 +1180,7 @@
del bins, counts
# If this isn't parallel, define the region as an AMRRegionStrict so
# particle IO works.
- if self._mpi_get_size() == None or self._mpi_get_size() == 1:
+ if self._mpi_get_size() == 1:
self._data_source = self.hierarchy.periodic_region_strict([0.5]*3, LE, RE)
# get the average spacing between particles for this region
# The except is for the serial case, where the full box is what we want.
diff -r 1aa6eb842a66 -r 4f3965faa48c yt/lagos/kd.py
--- a/yt/lagos/kd.py Sun Mar 21 14:58:21 2010 -0700
+++ b/yt/lagos/kd.py Sun Mar 21 16:18:08 2010 -0700
@@ -223,7 +223,7 @@
# if this node is close enough (the distances are calculated in the previous
# iteration), or if the query point is inside the node, continue on
- if (neighbors.minDistanceSquared > distanceSquared) or inside:
+ if True or inside:
# leafs don't have children, so this tests to see if this node
# is a leaf, and if it is a leaf, calculate distances to the query point
if (node.leftChild is None):
diff -r 1aa6eb842a66 -r 4f3965faa48c yt/lagos/parallelHOP/parallelHOP.py
--- a/yt/lagos/parallelHOP/parallelHOP.py Sun Mar 21 14:58:21 2010 -0700
+++ b/yt/lagos/parallelHOP/parallelHOP.py Sun Mar 21 16:18:08 2010 -0700
@@ -1131,10 +1131,7 @@
Set_list = []
# We only want the holes that are modulo mine.
keys = na.arange(groupID, dtype='int64')
- if self._mpi_get_size() == None:
- size = 1
- else:
- size = self._mpi_get_size()
+ size = self._mpi_get_size()
select = (keys % size == self.mine)
groupIDs = keys[select]
mine_groupIDs = set([]) # Records only ones modulo mine.
More information about the yt-svn
mailing list