[yt-svn] commit/yt-3.0: MatthewTurk: Adding dx, dy, dz to the Ramses data (should be made universal) and moving

Bitbucket commits-noreply at bitbucket.org
Thu Aug 30 13:46:27 PDT 2012


1 new commit in yt-3.0:


https://bitbucket.org/yt_analysis/yt-3.0/changeset/65d35775c9d4/
changeset:   65d35775c9d4
branch:      yt-3.0
user:        MatthewTurk
date:        2012-08-30 22:46:13
summary:     Adding dx, dy, dz to the Ramses data (should be made universal) and moving
around some items in the field info containers.
affected #:  5 files

diff -r b89b3c70056a0f7c0a19b654aa66211f02f0ff46 -r 65d35775c9d4e2ef76ab943ff4c823b1fbbdf0da yt/data_objects/field_info_container.py
--- a/yt/data_objects/field_info_container.py
+++ b/yt/data_objects/field_info_container.py
@@ -70,22 +70,32 @@
             raise KeyError("No field named %s" % (key,))
         return self.fallback[key]
 
+    name = ""
+
     @classmethod
-    def create_with_fallback(cls, fallback):
+    def create_with_fallback(cls, fallback, name = ""):
         obj = cls()
         obj.fallback = fallback
+        obj.name = name
         return obj
 
     def __contains__(self, key):
         if dict.__contains__(self, key): return True
         if self.fallback is None: return False
-        return self.fallback.has_key(key)
+        return key in self.fallback
 
     def __iter__(self):
-        for f in dict.__iter__(self): yield f
+        for f in dict.__iter__(self):
+            yield f
         if self.fallback:
             for f in self.fallback: yield f
 
+    def keys(self):
+        keys = dict.keys(self)
+        if self.fallback:
+            keys += self.fallback.keys()
+        return keys
+
 def TranslationFunc(field_name):
     def _TranslationFunc(field, data):
         return data[field_name]
@@ -95,6 +105,7 @@
     return
 
 FieldInfo = FieldInfoContainer()
+FieldInfo.name = id(FieldInfo)
 add_field = FieldInfo.add_field
 
 def derived_field(**kwargs):


diff -r b89b3c70056a0f7c0a19b654aa66211f02f0ff46 -r 65d35775c9d4e2ef76ab943ff4c823b1fbbdf0da yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -226,8 +226,6 @@
         if getattr(self, "field_dependencies", None) is None:
             self.field_dependencies = {}
 
-        
-
 def _reconstruct_pf(*args, **kwargs):
     pfs = ParameterFileStore()
     pf = pfs.get_pf_hash(*args)


diff -r b89b3c70056a0f7c0a19b654aa66211f02f0ff46 -r 65d35775c9d4e2ef76ab943ff4c823b1fbbdf0da yt/frontends/enzo/fields.py
--- a/yt/frontends/enzo/fields.py
+++ b/yt/frontends/enzo/fields.py
@@ -42,7 +42,7 @@
 
 import yt.utilities.lib as amr_utils
 
-EnzoFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
+EnzoFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo, "EFI")
 add_field = EnzoFieldInfo.add_field
 
 KnownEnzoFields = FieldInfoContainer()


diff -r b89b3c70056a0f7c0a19b654aa66211f02f0ff46 -r 65d35775c9d4e2ef76ab943ff4c823b1fbbdf0da yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -38,7 +38,6 @@
 from yt.data_objects.static_output import \
     StaticOutput
 
-from .fields import RAMSESFieldInfo, KnownRAMSESFields
 from .definitions import ramses_header
 from yt.utilities.definitions import \
     mpc_conversion, sec_conversion
@@ -51,6 +50,7 @@
 import yt.utilities.fortran_utils as fpu
 from yt.geometry.oct_container import \
     RAMSESOctreeContainer
+from .fields import RAMSESFieldInfo, KnownRAMSESFields
 
 class RAMSESDomainFile(object):
     _last_mask = None


diff -r b89b3c70056a0f7c0a19b654aa66211f02f0ff46 -r 65d35775c9d4e2ef76ab943ff4c823b1fbbdf0da yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -35,13 +35,12 @@
     ValidateGridType
 import yt.data_objects.universal_fields
 
+RAMSESFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo, "RFI")
+add_field = RAMSESFieldInfo.add_field
 
 KnownRAMSESFields = FieldInfoContainer()
 add_ramses_field = KnownRAMSESFields.add_field
 
-RAMSESFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
-add_field = RAMSESFieldInfo.add_field
-
 known_ramses_fields = [
     "Density",
     "x-velocity",
@@ -56,6 +55,18 @@
         add_ramses_field(f, function=NullFunc, take_log=True,
                   validators = [ValidateDataField(f)])
 
+def dx(field, data):
+    return data.fwidth[:,0]
+add_field("dx", function=dx)
+
+def dy(field, data):
+    return data.fwidth[:,1]
+add_field("dy", function=dy)
+
+def dz(field, data):
+    return data.fwidth[:,2]
+add_field("dz", function=dz)
+
 def _convertDensity(data):
     return data.convert("Density")
 KnownRAMSESFields["Density"]._units = r"\rm{g}/\rm{cm}^3"

Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/

--

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