[Yt-svn] yt: * Adding periodicity to HOP based on domain size
hg at spacepope.org
hg at spacepope.org
Mon Dec 13 13:58:41 PST 2010
hg Repository: yt
details: yt/rev/309549706702
changeset: 3601:309549706702
user: Matthew Turk <matthewturk at gmail.com>
date:
Mon Dec 13 13:58:37 2010 -0800
description:
* Adding periodicity to HOP based on domain size
* Adding fix for parallel, preloaded data detection to ensure that FieldDetector is all flat for Derived Quantities
diffstat:
yt/analysis_modules/halo_finding/halo_objects.py | 6 +++++-
yt/analysis_modules/halo_finding/hop/EnzoHop.c | 12 ++++++++----
yt/analysis_modules/halo_finding/hop/hop_hop.c | 8 ++++++--
yt/data_objects/derived_quantities.py | 2 +-
yt/data_objects/field_info_container.py | 16 ++++++++++++----
5 files changed, 32 insertions(+), 12 deletions(-)
diffs (138 lines):
diff -r f4c3e6f9e68f -r 309549706702 yt/analysis_modules/halo_finding/halo_objects.py
--- a/yt/analysis_modules/halo_finding/halo_objects.py Mon Dec 13 09:03:36 2010 -0800
+++ b/yt/analysis_modules/halo_finding/halo_objects.py Mon Dec 13 13:58:37 2010 -0800
@@ -1050,12 +1050,16 @@
HaloList.__init__(self, data_source, dm_only)
def _run_finder(self):
+ period_x, period_y, period_z = \
+ self.pf.domain_right_edge - self.pf.domain_left_edge
+ print "Setting period to", period_x, period_y, period_z
self.densities, self.tags = \
RunHOP(self.particle_fields["particle_position_x"],
self.particle_fields["particle_position_y"],
self.particle_fields["particle_position_z"],
self.particle_fields["ParticleMassMsun"],
- self.threshold)
+ self.threshold,
+ period_x, period_y, period_z)
self.particle_fields["densities"] = self.densities
self.particle_fields["tags"] = self.tags
diff -r f4c3e6f9e68f -r 309549706702 yt/analysis_modules/halo_finding/hop/EnzoHop.c
--- a/yt/analysis_modules/halo_finding/hop/EnzoHop.c Mon Dec 13 09:03:36 2010 -0800
+++ b/yt/analysis_modules/halo_finding/hop/EnzoHop.c Mon Dec 13 13:58:37 2010 -0800
@@ -36,7 +36,8 @@
#include "numpy/ndarrayobject.h"
void initgrouplist(Grouplist *g);
-void hop_main(KD kd, HC *my_comm, float densthres);
+void hop_main(KD kd, HC *my_comm, float densthres,
+ float period_x, float period_y, float period_z);
void regroup_main(float dens_outer, HC *my_comm);
static PyObject *_HOPerror;
@@ -102,11 +103,14 @@
npy_float64 totalmass = 0.0;
float normalize_to = 1.0;
float thresh = 160.0;
+ float period_x, period_y, period_z;
+ period_x = period_y = period_z = 1.0;
int i;
- if (!PyArg_ParseTuple(args, "OOOO|ff",
- &oxpos, &oypos, &ozpos, &omass, &thresh, &normalize_to))
+ if (!PyArg_ParseTuple(args, "OOOO|fffff",
+ &oxpos, &oypos, &ozpos, &omass, &thresh, &normalize_to,
+ &period_x, &period_y, &period_z))
return PyErr_Format(_HOPerror,
"EnzoHop: Invalid parameters.");
@@ -155,7 +159,7 @@
initgrouplist(my_comm.gl);
fprintf(stderr, "Calling hop... %d %0.3e\n",num_particles,thresh);
- hop_main(kd, &my_comm, thresh);
+ hop_main(kd, &my_comm, thresh, period_x, period_y, period_z);
fprintf(stderr, "Calling regroup...\n");
regroup_main(thresh, &my_comm);
diff -r f4c3e6f9e68f -r 309549706702 yt/analysis_modules/halo_finding/hop/hop_hop.c
--- a/yt/analysis_modules/halo_finding/hop/hop_hop.c Mon Dec 13 09:03:36 2010 -0800
+++ b/yt/analysis_modules/halo_finding/hop/hop_hop.c Mon Dec 13 13:58:37 2010 -0800
@@ -51,7 +51,8 @@
void outGroupMerge(SMX smx, HC *my_comm);
/* void main(int argc,char **argv) */
-void hop_main(KD kd, HC *my_comm, float densthres)
+void hop_main(KD kd, HC *my_comm, float densthres,
+ float period_x, float period_y, float period_z)
{
/* KD kd; */
SMX smx;
@@ -77,7 +78,10 @@
inputfile = NULL;
i = 1;
/* for (j=0;j<3;++j) fPeriod[j] = HUGE; */
- for (j=0;j<3;++j) fPeriod[j] = 1.0;
+/* for (j=0;j<3;++j) fPeriod[j] = 1.0; */
+ fPeriod[0] = period_x;
+ fPeriod[1] = period_y;
+ fPeriod[2] = period_z;
nMerge = 4;
diff -r f4c3e6f9e68f -r 309549706702 yt/data_objects/derived_quantities.py
--- a/yt/data_objects/derived_quantities.py Mon Dec 13 09:03:36 2010 -0800
+++ b/yt/data_objects/derived_quantities.py Mon Dec 13 13:58:37 2010 -0800
@@ -80,7 +80,7 @@
if preload:
if not lazy_reader: mylog.debug("Turning on lazy_reader because of preload")
lazy_reader = True
- e = FieldDetector()
+ e = FieldDetector(flat = True)
e.NumberOfParticles = 1
self.func(e, *args, **kwargs)
mylog.debug("Preloading %s", e.requested)
diff -r f4c3e6f9e68f -r 309549706702 yt/data_objects/field_info_container.py
--- a/yt/data_objects/field_info_container.py Mon Dec 13 09:03:36 2010 -0800
+++ b/yt/data_objects/field_info_container.py Mon Dec 13 13:58:37 2010 -0800
@@ -143,8 +143,9 @@
NumberOfParticles = 1
_read_exception = None
_id_offset = 0
- def __init__(self, nd = 16, pf = None):
+ def __init__(self, nd = 16, pf = None, flat = False):
self.nd = nd
+ self.flat = flat
self.ActiveDimensions = [nd,nd,nd]
self.LeftEdge = [0.0,0.0,0.0]
self.RightEdge = [1.0,1.0,1.0]
@@ -168,8 +169,14 @@
self.hierarchy = fake_hierarchy()
self.requested = []
self.requested_parameters = []
- defaultdict.__init__(self,
- lambda: na.ones((nd,nd,nd), dtype='float64') + 1e-4*na.random.random((nd,nd,nd)))
+ if not self.flat:
+ defaultdict.__init__(self,
+ lambda: na.ones((nd,nd,nd), dtype='float64')
+ + 1e-4*na.random.random((nd,nd,nd)))
+ else:
+ defaultdict.__init__(self,
+ lambda: na.ones((nd*nd*nd), dtype='float64')
+ + 1e-4*na.random.random((nd*nd*nd)))
def __missing__(self, item):
if FieldInfo.has_key(item) and \
FieldInfo[item]._function.func_name != '<lambda>':
@@ -184,7 +191,8 @@
for i in vv.requested_parameters:
if i not in self.requested_parameters: self.requested_parameters.append(i)
if vv is not None:
- self[item] = vv
+ if not self.flat: self[item] = vv
+ else: self[item] = vv.ravel()
return self[item]
self.requested.append(item)
return defaultdict.__missing__(self, item)
More information about the yt-svn
mailing list