# Path: nptdms/types.py
# def tds_data_type(enum_value, np_type, set_np_type=True):
#     def decorator(cls):
#     def __init__(self):
#     def __eq__(self, other):
#     def __repr__(self):
#     def read(cls, file, endianness="<"):
#     def read_values(cls, file, number_values, endianness="<"):
#     def __init__(self, value):
#     def __init__(self, value):
#     def read(cls, file, endianness="<"):
#     def from_bytes(cls, byte_array, endianness="<"):
#     def __init__(self, value):
#     def read(file, endianness="<"):
#     def read_values(cls, file, number_values, endianness="<"):
#     def __init__(self, value):
#     def read(cls, file, endianness="<"):
#     def __init__(self, value):
#     def read(cls, file, endianness="<"):
#     def from_bytes(cls, byte_array, endianness="<"):
# class TdmsType(object):
# class Bytes(TdmsType):
# class StructType(TdmsType):
# class Void(TdmsType):
# class Int8(StructType):
# class Int16(StructType):
# class Int32(StructType):
# class Int64(StructType):
# class Uint8(StructType):
# class Uint16(StructType):
# class Uint32(StructType):
# class Uint64(StructType):
# class SingleFloat(StructType):
# class DoubleFloat(StructType):
# class ExtendedFloat(TdmsType):
# class SingleFloatWithUnit(StructType):
# class DoubleFloatWithUnit(StructType):
# class ExtendedFloatWithUnit(TdmsType):
# class String(TdmsType):
# class Boolean(StructType):
# class TimeStamp(TdmsType):
# class ComplexSingleFloat(TdmsType):
# class ComplexDoubleFloat(TdmsType):
# class DaqMxRawData(TdmsType):
# 
# Path: nptdms/timestamp.py
# class TimestampArray(np.ndarray):
#     """ A numpy array of TDMS timestamps
# 
#         Indexing into a TimestampArray returns TdmsTimestamp objects.
#     """
# 
#     def __new__(cls, input_array):
#         """ Create a new TimestampArray
# 
#             The input array must be a structured numpy array with 'seconds' and 'second_fractions' fields.
#         """
#         obj = np.asarray(input_array).view(cls)
#         field_names = input_array.dtype.names
#         if field_names == ('second_fractions', 'seconds'):
#             obj._field_indices = (1, 0)
#         elif field_names == ('seconds', 'second_fractions'):
#             obj._field_indices = (0, 1)
#         else:
#             raise ValueError("Input array must have a dtype with 'seconds' and 'second_fractions' fields")
#         return obj
# 
#     def __array_finalize__(self, obj):
#         if obj is None:
#             return
#         self._field_indices = getattr(obj, '_field_indices', '<')
# 
#     def __getitem__(self, item):
#         val = super(TimestampArray, self).__getitem__(item)
#         if isinstance(item, str):
#             # Getting a field, we don't want to return this as a TimestampArray
#             # but as a normal numpy ndarray
#             return val.view(np.ndarray)
#         if isinstance(item, (int, np.number)):
#             # Getting a single item
#             return TdmsTimestamp(val[self._field_indices[0]], val[self._field_indices[1]])
#         # else getting a slice returns a new TimestampArray
#         return val
# 
#     @property
#     def seconds(self):
#         """ The number of seconds since the TDMS epoch (1904-01-01 00:00:00 UTC) as a numpy array
#         """
#         return self['seconds']
# 
#     @property
#     def second_fractions(self):
#         """ The number of 2**-64 fractions of a second as a numpy array
#         """
#         return self['second_fractions']
# 
#     def as_datetime64(self, resolution='us'):
#         """ Convert to an array of numpy datetime64 objects
# 
#             :param resolution: The resolution of the datetime64 objects to create as a numpy unit code.
#                 Must be one of 's', 'ms', 'us', 'ns' or 'ps'
#         """
#         try:
#             fractions_per_step = _fractions_per_step[resolution]
#         except KeyError:
#             raise ValueError("Unsupported resolution for converting to numpy datetime64: '{0}'".format(resolution))
#         return (
#                 EPOCH +
#                 self['seconds'] * np.timedelta64(1, 's') +
#                 (self['second_fractions'] / fractions_per_step) * np.timedelta64(1, resolution))
# 
# Path: nptdms/log.py
# class LogManager(object):
#     def __init__(self):
#     def get_logger(self, module_name):
#     def set_level(self, level):


import tempfile
import numpy as np
from nptdms import types
from nptdms.timestamp import TimestampArray
from nptdms.log import log_manager
""" Responsible for storing data read from TDMS files
"""



log = log_manager.get_logger(__name__)


def get_data_receiver(obj, num_values, raw_timestamps, memmap_dir=None):
    """Return a new channel data receiver to use for the given TDMS object

    :param obj: TDMS channel object to receive data for
    :param num_values: Number of values to be stored
    :param raw_timestamps: Whether to store timestamp data as raw TDMS timestamps or a numpy datetime64 array
    :param memmap_dir: Optional directory to store memory map files,
        or None to not use memory map files
    """
    if obj.data_type is None:
        return None


