[yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Dec 12 04:54:18 PST 2011
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/f0dec88aea40/
changeset: f0dec88aea40
branch: yt
user: chummels
date: 2011-12-07 00:52:57
summary: Modifying how smoothed covering grids calculate (and save) their various field values. Previously, they threw the field information away after each calculation, but I found a slow down of a factor of 50 in building such grids for my datasets. So I've modified it so that it keeps the information after it calculates. It may result in a factor of 2x memory consumption, but that is OK by me.
affected #: 1 file
diff -r a37631cda71afd84fba5b7ef36d127109c8fb356 -r f0dec88aea405c09fc33847b58b8dee7932041cb yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -88,6 +88,20 @@
return tr
return save_state
+def restore_field_information_state(func):
+ """
+ A decorator that takes a function with the API of (self, grid, field)
+ and ensures that after the function is called, the field_parameters will
+ be returned to normal.
+ """
+ def save_state(self, grid, field=None, *args, **kwargs):
+ old_params = grid.field_parameters
+ grid.field_parameters = self.field_parameters
+ tr = func(self, grid, field, *args, **kwargs)
+ grid.field_parameters = old_params
+ return tr
+ return save_state
+
def cache_mask(func):
"""
For computationally intensive indexing operations, we can cache
@@ -3467,7 +3481,7 @@
output_field, output_left)
self.field_data[field] = output_field
- @restore_grid_state
+ @restore_field_information_state
def _get_data_from_grid(self, grid, fields):
fields = ensure_list(fields)
g_fields = [grid[field].astype("float64") for field in fields]
https://bitbucket.org/yt_analysis/yt/changeset/3ec2c245c827/
changeset: 3ec2c245c827
branch: yt
user: chummels
date: 2011-12-07 20:21:03
summary: Merging.
affected #: 1 file
diff -r f0dec88aea405c09fc33847b58b8dee7932041cb -r 3ec2c245c82714557c87d8bd6fe4d06fbcb83b3c yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -265,6 +265,7 @@
def _find_parameter(self, ptype, pname, scalar = False):
nn = "/%s %s" % (ptype,
{False: "runtime parameters", True: "scalars"}[scalar])
+ if nn not in self._handle: raise KeyError(nn)
for tpname, pval in self._handle[nn][:]:
if tpname.strip() == pname:
return pval
@@ -285,20 +286,26 @@
[self._find_parameter("real", "%smin" % ax) for ax in 'xyz'])
self.domain_right_edge = na.array(
[self._find_parameter("real", "%smax" % ax) for ax in 'xyz'])
- self.dimensionality = self._find_parameter("integer", "dimensionality",
- scalar = True)
# Determine domain dimensions
try:
nxb = self._find_parameter("integer", "nxb", scalar = True)
nyb = self._find_parameter("integer", "nyb", scalar = True)
nzb = self._find_parameter("integer", "nzb", scalar = True)
+ dimensionality = self._find_parameter("integer", "dimensionality",
+ scalar = True)
except KeyError:
nxb, nyb, nzb = [int(self._handle["/simulation parameters"]['n%sb' % ax])
for ax in 'xyz']
+ dimensionality = 3
+ if nzb == 1: dimensionality = 2
+ if nyb == 1: dimensionality = 1
+ if dimensionality < 3:
+ mylog.warning("Guessing dimensionality as %s", dimensionality)
nblockx = self._find_parameter("integer", "nblockx")
nblocky = self._find_parameter("integer", "nblockx")
nblockz = self._find_parameter("integer", "nblockx")
+ self.dimensionality = dimensionality
self.domain_dimensions = \
na.array([nblockx*nxb,nblocky*nyb,nblockz*nzb])
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list