[Yt-svn] yt-commit r345 - in trunk/yt: . lagos
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Fri Dec 28 19:44:44 PST 2007
Author: mturk
Date: Fri Dec 28 19:44:43 2007
New Revision: 345
URL: http://yt.spacepope.org/changeset/345
Log:
Fixed problem with fields that require buffer zones with the new
restore_grid_state decorator.
Added plugin support -- now you can define your own fields in a file in your
homedirectory. The config directives are:
[lagos]
loadfieldplugins: True [default: False]
pluginfilename: yt_plugins.py [default]
Whatever code is in the file gets executed when you start up. This is powerful
and dangerous. Now, however, in that file you can define local fields you want
access to every time.
Started adding some support for 2-D datasets.
Modified:
trunk/yt/config.py
trunk/yt/lagos/BaseDataTypes.py
trunk/yt/lagos/BaseGridType.py
trunk/yt/lagos/DataReadingFuncs.py
trunk/yt/lagos/EnzoDefs.py
trunk/yt/lagos/HierarchyType.py
trunk/yt/lagos/__init__.py
Modified: trunk/yt/config.py
==============================================================================
--- trunk/yt/config.py (original)
+++ trunk/yt/config.py Fri Dec 28 19:44:43 2007
@@ -62,6 +62,8 @@
'User':os.getenv("USER"),
'timefunctions':'False',
'inGui':'False',
+ 'loadfieldplugins':'False',
+ 'pluginfilename':'yt_plugins.py',
},
"raven":{
'ImagePath':".",
Modified: trunk/yt/lagos/BaseDataTypes.py
==============================================================================
--- trunk/yt/lagos/BaseDataTypes.py (original)
+++ trunk/yt/lagos/BaseDataTypes.py Fri Dec 28 19:44:43 2007
@@ -28,7 +28,6 @@
def restore_grid_state(func):
def save_state(self, grid, field=None):
old_params = grid.field_parameters
- #print old_params, self.field_parameters
grid.field_parameters = self.field_parameters
tr = func(self, grid, field)
grid.field_parameters = old_params
@@ -896,10 +895,10 @@
def _generate_field_in_grids(self, field, num_ghost_zones=0):
for grid in self._grids:
- self.__touch_grid_field(field, grid)
+ self.__touch_grid_field(grid, field)
@restore_grid_state
- def __touch_grid_field(self, field, grid):
+ def __touch_grid_field(self, grid, field):
grid[field]
@restore_grid_state
Modified: trunk/yt/lagos/BaseGridType.py
==============================================================================
--- trunk/yt/lagos/BaseGridType.py (original)
+++ trunk/yt/lagos/BaseGridType.py Fri Dec 28 19:44:43 2007
@@ -216,7 +216,10 @@
self.__setup_dx()
def set_filename(self, filename):
- if filename[0] == os.path.sep:
+ if self.hierarchy._strip_path:
+ self.filename = os.path.join(self.hierarchy.directory,
+ os.path.basename(filename))
+ elif filename[0] == os.path.sep:
self.filename = filename
else:
self.filename = os.path.join(self.hierarchy.directory, filename)
Modified: trunk/yt/lagos/DataReadingFuncs.py
==============================================================================
--- trunk/yt/lagos/DataReadingFuncs.py (original)
+++ trunk/yt/lagos/DataReadingFuncs.py Fri Dec 28 19:44:43 2007
@@ -74,7 +74,10 @@
"""
f = tables.openFile(self.filename)
t = f.getNode("/", field).read().astype("float64")
- t = t.swapaxes(0,2)
+ try:
+ t = t.swapaxes(0,2)
+ except:
+ pass
f.close()
return t
Modified: trunk/yt/lagos/EnzoDefs.py
==============================================================================
--- trunk/yt/lagos/EnzoDefs.py (original)
+++ trunk/yt/lagos/EnzoDefs.py Fri Dec 28 19:44:43 2007
@@ -67,6 +67,7 @@
"CompilerPrecision": str,
"CurrentTimeIdentifier": int,
"BoundaryConditionName": str,
+ "TopGridRank": int,
}
unitList = {'mpc' : 1e0,
Modified: trunk/yt/lagos/HierarchyType.py
==============================================================================
--- trunk/yt/lagos/HierarchyType.py (original)
+++ trunk/yt/lagos/HierarchyType.py Fri Dec 28 19:44:43 2007
@@ -46,6 +46,7 @@
@type data_style: int
"""
eiTopGrid = None
+ _strip_path = False
@time_execution
def __init__(self, pf, data_style=None):
# For now, we default to HDF4, but allow specifying HDF5
@@ -127,6 +128,11 @@
break
if testGrid[0] != os.path.sep:
testGrid = os.path.join(self.directory, testGrid)
+ if not os.path.exists(testGrid):
+ testGrid = os.path.join(self.directory,
+ os.path.basename(testGrid))
+ mylog.debug("Your data uses the annoying hardcoded path.")
+ self._strip_path = True
try:
a = SD.SD(testGrid)
self.data_style = 4
Modified: trunk/yt/lagos/__init__.py
==============================================================================
--- trunk/yt/lagos/__init__.py (original)
+++ trunk/yt/lagos/__init__.py Fri Dec 28 19:44:43 2007
@@ -78,4 +78,15 @@
from OutputTypes import *
from Profiles import *
+# We load plugins. Keep in mind, this can be fairly dangerous -
+# the primary purpose is to allow people to have a set of functions
+# that get used every time that they don't have to *define* every time.
+# This way, other command-line tools can be used very simply.
+# Unfortunately, for now, I think the easiest and simplest way of doing
+# this is also the most dangerous way.
+if ytcfg.getboolean("lagos","loadfieldplugins"):
+ my_plugin_name = ytcfg.get("lagos","pluginfilename")
+ # We assume that it is with respect to the $HOME/.yt directory
+ execfile(os.path.expanduser("~/.yt/%s" % my_plugin_name))
+
log_fields = [] # @todo: GET RID OF THIS
\ No newline at end of file
More information about the yt-svn
mailing list