Skip to content

Commit ccb2087

Browse files
committed
Add proper single NMR in array edge case handling
1 parent 9f55722 commit ccb2087

File tree

5 files changed

+427
-221
lines changed

5 files changed

+427
-221
lines changed

nmrpy/data_objects.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,24 +342,29 @@ def species(self, species):
342342
@property
343343
def fid_object(self):
344344
try:
345-
self.__fid_object.raw_data = self.data.tolist()
345+
self.__fid_object.raw_data = [str(datum) for datum in self.raw_data]
346+
self.__fid_object.processed_data = [float(datum) for datum in self.data]
346347
except AttributeError:
347-
print('Warning: Fid.data is not yet set. Raw data will not be updated.')
348+
print('Warning: Fid.data is not yet set. Processed data will not be updated.')
349+
if not isinstance(self._params.get('acqtime'), float):
350+
return self.__fid_object
348351
try:
349352
self.__fid_object.nmr_parameters = Parameters(
350-
acquisition_time=self._params['at'],
353+
acquisition_time_period=self._params['at'],
351354
relaxation_time=self._params['d1'],
352355
repetition_time=self._params['rt'],
353356
number_of_transients=self._params['nt'],
354-
acquisition_times_array=self._params['acqtime'],
357+
acquisition_time_point=self._params['acqtime'],
355358
spectral_width_ppm=self._params['sw'],
356359
spectral_width_hz=self._params['sw_hz'],
357360
spectrometer_frequency=self._params['sfrq'],
358361
reference_frequency=self._params['reffrq'],
359362
spectral_width_left=self._params['sw_left'],
360363
)
361364
except AttributeError:
362-
print('Warning: Fid._params is not yet set. NMR parameters will not be updated.')
365+
print('Warning: Fid._params does not yet exist. NMR parameters will not be updated.')
366+
except TypeError:
367+
print('Warning: Fid._params exists but is not yet set. NMR parameters will not be updated.')
363368
return self.__fid_object
364369

365370
@fid_object.setter
@@ -1549,7 +1554,7 @@ def concentrations(self, concentrations):
15491554
if not all(len(concentrations[species]) == len(self.t) for species in concentrations.keys()):
15501555
raise ValueError('Length of concentrations must match length of FID data.')
15511556
for v in concentrations.values():
1552-
if not all(isinstance(i, (in4t, float)) for i in v):
1557+
if not all(isinstance(i, (int, float)) for i in v):
15531558
raise ValueError('Concentrations must be a list of integers or floats.')
15541559
self.__concentrations = concentrations
15551560

0 commit comments

Comments
 (0)