Parameters
    ----------
    Filepath : string
        filepath to the file containing the data used to initialise
        and create an instance of the DataObject class
    ObjectType : string, optional
        type to load the data as, takes the value 'default' if not specified.
        Options are:
        'data' : optoanalysis.DataObject
        'thermo' : optoanalysis.thermo.ThermoObject
    RelativeChannelNo : int, optional
        If loading a .bin file produced by the Saneae datalogger, used to specify
        the channel number
        If loading a .dat file produced by the labview NI5122 daq card, used to 
        specifiy the channel number if two channels where saved, if left None with 
        .dat files it will assume that the file to load only contains one channel.
        If NormaliseByMonitorOutput is True then specifies the monitor channel for
        loading a .dat file produced by the labview NI5122 daq card.
    SampleFreq : float, optional
        If loading a .dat file produced by the labview NI5122 daq card, used to
        manually specify the sample frequency
    PointsToLoad : int, optional
        Number of first points to read. -1 means all points (i.e., the complete file)
        WORKS WITH NI5122 DATA SO FAR ONLY!!!
    calcPSD : bool, optional
        Whether to calculate the PSD upon loading the file, can take some time
        off the loading and reduce memory usage if frequency space info is not required
    NPerSegmentPSD : int, optional
        NPerSegment to pass to scipy.signal.welch to calculate the PSD
    NormaliseByMonitorOutput : bool, optional
        If True the particle signal trace will be divided by the monitor output, which is
        specified by the channel number set in the RelativeChannelNo parameter. 
        WORKS WITH NI5122 DATA SO FAR ONLY!!!

    Returns
    -------
    Data : DataObject
        An instance of the DataObject class contaning the data
        that you requested to be loaded.

def load_data(Filepath, ObjectType='data', RelativeChannelNo=None, SampleFreq=None, PointsToLoad=-1, calcPSD=True, NPerSegmentPSD=1000000, NormaliseByMonitorOutput=False, silent=False):
    """
    Parameters
    ----------
    Filepath : string
        filepath to the file containing the data used to initialise
        and create an instance of the DataObject class
    ObjectType : string, optional
        type to load the data as, takes the value 'default' if not specified.
        Options are:
        'data' : optoanalysis.DataObject
        'thermo' : optoanalysis.thermo.ThermoObject
    RelativeChannelNo : int, optional
        If loading a .bin file produced by the Saneae datalogger, used to specify
        the channel number
        If loading a .dat file produced by the labview NI5122 daq card, used to 
        specifiy the channel number if two channels where saved, if left None with 
        .dat files it will assume that the file to load only contains one channel.
        If NormaliseByMonitorOutput is True then specifies the monitor channel for
        loading a .dat file produced by the labview NI5122 daq card.
    SampleFreq : float, optional
        If loading a .dat file produced by the labview NI5122 daq card, used to
        manually specify the sample frequency
    PointsToLoad : int, optional
        Number of first points to read. -1 means all points (i.e., the complete file)
        WORKS WITH NI5122 DATA SO FAR ONLY!!!
    calcPSD : bool, optional
        Whether to calculate the PSD upon loading the file, can take some time
        off the loading and reduce memory usage if frequency space info is not required
    NPerSegmentPSD : int, optional
        NPerSegment to pass to scipy.signal.welch to calculate the PSD
    NormaliseByMonitorOutput : bool, optional
        If True the particle signal trace will be divided by the monitor output, which is
        specified by the channel number set in the RelativeChannelNo parameter. 
        WORKS WITH NI5122 DATA SO FAR ONLY!!!

    Returns
    -------
    Data : DataObject
        An instance of the DataObject class contaning the data
        that you requested to be loaded.

    """
    if silent != True:
        print("Loading data from {}".format(Filepath))
    ObjectTypeDict = {
        'data' : DataObject,
        'thermo' : optoanalysis.thermo.ThermoObject,
        }
    try:
        Object = ObjectTypeDict[ObjectType]
    except KeyError:
        raise ValueError("You entered {}, this is not a valid object type".format(ObjectType))
    data = Object(Filepath, RelativeChannelNo, SampleFreq, PointsToLoad, calcPSD, NPerSegmentPSD, NormaliseByMonitorOutput)
    try:
        channel_number, run_number, repeat_number = [int(val) for val in re.findall('\d+', data.filename)]
        data.channel_number = channel_number
        data.run_number = run_number
        data.repeat_number = repeat_number
        if _does_file_exist(data.filepath.replace(data.filename, '') + "pressure.log"):
            print("pressure.log file exists")
            for line in open(data.filepath.replace(data.filename, '') + "pressure.log", 'r'):
                run_number, repeat_number, pressure = line.split(',')[1:]
                run_number = int(run_number)
                repeat_number = int(repeat_number)
                pressure = float(pressure)
                if (run_number == data.run_number) and (repeat_number == data.repeat_number):
                    data.pmbar = pressure    
    except ValueError:
        pass
    try:
        if _does_file_exist(glob(data.filepath.replace(data.filename, '*' + data.filename[20:-4] + ' - header.dat'))[0]):
            print("header file exists")
            with open(glob(data.filepath.replace(data.filename, '*' + data.filepath[20:-4] + ' - header.dat'))[0], encoding='ISO-8859-1') as f:
                lines = f.readlines()
            data.pmbar = (float(lines[68][-9:-1])+float(lines[69][-9:-1]))/2
    except (ValueError, IndexError):
        pass
    return data