Convenience method to run critic2 analysis on a folder containing
        typical VASP output files.
        This method will:
        1. Look for files CHGCAR, AECAR0, AECAR2, POTCAR or their gzipped
        counterparts.
        2. If AECCAR* files are present, constructs a temporary reference
        file as AECCAR0 + AECCAR2
        3. Runs critic2 analysis twice: once for charge, and a second time
        for the charge difference (magnetization density).
        :param path: path to folder to search in
        :param suffix: specific suffix to look for (e.g. '.relax1' for
        'CHGCAR.relax1.gz')
        :return:

def from_path(cls, path, suffix=''):
        """
        Convenience method to run critic2 analysis on a folder containing
        typical VASP output files.
        This method will:
        1. Look for files CHGCAR, AECAR0, AECAR2, POTCAR or their gzipped
        counterparts.
        2. If AECCAR* files are present, constructs a temporary reference
        file as AECCAR0 + AECCAR2
        3. Runs critic2 analysis twice: once for charge, and a second time
        for the charge difference (magnetization density).
        :param path: path to folder to search in
        :param suffix: specific suffix to look for (e.g. '.relax1' for
        'CHGCAR.relax1.gz')
        :return:
        """

        def _get_filepath(filename, warning, path=path, suffix=suffix):
            paths = glob.glob(os.path.join(path, filename + suffix + '*'))
            if not paths:
                warnings.warn(warning)
                return None
            if len(paths) > 1:
                # using reverse=True because, if multiple files are present,
                # they likely have suffixes 'static', 'relax', 'relax2', etc.
                # and this would give 'static' over 'relax2' over 'relax'
                # however, better to use 'suffix' kwarg to avoid this!
                paths.sort(reverse=True)
                warnings.warn('Multiple files detected, using {}'.format(os.path.basename(path)))
            path = paths[0]
            return path

        chgcar_path = _get_filepath('CHGCAR', 'Could not find CHGCAR!')
        chgcar = Chgcar.from_file(chgcar_path)

        aeccar0_path = _get_filepath('AECCAR0', 'Could not find AECCAR0, interpret Bader results with caution.')
        aeccar0 = Chgcar.from_file(aeccar0_path) if aeccar0_path else None

        aeccar2_path = _get_filepath('AECCAR2', 'Could not find AECCAR2, interpret Bader results with caution.')
        aeccar2 = Chgcar.from_file(aeccar2_path) if aeccar2_path else None

        chgcar_ref = aeccar0.linear_add(aeccar2) if (aeccar0 and aeccar2) else None

        return cls(chgcar.structure, chgcar, chgcar_ref)