# Path: pyfusion/test/tests.py
# class PfTestBase(object):
#     """Base class for generated sql and non-sql test cases."""
#     pass
# 
# class BasePyfusionTestCase(unittest.TestCase):
#     """Simple customisation of TestCase."""
#     def __init__(self, *args):
#         self.listed_device = CONFIG_TEST_DEVICE_NAME
#         self.listed_empty_device = CONFIG_EMPTY_TEST_DEVICE_NAME
#         self.unlisted_device = NONCONFIG_TEST_DEVICE_NAME
#         self.shot_number = TEST_SHOT_NUMBER
#         self.unlisted_config_section_type = UNLISTED_CONFIG_SECTION_TYPE
#         unittest.TestCase.__init__(self, *args)
# 
# Path: pyfusion/data/timeseries.py
# class TimeseriesData(BaseData):
#     def __init__(self, timebase = None, signal=None, channels=None, bypass_length_check=False, **kwargs):
#         self.timebase = timebase
#         self.channels = channels
#         self.scales = np.array([[1]])  # retain amplitude scaling info for later
#         if bypass_length_check == True:
#             self.signal = signal
#         else:
#             if signal.n_samples() == len(timebase):
#                 self.signal = signal
#             else:
#                 raise ValueError, "signal has different number of samples to timebase"
#         super(TimeseriesData, self).__init__(**kwargs)
# 
# 
#     def generate_frequency_series(self, NFFT, step, window='hamming'):
#         w =scipy.hamming(NFFT)
#         if len(self.signal.shape)==2:
#             signal = np.array([np.fft.rfft(w*self.signal[:,i:i+NFFT]/NFFT) for i in range(0, self.signal.shape[1]-NFFT, step)])
#         else:
#             signal = np.array([np.fft.rfft(w*self.signal[i:i+NFFT]/NFFT) for i in range(0, self.signal.shape[1]-NFFT, step)])
#         timebase = np.array([np.average(self.timebase[i:i+NFFT]) 
#                              for i in range(0, self.signal.shape[1]-NFFT, step)])
# 
#         #This is borrowed from here:
#         #http://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.fft.rfftfreq.html
#         d = (self.timebase[1] - self.timebase[0])
#         val = 1.0/(NFFT*d)
#         N = NFFT//2 + 1
#         frequency_base = np.round((np.arange(0, N, dtype=int)) * val,4)
#         return FrequencyseriesData(frequency_base = frequency_base, timebase=timebase, 
#                                    signal=signal,channels=self.channels,NFFT=NFFT, window='hamming',step=step)


import os
import pyfusion
from pyfusion.test.tests import PfTestBase, BasePyfusionTestCase
from pyfusion.data.timeseries import TimeseriesData
        from pyfusion.data.base import PfMetaData
        from pyfusion.devices.base import Device
        from pyfusion.devices.H1.device import H1
        from pyfusion.devices.H1.device import H1
"""
"""

TEST_DATA_PATH = os.path.abspath(os.path.dirname(__file__))
TEST_CONFIG_FILE = os.path.join(TEST_DATA_PATH, "test.cfg")

class H1DevTestCase(BasePyfusionTestCase):

    def setUp(self):
        pyfusion.conf.utils.clear_config()
        if pyfusion.orm_manager.IS_ACTIVE:
            pyfusion.orm_manager.Session.close_all()
            pyfusion.orm_manager.clear_mappers()
        pyfusion.conf.utils.read_config(TEST_CONFIG_FILE)


class CheckH1MirnovCoords(H1DevTestCase):

    def test_single_mirnov_channel_kappah_as_argument(self):
        d=pyfusion.getDevice('H1')
        data = d.acq.getdata(58073, 'H1_mirnov_array_1_coil_1')

# Path: pyfusion/test/tests.py
# class PfTestBase(object):
#     """Base class for generated sql and non-sql test cases."""
#     pass
# 
# class BasePyfusionTestCase(unittest.TestCase):
#     """Simple customisation of TestCase."""
#     def __init__(self, *args):
#         self.listed_device = CONFIG_TEST_DEVICE_NAME
#         self.listed_empty_device = CONFIG_EMPTY_TEST_DEVICE_NAME
#         self.unlisted_device = NONCONFIG_TEST_DEVICE_NAME
#         self.shot_number = TEST_SHOT_NUMBER
#         self.unlisted_config_section_type = UNLISTED_CONFIG_SECTION_TYPE
#         unittest.TestCase.__init__(self, *args)
# 
# Path: pyfusion/data/timeseries.py
# class TimeseriesData(BaseData):
#     def __init__(self, timebase = None, signal=None, channels=None, bypass_length_check=False, **kwargs):
#         self.timebase = timebase
#         self.channels = channels
#         self.scales = np.array([[1]])  # retain amplitude scaling info for later
#         if bypass_length_check == True:
#             self.signal = signal
#         else:
#             if signal.n_samples() == len(timebase):
#                 self.signal = signal
#             else:
#                 raise ValueError, "signal has different number of samples to timebase"
#         super(TimeseriesData, self).__init__(**kwargs)
# 
# 
#     def generate_frequency_series(self, NFFT, step, window='hamming'):
#         w =scipy.hamming(NFFT)
#         if len(self.signal.shape)==2:
#             signal = np.array([np.fft.rfft(w*self.signal[:,i:i+NFFT]/NFFT) for i in range(0, self.signal.shape[1]-NFFT, step)])
#         else:
#             signal = np.array([np.fft.rfft(w*self.signal[i:i+NFFT]/NFFT) for i in range(0, self.signal.shape[1]-NFFT, step)])
#         timebase = np.array([np.average(self.timebase[i:i+NFFT]) 
#                              for i in range(0, self.signal.shape[1]-NFFT, step)])
# 
#         #This is borrowed from here:
#         #http://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.fft.rfftfreq.html
#         d = (self.timebase[1] - self.timebase[0])
#         val = 1.0/(NFFT*d)
#         N = NFFT//2 + 1
#         frequency_base = np.round((np.arange(0, N, dtype=int)) * val,4)
#         return FrequencyseriesData(frequency_base = frequency_base, timebase=timebase, 
#                                    signal=signal,channels=self.channels,NFFT=NFFT, window='hamming',step=step)


# Path: pyfusion/devices/H1/tests.py
import os
import pyfusion
from pyfusion.test.tests import PfTestBase, BasePyfusionTestCase
from pyfusion.data.timeseries import TimeseriesData
        from pyfusion.data.base import PfMetaData
        from pyfusion.devices.base import Device
        from pyfusion.devices.H1.device import H1
        from pyfusion.devices.H1.device import H1

"""
"""

TEST_DATA_PATH = os.path.abspath(os.path.dirname(__file__))
TEST_CONFIG_FILE = os.path.join(TEST_DATA_PATH, "test.cfg")

class H1DevTestCase(BasePyfusionTestCase):

    def setUp(self):
        pyfusion.conf.utils.clear_config()
        if pyfusion.orm_manager.IS_ACTIVE:
            pyfusion.orm_manager.Session.close_all()
            pyfusion.orm_manager.clear_mappers()
        pyfusion.conf.utils.read_config(TEST_CONFIG_FILE)


class CheckH1MirnovCoords(H1DevTestCase):

    def test_single_mirnov_channel_kappah_as_argument(self):
        d=pyfusion.getDevice('H1')
        data = d.acq.getdata(58073, 'H1_mirnov_array_1_coil_1')

        self.assertTrue(isinstance(data, TimeseriesData))