def test_signal_unpack_data(self): """ Tests :func:`colour.continuous.signal.Signal.signal_unpack_data` method. """ domain, range_ = Signal.signal_unpack_data(self._range) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, np.arange(0, 10, 1)) domain, range_ = Signal.signal_unpack_data(self._range, self._domain) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) domain, range_ = Signal.signal_unpack_data( dict(zip(self._domain, self._range))) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) domain, range_ = Signal.signal_unpack_data( Signal(self._range, self._domain)) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) if is_pandas_installed(): from pandas import Series domain, range_ = Signal.signal_unpack_data( Series(dict(zip(self._domain, self._range)))) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain)
def test_signal_unpack_data(self): """ Tests :func:`colour.continuous.signal.Signal.signal_unpack_data` method. """ domain, range_ = Signal.signal_unpack_data(self._range) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, np.arange(0, 10, 1)) domain, range_ = Signal.signal_unpack_data(self._range, self._domain) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) domain, range_ = Signal.signal_unpack_data( dict(zip(self._domain, self._range))) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) domain, range_ = Signal.signal_unpack_data( Signal(self._range, self._domain)) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) if is_pandas_installed(): from pandas import Series domain, range_ = Signal.signal_unpack_data( Series(dict(zip(self._domain, self._range)))) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain)
def read(self): """ Reads and parses the spectral data JSON file path. Returns ------- bool Definition success. """ with open(self._path, 'r') as json_file: content = json.load(json_file) self._header = SpectralDataHeader_AMPAS(**content['header']) for attribute in ('units', 'reflection_geometry', 'transmission_geometry', 'bandwidth_FWHM', 'bandwidth_corrected'): setattr(self, '_{0}'.format(attribute), content['spectral_data'][attribute]) index = content['spectral_data']['index']['main'] data = content['spectral_data']['data']['main'] if len(index) == 1: self.domain, self.range = Signal.signal_unpack_data( {k: v[0] for k, v in data.items()}) else: self.signals = MultiSignals.multi_signals_unpack_data(data, labels=index) # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" # attributes according to outcome of # https://github.com/ampas/rawtoaces/issues/114. if ('manufacturer' in self._header._kwargs and 'model' in self._header._kwargs): self.name = '{0} {1}'.format(self._header._kwargs['manufacturer'], self._header._kwargs['model']) elif 'illuminant' in self._header._kwargs: self.name = self._header._kwargs['illuminant'] elif 'type' in self._header._kwargs: self.name = self._header._kwargs['type'] return self