# Path: nptdms/types.py
# def tds_data_type(enum_value, np_type, set_np_type=True):
#     def decorator(cls):
#     def __init__(self):
#     def __eq__(self, other):
#     def __repr__(self):
#     def read(cls, file, endianness="<"):
#     def read_values(cls, file, number_values, endianness="<"):
#     def __init__(self, value):
#     def __init__(self, value):
#     def read(cls, file, endianness="<"):
#     def from_bytes(cls, byte_array, endianness="<"):
#     def __init__(self, value):
#     def read(file, endianness="<"):
#     def read_values(cls, file, number_values, endianness="<"):
#     def __init__(self, value):
#     def read(cls, file, endianness="<"):
#     def __init__(self, value):
#     def read(cls, file, endianness="<"):
#     def from_bytes(cls, byte_array, endianness="<"):
# class TdmsType(object):
# class Bytes(TdmsType):
# class StructType(TdmsType):
# class Void(TdmsType):
# class Int8(StructType):
# class Int16(StructType):
# class Int32(StructType):
# class Int64(StructType):
# class Uint8(StructType):
# class Uint16(StructType):
# class Uint32(StructType):
# class Uint64(StructType):
# class SingleFloat(StructType):
# class DoubleFloat(StructType):
# class ExtendedFloat(TdmsType):
# class SingleFloatWithUnit(StructType):
# class DoubleFloatWithUnit(StructType):
# class ExtendedFloatWithUnit(TdmsType):
# class String(TdmsType):
# class Boolean(StructType):
# class TimeStamp(TdmsType):
# class ComplexSingleFloat(TdmsType):
# class ComplexDoubleFloat(TdmsType):
# class DaqMxRawData(TdmsType):
# 
# Path: nptdms/timestamp.py
# class TimestampArray(np.ndarray):
#     """ A numpy array of TDMS timestamps
# 
#         Indexing into a TimestampArray returns TdmsTimestamp objects.
#     """
# 
#     def __new__(cls, input_array):
#         """ Create a new TimestampArray
# 
#             The input array must be a structured numpy array with 'seconds' and 'second_fractions' fields.
#         """
#         obj = np.asarray(input_array).view(cls)
#         field_names = input_array.dtype.names
#         if field_names == ('second_fractions', 'seconds'):
#             obj._field_indices = (1, 0)
#         elif field_names == ('seconds', 'second_fractions'):
#             obj._field_indices = (0, 1)
#         else:
#             raise ValueError("Input array must have a dtype with 'seconds' and 'second_fractions' fields")
#         return obj
# 
#     def __array_finalize__(self, obj):
#         if obj is None:
#             return
#         self._field_indices = getattr(obj, '_field_indices', '<')
# 
#     def __getitem__(self, item):
#         val = super(TimestampArray, self).__getitem__(item)
#         if isinstance(item, str):
#             # Getting a field, we don't want to return this as a TimestampArray
#             # but as a normal numpy ndarray
#             return val.view(np.ndarray)
#         if isinstance(item, (int, np.number)):
#             # Getting a single item
#             return TdmsTimestamp(val[self._field_indices[0]], val[self._field_indices[1]])
#         # else getting a slice returns a new TimestampArray
#         return val
# 
#     @property
#     def seconds(self):
#         """ The number of seconds since the TDMS epoch (1904-01-01 00:00:00 UTC) as a numpy array
#         """
#         return self['seconds']
# 
#     @property
#     def second_fractions(self):
#         """ The number of 2**-64 fractions of a second as a numpy array
#         """
#         return self['second_fractions']
# 
#     def as_datetime64(self, resolution='us'):
#         """ Convert to an array of numpy datetime64 objects
# 
#             :param resolution: The resolution of the datetime64 objects to create as a numpy unit code.
#                 Must be one of 's', 'ms', 'us', 'ns' or 'ps'
#         """
#         try:
#             fractions_per_step = _fractions_per_step[resolution]
#         except KeyError:
#             raise ValueError("Unsupported resolution for converting to numpy datetime64: '{0}'".format(resolution))
#         return (
#                 EPOCH +
#                 self['seconds'] * np.timedelta64(1, 's') +
#                 (self['second_fractions'] / fractions_per_step) * np.timedelta64(1, resolution))
# 
# Path: nptdms/log.py
# class LogManager(object):
#     def __init__(self):
#     def get_logger(self, module_name):
#     def set_level(self, level):


# Path: nptdms/channel_data.py
import tempfile
import numpy as np
from nptdms import types
from nptdms.timestamp import TimestampArray
from nptdms.log import log_manager

""" Responsible for storing data read from TDMS files
"""



log = log_manager.get_logger(__name__)


def get_data_receiver(obj, num_values, raw_timestamps, memmap_dir=None):
    """Return a new channel data receiver to use for the given TDMS object

    :param obj: TDMS channel object to receive data for
    :param num_values: Number of values to be stored
    :param raw_timestamps: Whether to store timestamp data as raw TDMS timestamps or a numpy datetime64 array
    :param memmap_dir: Optional directory to store memory map files,
        or None to not use memory map files
    """
    if obj.data_type is None:
        return None


    if obj.data_type == types.DaqMxRawData: