[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Oct 2 07:35:33 PDT 2017
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/5429c7ccdc2d/
Changeset: 5429c7ccdc2d
User: Corentin Cadiou
Date: 2017-09-12 09:38:03+00:00
Summary: autodetect extra fields
Affected #: 1 file
diff -r fccca1fb4d585d705867a553e7fd5ec94ac7181d -r 5429c7ccdc2db4812cd3a151c3422822203aa05a yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -167,19 +167,35 @@
("particle_mass", "d"),
("particle_identifier", "i"),
("particle_refinement_level", "I")]
- if hvals["nstar_tot"] > 0:
- particle_fields += [("particle_age", "d"),
- ("particle_metallicity", "d")]
+
if self.ds._extra_particle_fields is not None:
particle_fields += self.ds._extra_particle_fields
field_offsets = {}
_pfields = {}
+
+ # Read offsets
for field, vtype in particle_fields:
if f.tell() >= flen: break
field_offsets["io", field] = f.tell()
_pfields["io", field] = vtype
fpu.skip(f, 1)
+
+ iextra = 0
+ while f.tell() < flen:
+ iextra += 1
+ field, vtype = ('particle_extra_field_%i' % iextra, 'd')
+ particle_fields.append((field, vtype))
+
+ field_offsets["io", field] = f.tell()
+ _pfields["io", field] = vtype
+ fpu.skip(f, 1)
+
+ if iextra > 0:
+ mylog.warning("Detected %s extra particle fields assuming kind"
+ "`double`. Consider using the `extra_particle_fields`"
+ "keyword argument if you have unexpected behavior.")
+
self.particle_field_offsets = field_offsets
self.particle_field_types = _pfields
self.particle_types = self.particle_types_raw = ("io",)
https://bitbucket.org/yt_analysis/yt/commits/8513e7bbd387/
Changeset: 8513e7bbd387
User: Corentin Cadiou
Date: 2017-09-12 09:53:38+00:00
Summary: test and warn
Affected #: 2 files
diff -r 5429c7ccdc2db4812cd3a151c3422822203aa05a -r 8513e7bbd38763afe27c3d6804c1bbe9121c6bcb yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -191,10 +191,12 @@
_pfields["io", field] = vtype
fpu.skip(f, 1)
- if iextra > 0:
- mylog.warning("Detected %s extra particle fields assuming kind"
- "`double`. Consider using the `extra_particle_fields`"
- "keyword argument if you have unexpected behavior.")
+ if iextra > 0 and not self.ds._warn_extra_fields:
+ self.ds._warn_extra_fields = True
+ w = ("Detected %s extra particle fields assuming kind "
+ "`double`. Consider using the `extra_particle_fields` "
+ "keyword argument if you have unexpected behavior.")
+ mylog.warning(w % iextra)
self.particle_field_offsets = field_offsets
self.particle_field_types = _pfields
@@ -556,7 +558,7 @@
_index_class = RAMSESIndex
_field_info_class = RAMSESFieldInfo
gamma = 1.4 # This will get replaced on hydro_fn open
-
+
def __init__(self, filename, dataset_type='ramses',
fields=None, storage_filename=None,
units_override=None, unit_system="cgs",
@@ -574,6 +576,7 @@
self.fluid_types += ("ramses",)
self._fields_in_file = fields
self._extra_particle_fields = extra_particle_fields
+ self._warn_extra_fields = False
self.force_cosmological = cosmological
Dataset.__init__(self, filename, dataset_type, units_override=units_override,
unit_system=unit_system)
diff -r 5429c7ccdc2db4812cd3a151c3422822203aa05a -r 8513e7bbd38763afe27c3d6804c1bbe9121c6bcb yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -127,6 +127,20 @@
families = dd[('all', 'family')]
assert all(families == 100)
+
+ramsesExtraFieldsSmall = 'ramses_extra_fields_small/output_00001'
+ at requires_file(ramsesExtraFieldsSmall)
+def test_extra_fields_2():
+ extra_fields = ['particle_extra_field_%s' % i for i in range(20)]
+ ds = yt.load(os.path.join(ramsesExtraFieldsSmall, 'info_00001.txt'))
+
+ # the dataset should contain the fields
+ for field, in extra_fields:
+ assert ('io', field) in ds.field_list
+
+ # In the dataset, the fields are integers, so we cannot test
+ # that they are accessed correctly.
+
ramses_rt = "ramses_rt_00088/output_00088/info_00088.txt"
@requires_file(ramses_rt)
def test_ramses_rt():
https://bitbucket.org/yt_analysis/yt/commits/a61f24956ace/
Changeset: a61f24956ace
User: Corentin Cadiou
Date: 2017-09-12 09:57:55+00:00
Summary: fix tests
Affected #: 1 file
diff -r 8513e7bbd38763afe27c3d6804c1bbe9121c6bcb -r a61f24956ace8dca917539de00ba383bf573e796 yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -114,7 +114,7 @@
ramsesExtraFieldsSmall = 'ramses_extra_fields_small/output_00001'
@requires_file(ramsesExtraFieldsSmall)
def test_extra_fields():
- extra_fields = [('family', 'I'), ('pointer', 'I')]
+ extra_fields = [('particle_family', 'I'), ('particle_pointer', 'I')]
ds = yt.load(os.path.join(ramsesExtraFieldsSmall, 'info_00001.txt'),
extra_particle_fields=extra_fields)
@@ -124,18 +124,18 @@
# Check the family (they should equal 100, for tracer particles)
dd = ds.all_data()
- families = dd[('all', 'family')]
+ families = dd[('all', 'particle_family')]
assert all(families == 100)
-ramsesExtraFieldsSmall = 'ramses_extra_fields_small/output_00001'
@requires_file(ramsesExtraFieldsSmall)
def test_extra_fields_2():
- extra_fields = ['particle_extra_field_%s' % i for i in range(20)]
+ extra_fields = ['particle_extra_field_%s' % (i + 1) for i in range(2)]
ds = yt.load(os.path.join(ramsesExtraFieldsSmall, 'info_00001.txt'))
+ print(ds.field_list)
# the dataset should contain the fields
- for field, in extra_fields:
+ for field in extra_fields:
assert ('io', field) in ds.field_list
# In the dataset, the fields are integers, so we cannot test
https://bitbucket.org/yt_analysis/yt/commits/a7f778370dd4/
Changeset: a7f778370dd4
User: Corentin Cadiou
Date: 2017-09-27 07:09:28+00:00
Summary: remove print statement
Affected #: 1 file
diff -r a61f24956ace8dca917539de00ba383bf573e796 -r a7f778370dd47e50e87f1cddff754fde1edcce8f yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -133,7 +133,6 @@
extra_fields = ['particle_extra_field_%s' % (i + 1) for i in range(2)]
ds = yt.load(os.path.join(ramsesExtraFieldsSmall, 'info_00001.txt'))
- print(ds.field_list)
# the dataset should contain the fields
for field in extra_fields:
assert ('io', field) in ds.field_list
https://bitbucket.org/yt_analysis/yt/commits/0231a9c04ac1/
Changeset: 0231a9c04ac1
User: ngoldbaum
Date: 2017-10-02 14:34:32+00:00
Summary: Merge pull request #1555 from cphyc/bugfix/ramses-autodetection
[RAMSES] autodetect extra fields
Affected #: 2 files
diff -r f292c74a3a4f6b535647dd138465dc2561b68850 -r 0231a9c04ac1101ef070028c7af3f71684643597 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -167,19 +167,37 @@
("particle_mass", "d"),
("particle_identifier", "i"),
("particle_refinement_level", "I")]
- if hvals["nstar_tot"] > 0:
- particle_fields += [("particle_age", "d"),
- ("particle_metallicity", "d")]
+
if self.ds._extra_particle_fields is not None:
particle_fields += self.ds._extra_particle_fields
field_offsets = {}
_pfields = {}
+
+ # Read offsets
for field, vtype in particle_fields:
if f.tell() >= flen: break
field_offsets["io", field] = f.tell()
_pfields["io", field] = vtype
fpu.skip(f, 1)
+
+ iextra = 0
+ while f.tell() < flen:
+ iextra += 1
+ field, vtype = ('particle_extra_field_%i' % iextra, 'd')
+ particle_fields.append((field, vtype))
+
+ field_offsets["io", field] = f.tell()
+ _pfields["io", field] = vtype
+ fpu.skip(f, 1)
+
+ if iextra > 0 and not self.ds._warn_extra_fields:
+ self.ds._warn_extra_fields = True
+ w = ("Detected %s extra particle fields assuming kind "
+ "`double`. Consider using the `extra_particle_fields` "
+ "keyword argument if you have unexpected behavior.")
+ mylog.warning(w % iextra)
+
self.particle_field_offsets = field_offsets
self.particle_field_types = _pfields
self.particle_types = self.particle_types_raw = ("io",)
@@ -540,7 +558,7 @@
_index_class = RAMSESIndex
_field_info_class = RAMSESFieldInfo
gamma = 1.4 # This will get replaced on hydro_fn open
-
+
def __init__(self, filename, dataset_type='ramses',
fields=None, storage_filename=None,
units_override=None, unit_system="cgs",
@@ -558,6 +576,7 @@
self.fluid_types += ("ramses",)
self._fields_in_file = fields
self._extra_particle_fields = extra_particle_fields
+ self._warn_extra_fields = False
self.force_cosmological = cosmological
Dataset.__init__(self, filename, dataset_type, units_override=units_override,
unit_system=unit_system)
diff -r f292c74a3a4f6b535647dd138465dc2561b68850 -r 0231a9c04ac1101ef070028c7af3f71684643597 yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -114,7 +114,7 @@
ramsesExtraFieldsSmall = 'ramses_extra_fields_small/output_00001'
@requires_file(ramsesExtraFieldsSmall)
def test_extra_fields():
- extra_fields = [('family', 'I'), ('pointer', 'I')]
+ extra_fields = [('particle_family', 'I'), ('particle_pointer', 'I')]
ds = yt.load(os.path.join(ramsesExtraFieldsSmall, 'info_00001.txt'),
extra_particle_fields=extra_fields)
@@ -124,9 +124,22 @@
# Check the family (they should equal 100, for tracer particles)
dd = ds.all_data()
- families = dd[('all', 'family')]
+ families = dd[('all', 'particle_family')]
assert all(families == 100)
+
+ at requires_file(ramsesExtraFieldsSmall)
+def test_extra_fields_2():
+ extra_fields = ['particle_extra_field_%s' % (i + 1) for i in range(2)]
+ ds = yt.load(os.path.join(ramsesExtraFieldsSmall, 'info_00001.txt'))
+
+ # the dataset should contain the fields
+ for field in extra_fields:
+ assert ('io', field) in ds.field_list
+
+ # In the dataset, the fields are integers, so we cannot test
+ # that they are accessed correctly.
+
ramses_rt = "ramses_rt_00088/output_00088/info_00088.txt"
@requires_file(ramses_rt)
def test_ramses_rt():
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