def unpack_trace(data,tr =False):
    """
    This function unpacks an (N,M) array into wl,t and the intensity trace

    Parameters:
        data: (N,M) 2D array in .txt format
        tr: Boolean, if True return only trace, default is False
    Returns:
        t: 1D array of length M giving time values
        wl: 1D array of length N giving wavelength values
        trace: (N,M) 2D array of intensity data
    """
    t = data[0,1:]
    wl = data[1:,0]
    trace = data[1:,1:]
    if tr == True:
        return trace
    else:
        return t,wl,trace