[Yt-svn] yt: 2 new changesets
hg at spacepope.org
hg at spacepope.org
Wed Aug 18 14:53:11 PDT 2010
hg Repository: yt
details: yt/rev/1ab39813789f
changeset: 1949:1ab39813789f
user: Matthew Turk <matthewturk at gmail.com>
date:
Wed Aug 18 14:52:50 2010 -0700
description:
Changed iteration order for Depth First Octree to match what Sunrise expects
hg Repository: yt
details: yt/rev/feb8e18f96fb
changeset: 1950:feb8e18f96fb
user: Matthew Turk <matthewturk at gmail.com>
date:
Wed Aug 18 14:53:08 2010 -0700
description:
Merging
diffstat:
yt/_amr_utils/DepthFirstOctree.pyx | 12 ++++++------
yt/lagos/BaseGridType.py | 15 +++++++++++----
yt/lagos/GadgetFields.py | 15 +++++++++------
yt/lagos/HierarchyType.py | 34 ++++++++++++++++++++++------------
yt/lagos/OutputTypes.py | 10 ++++++----
yt/lagos/__init__.py | 1 +
6 files changed, 55 insertions(+), 32 deletions(-)
diffs (239 lines):
diff -r 85a25c76e403 -r feb8e18f96fb yt/_amr_utils/DepthFirstOctree.pyx
--- a/yt/_amr_utils/DepthFirstOctree.pyx Thu Aug 12 16:35:20 2010 -0700
+++ b/yt/_amr_utils/DepthFirstOctree.pyx Wed Aug 18 14:53:08 2010 -0700
@@ -77,15 +77,15 @@
cdef np.float64_t child_dx
cdef np.ndarray[np.float64_t, ndim=1] child_leftedges
cdef np.float64_t cx, cy, cz
- for k_off in range(k_f):
- k = k_off + k_i
- cz = (leftedges[2] + k*dx)
+ for i_off in range(i_f):
+ i = i_off + i_i
+ cx = (leftedges[0] + i*dx)
for j_off in range(j_f):
j = j_off + j_i
cy = (leftedges[1] + j*dx)
- for i_off in range(i_f):
- i = i_off + i_i
- cx = (leftedges[0] + i*dx)
+ for k_off in range(k_f):
+ k = k_off + k_i
+ cz = (leftedges[2] + k*dx)
ci = grid.child_indices[i,j,k]
if ci == -1:
for fi in range(fields.shape[0]):
diff -r 85a25c76e403 -r feb8e18f96fb yt/lagos/BaseGridType.py
--- a/yt/lagos/BaseGridType.py Thu Aug 12 16:35:20 2010 -0700
+++ b/yt/lagos/BaseGridType.py Wed Aug 18 14:53:08 2010 -0700
@@ -27,6 +27,8 @@
#import yt.enki, gc
from yt.funcs import *
+import pdb
+
class AMRGridPatch(object):
_spatial = True
_num_ghost_zones = 0
@@ -362,7 +364,7 @@
mask[startIndex[0]:endIndex[0],
startIndex[1]:endIndex[1],
startIndex[2]:endIndex[2]] = tofill
-
+
def __generate_child_mask(self):
"""
Generates self.child_mask, which is zero where child grids exist (and
@@ -598,8 +600,9 @@
self.N = 0
self.Address = ''
self.NumberOfParticles = self.N
- self.ActiveDimensions = [0,0,0]
+ self.ActiveDimensions = na.array([0,0,0])
self._id_offset = 0
+ self.start_index = na.array([0,0,0])
for key,val in kwargs.items():
if key in dir(self):
@@ -609,6 +612,9 @@
#def __repr__(self):
# return "GadgetGrid_%04i" % (self.Address)
+ def get_global_startindex(self):
+ return self.start_index
+
def _prepare_grid(self):
#all of this info is already included in the snapshots
pass
@@ -621,12 +627,13 @@
# So first we figure out what the index is. We don't assume
# that dx=dy=dz , at least here. We probably do elsewhere.
id = self.id
- LE, RE = self.hierarchy.grid_left_edge[id,:], \
- self.hierarchy.grid_right_edge[id,:]
+ LE, RE = self.LeftEdge,self.RightEdge
self.dds = na.array((RE-LE)/self.ActiveDimensions)
if self.pf["TopGridRank"] < 2: self.dds[1] = 1.0
if self.pf["TopGridRank"] < 3: self.dds[2] = 1.0
self.data['dx'], self.data['dy'], self.data['dz'] = self.dds
+
+
class ChomboGrid(AMRGridPatch):
diff -r 85a25c76e403 -r feb8e18f96fb yt/lagos/GadgetFields.py
--- a/yt/lagos/GadgetFields.py Thu Aug 12 16:35:20 2010 -0700
+++ b/yt/lagos/GadgetFields.py Wed Aug 18 14:53:08 2010 -0700
@@ -38,11 +38,14 @@
"Mass":"MASS"
}
-for f,v in translation_dict.items():
- if v not in GadgetFieldInfo:
- add_field(f, function=lambda a,b: None, take_log=True,
- validators = [ValidateDataField("POS")],
- units=r"\rm{cm}")
+#for f,v in translation_dict.items():
+# add_field(f, function=lambda a,b: None, take_log=True,
+# validators = [ValidateDataField(v)],
+# units=r"\rm{cm}")
+# add_field(v, function=lambda a,b: None, take_log=True,
+# validators = [ValidateDataField(v)],
+# units=r"\rm{cm}")
+
add_field("Density", function=lambda a,b: None, take_log=True,
validators = [ValidateDataField("POS")],
@@ -50,7 +53,7 @@
add_field("VEL", function=lambda a,b: None, take_log=True,
validators = [ValidateDataField("VEL")],
- units=r"\rm{cm}/\rm{s}")
+ units=r"")
add_field("ID", function=lambda a,b: None, take_log=True,
validators = [ValidateDataField("ID")],
diff -r 85a25c76e403 -r feb8e18f96fb yt/lagos/HierarchyType.py
--- a/yt/lagos/HierarchyType.py Thu Aug 12 16:35:20 2010 -0700
+++ b/yt/lagos/HierarchyType.py Wed Aug 18 14:53:08 2010 -0700
@@ -1201,6 +1201,7 @@
self.ngrids = ngrids
self.grids = []
+
class GadgetHierarchy(AMRHierarchy):
grid = GadgetGrid
@@ -1219,7 +1220,7 @@
#example string:
#"(S'VEL'\np1\nS'ID'\np2\nS'MASS'\np3\ntp4\n."
#fields are surrounded with '
- fields_string=self._handle['root'].attrs['names']
+ fields_string=self._handle['root'].attrs['fieldnames']
#splits=fields_string.split("'")
#pick out the odd fields
#fields= [splits[j] for j in range(1,len(splits),2)]
@@ -1263,8 +1264,8 @@
kwargs = {}
kwargs['Address'] = loc
- kwargs['Children'] = [ch for ch in node.values()]
kwargs['Parent'] = parent
+ kwargs['Axis'] = self.pf._get_param('divideaxis',location=loc)
kwargs['Level'] = self.pf._get_param('level',location=loc)
kwargs['LeftEdge'] = self.pf._get_param('leftedge',location=loc)
kwargs['RightEdge'] = self.pf._get_param('rightedge',location=loc)
@@ -1274,22 +1275,31 @@
dx = self.pf._get_param('dx',location=loc)
dy = self.pf._get_param('dy',location=loc)
dz = self.pf._get_param('dz',location=loc)
- kwargs['ActiveDimensions'] = (dx,dy,dz)
+ divdims = na.array([1,1,1]
+ if not kwargs['IsLeaf']:
+ divdims[kwargs['Axis']] = 2
+ kwargs['ActiveDimensions'] = divdims
+ #Active dimensions:
+ #This is the number of childnodes, along with dimensiolaity
+ #ie, binary tree can be (2,1,1) but octree is (2,2,2)
+
+ idx+=1
+ #pdb.set_trace()
+ children = []
+ if not kwargs['IsLeaf']:
+ for child in node.values():
+ children,idx=self._walk_nodes(node,child,children,idx=idx)
+
+ kwargs['Children'] = children
grid = self.grid(idx,self.pf.parameter_filename,self,**kwargs)
- idx+=1
+ grids += children
grids += [grid,]
- #pdb.set_trace()
- if kwargs['IsLeaf']:
- return grids,idx
- else:
- for child in node.values():
- grids,idx=self._walk_nodes(node,child,grids,idx=idx)
return grids,idx
-
+
def _populate_grid_objects(self):
for g in self.grids:
g._prepare_grid()
- self.max_level = self._handle['root'].attrs['maxlevel']
+ self.max_level = cPickle.loads(self._handle['root'].attrs['maxlevel'])
def _setup_unknown_fields(self):
pass
diff -r 85a25c76e403 -r feb8e18f96fb yt/lagos/OutputTypes.py
--- a/yt/lagos/OutputTypes.py Thu Aug 12 16:35:20 2010 -0700
+++ b/yt/lagos/OutputTypes.py Wed Aug 18 14:53:08 2010 -0700
@@ -637,6 +637,8 @@
# generalization.
self.parameters["TopGridRank"] = 3
self.parameters["RefineBy"] = 2
+ self.parameters["DomainLeftEdge"] = self.leftedge
+ self.parameters["DomainRightEdge"] = self.rightedge
def _parse_parameter_file(self):
@@ -654,7 +656,7 @@
continue
val = fh['root'].attrs[kw]
if type(val)==type(''):
- try: val = cPickle.load(val)
+ try: val = cPickle.loads(val)
except: pass
#also, includes unit info
setattr(self,kw,val)
@@ -662,9 +664,8 @@
def _get_param(self,kw,location='/root'):
fh = h5py.File(self.parameter_filename)
val = fh[location].attrs[kw]
- if type(val)==type(''):
- try: val = cPickle.load(val)
- except: pass
+ try: val = cPickle.loads(val)
+ except: pass
return val
def _set_units(self):
@@ -676,6 +677,7 @@
self.time_units['1'] = 1
self.units['1'] = 1.0
self.units['unitary'] = 1.0
+ self.units['cm'] = 1.0
seconds = 1 #self["Time"]
self.time_units['years'] = seconds / (365*3600*24.0)
self.time_units['days'] = seconds / (3600*24.0)
diff -r 85a25c76e403 -r feb8e18f96fb yt/lagos/__init__.py
--- a/yt/lagos/__init__.py Thu Aug 12 16:35:20 2010 -0700
+++ b/yt/lagos/__init__.py Wed Aug 18 14:53:08 2010 -0700
@@ -78,6 +78,7 @@
from ChomboFields import *
from FLASHFields import *
from RAMSESFields import *
+from GadgetFields import *
fieldInfo = EnzoFieldInfo
# NOT the same as fieldInfo.add_field
More information about the yt-svn
mailing list