[yt-svn] commit/yt: brittonsmith: Merged in MatthewTurk/yt (pull request #1128)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Aug 6 12:36:42 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/6b790e3507a7/
Changeset: 6b790e3507a7
Branch: yt
User: brittonsmith
Date: 2014-08-06 21:36:32
Summary: Merged in MatthewTurk/yt (pull request #1128)
Allowing format revisions for Rockstar.
Affected #: 2 files
diff -r 2289aecc35992ca9153c06c79fb57be6ecb61bde -r 6b790e3507a791aeb1a0a801e8e8d7de7e1c56e8 yt/frontends/halo_catalogs/rockstar/definitions.py
--- a/yt/frontends/halo_catalogs/rockstar/definitions.py
+++ b/yt/frontends/halo_catalogs/rockstar/definitions.py
@@ -35,17 +35,25 @@
("unused", BINARY_HEADER_SIZE - 4*12 - 4 - 8*6 - 12, "c")
)
-halo_dt = np.dtype([
+# Note the final field here, which is a field for min/max format revision in
+# which the field appears.
+
+KNOWN_REVISIONS=[0, 1]
+
+halo_dt = [
('particle_identifier', np.int64),
('particle_position_x', np.float32),
('particle_position_y', np.float32),
('particle_position_z', np.float32),
+ ('particle_mposition_x', np.float32, (0, 0)),
+ ('particle_mposition_y', np.float32, (0, 0)),
+ ('particle_mposition_z', np.float32, (0, 0)),
('particle_velocity_x', np.float32),
('particle_velocity_y', np.float32),
('particle_velocity_z', np.float32),
- ('particle_corevel_x', np.float32),
- ('particle_corevel_y', np.float32),
- ('particle_corevel_z', np.float32),
+ ('particle_corevel_x', np.float32, (1, 100)),
+ ('particle_corevel_y', np.float32, (1, 100)),
+ ('particle_corevel_z', np.float32, (1, 100)),
('particle_bulkvel_x', np.float32),
('particle_bulkvel_y', np.float32),
('particle_bulkvel_z', np.float32),
@@ -75,15 +83,15 @@
('Ax', np.float32),
('Ay', np.float32),
('Az', np.float32),
- ('b_to_a2', np.float32),
- ('c_to_a2', np.float32),
- ('A2x', np.float32),
- ('A2y', np.float32),
- ('A2z', np.float32),
+ ('b_to_a2', np.float32, (1, 100)),
+ ('c_to_a2', np.float32, (1, 100)),
+ ('A2x', np.float32, (1, 100)),
+ ('A2y', np.float32, (1, 100)),
+ ('A2z', np.float32, (1, 100)),
('bullock_spin', np.float32),
('kin_to_pot', np.float32),
- ('m_pe_b', np.float32),
- ('m_pe_d', np.float32),
+ ('m_pe_b', np.float32, (1, 100)),
+ ('m_pe_d', np.float32, (1, 100)),
('num_p', np.int64),
('num_child_particles', np.int64),
('p_start', np.int64),
@@ -93,7 +101,20 @@
('min_pos_err', np.float32),
('min_vel_err', np.float32),
('min_bulkvel_err', np.float32),
-], align=True)
+]
+
+halo_dts = {}
+
+for rev in KNOWN_REVISIONS:
+ halo_dts[rev] = []
+ for item in halo_dt:
+ if len(item) == 2:
+ halo_dts[rev].append(item)
+ else:
+ mi, ma = item[2]
+ if (mi <= rev) and (rev <= ma):
+ halo_dts[rev].append(item[:2])
+ halo_dts[rev] = np.dtype(halo_dts[rev], align=True)
particle_dt = np.dtype([
('particle_identifier', np.int64),
diff -r 2289aecc35992ca9153c06c79fb57be6ecb61bde -r 6b790e3507a791aeb1a0a801e8e8d7de7e1c56e8 yt/frontends/halo_catalogs/rockstar/io.py
--- a/yt/frontends/halo_catalogs/rockstar/io.py
+++ b/yt/frontends/halo_catalogs/rockstar/io.py
@@ -24,7 +24,7 @@
BaseIOHandler
import yt.utilities.fortran_utils as fpu
-from .definitions import halo_dt
+from .definitions import halo_dts
from yt.utilities.lib.geometry_utils import compute_morton
from yt.geometry.oct_container import _ORDER_MAX
@@ -32,6 +32,10 @@
class IOHandlerRockstarBinary(BaseIOHandler):
_dataset_type = "rockstar_binary"
+ def __init__(self, *args, **kwargs):
+ super(IOHandlerRockstarBinary, self).__init__(*args, **kwargs)
+ self._halo_dt = halo_dts[self.ds.parameters['format_revision']]
+
def _read_fluid_selection(self, chunks, selector, fields, size):
raise NotImplementedError
@@ -45,11 +49,12 @@
for chunk in chunks:
for obj in chunk.objs:
data_files.update(obj.data_files)
+
for data_file in sorted(data_files):
pcount = data_file.header['num_halos']
with open(data_file.filename, "rb") as f:
f.seek(data_file._position_offset, os.SEEK_SET)
- halos = np.fromfile(f, dtype=halo_dt, count = pcount)
+ halos = np.fromfile(f, dtype=self._halo_dt, count = pcount)
x = halos['particle_position_x'].astype("float64")
y = halos['particle_position_y'].astype("float64")
z = halos['particle_position_z'].astype("float64")
@@ -70,7 +75,7 @@
with open(data_file.filename, "rb") as f:
for ptype, field_list in sorted(ptf.items()):
f.seek(data_file._position_offset, os.SEEK_SET)
- halos = np.fromfile(f, dtype=halo_dt, count = pcount)
+ halos = np.fromfile(f, dtype=self._halo_dt, count = pcount)
x = halos['particle_position_x'].astype("float64")
y = halos['particle_position_y'].astype("float64")
z = halos['particle_position_z'].astype("float64")
@@ -89,7 +94,7 @@
ind = 0
with open(data_file.filename, "rb") as f:
f.seek(data_file._position_offset, os.SEEK_SET)
- halos = np.fromfile(f, dtype=halo_dt, count = pcount)
+ halos = np.fromfile(f, dtype=self._halo_dt, count = pcount)
pos = np.empty((halos.size, 3), dtype="float64")
# These positions are in Mpc, *not* "code" units
pos = data_file.ds.arr(pos, "code_length")
@@ -121,6 +126,6 @@
return {'halos': data_file.header['num_halos']}
def _identify_fields(self, data_file):
- fields = [("halos", f) for f in halo_dt.fields if
+ fields = [("halos", f) for f in self._halo_dt.fields if
"padding" not in f]
return fields, {}
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