[yt-svn] commit/yt: 9 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun Jul 16 07:32:44 PDT 2017
9 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/26d65e2c265f/
Changeset: 26d65e2c265f
User: Salvatore Cielo
Date: 2017-06-12 17:01:16+00:00
Summary: Automatically identifying ramses-rt files, creating the correct fields accordingly.
Affected #: 2 files
diff -r 97d66bcd02227747896348ca0cfe764867499370 -r 26d65e2c265fdbe02ad2c1620fe51ffce0740dc1 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -378,10 +378,6 @@
'''
If no fluid fields are set, the code tries to set up a fluids array by hand
'''
- # TODO: SUPPORT RT - THIS REQUIRES IMPLEMENTING A NEW FILE READER!
- # Find nvar
-
-
# TODO: copy/pasted from DomainFile; needs refactoring!
num = os.path.basename(self.dataset.parameter_filename).split("."
)[0].split("_")[1]
@@ -408,32 +404,43 @@
self.ds.gamma = hvals['gamma']
nvar = hvals['nvar']
# OK, we got NVAR, now set up the arrays depending on what NVAR is
+ # but first check for radiative transfer!
+ foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
+ rt_flag = not os.system('ls ' + foldername + '/info_rt_*.txt 1>/dev/null 2>/dev/null')
+ if rt_flag: # rt run
+ if nvar < 10:
+ print('Detected RAMSES-RT file WITHOUT IR trapping.')
+ fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
+ else:
+ print('Detected RAMSES-RT file WITH IR trapping.')
+ fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pres_IR", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
+ else:
+ if nvar < 5:
+ mylog.debug("nvar=%s is too small! YT doesn't currently support 1D/2D runs in RAMSES %s")
+ raise ValueError
+ # Basic hydro runs
+ if nvar == 5:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "Pressure"]
+ if nvar > 5 and nvar < 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "Pressure", "Metallicity"]
+ # MHD runs - NOTE: THE MHD MODULE WILL SILENTLY ADD 3 TO THE NVAR IN THE MAKEFILE
+ if nvar == 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
+ "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
+ "Pressure"]
+ if nvar > 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
+ "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
+ "Pressure","Metallicity"]
# Allow some wiggle room for users to add too many variables
- if nvar < 5:
- mylog.debug("nvar=%s is too small! YT doesn't currently support 1D/2D runs in RAMSES %s")
- raise ValueError
- # Basic hydro runs
- if nvar == 5:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "Pressure"]
- if nvar > 5 and nvar < 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "Pressure", "Metallicity"]
- # MHD runs - NOTE: THE MHD MODULE WILL SILENTLY ADD 3 TO THE NVAR IN THE MAKEFILE
- if nvar == 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
- "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
- "Pressure"]
- if nvar > 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
- "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
- "Pressure","Metallicity"]
while len(fields) < nvar:
fields.append("var"+str(len(fields)))
mylog.debug("No fields specified by user; automatically setting fields array to %s", str(fields))
diff -r 97d66bcd02227747896348ca0cfe764867499370 -r 26d65e2c265fdbe02ad2c1620fe51ffce0740dc1 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -67,8 +67,12 @@
("x-velocity", (vel_units, ["velocity_x"], None)),
("y-velocity", (vel_units, ["velocity_y"], None)),
("z-velocity", (vel_units, ["velocity_z"], None)),
+ ("Pres_IR", (pressure_units, ["pres_IR"], None)),
("Pressure", (pressure_units, ["pressure"], None)),
("Metallicity", ("", ["metallicity"], None)),
+ ("HII", ("", ["HII"], None)),
+ ("HeII", ("", ["HeII"], None)),
+ ("HeIII",("", ["HeIII"], None)),
)
known_particle_fields = (
("particle_position_x", ("code_length", [], None)),
@@ -92,6 +96,18 @@
self.add_field(("gas", "temperature"), sampling_type="cell", function=_temperature,
units=self.ds.unit_system["temperature"])
self.create_cooling_fields()
+ # See if we need to load the rt fields
+ foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
+ rt_flag = not os.system('ls ' + foldername + '/info_rt_*.txt 1>/dev/null 2>/dev/null')
+ if rt_flag: # rt run
+ self.setup_rt_fields()
+
+ def setup_rt_fields(self):
+ def _temp_IR(field, data):
+ rv = data["gas", "pres_IR"]/data["gas", "density"]
+ rv *= mass_hydrogen_cgs/boltzmann_constant_cgs
+ return rv
+ self.add_field(("gas", "temp_IR"), sampling_type="cell", function=_temp_IR, units=self.ds.unit_system["temperature"])
def create_cooling_fields(self):
num = os.path.basename(self.ds.parameter_filename).split("."
https://bitbucket.org/yt_analysis/yt/commits/a2fa0fa37cf2/
Changeset: a2fa0fa37cf2
User: sacielo
Date: 2017-06-16 00:43:19+00:00
Summary: Indentations multiple of 4
Affected #: 2 files
diff -r 26d65e2c265fdbe02ad2c1620fe51ffce0740dc1 -r a2fa0fa37cf28c77d4c01c3aa1c025e90a4dce1d yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -408,38 +408,38 @@
foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
rt_flag = not os.system('ls ' + foldername + '/info_rt_*.txt 1>/dev/null 2>/dev/null')
if rt_flag: # rt run
- if nvar < 10:
- print('Detected RAMSES-RT file WITHOUT IR trapping.')
- fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
- else:
- print('Detected RAMSES-RT file WITH IR trapping.')
- fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pres_IR", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
+ if nvar < 10:
+ print('Detected RAMSES-RT file WITHOUT IR trapping.')
+ fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
+ else:
+ print('Detected RAMSES-RT file WITH IR trapping.')
+ fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pres_IR", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
else:
- if nvar < 5:
- mylog.debug("nvar=%s is too small! YT doesn't currently support 1D/2D runs in RAMSES %s")
- raise ValueError
- # Basic hydro runs
- if nvar == 5:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "Pressure"]
- if nvar > 5 and nvar < 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "Pressure", "Metallicity"]
- # MHD runs - NOTE: THE MHD MODULE WILL SILENTLY ADD 3 TO THE NVAR IN THE MAKEFILE
- if nvar == 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
- "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
- "Pressure"]
- if nvar > 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
- "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
- "Pressure","Metallicity"]
+ if nvar < 5:
+ mylog.debug("nvar=%s is too small! YT doesn't currently support 1D/2D runs in RAMSES %s")
+ raise ValueError
+ # Basic hydro runs
+ if nvar == 5:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "Pressure"]
+ if nvar > 5 and nvar < 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "Pressure", "Metallicity"]
+ # MHD runs - NOTE: THE MHD MODULE WILL SILENTLY ADD 3 TO THE NVAR IN THE MAKEFILE
+ if nvar == 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
+ "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
+ "Pressure"]
+ if nvar > 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
+ "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
+ "Pressure","Metallicity"]
# Allow some wiggle room for users to add too many variables
while len(fields) < nvar:
fields.append("var"+str(len(fields)))
diff -r 26d65e2c265fdbe02ad2c1620fe51ffce0740dc1 -r a2fa0fa37cf28c77d4c01c3aa1c025e90a4dce1d yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -100,7 +100,7 @@
foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
rt_flag = not os.system('ls ' + foldername + '/info_rt_*.txt 1>/dev/null 2>/dev/null')
if rt_flag: # rt run
- self.setup_rt_fields()
+ self.setup_rt_fields()
def setup_rt_fields(self):
def _temp_IR(field, data):
https://bitbucket.org/yt_analysis/yt/commits/04999b50c5a4/
Changeset: 04999b50c5a4
User: ngoldbaum
Date: 2017-06-16 19:56:50+00:00
Summary: Use the glob module instead of shelling out to ls
Affected #: 2 files
diff -r a2fa0fa37cf28c77d4c01c3aa1c025e90a4dce1d -r 04999b50c5a43b79ee676c0575e9e2285ea4ad01 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -15,6 +15,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import glob
import os
import numpy as np
import stat
@@ -406,7 +407,7 @@
# OK, we got NVAR, now set up the arrays depending on what NVAR is
# but first check for radiative transfer!
foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
- rt_flag = not os.system('ls ' + foldername + '/info_rt_*.txt 1>/dev/null 2>/dev/null')
+ rt_flag = any(glob.glob(os.sep.join([foldername, 'info_rt_*.txt'])))
if rt_flag: # rt run
if nvar < 10:
print('Detected RAMSES-RT file WITHOUT IR trapping.')
diff -r a2fa0fa37cf28c77d4c01c3aa1c025e90a4dce1d -r 04999b50c5a43b79ee676c0575e9e2285ea4ad01 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -13,6 +13,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import glob
import os
import numpy as np
@@ -98,7 +99,7 @@
self.create_cooling_fields()
# See if we need to load the rt fields
foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
- rt_flag = not os.system('ls ' + foldername + '/info_rt_*.txt 1>/dev/null 2>/dev/null')
+ rt_flag = any(glob.glob(os.sep.join([foldername, 'info_rt_*.txt'])))
if rt_flag: # rt run
self.setup_rt_fields()
https://bitbucket.org/yt_analysis/yt/commits/4f019dc0f4be/
Changeset: 4f019dc0f4be
User: ngoldbaum
Date: 2017-06-16 19:57:04+00:00
Summary: Convert print statements to logger calls
Affected #: 1 file
diff -r 04999b50c5a43b79ee676c0575e9e2285ea4ad01 -r 4f019dc0f4be092e605e76b5dff9e12563ceb58d yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -410,10 +410,10 @@
rt_flag = any(glob.glob(os.sep.join([foldername, 'info_rt_*.txt'])))
if rt_flag: # rt run
if nvar < 10:
- print('Detected RAMSES-RT file WITHOUT IR trapping.')
+ mylog.info('Detected RAMSES-RT file WITHOUT IR trapping.')
fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
else:
- print('Detected RAMSES-RT file WITH IR trapping.')
+ mylog.info('Detected RAMSES-RT file WITH IR trapping.')
fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pres_IR", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
else:
if nvar < 5:
https://bitbucket.org/yt_analysis/yt/commits/819f053510bd/
Changeset: 819f053510bd
User: ngoldbaum
Date: 2017-06-16 19:58:07+00:00
Summary: add basic test for ramses-rt functionality
Affected #: 1 file
diff -r 4f019dc0f4be092e605e76b5dff9e12563ceb58d -r 819f053510bd97a56d7ecf775b5ff0cddc2db5c8 yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -86,3 +86,23 @@
dd = ds.all_data()
families = dd[('all', 'family')]
assert all(families == 100)
+
+ramses_rt = "ramses_rt_00088/output_00088/info_00088.txt"
+ at requires_file(ramses_rt)
+def test_ramses_rt():
+ ds = yt.load(ramses_rt)
+ ad = ds.all_data()
+
+ expected_fields = ["Density", "x-velocity", "y-velocity", "z-velocity",
+ "Pres_IR", "Pressure", "Metallicity", "HII", "HeII",
+ "HeIII"]
+
+ for field in expected_fields:
+ assert(('ramses', field) in ds.field_list)
+
+ # test that field access works
+ ad['ramses', field]
+
+ # test that special derived fields for RT datasets works
+ assert(('gas', 'temp_IR') in ds.derived_field_list)
+ ad['gas', 'temp_IR']
https://bitbucket.org/yt_analysis/yt/commits/28e121682c67/
Changeset: 28e121682c67
User: ngoldbaum
Date: 2017-06-16 20:21:47+00:00
Summary: add species derived fields for fraction, density, and mass
Affected #: 2 files
diff -r 819f053510bd97a56d7ecf775b5ff0cddc2db5c8 -r 28e121682c674b19ed5eee840f78899576c27b18 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -71,9 +71,9 @@
("Pres_IR", (pressure_units, ["pres_IR"], None)),
("Pressure", (pressure_units, ["pressure"], None)),
("Metallicity", ("", ["metallicity"], None)),
- ("HII", ("", ["HII"], None)),
- ("HeII", ("", ["HeII"], None)),
- ("HeIII",("", ["HeIII"], None)),
+ ("HII", ("", ["H_p1_fraction"], None)),
+ ("HeII", ("", ["He_p1_fraction"], None)),
+ ("HeIII",("", ["He_p2_fraction"], None)),
)
known_particle_fields = (
("particle_position_x", ("code_length", [], None)),
@@ -102,13 +102,28 @@
rt_flag = any(glob.glob(os.sep.join([foldername, 'info_rt_*.txt'])))
if rt_flag: # rt run
self.setup_rt_fields()
-
+
def setup_rt_fields(self):
def _temp_IR(field, data):
rv = data["gas", "pres_IR"]/data["gas", "density"]
rv *= mass_hydrogen_cgs/boltzmann_constant_cgs
return rv
- self.add_field(("gas", "temp_IR"), sampling_type="cell", function=_temp_IR, units=self.ds.unit_system["temperature"])
+ self.add_field(("gas", "temp_IR"), sampling_type="cell",
+ function=_temp_IR,
+ units=self.ds.unit_system["temperature"])
+ for species in ['H_p1', 'He_p1', 'He_p2']:
+ def _species_density(field, data):
+ return data['gas', species+'_fraction']*data['gas', 'density']
+ self.add_field(('gas', species+'_density'), sampling_type='cell',
+ function=_species_density,
+ units=self.ds.unit_system['density'])
+ def _species_mass(field, data):
+ return (data['gas', species+'_density']*
+ data['index', 'cell_volume'])
+ self.add_field(('gas', species+'_mass'), sampling_type='cell',
+ function=_species_mass,
+ units=self.ds.unit_system['mass'])
+
def create_cooling_fields(self):
num = os.path.basename(self.ds.parameter_filename).split("."
diff -r 819f053510bd97a56d7ecf775b5ff0cddc2db5c8 -r 28e121682c674b19ed5eee840f78899576c27b18 yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -103,6 +103,14 @@
# test that field access works
ad['ramses', field]
- # test that special derived fields for RT datasets works
- assert(('gas', 'temp_IR') in ds.derived_field_list)
- ad['gas', 'temp_IR']
+ # test that special derived fields for RT datasets work
+ special_fields = [('gas', 'temp_IR')]
+ species = ['H_p1', 'He_p1', 'He_p2']
+ for specie in species:
+ special_fields.extend(
+ [('gas', specie+'_fraction'), ('gas', specie+'_density'),
+ ('gas', specie+'_mass')])
+
+ for field in special_fields:
+ assert(field in ds.derived_field_list)
+ ret = ad[field]
https://bitbucket.org/yt_analysis/yt/commits/bb399f28b56d/
Changeset: bb399f28b56d
User: ngoldbaum
Date: 2017-06-16 20:31:48+00:00
Summary: mention in docs that ramses-rt is supported
Affected #: 1 file
diff -r 28e121682c674b19ed5eee840f78899576c27b18 -r bb399f28b56db35542febfc923e6f3805578cfa3 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1921,6 +1921,9 @@
ds = yt.load("output_00001/info_00001.txt", extra_particle_fields=extra_fields)
# ('all', 'family') and ('all', 'info') now in ds.field_list
+yt supports outputs made by the mainline ``RAMSES`` code as well as the
+``RAMSES-RT`` fork. Files produces by ``RAMSES-RT`` are recognized as such
+based on the presence of a ``into_rt_*.txt`` file in the output directory.
.. _loading-sph-data:
https://bitbucket.org/yt_analysis/yt/commits/395ad4e4a1c0/
Changeset: 395ad4e4a1c0
User: ngoldbaum
Date: 2017-06-16 22:58:31+00:00
Summary: appease flake8
Affected #: 1 file
diff -r bb399f28b56db35542febfc923e6f3805578cfa3 -r 395ad4e4a1c0022733406ac8b66f9afb35d96fbe yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -113,4 +113,4 @@
for field in special_fields:
assert(field in ds.derived_field_list)
- ret = ad[field]
+ ad[field]
https://bitbucket.org/yt_analysis/yt/commits/fcedb2fbeb7c/
Changeset: fcedb2fbeb7c
User: ngoldbaum
Date: 2017-07-16 14:32:32+00:00
Summary: Merge pull request #1456 from ngoldbaum/sacielo
Automatically identify Ramses-RT fields
Affected #: 4 files
diff -r ef34e9c9249555c1ffa7f8d8abf0d52d5612065c -r fcedb2fbeb7c953194c0f10d808f6493b1eab945 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -1943,6 +1943,9 @@
ds = yt.load("output_00001/info_00001.txt", extra_particle_fields=extra_fields)
# ('all', 'family') and ('all', 'info') now in ds.field_list
+yt supports outputs made by the mainline ``RAMSES`` code as well as the
+``RAMSES-RT`` fork. Files produces by ``RAMSES-RT`` are recognized as such
+based on the presence of a ``into_rt_*.txt`` file in the output directory.
.. _loading-sph-data:
diff -r ef34e9c9249555c1ffa7f8d8abf0d52d5612065c -r fcedb2fbeb7c953194c0f10d808f6493b1eab945 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -15,6 +15,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import glob
import os
import numpy as np
import stat
@@ -378,10 +379,6 @@
'''
If no fluid fields are set, the code tries to set up a fluids array by hand
'''
- # TODO: SUPPORT RT - THIS REQUIRES IMPLEMENTING A NEW FILE READER!
- # Find nvar
-
-
# TODO: copy/pasted from DomainFile; needs refactoring!
num = os.path.basename(self.dataset.parameter_filename).split("."
)[0].split("_")[1]
@@ -408,32 +405,43 @@
self.ds.gamma = hvals['gamma']
nvar = hvals['nvar']
# OK, we got NVAR, now set up the arrays depending on what NVAR is
+ # but first check for radiative transfer!
+ foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
+ rt_flag = any(glob.glob(os.sep.join([foldername, 'info_rt_*.txt'])))
+ if rt_flag: # rt run
+ if nvar < 10:
+ mylog.info('Detected RAMSES-RT file WITHOUT IR trapping.')
+ fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
+ else:
+ mylog.info('Detected RAMSES-RT file WITH IR trapping.')
+ fields = ["Density", "x-velocity", "y-velocity", "z-velocity", "Pres_IR", "Pressure", "Metallicity", "HII", "HeII", "HeIII"]
+ else:
+ if nvar < 5:
+ mylog.debug("nvar=%s is too small! YT doesn't currently support 1D/2D runs in RAMSES %s")
+ raise ValueError
+ # Basic hydro runs
+ if nvar == 5:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "Pressure"]
+ if nvar > 5 and nvar < 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "Pressure", "Metallicity"]
+ # MHD runs - NOTE: THE MHD MODULE WILL SILENTLY ADD 3 TO THE NVAR IN THE MAKEFILE
+ if nvar == 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
+ "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
+ "Pressure"]
+ if nvar > 11:
+ fields = ["Density",
+ "x-velocity", "y-velocity", "z-velocity",
+ "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
+ "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
+ "Pressure","Metallicity"]
# Allow some wiggle room for users to add too many variables
- if nvar < 5:
- mylog.debug("nvar=%s is too small! YT doesn't currently support 1D/2D runs in RAMSES %s")
- raise ValueError
- # Basic hydro runs
- if nvar == 5:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "Pressure"]
- if nvar > 5 and nvar < 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "Pressure", "Metallicity"]
- # MHD runs - NOTE: THE MHD MODULE WILL SILENTLY ADD 3 TO THE NVAR IN THE MAKEFILE
- if nvar == 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
- "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
- "Pressure"]
- if nvar > 11:
- fields = ["Density",
- "x-velocity", "y-velocity", "z-velocity",
- "x-Bfield-left", "y-Bfield-left", "z-Bfield-left",
- "x-Bfield-right", "y-Bfield-right", "z-Bfield-right",
- "Pressure","Metallicity"]
while len(fields) < nvar:
fields.append("var"+str(len(fields)))
mylog.debug("No fields specified by user; automatically setting fields array to %s", str(fields))
diff -r ef34e9c9249555c1ffa7f8d8abf0d52d5612065c -r fcedb2fbeb7c953194c0f10d808f6493b1eab945 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -13,6 +13,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import glob
import os
import numpy as np
@@ -67,8 +68,12 @@
("x-velocity", (vel_units, ["velocity_x"], None)),
("y-velocity", (vel_units, ["velocity_y"], None)),
("z-velocity", (vel_units, ["velocity_z"], None)),
+ ("Pres_IR", (pressure_units, ["pres_IR"], None)),
("Pressure", (pressure_units, ["pressure"], None)),
("Metallicity", ("", ["metallicity"], None)),
+ ("HII", ("", ["H_p1_fraction"], None)),
+ ("HeII", ("", ["He_p1_fraction"], None)),
+ ("HeIII",("", ["He_p2_fraction"], None)),
)
known_particle_fields = (
("particle_position_x", ("code_length", [], None)),
@@ -92,6 +97,33 @@
self.add_field(("gas", "temperature"), sampling_type="cell", function=_temperature,
units=self.ds.unit_system["temperature"])
self.create_cooling_fields()
+ # See if we need to load the rt fields
+ foldername = os.path.abspath(os.path.dirname(self.ds.parameter_filename))
+ rt_flag = any(glob.glob(os.sep.join([foldername, 'info_rt_*.txt'])))
+ if rt_flag: # rt run
+ self.setup_rt_fields()
+
+ def setup_rt_fields(self):
+ def _temp_IR(field, data):
+ rv = data["gas", "pres_IR"]/data["gas", "density"]
+ rv *= mass_hydrogen_cgs/boltzmann_constant_cgs
+ return rv
+ self.add_field(("gas", "temp_IR"), sampling_type="cell",
+ function=_temp_IR,
+ units=self.ds.unit_system["temperature"])
+ for species in ['H_p1', 'He_p1', 'He_p2']:
+ def _species_density(field, data):
+ return data['gas', species+'_fraction']*data['gas', 'density']
+ self.add_field(('gas', species+'_density'), sampling_type='cell',
+ function=_species_density,
+ units=self.ds.unit_system['density'])
+ def _species_mass(field, data):
+ return (data['gas', species+'_density']*
+ data['index', 'cell_volume'])
+ self.add_field(('gas', species+'_mass'), sampling_type='cell',
+ function=_species_mass,
+ units=self.ds.unit_system['mass'])
+
def create_cooling_fields(self):
num = os.path.basename(self.ds.parameter_filename).split("."
diff -r ef34e9c9249555c1ffa7f8d8abf0d52d5612065c -r fcedb2fbeb7c953194c0f10d808f6493b1eab945 yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -86,3 +86,31 @@
dd = ds.all_data()
families = dd[('all', 'family')]
assert all(families == 100)
+
+ramses_rt = "ramses_rt_00088/output_00088/info_00088.txt"
+ at requires_file(ramses_rt)
+def test_ramses_rt():
+ ds = yt.load(ramses_rt)
+ ad = ds.all_data()
+
+ expected_fields = ["Density", "x-velocity", "y-velocity", "z-velocity",
+ "Pres_IR", "Pressure", "Metallicity", "HII", "HeII",
+ "HeIII"]
+
+ for field in expected_fields:
+ assert(('ramses', field) in ds.field_list)
+
+ # test that field access works
+ ad['ramses', field]
+
+ # test that special derived fields for RT datasets work
+ special_fields = [('gas', 'temp_IR')]
+ species = ['H_p1', 'He_p1', 'He_p2']
+ for specie in species:
+ special_fields.extend(
+ [('gas', specie+'_fraction'), ('gas', specie+'_density'),
+ ('gas', specie+'_mass')])
+
+ for field in special_fields:
+ assert(field in ds.derived_field_list)
+ ad[field]
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