#NEWLINE# def zero_pad( time_series , NFFT ) : #NEWLINE# #INDENT# '\n    Pad a time-series with zeros on either side, depending on its length\n\n    Parameters\n    ----------\n    time_series : n-d array\n       Time-series data with time as the last dimension\n\n    NFFT : int\n       The length to pad the data up to.\n\n    ' #NEWLINE# n_dims = len ( time_series . shape ) #NEWLINE# n_time_points = time_series . shape [ ( - 1 ) ] #NEWLINE# if ( n_dims > 1 ) : #NEWLINE# #INDENT# n_channels = time_series . shape [ : ( - 1 ) ] #NEWLINE# shape_out = ( n_channels + ( NFFT , ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# shape_out = NFFT #NEWLINE# #UNINDENT# if ( n_time_points < NFFT ) : #NEWLINE# #INDENT# tmp = time_series #NEWLINE# time_series = np . zeros ( shape_out , time_series . dtype ) #NEWLINE# time_series [ ... , : n_time_points ] = tmp #NEWLINE# del tmp #NEWLINE# #UNINDENT# return n_time_points