# 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

CheckH1MirnovCoords.h1 = True
CheckH1MirnovCoords.mds = True
CheckH1MirnovCoords.net = True
CheckH1MirnovCoords.slow = True
CheckH1MirnovCoords.busted = True

class CheckH1Device(H1DevTestCase):

    def test_load_h1(self):
    
        self.assertTrue(issubclass(H1, Device))
        
    def test_getdevice(self):
        h1test = pyfusion.getDevice('H1')

        self.assertTrue(isinstance(h1test, H1))

    def test_kh(self):
        h1test = pyfusion.getDevice('H1')
        shot_kh = (58073, 0.74)
        data = h1test.acq.getdata(shot_kh[0], 'H1_mirnov_array_1_coil_1')        
        #self.assertAlmostEqual(data.meta['kh'], shot_kh[1])


CheckH1Device.slow = True
CheckH1Device.h1 = True
CheckH1Device.mds = True
CheckH1Device.net = True


# 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


CheckH1MirnovCoords.h1 = True
CheckH1MirnovCoords.mds = True
CheckH1MirnovCoords.net = True
CheckH1MirnovCoords.slow = True
CheckH1MirnovCoords.busted = True

class CheckH1Device(H1DevTestCase):

    def test_load_h1(self):
    
        self.assertTrue(issubclass(H1, Device))
        
    def test_getdevice(self):
        h1test = pyfusion.getDevice('H1')

        self.assertTrue(isinstance(h1test, H1))

    def test_kh(self):
        h1test = pyfusion.getDevice('H1')
        shot_kh = (58073, 0.74)
        data = h1test.acq.getdata(shot_kh[0], 'H1_mirnov_array_1_coil_1')        
        #self.assertAlmostEqual(data.meta['kh'], shot_kh[1])


CheckH1Device.slow = True
CheckH1Device.h1 = True
CheckH1Device.mds = True
CheckH1Device.net = True


class CheckGetH1Device(PfTestBase):