[Yt-svn] yt-commit r1444 - trunk/yt/extensions
britton at wrangler.dreamhost.com
britton at wrangler.dreamhost.com
Thu Sep 10 09:55:33 PDT 2009
Author: britton
Date: Thu Sep 10 09:55:32 2009
New Revision: 1444
URL: http://yt.spacepope.org/changeset/1444
Log:
Changed the halo list write out routine so that the number of fields in the
header is the same as the number of columns of data. This was previously not
the case as some of the fields were lists. For example:
Old way:
# id center mass
0 0.5 0.5 0.5 1e15
New way:
# id center[0] center[1] center[2] mass
0 0.5 0.5 0.5 1e15
This will make it easier on codes that read in column data and match it to
the header.
Modified:
trunk/yt/extensions/HaloProfiler.py
Modified: trunk/yt/extensions/HaloProfiler.py
==============================================================================
--- trunk/yt/extensions/HaloProfiler.py (original)
+++ trunk/yt/extensions/HaloProfiler.py Thu Sep 10 09:55:32 2009
@@ -626,11 +626,20 @@
if halo_field in fields:
fields.remove(halo_field)
halo_fields.append(halo_field)
- file.write("\t".join(halo_fields + fields + ["\n"]))
+ # Make it so number of fields in header is same as number of data columns.
+ header_fields = []
+ for halo_field in halo_fields:
+ if isinstance(self.filtered_halos[0][halo_field], types.ListType):
+ header_fields.extend(["%s[%d]" % (halo_field, q)
+ for q in range(len(self.filtered_halos[0][halo_field]))])
+ else:
+ header_fields.append(halo_field)
+ file.write("# ")
+ file.write("\t".join(header_fields + fields + ["\n"]))
for halo in self.filtered_halos:
for halo_field in halo_fields:
- if isinstance(halo[halo_field],types.ListType):
+ if isinstance(halo[halo_field], types.ListType):
field_data = na.array(halo[halo_field])
field_data.tofile(file, sep="\t", format=format)
else:
More information about the yt-svn
mailing list