示例#1
0
    def _is_valid(self, *args, **kwargs):

        warn_h5py(args[0])

        if not is_chombo_hdf5(args[0]):
            return False

        pluto_ini_file_exists = False
        orion2_ini_file_exists = False

        if isinstance(args[0], str):
            dir_name = os.path.dirname(os.path.abspath(args[0]))
            pluto_ini_filename = os.path.join(dir_name, "pluto.ini")
            orion2_ini_filename = os.path.join(dir_name, "orion2.ini")
            pluto_ini_file_exists = os.path.isfile(pluto_ini_filename)
            orion2_ini_file_exists = os.path.isfile(orion2_ini_filename)

        if orion2_ini_file_exists:
            return False

        if pluto_ini_file_exists:
            return False

        try:
            fileh = h5py.File(args[0], mode='r')
            valid = "Charm_global" in fileh["/"]
            fileh.close()
            return valid
        except Exception:
            pass
        return False
示例#2
0
 def _is_valid(self, *args, **kwargs):
     warn_h5py(args[0])
     try:
         fileh = HDF5FileHandler(args[0])
         if ("bounding box" not in fileh["/"].keys()
                 and "localnp" in fileh["/"].keys()):
             return True
     except (OSError, ImportError):
         pass
     return False
示例#3
0
    def _is_valid(self, *args, **kwargs):
        warn_h5py(args[0])
        try:
            with h5.File(args[0], "r") as f:
                attrs = list(f["/"].attrs.keys())
                for i in opmd_required_attributes:
                    if i not in attrs:
                        return False

                if StrictVersion(f.attrs["openPMD"].decode()) not in ompd_known_versions:
                    return False

                if f.attrs["iterationEncoding"].decode() == "groupBased":
                    return True

                return False
        except (IOError, OSError, ImportError):
            return False
示例#4
0
    def _is_valid(cls, filename, *args, **kwargs):
        warn_h5py(filename)
        try:
            with h5py.File(filename, mode="r") as f:
                attrs = list(f["/"].attrs.keys())
                for i in opmd_required_attributes:
                    if i not in attrs:
                        return False

                if Version(f.attrs["openPMD"].decode()) not in ompd_known_versions:
                    return False

                if f.attrs["iterationEncoding"].decode() == "groupBased":
                    return True

                return False
        except (OSError, ImportError):
            return False
示例#5
0
    def _is_valid(cls, filename, *args, **kwargs):
        """Checks whether the supplied file can be read by this frontend."""
        warn_h5py(filename)
        try:
            with h5py.File(filename, mode="r") as f:
                attrs = list(f["/"].attrs.keys())
                for i in opmd_required_attributes:
                    if i not in attrs:
                        return False

                if Version(f.attrs["openPMD"].decode()) not in ompd_known_versions:
                    return False

                if f.attrs["iterationEncoding"].decode() == "fileBased":
                    return True

                return False
        except (OSError, ImportError):
            return False
示例#6
0
    def _is_valid(self, *args, **kwargs):
        """Checks whether the supplied file can be read by this frontend.
        """
        warn_h5py(args[0])
        try:
            f = h5.File(args[0], "r")
        except (IOError, OSError, ImportError):
            return False

        requirements = ["openPMD", "basePath", "meshesPath", "particlesPath"]
        attrs = list(f["/"].attrs.keys())
        for i in requirements:
            if i not in attrs:
                f.close()
                return False

        known_versions = [StrictVersion("1.0.0"), StrictVersion("1.0.1")]
        if StrictVersion(f.attrs["openPMD"].decode()) in known_versions:
            f.close()
            return True
        else:
            f.close()
            return False