[Yt-svn] yt-commit r541 - trunk/yt/lagos
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Thu Jun 5 15:38:01 PDT 2008
Author: mturk
Date: Thu Jun 5 15:38:00 2008
New Revision: 541
URL: http://yt.spacepope.org/changeset/541
Log:
Added the ability to force a data-save action. This translates into a keyword
for the phase plot store_profile operation.
Modified:
trunk/yt/lagos/HierarchyType.py
trunk/yt/lagos/Profiles.py
Modified: trunk/yt/lagos/HierarchyType.py
==============================================================================
--- trunk/yt/lagos/HierarchyType.py (original)
+++ trunk/yt/lagos/HierarchyType.py Thu Jun 5 15:38:00 2008
@@ -190,6 +190,7 @@
mode = 'a'
try:
self.__data_file = tables.openFile(fn, mode)
+ self.hithere = self.__data_file
my_name = self.get_data("/","MyName")
if my_name is None:
self.save_data(str(self.parameter_file), "/", "MyName")
@@ -201,13 +202,20 @@
self.__data_file = None
pass
- def save_data(self, array, node, name, set_attr=None):
+ def save_data(self, array, node, name, set_attr=None, force=False):
"""
Arbitrary numpy data will be saved to the region in the datafile
described by *node* and *name*. If data file does not exist, it throws
no error and simply does not save.
"""
if self.__data_file is None: return
+ if force:
+ try:
+ node_loc = self.__data_file.getNode(node)
+ if name in node_loc:
+ self.__data_file.removeNode(node, name, recursive=True)
+ except tables.exceptions.NoSuchNodeError:
+ pass
arr = self.__data_file.createArray(node, name, array, createparents=True)
if set_attr is not None:
for i, j in set_attr.items(): arr.setAttr(i,j)
Modified: trunk/yt/lagos/Profiles.py
==============================================================================
--- trunk/yt/lagos/Profiles.py (original)
+++ trunk/yt/lagos/Profiles.py Thu Jun 5 15:38:00 2008
@@ -398,7 +398,7 @@
def write_out(self, filename, format="%0.16e"):
pass # Will eventually dump HDF5
- def store_profile(self, name):
+ def store_profile(self, name, force=False):
"""
By identifying the profile with a fixed, user-input *name* we can
store it in the serialized data section of the hierarchy file.
@@ -425,7 +425,7 @@
values.append(self[field].ravel())
values = na.array(values).transpose()
self._data_source.hierarchy.save_data(values, "/Profiles", name,
- set_attr)
+ set_attr, force=force)
class StoredBinnedProfile3D(BinnedProfile3D):
def __init__(self, pf, name):
More information about the yt-svn
mailing list