Commit 7749b831 authored by ssomnath's avatar ssomnath
Browse files

BE conjugate guessing now accepts number of cores as an argument

parent 57564d93
......@@ -38,6 +38,7 @@ class BEodfTranslator(Translator):
super(BEodfTranslator, self).__init__(*args, **kwargs)
self.h5_raw = None
self.num_rand_spectra = kwargs.pop('num_rand_spectra', 1000)
self._cores = kwargs.pop('cores', None)
self.FFT_BE_wave = None
self.signal_type = None
self.expt_type = None
......@@ -523,7 +524,7 @@ class BEodfTranslator(Translator):
rand_spectra = self.__get_random_spectra(parsers, self.h5_raw.shape[0], udvs_steps, step_size,
num_spectra=self.num_rand_spectra)
take_conjugate = requires_conjugate(rand_spectra)
take_conjugate = requires_conjugate(rand_spectra, cores=self._cores)
self.mean_resp = np.zeros(shape=(self.h5_raw.shape[1]), dtype=np.complex64)
self.max_resp = np.zeros(shape=(self.h5_raw.shape[0]), dtype=np.float32)
......@@ -596,7 +597,7 @@ class BEodfTranslator(Translator):
step_size = self.h5_raw.shape[1] / udvs_steps
rand_spectra = self.__get_random_spectra([parser], self.h5_raw.shape[0], udvs_steps, step_size,
num_spectra=self.num_rand_spectra)
take_conjugate = requires_conjugate(rand_spectra)
take_conjugate = requires_conjugate(rand_spectra, cores=self._cores)
raw_vec = parser.read_all_data()
if take_conjugate:
print('Taking conjugate to ensure positive Quality factors')
......
......@@ -212,7 +212,7 @@ def parmsToDict(filepath, parms_to_remove=[]):
###############################################################################
def requires_conjugate(chosen_spectra, default_q=10):
def requires_conjugate(chosen_spectra, default_q=10, cores=None):
"""
Determines whether or not the conjugate of the data needs to be taken based on the quality factor
......@@ -222,6 +222,9 @@ def requires_conjugate(chosen_spectra, default_q=10):
N random spectra arranged as [instance, frequency]
default_q : unsigned int, Optional
Default value of Q factor that the SHO guess function results in for poor guesses
cores : uint, Optional
Number of CPU cores to use for the SHO guess.
Default = None - ask pyUSID.processing.comp_utils.recommend_cpu_cores for automatic assignment
Returns
-------
......@@ -232,7 +235,7 @@ def requires_conjugate(chosen_spectra, default_q=10):
opt = Optimize(data=chosen_spectra)
fitguess_results = opt.computeGuess(strategy='complex_gaussian',
processors=recommend_cpu_cores(chosen_spectra.shape[0]),
processors=recommend_cpu_cores(chosen_spectra.shape[0], requested_cores=cores),
options={'frequencies': np.arange(chosen_spectra.shape[1])})
q_results = np.array(fitguess_results)[:, 2]
......
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