[yt-svn] commit/yt: ngoldbaum: Merged in RicardaBeckmann/yt (pull request #1713)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Aug 27 09:17:53 PDT 2015


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/f40bc8a8486d/
Changeset:   f40bc8a8486d
Branch:      yt
User:        ngoldbaum
Date:        2015-08-27 16:17:40+00:00
Summary:     Merged in RicardaBeckmann/yt (pull request #1713)

A print_stats function for RAMSES
Affected #:  2 files

diff -r 89dd8b5534fee839aa66ece835c93beb36eb74db -r f40bc8a8486daeedee4c1a84238303283a91d445 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -44,6 +44,7 @@
     RAMSESOctreeContainer
 from yt.fields.particle_fields import \
     standard_particle_fields
+from yt.arraytypes import blankRecordArray
 
 class RAMSESDomainFile(object):
     _last_mask = None
@@ -108,7 +109,7 @@
                     print("You are running with the wrong number of fields.")
                     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
+                    #print"The last set of field sizes was: %s" % skipped
                     raise
                 if hvals['file_ncache'] == 0: continue
                 assert(hvals['file_ilevel'] == level+1)
@@ -464,6 +465,59 @@
         for subset in oobjs:
             yield YTDataChunk(dobj, "io", [subset], None, cache = cache)
 
+    def _initialize_level_stats(self):
+        levels=sum([dom.level_count for dom in self.domains])
+        desc = {'names': ['numcells','level'],
+                'formats':['Int64']*2}
+        max_level=self.dataset.min_level+self.dataset.max_level+2
+        self.level_stats = blankRecordArray(desc, max_level)
+        self.level_stats['level'] = [i for i in range(max_level)]
+        self.level_stats['numcells'] = [0 for i in range(max_level)]
+        for level in range(self.dataset.min_level+1):
+            self.level_stats[level+1]['numcells']=2**(level*self.dataset.dimensionality)
+        for level in range(self.max_level+1):
+            self.level_stats[level+self.dataset.min_level+1]['numcells'] = levels[level]
+
+    def print_stats(self):
+        
+        # This function prints information based on the fluid on the grids,
+        # and therefore does not work for DM only runs. 
+        if not self.fluid_field_list:
+            print("This function is not implemented for DM only runs")
+            return
+
+        self._initialize_level_stats()
+        """
+        Prints out (stdout) relevant information about the simulation
+        """
+        header = "%3s\t%14s\t%14s" % ("level", "# cells","# cells^3")
+        print(header)
+        print("%s" % (len(header.expandtabs())*"-"))
+        for level in range(self.dataset.min_level+self.dataset.max_level+2):
+            print("% 3i\t% 14i\t% 14i" % \
+                  (level,
+                   self.level_stats['numcells'][level],
+                   np.ceil(self.level_stats['numcells'][level]**(1./3))))
+        print("-" * 46)
+        print("   \t% 14i" % (self.level_stats['numcells'].sum()))
+        print("\n")
+
+        dx = self.get_smallest_dx()
+        try:
+            print("z = %0.8f" % (self.dataset.current_redshift))
+        except:
+            pass
+        print("t = %0.8e = %0.8e s = %0.8e years" % \
+            (self.ds.current_time.in_units("code_time"),
+             self.ds.current_time.in_units("s"),
+             self.ds.current_time.in_units("yr")))
+        print("\nSmallest Cell:")
+        u=[]
+        for item in ("Mpc", "pc", "AU", "cm"):
+            print("\tWidth: %0.3e %s" % (dx.in_units(item), item))
+
+
+
 class RAMSESDataset(Dataset):
     _index_class = RAMSESIndex
     _field_info_class = RAMSESFieldInfo

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