[yt-svn] commit/yt: 6 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Oct 13 18:18:25 PDT 2017
6 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/9194fbe75a66/
Changeset: 9194fbe75a66
User: Josh Borrow
Date: 2017-10-05 13:11:22+00:00
Summary: Added a more gracefull fallback for gadget data that is missing redshift information.
Affected #: 1 file
diff -r 0231a9c04ac1101ef070028c7af3f71684643597 -r 9194fbe75a660fbd34e2a8b5ba3fc346be6ca0de yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -202,10 +202,25 @@
self.cosmological_simulation = 1
- self.current_redshift = hvals["Redshift"]
- self.omega_lambda = hvals["OmegaLambda"]
- self.omega_matter = hvals["Omega0"]
- self.hubble_constant = hvals["HubbleParam"]
+ try:
+ self.current_redshift = hvals["Redshift"]
+ except KeyError:
+ # Probably not a cosmological dataset, we should just set
+ # z = 0 and let the user know
+ self.current_redshift = 0.0
+ only_on_root(
+ mylog.info, "Redshift is not set in Header. Assuming z=0.")
+
+ try:
+ self.omega_lambda = hvals["OmegaLambda"]
+ self.omega_matter = hvals["Omega0"]
+ self.hubble_constant = hvals["HubbleParam"]
+ except KeyError:
+ # If these are not set it is definitely not a cosmological dataset.
+ self.omega_lambda = 0.0
+ self.omega_matter = 1.0 # Just in case somebody asks for it.
+ # Hubble is set below for Omega Lambda = 0.
+
# According to the Gadget manual, OmegaLambda will be zero for
# non-cosmological datasets. However, it may be the case that
# individuals are running cosmological simulations *without* Lambda, in
https://bitbucket.org/yt_analysis/yt/commits/a496d5e3e4d9/
Changeset: a496d5e3e4d9
User: Josh Borrow
Date: 2017-10-05 13:36:51+00:00
Summary: Fixed an indexing issue with numpy. Previously this would throw
TypeError: only integer scalar arrays can be converted to a scalar index
See the following StackOverflow:
https://stackoverflow.com/questions/42128830/typeerror-only-integer-scalar-arrays-can-be-converted-to-a-scalar-index
Affected #: 1 file
diff -r 9194fbe75a660fbd34e2a8b5ba3fc346be6ca0de -r a496d5e3e4d9c17621a762c50fc79b9e263a0741 yt/geometry/particle_geometry_handler.py
--- a/yt/geometry/particle_geometry_handler.py
+++ b/yt/geometry/particle_geometry_handler.py
@@ -75,7 +75,9 @@
cls = self.dataset._file_class
self.data_files = \
[cls(self.dataset, self.io, template % {'num':i}, i)
- for i in range(ndoms)]
+ for i in range(ndoms[0])]
+ # This [0] index is required as newer versions of numpy do not like
+ # using single-length arrays for indexing.
def _initialize_particle_handler(self):
self._setup_data_io()
https://bitbucket.org/yt_analysis/yt/commits/31846fcf4607/
Changeset: 31846fcf4607
User: Josh Borrow
Date: 2017-10-05 14:52:07+00:00
Summary: Changed to use int() rather than the 0 index as ndoms is sometimes an integer
Affected #: 1 file
diff -r a496d5e3e4d9c17621a762c50fc79b9e263a0741 -r 31846fcf46078b7d0cfeab21041117c1e1d144f7 yt/geometry/particle_geometry_handler.py
--- a/yt/geometry/particle_geometry_handler.py
+++ b/yt/geometry/particle_geometry_handler.py
@@ -75,9 +75,7 @@
cls = self.dataset._file_class
self.data_files = \
[cls(self.dataset, self.io, template % {'num':i}, i)
- for i in range(ndoms[0])]
- # This [0] index is required as newer versions of numpy do not like
- # using single-length arrays for indexing.
+ for i in range(int(ndoms))]
def _initialize_particle_handler(self):
self._setup_data_io()
https://bitbucket.org/yt_analysis/yt/commits/f9c32d099287/
Changeset: f9c32d099287
User: Josh Borrow
Date: 2017-10-05 16:36:52+00:00
Summary: Added test for non-cosmological fallback with GADGET files.
Affected #: 1 file
diff -r 31846fcf46078b7d0cfeab21041117c1e1d144f7 -r f9c32d09928715cbdf34e4c62216e0cb56d87562 yt/frontends/gadget/tests/test_outputs.py
--- a/yt/frontends/gadget/tests/test_outputs.py
+++ b/yt/frontends/gadget/tests/test_outputs.py
@@ -27,6 +27,7 @@
isothermal_bin = "IsothermalCollapse/snap_505"
BE_Gadget = "BigEndianGadgetBinary/BigEndianGadgetBinary"
LE_SnapFormat2 = "Gadget3-snap-format2/Gadget3-snap-format2"
+keplerian_ring = "KeplerianRing/keplerian_ring_test_data.hdf5"
# This maps from field names to weight field names to use for projections
iso_fields = OrderedDict(
@@ -57,6 +58,18 @@
assert isinstance(data_dir_load(LE_SnapFormat2), GadgetDataset)
+ at requires_file(keplerian_ring)
+def test_NonCosmoDataset():
+ """
+ Non-cosmological datasets may not have the cosmological parametrs in the
+ Header. The code should fall back gracefully when they are not present,
+ with the Redshift set to 0.
+ """
+ data = data_dir_load(keplerian_ring)
+ assert data.current_redshift == 0.0
+ assert data.cosmological_simulation == 0
+
+
@requires_ds(isothermal_h5)
def test_iso_collapse():
ds = data_dir_load(isothermal_h5, kwargs=iso_kwargs)
https://bitbucket.org/yt_analysis/yt/commits/457baefbce50/
Changeset: 457baefbce50
User: Josh Borrow
Date: 2017-10-05 16:47:50+00:00
Summary: function name refactor for pep8
Affected #: 1 file
diff -r f9c32d09928715cbdf34e4c62216e0cb56d87562 -r 457baefbce506ffbf17b8c4859edc553a97d20b1 yt/frontends/gadget/tests/test_outputs.py
--- a/yt/frontends/gadget/tests/test_outputs.py
+++ b/yt/frontends/gadget/tests/test_outputs.py
@@ -49,7 +49,7 @@
@requires_file(isothermal_bin)
@requires_file(BE_Gadget)
@requires_file(LE_SnapFormat2)
-def test_GadgetDataset():
+def test_gadget_dataset():
assert isinstance(data_dir_load(isothermal_h5, kwargs=iso_kwargs),
GadgetHDF5Dataset)
assert isinstance(data_dir_load(isothermal_bin, kwargs=iso_kwargs),
@@ -59,7 +59,7 @@
@requires_file(keplerian_ring)
-def test_NonCosmoDataset():
+def test_non_cosmo_dataset():
"""
Non-cosmological datasets may not have the cosmological parametrs in the
Header. The code should fall back gracefully when they are not present,
https://bitbucket.org/yt_analysis/yt/commits/347451182182/
Changeset: 347451182182
User: ngoldbaum
Date: 2017-10-14 01:18:13+00:00
Summary: Merge pull request #1578 from JBorrow/improve-gadget-fallback
Improve gadget loading fallback when some items are not present in the Header
Affected #: 3 files
diff -r 1f6f5965a37b0835b4817329ebfcdab7e42b72af -r 3474511821829347817936947982b7bd434d3f85 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -202,10 +202,25 @@
self.cosmological_simulation = 1
- self.current_redshift = hvals["Redshift"]
- self.omega_lambda = hvals["OmegaLambda"]
- self.omega_matter = hvals["Omega0"]
- self.hubble_constant = hvals["HubbleParam"]
+ try:
+ self.current_redshift = hvals["Redshift"]
+ except KeyError:
+ # Probably not a cosmological dataset, we should just set
+ # z = 0 and let the user know
+ self.current_redshift = 0.0
+ only_on_root(
+ mylog.info, "Redshift is not set in Header. Assuming z=0.")
+
+ try:
+ self.omega_lambda = hvals["OmegaLambda"]
+ self.omega_matter = hvals["Omega0"]
+ self.hubble_constant = hvals["HubbleParam"]
+ except KeyError:
+ # If these are not set it is definitely not a cosmological dataset.
+ self.omega_lambda = 0.0
+ self.omega_matter = 1.0 # Just in case somebody asks for it.
+ # Hubble is set below for Omega Lambda = 0.
+
# According to the Gadget manual, OmegaLambda will be zero for
# non-cosmological datasets. However, it may be the case that
# individuals are running cosmological simulations *without* Lambda, in
diff -r 1f6f5965a37b0835b4817329ebfcdab7e42b72af -r 3474511821829347817936947982b7bd434d3f85 yt/frontends/gadget/tests/test_outputs.py
--- a/yt/frontends/gadget/tests/test_outputs.py
+++ b/yt/frontends/gadget/tests/test_outputs.py
@@ -27,6 +27,7 @@
isothermal_bin = "IsothermalCollapse/snap_505"
BE_Gadget = "BigEndianGadgetBinary/BigEndianGadgetBinary"
LE_SnapFormat2 = "Gadget3-snap-format2/Gadget3-snap-format2"
+keplerian_ring = "KeplerianRing/keplerian_ring_test_data.hdf5"
# This maps from field names to weight field names to use for projections
iso_fields = OrderedDict(
@@ -48,7 +49,7 @@
@requires_file(isothermal_bin)
@requires_file(BE_Gadget)
@requires_file(LE_SnapFormat2)
-def test_GadgetDataset():
+def test_gadget_dataset():
assert isinstance(data_dir_load(isothermal_h5, kwargs=iso_kwargs),
GadgetHDF5Dataset)
assert isinstance(data_dir_load(isothermal_bin, kwargs=iso_kwargs),
@@ -57,6 +58,18 @@
assert isinstance(data_dir_load(LE_SnapFormat2), GadgetDataset)
+ at requires_file(keplerian_ring)
+def test_non_cosmo_dataset():
+ """
+ Non-cosmological datasets may not have the cosmological parametrs in the
+ Header. The code should fall back gracefully when they are not present,
+ with the Redshift set to 0.
+ """
+ data = data_dir_load(keplerian_ring)
+ assert data.current_redshift == 0.0
+ assert data.cosmological_simulation == 0
+
+
@requires_ds(isothermal_h5)
def test_iso_collapse():
ds = data_dir_load(isothermal_h5, kwargs=iso_kwargs)
diff -r 1f6f5965a37b0835b4817329ebfcdab7e42b72af -r 3474511821829347817936947982b7bd434d3f85 yt/geometry/particle_geometry_handler.py
--- a/yt/geometry/particle_geometry_handler.py
+++ b/yt/geometry/particle_geometry_handler.py
@@ -75,7 +75,7 @@
cls = self.dataset._file_class
self.data_files = \
[cls(self.dataset, self.io, template % {'num':i}, i)
- for i in range(ndoms)]
+ for i in range(int(ndoms))]
def _initialize_particle_handler(self):
self._setup_data_io()
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