def _normalize_window(window, nfft, library, dtype):
if library == '<STR_LIT>' and isinstance(window, numpy.ndarray):<EOL><INDENT>from ._lal import window_from_array<EOL>return window_from_array(window)<EOL><DEDENT>if library == '<STR_LIT>':<EOL><INDENT>from ._lal import generate_window<EOL>return generate_window(nfft, window=window, dtype=dtype)<EOL><DEDENT>if isinstance(window, string_types):<EOL><INDENT>window = canonical_name(window)<EOL><DEDENT>if isinstance(window, string_types + (tuple,)):<EOL><INDENT>return get_window(window, nfft)<EOL><DEDENT>return None<EOL>
Normalise a window specification for a PSD calculation

    Parameters
    ----------
    window : `str`, `numpy.ndarray`, `None`
        the input window specification

    nfft : `int`
        the length of the Fourier transform, in samples

    library : `str`
        the name of the library that provides the PSD routine

    dtype : `type`
        the required type of the window array, only used if
        `library='lal'` is given

    Returns
    -------
    window : `numpy.ndarray`, `lal.REAL8Window`
        a numpy-, or `LAL`-format window array