[yt-svn] commit/yt: MatthewTurk: Merged in ngoldbaum/yt (pull request #1242)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Oct 10 03:24:04 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/5ba254a71989/
Changeset: 5ba254a71989
Branch: yt
User: MatthewTurk
Date: 2014-10-10 10:23:53+00:00
Summary: Merged in ngoldbaum/yt (pull request #1242)
Generic data loading fixes
Affected #: 1 file
diff -r 88b61bedaddf676bf3499a6c52e4a14aa28e1ee9 -r 5ba254a71989d47a89c40e81c3cdefd710ee8341 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -364,8 +364,10 @@
_additional_fields = ()
@property
- def all_fields(self):
- fields = list(self._additional_fields) + self[0].keys()
+ def all_fields(self):
+ self_fields = chain.from_iterable(s.keys() for s in self.values())
+ self_fields = list(set(self_fields))
+ fields = list(self._additional_fields) + self_fields
fields = list(set(fields))
return fields
@@ -471,8 +473,6 @@
field_units[k] = v.units
new_data[k] = v.copy().d
data = new_data
- elif all([isinstance(val, np.ndarray) for val in data.values()]):
- field_units = {field:'' for field in data.keys()}
elif all([(len(val) == 2) for val in data.values()]):
new_data, field_units = {}, {}
for field in data:
@@ -489,6 +489,9 @@
raise RuntimeError("The data dict appears to be invalid.\n" +
str(e))
data = new_data
+ elif all([iterable(val) for val in data.values()]):
+ field_units = {field:'' for field in data.keys()}
+ data = dict((field, np.array(val)) for field, val in data.iteritems())
else:
raise RuntimeError("The data dict appears to be invalid. "
"The data dictionary must map from field "
@@ -763,12 +766,13 @@
... dimensions = [32, 32, 32],
... number_of_particles = 0)
... ]
- ...
+ ...
>>> for g in grid_data:
- ... g["Density"] = np.random.random(g["dimensions"]) * 2**g["level"]
+ ... g["density"] = np.random.random(g["dimensions"]) * 2**g["level"]
...
- >>> units = dict(Density='g/cm**3')
- >>> ds = load_amr_grids(grid_data, [32, 32, 32], 1.0)
+ >>> units = dict(density='g/cm**3')
+ >>> ds = load_amr_grids(grid_data, [8, 8, 8], field_units=units,
+ ... length_unit=1.0)
"""
domain_dimensions = np.array(domain_dimensions)
@@ -822,6 +826,11 @@
if magnetic_unit is None:
magnetic_unit = 'code_magnetic'
+ particle_types = {}
+
+ for grid in grid_data:
+ particle_types.update(set_particle_types(grid))
+
handler = StreamHandler(
grid_left_edges,
grid_right_edges,
@@ -833,7 +842,7 @@
sfh,
field_units,
(length_unit, mass_unit, time_unit, velocity_unit, magnetic_unit),
- particle_types=set_particle_types(grid_data[0])
+ particle_types=particle_types
)
handler.name = "AMRGridData"
@@ -1018,7 +1027,7 @@
magnetic_unit : float
Conversion factor from simulation magnetic units to gauss
bbox : array_like (xdim:zdim, LE:RE), optional
- Size of computational domain in units sim_unit_to_cm
+ Size of computational domain in units of the length_unit
sim_time : float, optional
The simulation time in seconds
periodicity : tuple of booleans
@@ -1191,10 +1200,8 @@
coordinates : array_like
This should be of size (M,3) where M is the number of vertices
indicated in the connectivity matrix.
- sim_unit_to_cm : float
- Conversion factor from simulation units to centimeters
bbox : array_like (xdim:zdim, LE:RE), optional
- Size of computational domain in units sim_unit_to_cm
+ Size of computational domain in units of the length unit.
sim_time : float, optional
The simulation time in seconds
mass_unit : string
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