Commit a6a8de75 authored by Theo Steininger's avatar Theo Steininger
Browse files

Set PowerSpace.weight to bin-volume.

parent fe8f6318
...@@ -85,10 +85,9 @@ class PowerSpace(Space): ...@@ -85,10 +85,9 @@ class PowerSpace(Space):
# ---Overwritten properties and methods--- # ---Overwritten properties and methods---
def __init__(self, harmonic_partner, distribution_strategy=None, def __init__(self, harmonic_partner, distribution_strategy=None,
volume_type='rho', binbounds=None): binbounds=None):
super(PowerSpace, self).__init__() super(PowerSpace, self).__init__()
self._needed_for_hash += ['_harmonic_partner', '_binbounds', self._needed_for_hash += ['_harmonic_partner', '_binbounds']
'volume_type']
if distribution_strategy is None: if distribution_strategy is None:
distribution_strategy = gc['default_distribution_strategy'] distribution_strategy = gc['default_distribution_strategy']
...@@ -127,8 +126,6 @@ class PowerSpace(Space): ...@@ -127,8 +126,6 @@ class PowerSpace(Space):
(self._binbounds, self._pindex, self._kindex, self._rho) = \ (self._binbounds, self._pindex, self._kindex, self._rho) = \
self._powerIndexCache[key] self._powerIndexCache[key]
self.volume_type = str(volume_type)
@staticmethod @staticmethod
def _compute_pindex(harmonic_partner, distance_array, binbounds, def _compute_pindex(harmonic_partner, distance_array, binbounds,
distribution_strategy): distribution_strategy):
...@@ -201,25 +198,14 @@ class PowerSpace(Space): ...@@ -201,25 +198,14 @@ class PowerSpace(Space):
binbounds=self._binbounds) binbounds=self._binbounds)
def weight(self, x, power, axes, inplace=False): def weight(self, x, power, axes, inplace=False):
if self.volume_type == 'unit':
if inplace:
return x
else:
return x.copy()
if self.volume_type == 'rho':
weight = self.rho
elif self.volume_type == 'volume':
try: try:
weight = self._volume_weight weight = self._volume_weight
except AttributeError: except AttributeError:
k = self.kindex from ...field import Field
weight = np.empty_like(k) weight_field = Field(domain=self.harmonic_partner, val=1).weight()
weight[1:-1] = (k[2:] - k[:-2])/2 self._volume_weight = \
weight[0] = k[1] - k[0] self.pindex.bincount(weights=weight_field.val).get_full_data()
weight[-1] = k[-1] - k[-2] weight = self._volume_weight
self._volume_weight = weight
reshaper = [1, ] * len(x.shape) reshaper = [1, ] * len(x.shape)
# we know len(axes) is always 1 # we know len(axes) is always 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment