Commit f389aa57 authored by Theo Steininger's avatar Theo Steininger

Fixed a dtype bug in GFFT

parent c3989d90
Pipeline #10517 failed with stages
in 29 minutes and 36 seconds
......@@ -151,11 +151,11 @@ class Field(Loggable, Versionable, object):
def power_analyze(self, spaces=None, log=False, nbin=None, binbounds=None,
real_signal=True):
# assert that all spaces in `self.domain` are either harmonic or
# check if all spaces in `self.domain` are either harmonic or
# power_space instances
for sp in self.domain:
if not sp.harmonic and not isinstance(sp, PowerSpace):
raise AttributeError(
self.logger.info(
"Field has a space in `domain` which is neither "
"harmonic nor a PowerSpace.")
......@@ -288,11 +288,11 @@ class Field(Loggable, Versionable, object):
def power_synthesize(self, spaces=None, real_signal=True,
mean=None, std=None):
# assert that all spaces in `self.domain` are either of signal-type or
# check if all spaces in `self.domain` are either of signal-type or
# power_space instances
for sp in self.domain:
if not sp.harmonic and not isinstance(sp, PowerSpace):
raise AttributeError(
self.logger.info(
"Field has a space in `domain` which is neither "
"harmonic nor a PowerSpace.")
......@@ -352,11 +352,7 @@ class Field(Loggable, Versionable, object):
preserve_gaussian_variance=True)[0]
for x in result_list]
else:
# # if the synthesized field is complex in signal space,
# # one must correct the variance here, since one draws
# # sqrt(twice) the power via real- and imaginary-part
# result_val_list = [x.val*np.sqrt(0.5) for x in result_list]
result_val_list = [x.val for x in result_list]
result_val_list = [x.val for x in result_list]
# weight the random fields with the power spectrum
# therefore get the pindex from the power space
......
......@@ -592,6 +592,7 @@ class GFFT(Transform):
# Array for storing the result
return_val = None
result_dtype = np.result_type(np.complex, self.codomain.dtype)
for slice_list in utilities.get_slice_list(temp_inp.shape, axes):
......@@ -601,7 +602,7 @@ class GFFT(Transform):
else:
# initialize the return_val object if needed
if return_val is None:
return_val = np.empty_like(temp_inp)
return_val = np.empty_like(temp_inp, dtype=result_dtype)
inp = temp_inp[slice_list]
inp = self.fft_machine.gfft(
......@@ -622,12 +623,11 @@ class GFFT(Transform):
else:
return_val[slice_list] = inp
result_dtype = np.result_type(np.complex, self.codomain.dtype)
if isinstance(val, distributed_data_object):
new_val = val.copy_empty(dtype=result_dtype)
new_val.set_full_data(return_val, copy=False)
return_val = new_val
else:
return_val = return_val.astype(result_type, copy=False)
return_val = return_val.astype(result_dtype, copy=False)
return return_val
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