[yt-svn] commit/yt: 6 new changesets
Bitbucket
commits-noreply at bitbucket.org
Wed Feb 22 12:48:16 PST 2012
6 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/e6dae57f8a91/
changeset: e6dae57f8a91
branch: yt
user: jsoishi
date: 2012-02-16 23:24:35
summary: handle case of orion datasets without star particles.
affected #: 1 file
diff -r 1813cc76ec989338de44f8470cceb939e8fef777 -r e6dae57f8a913d4f7e873f3277d7510fefa1ea06 yt/frontends/orion/data_structures.py
--- a/yt/frontends/orion/data_structures.py
+++ b/yt/frontends/orion/data_structures.py
@@ -136,30 +136,33 @@
"""
self.grid_particle_count = na.zeros(len(self.grids))
fn = self.pf.fullplotdir + "/StarParticles"
- with open(fn, 'r') as f:
- lines = f.readlines()
- self.num_stars = int(lines[0].strip())
- for line in lines[1:]:
- particle_position_x = float(line.split(' ')[1])
- particle_position_y = float(line.split(' ')[2])
- particle_position_z = float(line.split(' ')[3])
- coord = [particle_position_x, particle_position_y, particle_position_z]
- # for each particle, determine which grids contain it
- # copied from object_finding_mixin.py
- mask=na.ones(self.num_grids)
- for i in xrange(len(coord)):
- na.choose(na.greater(self.grid_left_edge[:,i],coord[i]), (mask,0), mask)
- na.choose(na.greater(self.grid_right_edge[:,i],coord[i]), (0,mask), mask)
- ind = na.where(mask == 1)
- selected_grids = self.grids[ind]
- # in orion, particles always live on the finest level.
- # so, we want to assign the particle to the finest of
- # the grids we just found
- if len(selected_grids) != 0:
- grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
- ind = na.where(self.grids == grid)[0][0]
- self.grid_particle_count[ind] += 1
- self.grids[ind].NumberOfParticles += 1
+ try:
+ with open(fn, 'r') as f:
+ lines = f.readlines()
+ self.num_stars = int(lines[0].strip())
+ for line in lines[1:]:
+ particle_position_x = float(line.split(' ')[1])
+ particle_position_y = float(line.split(' ')[2])
+ particle_position_z = float(line.split(' ')[3])
+ coord = [particle_position_x, particle_position_y, particle_position_z]
+ # for each particle, determine which grids contain it
+ # copied from object_finding_mixin.py
+ mask=na.ones(self.num_grids)
+ for i in xrange(len(coord)):
+ na.choose(na.greater(self.grid_left_edge[:,i],coord[i]), (mask,0), mask)
+ na.choose(na.greater(self.grid_right_edge[:,i],coord[i]), (0,mask), mask)
+ ind = na.where(mask == 1)
+ selected_grids = self.grids[ind]
+ # in orion, particles always live on the finest level.
+ # so, we want to assign the particle to the finest of
+ # the grids we just found
+ if len(selected_grids) != 0:
+ grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
+ ind = na.where(self.grids == grid)[0][0]
+ self.grid_particle_count[ind] += 1
+ self.grids[ind].NumberOfParticles += 1
+ except IOError:
+ mylog.warning("No star particles found.")
def readGlobalHeader(self,filename,paranoid_read):
"""
https://bitbucket.org/yt_analysis/yt/changeset/b02dde495db8/
changeset: b02dde495db8
branch: yt
user: alrosen
date: 2012-02-03 02:23:35
summary: Orion frontend now looks for sink particles as well as star particles
affected #: 1 file
diff -r e6dae57f8a913d4f7e873f3277d7510fefa1ea06 -r b02dde495db8b8c12492c47f294c82e3dc004ea7 yt/frontends/orion/data_structures.py
--- a/yt/frontends/orion/data_structures.py
+++ b/yt/frontends/orion/data_structures.py
@@ -135,8 +135,35 @@
"""
self.grid_particle_count = na.zeros(len(self.grids))
- fn = self.pf.fullplotdir + "/StarParticles"
try:
+ fn = self.pf.fullplotdir + "/StarParticles"
+ with open(fn, 'r') as f:
+ print 'You do not appear to have a star particle file :(\n'
+ lines = f.readlines()
+ self.num_stars = int(lines[0].strip())
+ for line in lines[1:]:
+ particle_position_x = float(line.split(' ')[1])
+ particle_position_y = float(line.split(' ')[2])
+ particle_position_z = float(line.split(' ')[3])
+ coord = [particle_position_x, particle_position_y, particle_position_z]
+ # for each particle, determine which grids contain it
+ # copied from object_finding_mixin.py
+ mask=na.ones(self.num_grids)
+ for i in xrange(len(coord)):
+ na.choose(na.greater(self.grid_left_edge[:,i],coord[i]), (mask,0), mask)
+ na.choose(na.greater(self.grid_right_edge[:,i],coord[i]), (0,mask), mask)
+ ind = na.where(mask == 1)
+ selected_grids = self.grids[ind]
+ # in orion, particles always live on the finest level.
+ # so, we want to assign the particle to the finest of
+ # the grids we just found
+ if len(selected_grids) != 0:
+ grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
+ ind = na.where(self.grids == grid)[0][0]
+ self.grid_particle_count[ind] += 1
+ self.grids[ind].NumberOfParticles += 1
+ except IOError:
+ fn = self.pf.fullplotdir + "/SinkParticles"
with open(fn, 'r') as f:
lines = f.readlines()
self.num_stars = int(lines[0].strip())
@@ -161,8 +188,6 @@
ind = na.where(self.grids == grid)[0][0]
self.grid_particle_count[ind] += 1
self.grids[ind].NumberOfParticles += 1
- except IOError:
- mylog.warning("No star particles found.")
def readGlobalHeader(self,filename,paranoid_read):
"""
https://bitbucket.org/yt_analysis/yt/changeset/1428ddbc83bb/
changeset: 1428ddbc83bb
branch: yt
user: alrosen
date: 2012-02-21 23:05:13
summary: Altered orion frontend to find Starparticle or SinkParticle file. If neither exists, the IOError is skipped.
affected #: 1 file
diff -r b02dde495db8b8c12492c47f294c82e3dc004ea7 -r 1428ddbc83bbedcaa347c9e6abbc4470510fe2e3 yt/frontends/orion/data_structures.py
--- a/yt/frontends/orion/data_structures.py
+++ b/yt/frontends/orion/data_structures.py
@@ -138,7 +138,6 @@
try:
fn = self.pf.fullplotdir + "/StarParticles"
with open(fn, 'r') as f:
- print 'You do not appear to have a star particle file :(\n'
lines = f.readlines()
self.num_stars = int(lines[0].strip())
for line in lines[1:]:
@@ -163,32 +162,35 @@
self.grid_particle_count[ind] += 1
self.grids[ind].NumberOfParticles += 1
except IOError:
- fn = self.pf.fullplotdir + "/SinkParticles"
- with open(fn, 'r') as f:
- lines = f.readlines()
- self.num_stars = int(lines[0].strip())
- for line in lines[1:]:
- particle_position_x = float(line.split(' ')[1])
- particle_position_y = float(line.split(' ')[2])
- particle_position_z = float(line.split(' ')[3])
- coord = [particle_position_x, particle_position_y, particle_position_z]
- # for each particle, determine which grids contain it
- # copied from object_finding_mixin.py
- mask=na.ones(self.num_grids)
- for i in xrange(len(coord)):
- na.choose(na.greater(self.grid_left_edge[:,i],coord[i]), (mask,0), mask)
- na.choose(na.greater(self.grid_right_edge[:,i],coord[i]), (0,mask), mask)
- ind = na.where(mask == 1)
- selected_grids = self.grids[ind]
- # in orion, particles always live on the finest level.
- # so, we want to assign the particle to the finest of
- # the grids we just found
- if len(selected_grids) != 0:
- grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
- ind = na.where(self.grids == grid)[0][0]
- self.grid_particle_count[ind] += 1
- self.grids[ind].NumberOfParticles += 1
-
+ try:
+ fn = self.pf.fullplotdir + "/SinkParticles"
+ with open(fn, 'r') as f:
+ lines = f.readlines()
+ self.num_stars = int(lines[0].strip())
+ for line in lines[1:]:
+ particle_position_x = float(line.split(' ')[1])
+ particle_position_y = float(line.split(' ')[2])
+ particle_position_z = float(line.split(' ')[3])
+ coord = [particle_position_x, particle_position_y, particle_position_z]
+ # for each particle, determine which grids contain it
+ # copied from object_finding_mixin.py
+ mask=na.ones(self.num_grids)
+ for i in xrange(len(coord)):
+ na.choose(na.greater(self.grid_left_edge[:,i],coord[i]), (mask,0), mask)
+ na.choose(na.greater(self.grid_right_edge[:,i],coord[i]), (0,mask), mask)
+ ind = na.where(mask == 1)
+ selected_grids = self.grids[ind]
+ # in orion, particles always live on the finest level.
+ # so, we want to assign the particle to the finest of
+ # the grids we just found
+ if len(selected_grids) != 0:
+ grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
+ ind = na.where(self.grids == grid)[0][0]
+ self.grid_particle_count[ind] += 1
+ self.grids[ind].NumberOfParticles += 1
+ except IOError:
+ pass
+
def readGlobalHeader(self,filename,paranoid_read):
"""
read the global header file for an Orion plotfile output.
https://bitbucket.org/yt_analysis/yt/changeset/6272bc9114d7/
changeset: 6272bc9114d7
branch: yt
user: jsoishi
date: 2012-02-22 18:25:10
summary: reworked orion particle reading to generalize reader. note that this does NOT read the star/sink particle mass in, which seems...strange to me.
affected #: 1 file
diff -r 1428ddbc83bbedcaa347c9e6abbc4470510fe2e3 -r 6272bc9114d7d928fbdf46e196c4566e2c728c7f yt/frontends/orion/data_structures.py
--- a/yt/frontends/orion/data_structures.py
+++ b/yt/frontends/orion/data_structures.py
@@ -131,12 +131,27 @@
def _read_particles(self):
"""
- reads in particles and assigns them to grids
+ reads in particles and assigns them to grids. Will search for
+ Star particles, then sink particles if no star particle file
+ is found, and finally will simply note that no particles are
+ found if neither works. To add a new Orion particle type,
+ simply add it to the if/elif/else block.
"""
self.grid_particle_count = na.zeros(len(self.grids))
+
+ if self._readOrionParticleFile(self.pf.fullplotdir + "/StarParticles"):
+ pass
+ elif self._readOrionParticleFile(self.pf.fullplotdir + "/SinkParticles"):
+ pass
+ else:
+ mylog.warning("No particles found.")
+
+ def _readOrionParticleFile(self, fn):
+ """actually reads the orion particle data file itself.
+
+ """
try:
- fn = self.pf.fullplotdir + "/StarParticles"
with open(fn, 'r') as f:
lines = f.readlines()
self.num_stars = int(lines[0].strip())
@@ -162,33 +177,6 @@
self.grid_particle_count[ind] += 1
self.grids[ind].NumberOfParticles += 1
except IOError:
- try:
- fn = self.pf.fullplotdir + "/SinkParticles"
- with open(fn, 'r') as f:
- lines = f.readlines()
- self.num_stars = int(lines[0].strip())
- for line in lines[1:]:
- particle_position_x = float(line.split(' ')[1])
- particle_position_y = float(line.split(' ')[2])
- particle_position_z = float(line.split(' ')[3])
- coord = [particle_position_x, particle_position_y, particle_position_z]
- # for each particle, determine which grids contain it
- # copied from object_finding_mixin.py
- mask=na.ones(self.num_grids)
- for i in xrange(len(coord)):
- na.choose(na.greater(self.grid_left_edge[:,i],coord[i]), (mask,0), mask)
- na.choose(na.greater(self.grid_right_edge[:,i],coord[i]), (0,mask), mask)
- ind = na.where(mask == 1)
- selected_grids = self.grids[ind]
- # in orion, particles always live on the finest level.
- # so, we want to assign the particle to the finest of
- # the grids we just found
- if len(selected_grids) != 0:
- grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
- ind = na.where(self.grids == grid)[0][0]
- self.grid_particle_count[ind] += 1
- self.grids[ind].NumberOfParticles += 1
- except IOError:
pass
def readGlobalHeader(self,filename,paranoid_read):
https://bitbucket.org/yt_analysis/yt/changeset/fa4c38d6418d/
changeset: fa4c38d6418d
branch: yt
user: jsoishi
date: 2012-02-22 19:41:10
summary: fixed up a transplant mistake.
affected #: 1 file
diff -r 6272bc9114d7d928fbdf46e196c4566e2c728c7f -r fa4c38d6418dd9a2c86d7a6ba6b85dcd40fddf80 yt/frontends/orion/data_structures.py
--- a/yt/frontends/orion/data_structures.py
+++ b/yt/frontends/orion/data_structures.py
@@ -167,17 +167,17 @@
na.choose(na.greater(self.grid_left_edge[:,i],coord[i]), (mask,0), mask)
na.choose(na.greater(self.grid_right_edge[:,i],coord[i]), (0,mask), mask)
ind = na.where(mask == 1)
- selected_grids = self.grids[ind]
- # in orion, particles always live on the finest level.
- # so, we want to assign the particle to the finest of
- # the grids we just found
- if len(selected_grids) != 0:
- grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
- ind = na.where(self.grids == grid)[0][0]
- self.grid_particle_count[ind] += 1
- self.grids[ind].NumberOfParticles += 1
+ selected_grids = self.grids[ind]
+ # in orion, particles always live on the finest level.
+ # so, we want to assign the particle to the finest of
+ # the grids we just found
+ if len(selected_grids) != 0:
+ grid = sorted(selected_grids, key=lambda grid: grid.Level)[-1]
+ ind = na.where(self.grids == grid)[0][0]
+ self.grid_particle_count[ind] += 1
+ self.grids[ind].NumberOfParticles += 1
except IOError:
- pass
+ return None
def readGlobalHeader(self,filename,paranoid_read):
"""
https://bitbucket.org/yt_analysis/yt/changeset/2947574e0910/
changeset: 2947574e0910
branch: yt
user: jsoishi
date: 2012-02-22 21:21:02
summary: corrected bug, thanks to Andrew Myers
affected #: 1 file
diff -r fa4c38d6418dd9a2c86d7a6ba6b85dcd40fddf80 -r 2947574e0910295daad446e0cd1dd8a006ec6c02 yt/frontends/orion/data_structures.py
--- a/yt/frontends/orion/data_structures.py
+++ b/yt/frontends/orion/data_structures.py
@@ -178,6 +178,8 @@
self.grids[ind].NumberOfParticles += 1
except IOError:
return None
+
+ return True
def readGlobalHeader(self,filename,paranoid_read):
"""
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list