Commit 50e8b448 authored by Gordian Edenhofer's avatar Gordian Edenhofer
Browse files

correlated_fields.py: Support CF without zm

Adapt the statistics summary to not require the zero-mode.
parent 25a5afce
...@@ -674,7 +674,7 @@ class CorrelatedFieldMaker: ...@@ -674,7 +674,7 @@ class CorrelatedFieldMaker:
zm = _Distributor(dofdex, zm.target, UnstructuredDomain(self._total_N)) @ zm zm = _Distributor(dofdex, zm.target, UnstructuredDomain(self._total_N)) @ zm
self._azm = zm self._azm = zm
def finalize(self, prior_info=100): def finalize(self, prior_info=100, normalize=True):
"""Finishes model construction process and returns the constructed """Finishes model construction process and returns the constructed
operator. operator.
...@@ -697,9 +697,6 @@ class CorrelatedFieldMaker: ...@@ -697,9 +697,6 @@ class CorrelatedFieldMaker:
spaces = tuple(range(n_amplitudes)) spaces = tuple(range(n_amplitudes))
amp_space = 0 amp_space = 0
expander = ContractionOperator(hspace, spaces=spaces).adjoint
azm = expander @ self.azm
ht = HarmonicTransformOperator(hspace, ht = HarmonicTransformOperator(hspace,
self._target_subdomains[0][amp_space], self._target_subdomains[0][amp_space],
space=spaces[0]) space=spaces[0])
...@@ -707,14 +704,24 @@ class CorrelatedFieldMaker: ...@@ -707,14 +704,24 @@ class CorrelatedFieldMaker:
ht = HarmonicTransformOperator(ht.target, ht = HarmonicTransformOperator(ht.target,
self._target_subdomains[i][amp_space], self._target_subdomains[i][amp_space],
space=spaces[i]) @ ht space=spaces[i]) @ ht
a = list(self.get_normalized_amplitudes())
if normalize:
expander = ContractionOperator(hspace, spaces=spaces).adjoint
azm = expander @ self.azm
a = list(self.get_normalized_amplitudes())
else:
a = list(self.fluctuations)
for ii in range(n_amplitudes): for ii in range(n_amplitudes):
co = ContractionOperator(hspace, spaces[:ii] + spaces[ii + 1:]) co = ContractionOperator(hspace, spaces[:ii] + spaces[ii + 1:])
pp = a[ii].target[amp_space] pp = a[ii].target[amp_space]
pd = PowerDistributor(co.target, pp, amp_space) pd = PowerDistributor(co.target, pp, amp_space)
a[ii] = co.adjoint @ pd @ a[ii] a[ii] = co.adjoint @ pd @ a[ii]
corr = reduce(mul, a) corr = reduce(mul, a)
op = ht(azm*corr*ducktape(hspace, None, self._prefix + 'xi')) if normalize:
op = ht(azm*corr*ducktape(hspace, None, self._prefix + 'xi'))
else:
op = ht(corr*ducktape(hspace, None, self._prefix + 'xi'))
if self._offset_mean is not None: if self._offset_mean is not None:
offset = self._offset_mean offset = self._offset_mean
...@@ -734,15 +741,22 @@ class CorrelatedFieldMaker: ...@@ -734,15 +741,22 @@ class CorrelatedFieldMaker:
if prior_info == 0: if prior_info == 0:
return return
lst = [('Offset amplitude', self.amplitude_total_offset), lst = []
('Total fluctuation amplitude', self.total_fluctuation)] try:
lst.append(('Offset amplitude', self.amplitude_total_offset))
except NotImplementedError: # AZM mustn't be set to get stats
pass
lst.append(('Total fluctuation amplitude', self.total_fluctuation))
namps = len(self._a) namps = len(self._a)
if namps > 1: if namps > 1:
for ii in range(namps): for ii in range(namps):
lst.append(('Slice fluctuation (space {})'.format(ii),
self.slice_fluctuation(ii)))
lst.append(('Average fluctuation (space {})'.format(ii), lst.append(('Average fluctuation (space {})'.format(ii),
self.average_fluctuation(ii))) self.average_fluctuation(ii)))
try:
lst.append(('Slice fluctuation (space {})'.format(ii),
self.slice_fluctuation(ii)))
except NotImplementedError: # AZM mustn't be set to get stats
pass
for kk, op in lst: for kk, op in lst:
sc = StatCalculator() sc = StatCalculator()
......
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