[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Dec 20 05:25:37 PST 2013
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/c92577ce3fec/
Changeset: c92577ce3fec
Branch: yt-3.0
User: MatthewTurk
Date: 2013-11-25 16:31:08
Summary: Adding field_aliases to RAMSES datasets.
Affected #: 3 files
diff -r 6e029bcb0dbf8680278737524cce19e3365cbea1 -r c92577ce3fecdc2b0120dfb6cab88a114b734a36 yt/frontends/ramses/api.py
--- a/yt/frontends/ramses/api.py
+++ b/yt/frontends/ramses/api.py
@@ -22,3 +22,6 @@
from .io import \
IOHandlerRAMSES
+
+from .definitions import \
+ field_aliases
diff -r 6e029bcb0dbf8680278737524cce19e3365cbea1 -r c92577ce3fecdc2b0120dfb6cab88a114b734a36 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -28,7 +28,7 @@
from yt.data_objects.octree_subset import \
OctreeSubset
-from .definitions import ramses_header
+from .definitions import ramses_header, field_aliases
from yt.utilities.definitions import \
mpc_conversion, sec_conversion
from yt.utilities.lib import \
@@ -404,12 +404,11 @@
_particle_coordinates_name = "Coordinates"
def __init__(self, filename, data_style='ramses',
- fields = None,
+ fields = "standard_six",
storage_filename = None):
# Here we want to initiate a traceback, if the reader is not built.
- if fields is None:
- fields = ["Density", "x-velocity", "y-velocity",
- "z-velocity", "Pressure", "Metallicity"]
+ if isinstance(fields, types.StringTypes):
+ fields = field_aliases[fields]
self._fields_in_file = fields
StaticOutput.__init__(self, filename, data_style)
self.storage_filename = storage_filename
diff -r 6e029bcb0dbf8680278737524cce19e3365cbea1 -r c92577ce3fecdc2b0120dfb6cab88a114b734a36 yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -45,3 +45,18 @@
('numbl', hvals['nlevelmax'] * hvals['ncpu'], 'i'),
)
yield tree_header
+
+field_aliases = {
+ 'standard_five': ('Density',
+ 'x-velocity',
+ 'y-velocity',
+ 'z-velocity',
+ 'Pressure'),
+ 'standard_six': ('Density',
+ 'x-velocity',
+ 'y-velocity',
+ 'z-velocity',
+ 'Pressure',
+ 'Metallicity'),
+
+}
https://bitbucket.org/yt_analysis/yt/commits/ac515f44efd5/
Changeset: ac515f44efd5
Branch: yt-3.0
User: samgeen
Date: 2013-11-27 12:02:31
Summary: Added support for automatic field creation in RAMSESStaticOutput; RT data still missing
Affected #: 2 files
diff -r 6e029bcb0dbf8680278737524cce19e3365cbea1 -r ac515f44efd5dd7767cd03b01fa1364b289f5611 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -13,6 +13,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import os
import numpy as np
import stat
import weakref
@@ -52,10 +53,10 @@
_last_mask = None
_last_selector_id = None
- def __init__(self, pf, domain_id, nvar):
- self.nvar = nvar
+ def __init__(self, pf, domain_id):
self.pf = pf
self.domain_id = domain_id
+ self.nvar = 0 # Set this later!
num = os.path.basename(pf.parameter_filename).split("."
)[0].split("_")[1]
basename = "%s/%%s_%s.out%05i" % (
@@ -65,6 +66,7 @@
for t in ['grav', 'hydro', 'part', 'amr']:
setattr(self, "%s_fn" % t, basename % t)
self._read_amr_header()
+ self._read_hydro_header()
self._read_particle_header()
self._read_amr()
@@ -102,9 +104,9 @@
hvals = fpu.read_attrs(f, header, "=")
except AssertionError:
print "You are running with the wrong number of fields."
- print "Please specify these in the load command."
- print "We are looking for %s fields." % self.nvar
- print "The last set of field sizes was: %s" % skipped
+ print "If you specified these in the load command, check the array length."
+ print "In this file there are %s hydro fields." % skipped
+ #print "The last set of field sizes was: %s" % skipped
raise
if hvals['file_ncache'] == 0: continue
assert(hvals['file_ilevel'] == level+1)
@@ -116,6 +118,13 @@
self._level_count = level_count
return self._hydro_offset
+ def _read_hydro_header(self):
+ if self.nvar > 0: return self.nvar
+ # Read the number of hydro variables
+ f = open(self.hydro_fn, "rb")
+ fpu.skip(f, 1)
+ self.nvar = fpu.read_vector(f, "i")[0]
+
def _read_particle_header(self):
if not os.path.exists(self.part_fn):
self.local_particle_count = 0
@@ -320,6 +329,7 @@
class RAMSESGeometryHandler(OctreeGeometryHandler):
def __init__(self, pf, data_style='ramses'):
+ self._pf = pf # TODO: Figure out the class composition better!
self.fluid_field_list = pf._fields_in_file
self.data_style = data_style
self.parameter_file = weakref.proxy(pf)
@@ -332,8 +342,7 @@
super(RAMSESGeometryHandler, self).__init__(pf, data_style)
def _initialize_oct_handler(self):
- nv = len(self.fluid_field_list)
- self.domains = [RAMSESDomainFile(self.parameter_file, i + 1, nv)
+ self.domains = [RAMSESDomainFile(self.parameter_file, i + 1)
for i in range(self.parameter_file['ncpu'])]
total_octs = sum(dom.local_oct_count #+ dom.ngridbound.sum()
for dom in self.domains)
@@ -341,14 +350,69 @@
self.num_grids = total_octs
def _detect_fields(self):
- # TODO: Add additional fields
+ # Do we want to attempt to figure out what the fields are in the file?
pfl = set([])
+ if len(self.fluid_field_list) <= 0:
+ self._setup_auto_fields()
for domain in self.domains:
pfl.update(set(domain.particle_field_offsets.keys()))
self.particle_field_list = list(pfl)
self.field_list = [("gas", f) for f in self.fluid_field_list] \
+ self.particle_field_list
+ def _setup_auto_fields(self):
+ '''
+ 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._pf.parameter_filename).split("."
+ )[0].split("_")[1]
+ testdomain = 1 # Just pick the first domain file to read
+ basename = "%s/%%s_%s.out%05i" % (
+ os.path.abspath(
+ os.path.dirname(self._pf.parameter_filename)),
+ num, testdomain)
+ hydro_fn = basename % "hydro"
+ # Do we have a hydro file?
+ if hydro_fn:
+ # Read the number of hydro variables
+ f = open(hydro_fn, "rb")
+ fpu.skip(f, 1)
+ nvar = fpu.read_vector(f, "i")[0]
+ # OK, we got NVAR, now set up the arrays depending on what NVAR is
+ # 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))
+ self.fluid_field_list = fields
+
def _setup_derived_fields(self):
self._parse_cooling()
super(RAMSESGeometryHandler, self)._setup_derived_fields()
@@ -404,12 +468,12 @@
_particle_coordinates_name = "Coordinates"
def __init__(self, filename, data_style='ramses',
- fields = None,
+ fields = [],
storage_filename = None):
- # Here we want to initiate a traceback, if the reader is not built.
- if fields is None:
- fields = ["Density", "x-velocity", "y-velocity",
- "z-velocity", "Pressure", "Metallicity"]
+ '''
+ fields: An array of hydro variable fields in order of position in the hydro_XXXXX.outYYYYY file
+ If set to None, will try a default set of fields
+ '''
self._fields_in_file = fields
StaticOutput.__init__(self, filename, data_style)
self.storage_filename = storage_filename
@@ -522,4 +586,3 @@
if not os.path.basename(args[0]).startswith("info_"): return False
fn = args[0].replace("info_", "amr_").replace(".txt", ".out00001")
return os.path.exists(fn)
-
diff -r 6e029bcb0dbf8680278737524cce19e3365cbea1 -r ac515f44efd5dd7767cd03b01fa1364b289f5611 yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -28,6 +28,17 @@
('nout', 3, 'I')
)
yield header
+ # TODO: REMOVE
+ '''
+ hydro_header = ( ('ncpu', 1, 'i'),
+ ('nvar', 1, 'i'),
+ ('ndim', 1, 'i'),
+ ('nlevelmax', 1, 'i'),
+ ('nboundary', 1, 'i'),
+ ('gamma', 1, 'd')
+ )
+ yield hydro_header
+ '''
noutput, iout, ifout = hvals['nout']
next_set = ( ('tout', noutput, 'd'),
('aout', noutput, 'd'),
https://bitbucket.org/yt_analysis/yt/commits/a53475a4c791/
Changeset: a53475a4c791
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-02 16:34:19
Summary: Merging the two RAMSES PRs
Affected #: 2 files
diff -r c92577ce3fecdc2b0120dfb6cab88a114b734a36 -r a53475a4c79104e8019ae9013df89c7eeb3bd2e4 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -13,6 +13,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import os
import numpy as np
import stat
import weakref
@@ -52,10 +53,10 @@
_last_mask = None
_last_selector_id = None
- def __init__(self, pf, domain_id, nvar):
- self.nvar = nvar
+ def __init__(self, pf, domain_id):
self.pf = pf
self.domain_id = domain_id
+ self.nvar = 0 # Set this later!
num = os.path.basename(pf.parameter_filename).split("."
)[0].split("_")[1]
basename = "%s/%%s_%s.out%05i" % (
@@ -65,6 +66,7 @@
for t in ['grav', 'hydro', 'part', 'amr']:
setattr(self, "%s_fn" % t, basename % t)
self._read_amr_header()
+ self._read_hydro_header()
self._read_particle_header()
self._read_amr()
@@ -102,9 +104,9 @@
hvals = fpu.read_attrs(f, header, "=")
except AssertionError:
print "You are running with the wrong number of fields."
- print "Please specify these in the load command."
- print "We are looking for %s fields." % self.nvar
- print "The last set of field sizes was: %s" % skipped
+ print "If you specified these in the load command, check the array length."
+ print "In this file there are %s hydro fields." % skipped
+ #print "The last set of field sizes was: %s" % skipped
raise
if hvals['file_ncache'] == 0: continue
assert(hvals['file_ilevel'] == level+1)
@@ -116,6 +118,13 @@
self._level_count = level_count
return self._hydro_offset
+ def _read_hydro_header(self):
+ if self.nvar > 0: return self.nvar
+ # Read the number of hydro variables
+ f = open(self.hydro_fn, "rb")
+ fpu.skip(f, 1)
+ self.nvar = fpu.read_vector(f, "i")[0]
+
def _read_particle_header(self):
if not os.path.exists(self.part_fn):
self.local_particle_count = 0
@@ -320,6 +329,7 @@
class RAMSESGeometryHandler(OctreeGeometryHandler):
def __init__(self, pf, data_style='ramses'):
+ self._pf = pf # TODO: Figure out the class composition better!
self.fluid_field_list = pf._fields_in_file
self.data_style = data_style
self.parameter_file = weakref.proxy(pf)
@@ -332,8 +342,7 @@
super(RAMSESGeometryHandler, self).__init__(pf, data_style)
def _initialize_oct_handler(self):
- nv = len(self.fluid_field_list)
- self.domains = [RAMSESDomainFile(self.parameter_file, i + 1, nv)
+ self.domains = [RAMSESDomainFile(self.parameter_file, i + 1)
for i in range(self.parameter_file['ncpu'])]
total_octs = sum(dom.local_oct_count #+ dom.ngridbound.sum()
for dom in self.domains)
@@ -341,14 +350,69 @@
self.num_grids = total_octs
def _detect_fields(self):
- # TODO: Add additional fields
+ # Do we want to attempt to figure out what the fields are in the file?
pfl = set([])
+ if len(self.fluid_field_list) <= 0:
+ self._setup_auto_fields()
for domain in self.domains:
pfl.update(set(domain.particle_field_offsets.keys()))
self.particle_field_list = list(pfl)
self.field_list = [("gas", f) for f in self.fluid_field_list] \
+ self.particle_field_list
+ def _setup_auto_fields(self):
+ '''
+ 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._pf.parameter_filename).split("."
+ )[0].split("_")[1]
+ testdomain = 1 # Just pick the first domain file to read
+ basename = "%s/%%s_%s.out%05i" % (
+ os.path.abspath(
+ os.path.dirname(self._pf.parameter_filename)),
+ num, testdomain)
+ hydro_fn = basename % "hydro"
+ # Do we have a hydro file?
+ if hydro_fn:
+ # Read the number of hydro variables
+ f = open(hydro_fn, "rb")
+ fpu.skip(f, 1)
+ nvar = fpu.read_vector(f, "i")[0]
+ # OK, we got NVAR, now set up the arrays depending on what NVAR is
+ # 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))
+ self.fluid_field_list = fields
+
def _setup_derived_fields(self):
self._parse_cooling()
super(RAMSESGeometryHandler, self)._setup_derived_fields()
@@ -404,11 +468,14 @@
_particle_coordinates_name = "Coordinates"
def __init__(self, filename, data_style='ramses',
- fields = "standard_six",
- storage_filename = None):
+ fields = None, storage_filename = None):
# Here we want to initiate a traceback, if the reader is not built.
if isinstance(fields, types.StringTypes):
fields = field_aliases[fields]
+ '''
+ fields: An array of hydro variable fields in order of position in the hydro_XXXXX.outYYYYY file
+ If set to None, will try a default set of fields
+ '''
self._fields_in_file = fields
StaticOutput.__init__(self, filename, data_style)
self.storage_filename = storage_filename
@@ -521,4 +588,3 @@
if not os.path.basename(args[0]).startswith("info_"): return False
fn = args[0].replace("info_", "amr_").replace(".txt", ".out00001")
return os.path.exists(fn)
-
diff -r c92577ce3fecdc2b0120dfb6cab88a114b734a36 -r a53475a4c79104e8019ae9013df89c7eeb3bd2e4 yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -28,6 +28,17 @@
('nout', 3, 'I')
)
yield header
+ # TODO: REMOVE
+ '''
+ hydro_header = ( ('ncpu', 1, 'i'),
+ ('nvar', 1, 'i'),
+ ('ndim', 1, 'i'),
+ ('nlevelmax', 1, 'i'),
+ ('nboundary', 1, 'i'),
+ ('gamma', 1, 'd')
+ )
+ yield hydro_header
+ '''
noutput, iout, ifout = hvals['nout']
next_set = ( ('tout', noutput, 'd'),
('aout', noutput, 'd'),
https://bitbucket.org/yt_analysis/yt/commits/7f9e09473bc6/
Changeset: 7f9e09473bc6
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-02 16:36:20
Summary: Modifying the field detection slightly.
Affected #: 1 file
diff -r a53475a4c79104e8019ae9013df89c7eeb3bd2e4 -r 7f9e09473bc67cd46fddbee2b12fe1cbdde22f2b yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -352,7 +352,7 @@
def _detect_fields(self):
# Do we want to attempt to figure out what the fields are in the file?
pfl = set([])
- if len(self.fluid_field_list) <= 0:
+ if self.fluid_field_list is None or len(self.fluid_field_list) <= 0:
self._setup_auto_fields()
for domain in self.domains:
pfl.update(set(domain.particle_field_offsets.keys()))
https://bitbucket.org/yt_analysis/yt/commits/e6ec5beff85a/
Changeset: e6ec5beff85a
Branch: yt-3.0
User: MatthewTurk
Date: 2013-12-20 14:25:31
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #659)
RAMSES field detection
Affected #: 3 files
diff -r 7026b9ddfc20c9f9f05e654fdbf84c89a42007d1 -r e6ec5beff85ab551ea9347155b71efc076c87ab4 yt/frontends/ramses/api.py
--- a/yt/frontends/ramses/api.py
+++ b/yt/frontends/ramses/api.py
@@ -22,3 +22,6 @@
from .io import \
IOHandlerRAMSES
+
+from .definitions import \
+ field_aliases
diff -r 7026b9ddfc20c9f9f05e654fdbf84c89a42007d1 -r e6ec5beff85ab551ea9347155b71efc076c87ab4 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -13,6 +13,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import os
import numpy as np
import stat
import weakref
@@ -28,7 +29,7 @@
from yt.data_objects.octree_subset import \
OctreeSubset
-from .definitions import ramses_header
+from .definitions import ramses_header, field_aliases
from yt.utilities.definitions import \
mpc_conversion, sec_conversion
from yt.utilities.lib import \
@@ -52,10 +53,10 @@
_last_mask = None
_last_selector_id = None
- def __init__(self, pf, domain_id, nvar):
- self.nvar = nvar
+ def __init__(self, pf, domain_id):
self.pf = pf
self.domain_id = domain_id
+ self.nvar = 0 # Set this later!
num = os.path.basename(pf.parameter_filename).split("."
)[0].split("_")[1]
basename = "%s/%%s_%s.out%05i" % (
@@ -65,6 +66,7 @@
for t in ['grav', 'hydro', 'part', 'amr']:
setattr(self, "%s_fn" % t, basename % t)
self._read_amr_header()
+ self._read_hydro_header()
self._read_particle_header()
self._read_amr()
@@ -102,9 +104,9 @@
hvals = fpu.read_attrs(f, header, "=")
except AssertionError:
print "You are running with the wrong number of fields."
- print "Please specify these in the load command."
- print "We are looking for %s fields." % self.nvar
- print "The last set of field sizes was: %s" % skipped
+ print "If you specified these in the load command, check the array length."
+ print "In this file there are %s hydro fields." % skipped
+ #print "The last set of field sizes was: %s" % skipped
raise
if hvals['file_ncache'] == 0: continue
assert(hvals['file_ilevel'] == level+1)
@@ -116,6 +118,13 @@
self._level_count = level_count
return self._hydro_offset
+ def _read_hydro_header(self):
+ if self.nvar > 0: return self.nvar
+ # Read the number of hydro variables
+ f = open(self.hydro_fn, "rb")
+ fpu.skip(f, 1)
+ self.nvar = fpu.read_vector(f, "i")[0]
+
def _read_particle_header(self):
if not os.path.exists(self.part_fn):
self.local_particle_count = 0
@@ -320,6 +329,7 @@
class RAMSESGeometryHandler(OctreeGeometryHandler):
def __init__(self, pf, data_style='ramses'):
+ self._pf = pf # TODO: Figure out the class composition better!
self.fluid_field_list = pf._fields_in_file
self.data_style = data_style
self.parameter_file = weakref.proxy(pf)
@@ -332,8 +342,7 @@
super(RAMSESGeometryHandler, self).__init__(pf, data_style)
def _initialize_oct_handler(self):
- nv = len(self.fluid_field_list)
- self.domains = [RAMSESDomainFile(self.parameter_file, i + 1, nv)
+ self.domains = [RAMSESDomainFile(self.parameter_file, i + 1)
for i in range(self.parameter_file['ncpu'])]
total_octs = sum(dom.local_oct_count #+ dom.ngridbound.sum()
for dom in self.domains)
@@ -341,14 +350,69 @@
self.num_grids = total_octs
def _detect_fields(self):
- # TODO: Add additional fields
+ # Do we want to attempt to figure out what the fields are in the file?
pfl = set([])
+ if self.fluid_field_list is None or len(self.fluid_field_list) <= 0:
+ self._setup_auto_fields()
for domain in self.domains:
pfl.update(set(domain.particle_field_offsets.keys()))
self.particle_field_list = list(pfl)
self.field_list = [("gas", f) for f in self.fluid_field_list] \
+ self.particle_field_list
+ def _setup_auto_fields(self):
+ '''
+ 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._pf.parameter_filename).split("."
+ )[0].split("_")[1]
+ testdomain = 1 # Just pick the first domain file to read
+ basename = "%s/%%s_%s.out%05i" % (
+ os.path.abspath(
+ os.path.dirname(self._pf.parameter_filename)),
+ num, testdomain)
+ hydro_fn = basename % "hydro"
+ # Do we have a hydro file?
+ if hydro_fn:
+ # Read the number of hydro variables
+ f = open(hydro_fn, "rb")
+ fpu.skip(f, 1)
+ nvar = fpu.read_vector(f, "i")[0]
+ # OK, we got NVAR, now set up the arrays depending on what NVAR is
+ # 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))
+ self.fluid_field_list = fields
+
def _setup_derived_fields(self):
self._parse_cooling()
super(RAMSESGeometryHandler, self)._setup_derived_fields()
@@ -404,12 +468,14 @@
_particle_coordinates_name = "Coordinates"
def __init__(self, filename, data_style='ramses',
- fields = None,
- storage_filename = None):
+ fields = None, storage_filename = None):
# Here we want to initiate a traceback, if the reader is not built.
- if fields is None:
- fields = ["Density", "x-velocity", "y-velocity",
- "z-velocity", "Pressure", "Metallicity"]
+ if isinstance(fields, types.StringTypes):
+ fields = field_aliases[fields]
+ '''
+ fields: An array of hydro variable fields in order of position in the hydro_XXXXX.outYYYYY file
+ If set to None, will try a default set of fields
+ '''
self._fields_in_file = fields
StaticOutput.__init__(self, filename, data_style)
self.storage_filename = storage_filename
@@ -522,4 +588,3 @@
if not os.path.basename(args[0]).startswith("info_"): return False
fn = args[0].replace("info_", "amr_").replace(".txt", ".out00001")
return os.path.exists(fn)
-
diff -r 7026b9ddfc20c9f9f05e654fdbf84c89a42007d1 -r e6ec5beff85ab551ea9347155b71efc076c87ab4 yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -28,6 +28,17 @@
('nout', 3, 'I')
)
yield header
+ # TODO: REMOVE
+ '''
+ hydro_header = ( ('ncpu', 1, 'i'),
+ ('nvar', 1, 'i'),
+ ('ndim', 1, 'i'),
+ ('nlevelmax', 1, 'i'),
+ ('nboundary', 1, 'i'),
+ ('gamma', 1, 'd')
+ )
+ yield hydro_header
+ '''
noutput, iout, ifout = hvals['nout']
next_set = ( ('tout', noutput, 'd'),
('aout', noutput, 'd'),
@@ -45,3 +56,18 @@
('numbl', hvals['nlevelmax'] * hvals['ncpu'], 'i'),
)
yield tree_header
+
+field_aliases = {
+ 'standard_five': ('Density',
+ 'x-velocity',
+ 'y-velocity',
+ 'z-velocity',
+ 'Pressure'),
+ 'standard_six': ('Density',
+ 'x-velocity',
+ 'y-velocity',
+ 'z-velocity',
+ 'Pressure',
+ 'Metallicity'),
+
+}
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