def export(self, output, tight=False, concat=True, close_pdf=None,
               use_time=False, **kwargs):
        """Exports the figures of the project to one or more image files

        Parameters
        ----------
        output: str, iterable or matplotlib.backends.backend_pdf.PdfPages
            if string or list of strings, those define the names of the output
            files. Otherwise you may provide an instance of
            :class:`matplotlib.backends.backend_pdf.PdfPages` to save the
            figures in it.
            If string (or iterable of strings), attribute names in the
            xarray.DataArray.attrs attribute as well as index dimensions
            are replaced by the respective value (see examples below).
            Furthermore a single format string without key (e.g. %i, %s, %d,
            etc.) is replaced by a counter.
        tight: bool
            If True, it is tried to figure out the tight bbox of the figure
            (same as bbox_inches='tight')
        concat: bool
            if True and the output format is `pdf`, all figures are
            concatenated into one single pdf
        close_pdf: bool or None
            If True and the figures are concatenated into one single pdf,
            the resulting pdf instance is closed. If False it remains open.
            If None and `output` is a string, it is the same as
            ``close_pdf=True``, if None and `output` is neither a string nor an
            iterable, it is the same as ``close_pdf=False``
        use_time: bool
            If True, formatting strings for the
            :meth:`datetime.datetime.strftime` are expected to be found in
            `output` (e.g. ``'%m'``, ``'%Y'``, etc.). If so, other formatting
            strings must be escaped by double ``'%'`` (e.g. ``'%%i'`` instead
            of (``'%i'``))
        ``**kwargs``
            Any valid keyword for the :func:`matplotlib.pyplot.savefig`
            function

        Returns
        -------
        matplotlib.backends.backend_pdf.PdfPages or None
            a PdfPages instance if output is a string and close_pdf is False,
            otherwise None

        Examples
        --------
        Simply save all figures into one single pdf::

            >>> p = psy.gcp()
            >>> p.export('my_plots.pdf')

        Save all figures into separate pngs with increasing numbers (e.g.
        ``'my_plots_1.png'``)::

            >>> p.export('my_plots_%i.png')

        Save all figures into separate pngs with the name of the variables
        shown in each figure (e.g. ``'my_plots_t2m.png'``)::

            >>> p.export('my_plots_%(name)s.png')

        Save all figures into separate pngs with the name of the variables
        shown in each figure and with increasing numbers (e.g.
        ``'my_plots_1_t2m.png'``)::

            >>> p.export('my_plots_%i_%(name)s.png')

        Specify the names for each figure directly via a list::

            >>> p.export(['my_plots1.pdf', 'my_plots2.pdf'])
        """
        from matplotlib.backends.backend_pdf import PdfPages
        if tight:
            kwargs['bbox_inches'] = 'tight'

        if use_time:
            def insert_time(s, attrs):
                time = attrs[tname]
                try:  # assume a valid datetime.datetime instance
                    s = pd.to_datetime(time).strftime(s)
                except ValueError:
                    pass
                return s

            tnames = self._get_tnames()
            tname = next(iter(tnames)) if len(tnames) == 1 else None
        else:
            def insert_time(s, attrs):
                return s

            tname = None

        if isinstance(output, six.string_types):  # a single string
            out_fmt = kwargs.pop('format', os.path.splitext(output))[1][1:]
            if out_fmt.lower() == 'pdf' and concat:
                attrs = self.joined_attrs('-')
                if tname is not None and tname in attrs:
                    output = insert_time(output, attrs)
                pdf = PdfPages(safe_modulo(output, attrs))

                def save(fig):
                    pdf.savefig(fig, **kwargs)

                def close():
                    if close_pdf is None or close_pdf:
                        pdf.close()
                        return
                    return pdf
            else:
                def save(fig):
                    attrs = self.figs[fig].joined_attrs('-')
                    out = output
                    if tname is not None and tname in attrs:
                        out = insert_time(out, attrs)
                    try:
                        out = safe_modulo(out, i, print_warning=False)
                    except TypeError:
                        pass
                    fig.savefig(safe_modulo(out, attrs), **kwargs)

                def close():
                    pass
        elif isinstance(output, Iterable):  # a list of strings
            output = cycle(output)

            def save(fig):
                attrs = self.figs[fig].joined_attrs('-')
                out = next(output)
                if tname is not None and tname in attrs:
                    out = insert_time(out, attrs)
                try:
                    out = safe_modulo(next(output), i, print_warning=False)
                except TypeError:
                    pass
                fig.savefig(safe_modulo(out, attrs), **kwargs)

            def close():
                pass
        else:  # an instances of matplotlib.backends.backend_pdf.PdfPages
            def save(fig):
                output.savefig(fig, **kwargs)

            def close():
                if close_pdf:
                    output.close()
        for i, fig in enumerate(self.figs, 1):
            save(fig)
        return close()
Exports the figures of the project to one or more image files

        Parameters
        ----------
        output: str, iterable or matplotlib.backends.backend_pdf.PdfPages
            if string or list of strings, those define the names of the output
            files. Otherwise you may provide an instance of
            :class:`matplotlib.backends.backend_pdf.PdfPages` to save the
            figures in it.
            If string (or iterable of strings), attribute names in the
            xarray.DataArray.attrs attribute as well as index dimensions
            are replaced by the respective value (see examples below).
            Furthermore a single format string without key (e.g. %i, %s, %d,
            etc.) is replaced by a counter.
        tight: bool
            If True, it is tried to figure out the tight bbox of the figure
            (same as bbox_inches='tight')
        concat: bool
            if True and the output format is `pdf`, all figures are
            concatenated into one single pdf
        close_pdf: bool or None
            If True and the figures are concatenated into one single pdf,
            the resulting pdf instance is closed. If False it remains open.
            If None and `output` is a string, it is the same as
            ``close_pdf=True``, if None and `output` is neither a string nor an
            iterable, it is the same as ``close_pdf=False``
        use_time: bool
            If True, formatting strings for the
            :meth:`datetime.datetime.strftime` are expected to be found in
            `output` (e.g. ``'%m'``, ``'%Y'``, etc.). If so, other formatting
            strings must be escaped by double ``'%'`` (e.g. ``'%%i'`` instead
            of (``'%i'``))
        ``**kwargs``
            Any valid keyword for the :func:`matplotlib.pyplot.savefig`
            function

        Returns
        -------
        matplotlib.backends.backend_pdf.PdfPages or None
            a PdfPages instance if output is a string and close_pdf is False,
            otherwise None

        Examples
        --------
        Simply save all figures into one single pdf::

            >>> p = psy.gcp()
            >>> p.export('my_plots.pdf')

        Save all figures into separate pngs with increasing numbers (e.g.
        ``'my_plots_1.png'``)::

            >>> p.export('my_plots_%i.png')

        Save all figures into separate pngs with the name of the variables
        shown in each figure (e.g. ``'my_plots_t2m.png'``)::

            >>> p.export('my_plots_%(name)s.png')

        Save all figures into separate pngs with the name of the variables
        shown in each figure and with increasing numbers (e.g.
        ``'my_plots_1_t2m.png'``)::

            >>> p.export('my_plots_%i_%(name)s.png')

        Specify the names for each figure directly via a list::

            >>> p.export(['my_plots1.pdf', 'my_plots2.pdf'])