Commit 49218708 authored by Philipp Arras's avatar Philipp Arras

Actually return amplitude in one-space case

parent beebf0dc
Pipeline #63676 passed with stages
in 9 minutes and 15 seconds
...@@ -38,7 +38,7 @@ if __name__ == '__main__': ...@@ -38,7 +38,7 @@ if __name__ == '__main__':
fa.add_fluctuations(ift.RGSpace(32), 3, 5, 1, 1e-6, 2, fa.add_fluctuations(ift.RGSpace(32), 3, 5, 1, 1e-6, 2,
1e-6, slope_means[1], 1, 'freq') 1e-6, slope_means[1], 1, 'freq')
correlated_field = fa.finalize() correlated_field = fa.finalize()
amplitudes = fa.amplitudes amplitudes = fa.normalized_amplitudes
plt.style.use('seaborn-notebook') plt.style.use('seaborn-notebook')
tgt = correlated_field.target tgt = correlated_field.target
......
...@@ -61,7 +61,7 @@ if __name__ == '__main__': ...@@ -61,7 +61,7 @@ if __name__ == '__main__':
cfmaker.add_fluctuations(position_space, cfmaker.add_fluctuations(position_space,
1., 1e-2, 1, .5, .1, .5, -3, 0.5, '') 1., 1e-2, 1, .5, .1, .5, -3, 0.5, '')
correlated_field = cfmaker.finalize() correlated_field = cfmaker.finalize()
A = cfmaker.amplitudes[0] A = cfmaker.amplitude
# Apply a nonlinearity # Apply a nonlinearity
signal = ift.sigmoid(correlated_field) signal = ift.sigmoid(correlated_field)
......
...@@ -78,8 +78,8 @@ if __name__ == '__main__': ...@@ -78,8 +78,8 @@ if __name__ == '__main__':
-1.5, .5, 'amp2') -1.5, .5, 'amp2')
correlated_field = cfmaker.finalize() correlated_field = cfmaker.finalize()
A1 = cfmaker.amplitudes[0] A1 = cfmaker.normalized_amplitudes[0]
A2 = cfmaker.amplitudes[1] A2 = cfmaker.normalized_amplitudes[1]
DC = SingleDomain(correlated_field.target, position_space) DC = SingleDomain(correlated_field.target, position_space)
# Apply a nonlinearity # Apply a nonlinearity
......
...@@ -7,7 +7,7 @@ sspace = ift.RGSpace((128,)) ...@@ -7,7 +7,7 @@ sspace = ift.RGSpace((128,))
fa = ift.CorrelatedFieldMaker.make(10, 0.1, '') fa = ift.CorrelatedFieldMaker.make(10, 0.1, '')
fa.add_fluctuations(sspace, 10, 2, 1, 1e-6, 2, 1e-6, -2, 1e-6, 'spatial') fa.add_fluctuations(sspace, 10, 2, 1, 1e-6, 2, 1e-6, -2, 1e-6, 'spatial')
op = fa.finalize() op = fa.finalize()
A = fa.amplitudes[0] A = fa.amplitude
cstpos = ift.from_random('normal', op.domain) cstpos = ift.from_random('normal', op.domain)
p1, p2 = [ift.Plot() for _ in range(2)] p1, p2 = [ift.Plot() for _ in range(2)]
......
...@@ -372,7 +372,7 @@ class CorrelatedFieldMaker: ...@@ -372,7 +372,7 @@ class CorrelatedFieldMaker:
lst = [('Offset amplitude', self.amplitude_total_offset), lst = [('Offset amplitude', self.amplitude_total_offset),
('Total fluctuation amplitude', self.total_fluctuation)] ('Total fluctuation amplitude', self.total_fluctuation)]
namps = len(self.amplitudes) 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), lst.append(('Slice fluctuation (space {})'.format(ii),
...@@ -399,9 +399,19 @@ class CorrelatedFieldMaker: ...@@ -399,9 +399,19 @@ class CorrelatedFieldMaker:
return fluctuations_slice_mean/np.mean(np.sqrt(scm)) return fluctuations_slice_mean/np.mean(np.sqrt(scm))
@property @property
def amplitudes(self): def normalized_amplitudes(self):
return self._a return self._a
@property
def amplitude(self):
if len(self._a) > 1:
s = ('If more than one spectrum is present in the model,',
' no unique set of amplitudes exist because only the',
' relative scale is determined.')
raise NotImplementedError(s)
expand = VdotOperator(full(self._a[0].target, 1)).adjoint
return self._a[0]*(expand @ self.amplitude_total_offset)
@property @property
def amplitude_total_offset(self): def amplitude_total_offset(self):
return self._azm return self._azm
......
Markdown is supported
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