[yt-svn] commit/yt-3.0: MatthewTurk: Active particle types that are defined in files are found and identified. If
Bitbucket
commits-noreply at bitbucket.org
Thu Aug 9 15:30:26 PDT 2012
1 new commit in yt-3.0:
https://bitbucket.org/yt_analysis/yt-3.0/changeset/124c39a69756/
changeset: 124c39a69756
branch: yt-3.0
user: MatthewTurk
date: 2012-08-10 00:30:16
summary: Active particle types that are defined in files are found and identified. If
they have been pre-declared, they can get to the "read the field in" stage.
However, that function has yet to be implemented.
affected #: 3 files
diff -r 3b093c03ed2b4290bde5fdf8129b38c44960c2f4 -r 124c39a69756b859be5606fdfc64729b8efc89e8 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -231,9 +231,8 @@
ftype, fname = field
if fname in self._container_fields:
return self._generate_container_field(field)
- elif fname not in self.pf.field_info:
- raise KeyError(field)
- elif self.pf.field_info[fname].particle_type:
+ finfo = self._get_field_info(*field)
+ if finfo.particle_type:
return self._generate_particle_field(field)
else:
return self._generate_fluid_field(field)
@@ -275,7 +274,8 @@
else:
gen_obj = self._current_chunk.objs[0]
try:
- self.pf.field_info[fname].check_available(gen_obj)
+ finfo = self._get_field_info(*field)
+ finfo.check_available(gen_obj)
except NeedsGridType, ngt_exception:
if ngt_exception.ghost_zones != 0:
raise NotImplementedError
@@ -294,7 +294,7 @@
rv[ind:ind+data.size] = data
ind += data.size
else:
- rv = self.pf.field_info[fname](gen_obj)
+ rv = self._get_field_info(*field)(gen_obj)
return rv
def _count_particles(self, ftype):
@@ -364,11 +364,12 @@
for i in self._con_args])
return s
- def _get_field_info(self, fname):
- if fname not in self.pf.field_info:
- raise YTFieldNotFound(fname, self.pf)
- finfo = self.pf.field_info[fname]
- return finfo
+ def _get_field_info(self, ftype, fname):
+ if (ftype, fname) in self.pf.field_info:
+ return self.pf.field_info[(ftype, fname)]
+ if fname in self.pf.field_info:
+ return self.pf.field_info[fname]
+ raise YTFieldNotFound((fname, ftype), self.pf)
def _determine_fields(self, fields):
fields = ensure_list(fields)
@@ -383,11 +384,11 @@
not isinstance(field[1], types.StringTypes):
raise YTFieldNotParseable(field)
ftype, fname = field
- finfo = self._get_field_info(fname)
+ finfo = self._get_field_info(ftype, fname)
explicit_fields.append(field)
else:
fname = field
- finfo = self._get_field_info(fname)
+ finfo = self._get_field_info("unknown", fname)
if finfo.particle_type:
ftype = "all"
else:
@@ -458,7 +459,8 @@
# We now split up into readers for the types of fields
fluids, particles = [], []
for ftype, fname in fields_to_get:
- if self.pf.field_info[fname].particle_type:
+ finfo = self._get_field_info(ftype, fname)
+ if finfo.particle_type:
particles.append((ftype, fname))
else:
fluids.append((ftype, fname))
@@ -469,8 +471,10 @@
fluids, self, self._current_chunk)
self.field_data.update(read_fluids)
+ print "READING GENNING", particles
read_particles, gen_particles = self.hierarchy._read_particle_fields(
particles, self, self._current_chunk)
+ print "BACK", read_particles, gen_particles
self.field_data.update(read_particles)
fields_to_generate = gen_fluids + gen_particles
index = 0
diff -r 3b093c03ed2b4290bde5fdf8129b38c44960c2f4 -r 124c39a69756b859be5606fdfc64729b8efc89e8 yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -913,6 +913,9 @@
else:
self.current_redshift = self.omega_lambda = self.omega_matter = \
self.hubble_constant = self.cosmological_simulation = 0.0
+ self.particle_types = []
+ for ptype in self.parameters.get("AppendActiveParticleType", []):
+ self.particle_types.append(ptype)
def _set_units(self):
"""
diff -r 3b093c03ed2b4290bde5fdf8129b38c44960c2f4 -r 124c39a69756b859be5606fdfc64729b8efc89e8 yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -306,7 +306,7 @@
fields_to_return = {}
fields_to_read, fields_to_generate = [], []
for ftype, fname in fields:
- if fname in self.field_list:
+ if fname in self.field_list or (ftype, fname) in self.field_list:
fields_to_read.append((ftype, fname))
else:
fields_to_generate.append((ftype, fname))
Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/
--
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